[PATCH v2] malloc: replace instances of __builtin_expect with __glibc_unlikely

Wilco Dijkstra Wilco.Dijkstra@arm.com
Thu Jun 26 15:14:09 GMT 2025


Hi William,

> Replaced all instances of __builtin_expect to __glibc_unlikely
> within malloc.c and malloc-debug.c. This improves the portability
> of glibc by avoiding calls to GNU C built-in functions. Since all
> the expected results from calls to __builtin_expect were 0,
> __glibc_likely was never used as a replacement. Multiple
> calls to __builtin_expect within a single if statement have
> been replaced with one call to __glibc_unlikely, which wraps
> every condition.
>
> Changes from v1:
> - Add Wilco's suggestion to refactor in malloc-debug.c

LGTM.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>

I'll commit this in a bit.

Cheers,
Wilco


More information about the Libc-alpha mailing list