diff --git a/libc/private/bionic_macros.h b/libc/private/bionic_macros.h index a3a69853d..61794bd54 100644 --- a/libc/private/bionic_macros.h +++ b/libc/private/bionic_macros.h @@ -37,6 +37,8 @@ (((value) + (alignment) - 1) & ~((alignment) - 1)) #define BIONIC_ROUND_UP_POWER_OF_2(value) \ - (1UL << (sizeof(value) * 8 - 1 - __builtin_clz(value))) + (sizeof(value) == 8) \ + ? (1UL << (64 - __builtin_clzl(static_cast(value)))) \ + : (1UL << (32 - __builtin_clz(static_cast(value)))) #endif // _BIONIC_MACROS_H_