From a201939a8150bc4c2f221925797ea2751c74b77c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 7 Dec 2024 15:59:37 -0500 Subject: Use likely()/unlikely() macros and a few bugfixes for integers --- stdlib/util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'stdlib/util.h') 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 -- cgit v1.2.3