[Pixman] [PATCH 1/3] pixman-compiler.h: Add unlikely() macro

Søren Sandmann sandmann at cs.au.dk
Thu Jan 31 12:01:43 PST 2013


From: Søren Sandmann Pedersen <ssp at redhat.com>

When compiling with GCC this macro expands to __builtin_expect((expr), 0).
On other compilers, it just expands to (expr).
---
 pixman/pixman-compiler.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h
index 2e45dea..9b190b4 100644
--- a/pixman/pixman-compiler.h
+++ b/pixman/pixman-compiler.h
@@ -19,6 +19,12 @@
 #endif
 
 #if defined (__GNUC__)
+#  define unlikely(expr) __builtin_expect ((expr), 0)
+#else
+#  define unlikely(expr)  (expr)
+#endif
+
+#if defined (__GNUC__)
 #  define MAYBE_UNUSED  __attribute__((unused))
 #else
 #  define MAYBE_UNUSED
-- 
1.7.4



More information about the Pixman mailing list