Use fallthrough attribute
[fio.git] / compiler / compiler.h
index ddfbcc124e77ac2b1a5d7aea1640ccbc4577a331..8988236c828a909bca94df49891508fcfc8d8945 100644 (file)
@@ -1,17 +1,10 @@
 #ifndef FIO_COMPILER_H
 #define FIO_COMPILER_H
 
-/* IWYU pragma: begin_exports */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
-#include "compiler-gcc4.h"
-#else
-#error Compiler too old, need at least gcc 4.1.0
-#endif
-/* IWYU pragma: end_exports */
+#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 FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f))
 #endif
 
+#ifndef __has_attribute
+#define __GCC4_has_attribute___fallthrough__   0
+#endif
+
+#if __has_attribute(__fallthrough__)
+#define fallthrough     __attribute__((__fallthrough__))
+#else
+#define fallthrough    do {} while (0)  /* fallthrough */
+#endif
+
 #endif