Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150527267
D30431.id89756.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D30431.id89756.diff
View Options
Index: sys/compat/linuxkpi/common/include/linux/kernel.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/kernel.h
+++ sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -88,8 +88,23 @@
#define S64_C(x) x ## LL
#define U64_C(x) x ## ULL
+/*
+ * BUILD_BUG_ON() can happen inside functions where _Static_assert() does not
+ * seem to work. Use old-schoold-ish CTASSERT from before commit
+ * a3085588a88fa58eb5b1eaae471999e1995a29cf but also make sure we do not
+ * end up with an unused typedef or variable. The compiler should optimise
+ * it away entirely.
+ */
+#define _O_CTASSERT(x) _O__CTASSERT(x, __LINE__)
+#define _O__CTASSERT(x, y) _O___CTASSERT(x, y)
+#define _O___CTASSERT(x, y) do { \
+ typedef char __assert_line_ ## y[(x) ? 1 : -1]; \
+ __assert_line_ ## y _x; \
+ _x[0] = '\0'; \
+} while(0)
+
#define BUILD_BUG() do { CTASSERT(0); } while (0)
-#define BUILD_BUG_ON(x) CTASSERT(!(x))
+#define BUILD_BUG_ON(x) _O_CTASSERT(!(x))
#define BUILD_BUG_ON_MSG(x, msg) BUILD_BUG_ON(x)
#define BUILD_BUG_ON_NOT_POWER_OF_2(x) BUILD_BUG_ON(!powerof2(x))
#define BUILD_BUG_ON_INVALID(expr) while (0) { (void)(expr); }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 1:24 AM (4 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30740399
Default Alt Text
D30431.id89756.diff (1 KB)
Attached To
Mode
D30431: LinuxKPI: change BUILD_BUG_ON()
Attached
Detach File
Event Timeline
Log In to Comment