X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Fcompiler.h;h=1ea66968b10b6cbad675bcb55d55e823f95088a8;hp=11eaa2398f2a560dd336872c1e355a9d2d955fcf;hb=de58d5f57732df8129fbfd71d46ae5968ac59646;hpb=855b49ef85d274588a2848d9c69974f9b88d343a diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 11eaa239..1ea66968 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 @@ -58,8 +64,13 @@ # 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) @@ -88,8 +99,11 @@ # 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 #endif /* _WIMLIB_COMPILER_H */