4 * The author dedicates this file to the public domain.
5 * You can do whatever you want with this file.
8 #ifndef _WIMLIB_COMPILER_H
9 #define _WIMLIB_COMPILER_H
12 # include "wimlib/compiler-gcc.h"
14 # error "Unrecognized compiler. Please add a header file for your compiler."
21 #ifndef _packed_attribute
22 # error "missing required definition of _packed_attribute"
25 #ifndef _aligned_attribute
26 # error "missing required definition of _aligned_attribute"
29 #ifndef _may_alias_attribute
30 # error "missing required definition of _may_alias_attribute"
34 # define likely(expr) (expr)
38 # define unlikely(expr) (expr)
41 /* prefetchr() - prefetch into L1 cache for read */
43 # define prefetchr(addr)
46 /* prefetchw() - prefetch into L1 cache for write */
48 # define prefetchw(addr)
51 #ifndef _cold_attribute
52 # define _cold_attribute
55 #ifndef _malloc_attribute
56 # define _malloc_attribute
59 #ifndef _format_attribute
60 # define _format_attribute(type, format_str, format_start)
67 /* Same as 'noinline', but 'noinline_for_stack' documents that 'noinline' is
68 * being used to prevent the annotated function from being inlined into a
69 * recursive function and increasing its stack usage. */
70 #define noinline_for_stack noinline
72 #ifndef CPU_IS_BIG_ENDIAN
73 # error "missing required endianness definition"
76 #define CPU_IS_LITTLE_ENDIAN (!CPU_IS_BIG_ENDIAN)
78 #ifndef UNALIGNED_ACCESS_SPEED
79 # define UNALIGNED_ACCESS_SPEED 0
82 #define UNALIGNED_ACCESS_IS_ALLOWED (UNALIGNED_ACCESS_SPEED >= 1)
83 #define UNALIGNED_ACCESS_IS_FAST (UNALIGNED_ACCESS_SPEED >= 2)
84 #define UNALIGNED_ACCESS_IS_VERY_FAST (UNALIGNED_ACCESS_SPEED >= 3)
87 # error "missing required definition of typeof"
90 #if !defined(min) || !defined(max) || !defined(swap)
91 # error "missing required definitions of min(), max(), and swap() macros"
95 # define _bitwise_attr __attribute__((bitwise))
96 # define _force_attr __attribute__((force))
98 # define _bitwise_attr
102 /* STATIC_ASSERT() - verify the truth of an expression at compilation time. */
103 #if __STDC_VERSION__ >= 201112L
104 # define STATIC_ASSERT(expr) _Static_assert((expr), "")
106 # define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)]))
109 #define CONCAT_IMPL(s1, s2) s1##s2
111 /* CONCAT() - concatenate two tokens at preprocessing time. */
112 #define CONCAT(s1, s2) CONCAT_IMPL(s1, s2)
114 #endif /* _WIMLIB_COMPILER_H */