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