diff options
| author | Chia-I Wu <olv@lunarg.com> | 2015-02-17 14:20:58 -0700 |
|---|---|---|
| committer | Chia-I Wu <olv@lunarg.com> | 2015-02-18 10:28:49 -0700 |
| commit | c15ee675c83e82726f6b02776a32528e5e624eed (patch) | |
| tree | 2070945b5af0a9d7cda3b75d22f69cf003562145 | |
| parent | 51d58df03f34a783b683ef4a3eba079f1c3aa325 (diff) | |
| download | usermoji-c15ee675c83e82726f6b02776a32528e5e624eed.tar.xz | |
icd: add likely()/unlikely()
They will be expanded to __builtin_expect(...) on gcc.
| -rw-r--r-- | icd/common/icd-utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/icd/common/icd-utils.h b/icd/common/icd-utils.h index c8eedea8..5304d158 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) |
