]> wimlib.net Git - wimlib/blob - include/wimlib/compiler.h
Header fixes
[wimlib] / include / wimlib / compiler.h
1 /*
2  * compiler.h
3  *
4  * The author dedicates this file to the public domain.
5  * You can do whatever you want with this file.
6  */
7
8 #ifndef _WIMLIB_COMPILER_H
9 #define _WIMLIB_COMPILER_H
10
11 #ifdef __GNUC__
12 #  include "wimlib/compiler-gcc.h"
13 #else
14 #  error "Unrecognized compiler.  Please add a header file for your compiler."
15 #endif
16
17 #ifndef WIMLIBAPI
18 #  define WIMLIBAPI
19 #endif
20
21 #ifndef _packed_attribute
22 #  error "missing required definition of _packed_attribute"
23 #endif
24
25 #ifndef _aligned_attribute
26 #  error "missing required definition of _aligned_attribute"
27 #endif
28
29 #ifndef _may_alias_attribute
30 #  error "missing required definition of _may_alias_attribute"
31 #endif
32
33 #ifndef likely
34 #  define likely(expr)          (expr)
35 #endif
36
37 #ifndef unlikely
38 #  define unlikely(expr)        (expr)
39 #endif
40
41 #ifndef prefetch
42 #  define prefetch(addr)
43 #endif
44
45 #ifndef _cold_attribute
46 #  define _cold_attribute
47 #endif
48
49 #ifndef _malloc_attribute
50 #  define _malloc_attribute
51 #endif
52
53 #ifndef _format_attribute
54 #  define _format_attribute(type, format_str, format_start)
55 #endif
56
57 #ifndef CPU_IS_BIG_ENDIAN
58 #  error "missing required definition of CPU_IS_BIG_ENDIAN"
59 #endif
60
61 #define CPU_IS_LITTLE_ENDIAN (!CPU_IS_BIG_ENDIAN)
62
63 #ifndef UNALIGNED_ACCESS_SPEED
64 #  define UNALIGNED_ACCESS_SPEED 0
65 #endif
66
67 #define UNALIGNED_ACCESS_IS_ALLOWED     (UNALIGNED_ACCESS_SPEED >= 1)
68 #define UNALIGNED_ACCESS_IS_FAST        (UNALIGNED_ACCESS_SPEED >= 2)
69 #define UNALIGNED_ACCESS_IS_VERY_FAST   (UNALIGNED_ACCESS_SPEED >= 3)
70
71 #ifndef typeof
72 #  error "missing required definition of typeof"
73 #endif
74
75 #if !defined(min) || !defined(max) || !defined(swap)
76 #  error "missing required definitions of min(), max(), and swap() macros"
77 #endif
78
79 #ifdef __CHECKER__
80 #  define _bitwise_attr __attribute__((bitwise))
81 #  define _force_attr   __attribute__((force))
82 #else
83 #  define _bitwise_attr
84 #  define _force_attr
85 #endif
86
87 #ifndef BUILD_BUG_ON
88 #  define BUILD_BUG_ON(expr)    ((void)sizeof(char[1 - 2*!!(expr)]))
89 #endif
90
91 #endif /* _WIMLIB_COMPILER_H */