X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=compiler%2Fcompiler.h;h=44fa87b90cf8c5959ec76c8544aa90480b89f318;hb=dc10c23ab9a7b34f50a4957789ce1f2e0883366b;hp=8eba2929f6b3f8e9cd431b12ac186b62921712d4;hpb=5b3da1650f5069547712d993b6096291d3b2bb14;p=fio.git diff --git a/compiler/compiler.h b/compiler/compiler.h index 8eba2929..44fa87b9 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -1,17 +1,10 @@ #ifndef FIO_COMPILER_H #define FIO_COMPILER_H -/* IWYU pragma: begin_exports */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __clang_major__ >= 6 -#include "compiler-gcc4.h" -#else -#error Compiler too old, need at least gcc 4.9 -#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 @@ -69,8 +62,18 @@ #endif #ifdef FIO_INTERNAL -#define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0]))) -#define FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f)) +#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 __GCC4_has_attribute___fallthrough__ 0 +#endif + +#if __has_attribute(__fallthrough__) +#define fallthrough __attribute__((__fallthrough__)) +#else +#define fallthrough do {} while (0) /* fallthrough */ #endif #endif