1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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.
This commit is contained in:
Alex Dowad
2023-09-08 20:33:11 +02:00
committed by Jakub Zelenka
parent 1f25dea498
commit 0c22276888

View File

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