inew compatibility header from Ian Abbott <abbotti@mev.co.uk>
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 23:15:05 +0000 (23:15 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 23:15:05 +0000 (23:15 +0000)
include/linux/compiler.h [new file with mode: 0644]

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
new file mode 100644 (file)
index 0000000..658110c
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * linux/compiler.h compatibility header
+ */
+
+#ifndef _COMPAT_COMPILER_H
+#define _COMPAT_COMPILER_H
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
+
+#include_next <linux/compiler.h>
+
+#else
+
+/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
+   a mechanism by which the user can annotate likely branch directions and
+   expect the blocks to be reordered appropriately.  Define __builtin_expect
+   to nothing for earlier compilers.  */
+
+#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
+#define __builtin_expect(x, expected_value) (x)
+#endif
+#endif
+
+#ifndef likely
+#define likely(x)      __builtin_expect(!!(x),1)
+#define unlikely(x)    __builtin_expect(!!(x),0)
+#endif
+
+#endif /* _COMPAT_COMPILER_H */
+
+