diff options
| author | Russ White <russ@riw.us> | 2023-04-04 08:20:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 08:20:25 -0400 |
| commit | c0656e90406bcac5094a8bce86c03c1913a80831 (patch) | |
| tree | c7f3e393f0ba2deab99c721fd2b452710a74f485 /lib/compiler.h | |
| parent | 6fc9bfb11ddf5c187bad91e1a759361d249f512f (diff) | |
| parent | 71cb4a57a8a2047623497d2e4100b5c99d236b81 (diff) | |
Merge pull request #12837 from donaldsharp/unlikely_routemap
Unlikely routemap
Diffstat (limited to 'lib/compiler.h')
| -rw-r--r-- | lib/compiler.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/compiler.h b/lib/compiler.h index d12e282832..29fcfbefbf 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -439,6 +439,14 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8, #pragma diag_suppress 167 #endif /* __INTELISENSE__ */ +#if defined(__GNUC__) && (__GNUC__ >= 3) +#define likely(_x) __builtin_expect(!!(_x), 1) +#define unlikely(_x) __builtin_expect(!!(_x), 0) +#else +#define likely(_x) !!(_x) +#define unlikely(_x) !!(_x) +#endif + #ifdef __cplusplus } #endif |
