diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
| commit | a201939a8150bc4c2f221925797ea2751c74b77c (patch) | |
| tree | 26fee4ec601319fd8771435087931023e393fe92 /stdlib/util.h | |
| parent | 683b0f5141ad21914d77cd4b4b81e7e2161f90f3 (diff) | |
Use likely()/unlikely() macros and a few bugfixes for integers
Diffstat (limited to 'stdlib/util.h')
| -rw-r--r-- | stdlib/util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/stdlib/util.h b/stdlib/util.h index 310ba905..98c087a7 100644 --- a/stdlib/util.h +++ b/stdlib/util.h @@ -39,6 +39,14 @@ #define INLINE inline __attribute__ ((always_inline)) #endif +#ifndef likely +#define likely(x) (__builtin_expect(!!(x), 1)) +#endif + +#ifndef unlikely +#define unlikely(x) (__builtin_expect(!!(x), 0)) +#endif + // GCC lets you define macro-like functions which are always inlined and never // compiled using this combination of flags. See: https://gcc.gnu.org/onlinedocs/gcc/Inline.html #ifndef MACROLIKE |
