From 7629fd211f7c7877fcc7a27e540ea9c0f007af35 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 5 Jun 2022 17:38:50 +0200 Subject: [PATCH] Update word size detection The detection for word size was dependent on `__LONG_WIDTH__` for at least gcc Alpine Linux (probably other musl distros too). This is not working with clang which does not define `__LONG_WIDTH__`. Replace `__LONG_WIDTH__` by `__SIZE_WIDTH__`. As this will not work as expected for x32 ABI, add a robust x32 detection first. --- lib/env.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/env.h b/lib/env.h index 0b84ebb3..4aa23ac0 100644 --- a/lib/env.h +++ b/lib/env.h @@ -43,12 +43,15 @@ #endif // Detect word size: -#if defined(_INTEGRAL_MAX_BITS) +#if defined(__x86_64__) && defined(__ILP32__) +// this is the way to detect x32 ABI per https://wiki.debian.org/X32Port +# define BASE64_WORDSIZE 64 +#elif defined(_INTEGRAL_MAX_BITS) # define BASE64_WORDSIZE _INTEGRAL_MAX_BITS #elif defined(__WORDSIZE) # define BASE64_WORDSIZE __WORDSIZE -#elif defined (__LONG_WIDTH__) -# define BASE64_WORDSIZE __LONG_WIDTH__ +#elif defined (__SIZE_WIDTH__) +# define BASE64_WORDSIZE __SIZE_WIDTH__ #else # error BASE64_WORDSIZE_NOT_DEFINED #endif