util/macros: coerce likely/unlikely to bool even without __builtin_expect
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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>
This commit is contained in:
Olivia Lee 2025-10-09 11:16:51 -07:00 committed by Marge Bot
parent 196c7903b9
commit 10a8defecc

View file

@ -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