chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31c15e2
)
macro: use C11 static_assert() macro for static assertions
author
Lennart Poettering
<lennart@poettering.net>
Tue, 25 Dec 2012 10:52:14 +0000
(11:52 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Mon, 31 Dec 2012 20:24:26 +0000
(21:24 +0100)
src/shared/macro.h
patch
|
blob
|
history
diff --git
a/src/shared/macro.h
b/src/shared/macro.h
index e930fdab5333e13ed00535e7c820be1247a8ffa1..700171b8324e45bc2b4c48e1b01b5c8e486ff4ef 100644
(file)
--- a/
src/shared/macro.h
+++ b/
src/shared/macro.h
@@
-119,14
+119,21
@@
static inline size_t ALIGN_TO(size_t l, size_t ali) {
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
} while (false)
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
} while (false)
-#define assert_cc(expr) \
- do { \
- switch (0) { \
- case 0: \
- case !!(expr): \
- ; \
- } \
+#if defined(static_assert)
+#define assert_cc(expr) \
+ do { \
+ static_assert(expr, #expr); \
} while (false)
} while (false)
+#else
+#define assert_cc(expr) \
+ do { \
+ switch (0) { \
+ case 0: \
+ case !!(expr): \
+ ; \
+ } \
+ } while (false)
+#endif
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))