From 0c22276888062a87f4edbb50446387430b524790 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Fri, 8 Sep 2023 20:33:11 +0200 Subject: [PATCH] PHP_HAVE_BUILTIN_USUB_OVERFLOW macro is defined even if __builtin_usub_overflow not available ...So conditionally including code which uses __builtin_usub_overflow (for performance) if the macro is defined is not correct. We also need to check if the macro is defined as a non-zero value. Apparently this broke the build for a user whose C compiler is GCC 4.9.4. Sorry, user! That was my fault! Thanks to Jakub Zelenka for reporting the issue. --- ext/mbstring/libmbfl/filters/mbfilter_utf16.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c index 9e584cb354c..6e687c941c2 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c @@ -746,7 +746,7 @@ static size_t mb_utf16be_to_wchar_avx2(unsigned char **in, size_t *in_len, uint3 *out++ = (((n & 0x3FF) << 10) | (n2 & 0x3FF)) + 0x10000; bufsize--; len -= 4; -#ifdef PHP_HAVE_BUILTIN_USUB_OVERFLOW +#if defined(PHP_HAVE_BUILTIN_USUB_OVERFLOW) && PHP_HAVE_BUILTIN_USUB_OVERFLOW /* Subtracting 2 from `n_chars` will automatically set the CPU's flags; * branch directly off the appropriate flag (CF on x86) rather than using * another instruction (CMP on x86) to check for underflow */ @@ -932,7 +932,7 @@ static size_t mb_utf16le_to_wchar_avx2(unsigned char **in, size_t *in_len, uint3 *out++ = (((n & 0x3FF) << 10) | (n2 & 0x3FF)) + 0x10000; bufsize--; len -= 4; -#ifdef PHP_HAVE_BUILTIN_USUB_OVERFLOW +#if defined(PHP_HAVE_BUILTIN_USUB_OVERFLOW) && PHP_HAVE_BUILTIN_USUB_OVERFLOW if (__builtin_usub_overflow(n_chars, 2, &n_chars)) { break; }