hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/tools/include/linux/compiler.h
....@@ -10,6 +10,32 @@
1010 # define __compiletime_error(message)
1111 #endif
1212
13
+#ifdef __OPTIMIZE__
14
+# define __compiletime_assert(condition, msg, prefix, suffix) \
15
+ do { \
16
+ extern void prefix ## suffix(void) __compiletime_error(msg); \
17
+ if (!(condition)) \
18
+ prefix ## suffix(); \
19
+ } while (0)
20
+#else
21
+# define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0)
22
+#endif
23
+
24
+#define _compiletime_assert(condition, msg, prefix, suffix) \
25
+ __compiletime_assert(condition, msg, prefix, suffix)
26
+
27
+/**
28
+ * compiletime_assert - break build and emit msg if condition is false
29
+ * @condition: a compile-time constant condition to check
30
+ * @msg: a message to emit if condition is false
31
+ *
32
+ * In tradition of POSIX assert, this macro will break the build if the
33
+ * supplied condition is *false*, emitting the supplied error message if the
34
+ * compiler has support to do so.
35
+ */
36
+#define compiletime_assert(condition, msg) \
37
+ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
38
+
1339 /* Optimization barrier */
1440 /* The "volatile" is due to gcc bugs */
1541 #define barrier() __asm__ __volatile__("": : :"memory")
....@@ -81,8 +107,6 @@
81107 #ifndef noinline
82108 # define noinline
83109 #endif
84
-
85
-#define uninitialized_var(x) x = *(&(x))
86110
87111 #include <linux/types.h>
88112
....@@ -172,4 +196,8 @@
172196 # define __fallthrough
173197 #endif
174198
199
+/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
200
+#define ___PASTE(a, b) a##b
201
+#define __PASTE(a, b) ___PASTE(a, b)
202
+
175203 #endif /* _TOOLS_LINUX_COMPILER_H */