diff options
| author | Olivia Lee <olivia.lee@collabora.com> | 2025-10-09 11:16:51 -0700 |
|---|---|---|
| committer | Marge Bot <marge-bot@fdo.invalid> | 2025-10-10 01:37:28 +0000 |
| commit | 10a8defecc7804247ae6bc0bfae8b650e87df3c4 (patch) | |
| tree | a7dd142a13754aa4941ce55ba310bf7785305804 | |
| parent | 196c7903b9a0305524d1d059b551071900fa6dfd (diff) | |
util/macros: coerce likely/unlikely to bool even without __builtin_expect
Coercing the argument to a bool when we have __builtin_expect but
leaving it unmodified otherwise is a recipe for really subtle bugs. I
don't know if any bugs like that exist currently, but I almost
introduced one in panfrost.
Signed-off-by: Olivia Lee <olivia.lee@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37801>
| -rw-r--r-- | src/util/macros.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/macros.h b/src/util/macros.h index d9487688900..007006744ed 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -66,8 +66,8 @@ # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) # else -# define likely(x) (x) -# define unlikely(x) (x) +# define likely(x) (!!(x)) +# define unlikely(x) (!!(x)) # endif #endif |