Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/common/include/linux linux: Simplify build_...



details:   https://anonhg.NetBSD.org/src/rev/6fda4b3d245a
branches:  trunk
changeset: 1028494:6fda4b3d245a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:10:48 2021 +0000

description:
linux: Simplify build_bug.h and add static_assert.

diffstat:

 sys/external/bsd/common/include/linux/build_bug.h |  18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diffs (34 lines):

diff -r 0b2699fbc954 -r 6fda4b3d245a sys/external/bsd/common/include/linux/build_bug.h
--- a/sys/external/bsd/common/include/linux/build_bug.h Sun Dec 19 11:10:41 2021 +0000
+++ b/sys/external/bsd/common/include/linux/build_bug.h Sun Dec 19 11:10:48 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: build_bug.h,v 1.1 2021/12/19 11:10:41 riastradh Exp $  */
+/*     $NetBSD: build_bug.h,v 1.2 2021/12/19 11:10:48 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -31,17 +31,15 @@
 
 #include <lib/libkern/libkern.h>
 
-/*
- * static_assert is violated with runtime-only compiler semantics in a few
- * places. Instead of breaking the build, stop asserting these corner cases.
- */
+/* Required to be false _or_ nonconstant.  */
+#define        BUILD_BUG_ON(EXPR)                                                    \
+       CTASSERT(__builtin_choose_expr(__builtin_constant_p(EXPR), !(EXPR), 1))
 
-#define DRMCTASSERT(x) CTASSERT((__builtin_choose_expr(                \
-                       __builtin_constant_p(x), (x), 1)))
+/* Required to be constant _and_ true.  XXX Should take optional message.  */
+#define        static_assert(EXPR)             CTASSERT(EXPR)
 
-#define        BUILD_BUG()             do {} while (0)
-#define        BUILD_BUG_ON(CONDITION) DRMCTASSERT(!(CONDITION))
-#define        BUILD_BUG_ON_MSG(CONDITION,MSG) DRMCTASSERT(!(CONDITION))
+#define        BUILD_BUG()                     do {} while (0)
+#define        BUILD_BUG_ON_MSG(EXPR,MSG)      BUILD_BUG_ON(EXPR)
 #define        BUILD_BUG_ON_INVALID(EXPR)      ((void)sizeof((long)(EXPR)))
 
 #endif /* _LINUX_BUILD_BUG_H_ */



Home | Main Index | Thread Index | Old Index