summaryrefslogtreecommitdiff
path: root/include/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/compiler.h')
-rw-r--r--include/compiler.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/include/compiler.h b/include/compiler.h
index 4e44840d..18576724 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -3,6 +3,28 @@
#ifndef COMPILER_H_
#define COMPILER_H_
+/*
+ * These are special ones that get our unit tests in trouble with the
+ * compiler optimizer dropping out tests...
+ */
+#ifdef NONNULL
+# undef NONNULL
+#endif
+#ifdef RETURNS_NONNULL
+# undef RETURNS_NONNULL
+#endif
+#ifdef SHIM_UNIT_TEST
+# define NONNULL(first, args...)
+# define RETURNS_NONNULL
+#else
+# define NONNULL(first, args...) __attribute__((__nonnull__(first, ## args)))
+#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)))
+# define RETURNS_NONNULL __attribute__((__returns_nonnull__))
+#else
+# define RETURNS_NONNULL
+#endif
+#endif
+
#ifndef UNUSED
#define UNUSED __attribute__((__unused__))
#endif
@@ -12,6 +34,9 @@
#ifndef PUBLIC
#define PUBLIC __attribute__((__visibility__ ("default")))
#endif
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__((__deprecated__))
+#endif
#ifndef DESTRUCTOR
#define DESTRUCTOR __attribute__((destructor))
#endif
@@ -21,12 +46,15 @@
#ifndef ALIAS
#define ALIAS(x) __attribute__((weak, alias (#x)))
#endif
-#ifndef NONNULL
+#ifndef ALLOCFUNC
+#define ALLOCFUNC(dealloc, dealloc_arg) __attribute__((__malloc__(dealloc, dealloc_arg)))
#endif
-#define NONNULL(first, args...) __attribute__((__nonnull__(first, ## args)))
#ifndef PRINTF
#define PRINTF(first, args...) __attribute__((__format__(printf, first, ## args)))
#endif
+#ifndef PURE
+#define PURE __attribute__((__pure__))
+#endif
#ifndef FLATTEN
#define FLATTEN __attribute__((__flatten__))
#endif
@@ -56,6 +84,9 @@
#endif
#ifndef __CONCAT
+#define __CONCAT(a, b) a ## b
+#endif
+#ifndef __CONCAT3
#define __CONCAT3(a, b, c) a ## b ## c
#endif
#ifndef CAT
@@ -152,5 +183,10 @@
#define MIN(a, b) ({(a) < (b) ? (a) : (b);})
#define MAX(a, b) ({(a) <= (b) ? (b) : (a);})
+/**
+ * Builtins that don't go in string.h
+ */
+#define unreachable() __builtin_unreachable()
+
#endif /* !COMPILER_H_ */
// vim:fenc=utf-8:tw=75:et