diff options
author | Ran Benita <ran234@gmail.com> | 2014-02-08 12:29:51 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-02-08 12:42:16 +0200 |
commit | 10643d8aa41666f037b02d79ca04573b85646457 (patch) | |
tree | 8616ef429a8b49ee00a82bd6a7e76dbc913da823 /src/utils.h | |
parent | 0e20cfed67a579305fef9501fdd2f27634cd2aa3 (diff) | |
download | xorg-lib-libxkbcommon-10643d8aa41666f037b02d79ca04573b85646457.tar.gz |
Define likely()/unlikely() macros
It serves as nice "hotspot" annotations, and can also help things, so
why not.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index f7fc7a5..6affee1 100644 --- a/src/utils.h +++ b/src/utils.h @@ -195,6 +195,14 @@ unmap_file(const char *str, size_t size); # define secure_getenv getenv #endif +#if defined(HAVE___BUILTIN_EXPECT) +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +#else +# define likely(x) (x) +# define unlikely(x) (x) +#endif + /* Compiler Attributes */ #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) |