summaryrefslogtreecommitdiff
path: root/lib/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compiler.h')
-rw-r--r--lib/compiler.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/compiler.h b/lib/compiler.h
index 29fcfbefbf..0a54c02d20 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -33,7 +33,7 @@ extern "C" {
# define _RET_NONNULL , returns_nonnull
#endif
#if __has_attribute(fallthrough)
-# define _FALLTHROUGH __attribute__((fallthrough));
+# define fallthrough __attribute__((fallthrough));
#endif
# define _CONSTRUCTOR(x) constructor(x)
# define _DEPRECATED(x) deprecated(x)
@@ -57,7 +57,7 @@ extern "C" {
# define __has_attribute(x) 0
#endif
#if __GNUC__ >= 7
-# define _FALLTHROUGH __attribute__((fallthrough));
+# define fallthrough __attribute__((fallthrough));
#endif
#endif
@@ -112,8 +112,8 @@ extern "C" {
#ifndef _ALLOC_SIZE
# define _ALLOC_SIZE(x)
#endif
-#ifndef _FALLTHROUGH
-#define _FALLTHROUGH
+#ifndef fallthrough
+#define fallthrough
#endif
#ifndef _DEPRECATED
#define _DEPRECATED(x) deprecated
@@ -122,6 +122,14 @@ extern "C" {
#define assume(x)
#endif
+#ifdef __COVERITY__
+/* __coverity_panic__() is named a bit poorly, it's essentially the same as
+ * __builtin_unreachable(). Used to eliminate false positives.
+ */
+#undef assume
+#define assume(x) do { if (!(x)) __coverity_panic__(); } while (0)
+#endif
+
/* for helper functions defined inside macros */
#define macro_inline static inline __attribute__((unused))
#define macro_pure static inline __attribute__((unused, pure))