summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-02-08 12:29:51 +0200
committerRan Benita <ran234@gmail.com>2014-02-08 12:42:16 +0200
commit10643d8aa41666f037b02d79ca04573b85646457 (patch)
tree8616ef429a8b49ee00a82bd6a7e76dbc913da823 /src/utils.h
parent0e20cfed67a579305fef9501fdd2f27634cd2aa3 (diff)
downloadxorg-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.h8
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__)