X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Fcompiler.h;h=222f889bb7c308a7c37fe93e0bdc6e9b92ecaec3;hb=5ba1093ddc24f41f2f4179aeb8e2c8e86401af8c;hp=a1f513f5da76cb7632a59e10a749bb665fc2b72d;hpb=0ecb0529b5fcacc1abafa1f3f02a40c44783ada8;p=wimlib diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index a1f513f5..222f889b 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -38,8 +38,14 @@ # define unlikely(expr) (expr) #endif -#ifndef prefetch -# define prefetch(addr) +/* prefetchr() - prefetch into L1 cache for read */ +#ifndef prefetchr +# define prefetchr(addr) +#endif + +/* prefetchw() - prefetch into L1 cache for write */ +#ifndef prefetchw +# define prefetchw(addr) #endif #ifndef _cold_attribute @@ -54,8 +60,17 @@ # define _format_attribute(type, format_str, format_start) #endif +#ifndef noinline +# define noinline +#endif + +/* Same as 'noinline', but 'noinline_for_stack' documents that 'noinline' is + * being used to prevent the annotated function from being inlined into a + * recursive function and increasing its stack usage. */ +#define noinline_for_stack noinline + #ifndef CPU_IS_BIG_ENDIAN -# error "missing required definition of CPU_IS_BIG_ENDIAN" +# error "missing required endianness definition" #endif #define CPU_IS_LITTLE_ENDIAN (!CPU_IS_BIG_ENDIAN) @@ -84,8 +99,16 @@ # define _force_attr #endif -#ifndef BUILD_BUG_ON -# define BUILD_BUG_ON(expr) ((void)sizeof(char[1 - 2*!!(expr)])) +/* STATIC_ASSERT() - verify the truth of an expression at compilation time. */ +#if __STDC_VERSION__ >= 201112L +# define STATIC_ASSERT(expr) _Static_assert((expr), "") +#else +# define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)])) #endif +#define CONCAT_IMPL(s1, s2) s1##s2 + +/* CONCAT() - concatenate two tokens at preprocessing time. */ +#define CONCAT(s1, s2) CONCAT_IMPL(s1, s2) + #endif /* _WIMLIB_COMPILER_H */