File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 10
10
# define __compiletime_error (message )
11
11
#endif
12
12
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
+
13
39
/* Optimization barrier */
14
40
/* The "volatile" is due to gcc bugs */
15
41
#define barrier () __asm__ __volatile__("": : :"memory")
You can’t perform that action at this time.
0 commit comments