From cd53e928bfc792deb22d5c91f79c3c8221ed4649 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 24 Jun 2013 11:48:22 -0400 Subject: [PATCH] ck_cc: Add branch execution hint support for GCC. --- include/ck_cc.h | 8 ++++++++ include/gcc/ck_cc.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/ck_cc.h b/include/ck_cc.h index 5586cdc..4c35e19 100644 --- a/include/ck_cc.h +++ b/include/ck_cc.h @@ -77,4 +77,12 @@ #define CK_CC_CACHELINE #endif +#ifndef CK_CC_LIKELY +#define CK_CC_LIKELY(x) +#endif + +#ifndef CK_CC_UNLIKELY +#define CK_CC_UNLIKELY(x) +#endif + #endif /* _CK_CC_H */ diff --git a/include/gcc/ck_cc.h b/include/gcc/ck_cc.h index b4a0e2b..8feaaa5 100644 --- a/include/gcc/ck_cc.h +++ b/include/gcc/ck_cc.h @@ -75,6 +75,12 @@ #pragma GCC poison malloc free #endif +/* + * Branch execution hints. + */ +#define CK_CC_LIKELY(x) (__builtin_expect(!!(x), 1)) +#define CK_CC_UNLIKELY(x) (__builtin_expect(!!(x), 0)) + /* * Some compilers are overly strict regarding aliasing semantics. * Unfortunately, in many cases it makes more sense to pay aliasing