]> wimlib.net Git - wimlib/blobdiff - include/wimlib/compiler.h
bitops: rename bit scan functions
[wimlib] / include / wimlib / compiler.h
index a43bb769fdce9c752e3a75920c6ce48744133579..6bce5d0152e11742905461df5d1b6fcc1b71411d 100644 (file)
 #endif
 
 /* (Optional) Find Last Set bit and Find First Set bit macros.  */
-#define compiler_fls32(n)      (31 - __builtin_clz(n))
-#define compiler_fls64(n)      (63 - __builtin_clzll(n))
-#define compiler_ffs32(n)      __builtin_ctz(n)
-#define compiler_ffs64(n)      __builtin_ctzll(n)
+#define compiler_bsr32(n)      (31 - __builtin_clz(n))
+#define compiler_bsr64(n)      (63 - __builtin_clzll(n))
+#define compiler_bsf32(n)      __builtin_ctz(n)
+#define compiler_bsf64(n)      __builtin_ctzll(n)
 
 /* Optional definitions for checking with 'sparse'.  */
 #ifdef __CHECKER__
 #  define STATIC_ASSERT(expr)  ((void)sizeof(char[1 - 2 * !(expr)]))
 #endif
 
+/* STATIC_ASSERT_ZERO() - verify the truth of an expression at compilation time
+ * and also produce a result of value '0' to be used in constant expressions */
+#define STATIC_ASSERT_ZERO(expr) ((int)sizeof(char[-!(expr)]))
+
 #define CONCAT_IMPL(s1, s2)    s1##s2
 
 /* CONCAT() - concatenate two tokens at preprocessing time.  */