]> wimlib.net Git - wimlib/blobdiff - include/wimlib/compiler.h
decompress_common.h: Optimize bitstream_ensure_bits()
[wimlib] / include / wimlib / compiler.h
index 19a9ebe70c6763cd9efb91242487a80eb45dd78d..fd8942f15bf025bec6aa5485fcfadc07402d2096 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * compiler.h
+ *
+ * The author dedicates this file to the public domain.
+ * You can do whatever you want with this file.
+ */
+
 #ifndef _WIMLIB_COMPILER_H
 #define _WIMLIB_COMPILER_H
 
 #      define _malloc_attribute __attribute__((malloc))
 #      define _warn_unused_result_attribute __attribute__((warn_unused_result))
 #      define _aligned_attribute(size) __attribute__((aligned(size)))
+#      define likely(x) __builtin_expect(!!(x), 1)
+#      define unlikely(x) __builtin_expect(!!(x), 0)
+#      define inline inline __attribute__((always_inline))
+#      define prefetch(x) __builtin_prefetch(x)
+#      define is_constant(x) __builtin_constant_p(x)
 #else
 #      define WIMLIBAPI
 #      define _always_inline_attribute inline
 #      define _malloc_attribute
 #      define _warn_unused_result_attribute
 #      define _aligned_attribute(size)
+#      define likely(x) (x)
+#      define unlikely(x) (x)
+#      define prefetch(x)
+#      define is_constant(x) (0)
 #endif /* __GNUC__ */
 
 #endif /* _WIMLIB_COMPILER_H */