From c15ee675c83e82726f6b02776a32528e5e624eed Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 17 Feb 2015 14:20:58 -0700 Subject: [PATCH] icd: add likely()/unlikely() They will be expanded to __builtin_expect(...) on gcc. --- icd/common/icd-utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/icd/common/icd-utils.h b/icd/common/icd-utils.h index c8eedea..5304d15 100644 --- a/icd/common/icd-utils.h +++ b/icd/common/icd-utils.h @@ -40,6 +40,14 @@ #define U_ASSERT_ONLY #endif +#if defined(__GNUC__) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define likely(x) (x) +#define unlikely(x) (x) +#endif + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define u_popcount(u) __builtin_popcount(u) -- 2.7.4