Commit | Line | Data |
---|---|---|
4fee8096 JA |
1 | #ifndef FIO_COMPILER_H |
2 | #define FIO_COMPILER_H | |
3 | ||
4 | #if __GNUC__ >= 4 | |
5 | #include "compiler-gcc4.h" | |
73e07acd | 6 | #elif __GNUC__ == 3 |
4fee8096 JA |
7 | #include "compiler-gcc3.h" |
8 | #else | |
9 | #error Compiler too old, need gcc at least gcc 3.x | |
10 | #endif | |
11 | ||
993cca04 JA |
12 | #ifndef __must_check |
13 | #define __must_check | |
14 | #endif | |
15 | ||
7b4203d7 JA |
16 | /* |
17 | * Mark unused variables passed to ops functions as unused, to silence gcc | |
18 | */ | |
19 | #define fio_unused __attribute__((__unused__)) | |
20 | #define fio_init __attribute__((constructor)) | |
21 | #define fio_exit __attribute__((destructor)) | |
22 | ||
225ba9e3 JA |
23 | #define fio_unlikely(x) __builtin_expect(!!(x), 0) |
24 | ||
ff8039b7 JA |
25 | /* |
26 | * Check at compile time that something is of a particular type. | |
27 | * Always evaluates to 1 so you may use it easily in comparisons. | |
28 | */ | |
29 | #define typecheck(type,x) \ | |
30 | ({ type __dummy; \ | |
31 | typeof(x) __dummy2; \ | |
32 | (void)(&__dummy == &__dummy2); \ | |
33 | 1; \ | |
34 | }) | |
35 | ||
4fee8096 | 36 | #endif |