ci: Verify the Android build
[fio.git] / compiler / compiler.h
index 40e857c004c6e4304565ad1e446b4bffaf90eb35..fefadeaa89fc5e4043d3024a98488f07fe9cbdb9 100644 (file)
@@ -1,17 +1,10 @@
 #ifndef FIO_COMPILER_H
 #define FIO_COMPILER_H
 
-#if __GNUC__ >= 4
-#include "compiler-gcc4.h"
-#elif __GNUC__ == 3
-#include "compiler-gcc3.h"
-#else
-#error Compiler too old, need gcc at least gcc 3.x
-#endif
+#define __must_check           __attribute__((warn_unused_result))
 
-#ifndef __must_check
-#define __must_check
-#endif
+#define __compiletime_warning(message) __attribute__((warning(message)))
+#define __compiletime_error(message)   __attribute__((error(message)))
 
 /*
  * Mark unused variables passed to ops functions as unused, to silence gcc
  */
 #define typecheck(type,x) \
 ({     type __dummy; \
-       typeof(x) __dummy2; \
+       __typeof__(x) __dummy2; \
        (void)(&__dummy == &__dummy2); \
        1; \
 })
 
+
+#if defined(CONFIG_STATIC_ASSERT)
+#define compiletime_assert(condition, msg) _Static_assert(condition, msg)
+
+#elif !defined(CONFIG_DISABLE_OPTIMIZATIONS)
+
 #ifndef __compiletime_error
 #define __compiletime_error(message)
 #endif
+
 #ifndef __compiletime_error_fallback
 #define __compiletime_error_fallback(condition)        do { } while (0)
 #endif
 #define compiletime_assert(condition, msg) \
        _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
 
+#else
+
+#define compiletime_assert(condition, msg)     do { } while (0)
+
+#endif
+
+#ifdef FIO_INTERNAL
+#define FIO_ARRAY_SIZE(x)    (sizeof((x)) / (sizeof((x)[0])))
+#define FIO_FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f))
+#endif
+
+#ifndef __has_attribute
+#define __has_attribute(x) __GCC4_has_attribute_##x
+#define __GCC4_has_attribute___fallthrough__   0
+#endif
+
+#if __has_attribute(__fallthrough__)
+#define fio_fallthrough         __attribute__((__fallthrough__))
+#else
+#define fio_fallthrough        do {} while (0)  /* fallthrough */
+#endif
+
 #endif