ck_cc: Add branch execution hint support for GCC.

ck_pring
Samy Al Bahra 12 years ago
parent b63fe45460
commit cd53e928bf

@ -77,4 +77,12 @@
#define CK_CC_CACHELINE #define CK_CC_CACHELINE
#endif #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 */ #endif /* _CK_CC_H */

@ -75,6 +75,12 @@
#pragma GCC poison malloc free #pragma GCC poison malloc free
#endif #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. * Some compilers are overly strict regarding aliasing semantics.
* Unfortunately, in many cases it makes more sense to pay aliasing * Unfortunately, in many cases it makes more sense to pay aliasing

Loading…
Cancel
Save