summaryrefslogtreecommitdiff
path: root/src/cairo-compiler-private.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-13 11:13:22 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-13 11:36:44 +0000
commit0769d39d0093ec3bff5b72ecbfcef1bae2f03be2 (patch)
tree3a5558719e8ed45f3a72b478555f87fc65e93aa7 /src/cairo-compiler-private.h
parentb06c50cc54140a662adacde6336a3e7777f26ac3 (diff)
downloadcairo-0769d39d0093ec3bff5b72ecbfcef1bae2f03be2.tar.gz
Add predicate likelihood macros.
Define the couple of standard macros that we can use to guide gcc optimisations of which code path will be most likely taken.
Diffstat (limited to 'src/cairo-compiler-private.h')
-rw-r--r--src/cairo-compiler-private.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index b93fd8298..76b8e8014 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -139,6 +139,23 @@
#define cairo_const
#endif
+#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#define _CAIRO_BOOLEAN_EXPR(expr) \
+ __extension__ ({ \
+ int _cairo_boolean_var_; \
+ if (expr) \
+ _cairo_boolean_var_ = 1; \
+ else \
+ _cairo_boolean_var_ = 0; \
+ _cairo_boolean_var_; \
+})
+#define _cairo_likely(expr) (__builtin_expect (_CAIRO_BOOLEAN_EXPR(expr), 1))
+#define _cairo_unlikely(expr) (__builtin_expect (_CAIRO_BOOLEAN_EXPR(expr), 0))
+#else
+#define _cairo_likely(expr) (expr)
+#define _cairo_unlikely(expr) (expr)
+#endif
+
#ifndef __GNUC__
#undef __attribute__
#define __attribute__(x)