mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-26 23:00:45 +02:00
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.
This commit is contained in:
parent
b06c50cc54
commit
0769d39d00
1 changed files with 17 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue