Skip to content

Commit 50ca242

Browse files
committedSep 8, 2023
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.
1 parent be87cf9 commit 50ca242

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎ext/mbstring/libmbfl/filters/mbfilter_utf16.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ static size_t mb_utf16be_to_wchar_avx2(unsigned char **in, size_t *in_len, uint3
746746
*out++ = (((n & 0x3FF) << 10) | (n2 & 0x3FF)) + 0x10000;
747747
bufsize--;
748748
len -= 4;
749-
#ifdef PHP_HAVE_BUILTIN_USUB_OVERFLOW
749+
#if defined(PHP_HAVE_BUILTIN_USUB_OVERFLOW) && PHP_HAVE_BUILTIN_USUB_OVERFLOW
750750
/* Subtracting 2 from `n_chars` will automatically set the CPU's flags;
751751
* branch directly off the appropriate flag (CF on x86) rather than using
752752
* 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
932932
*out++ = (((n & 0x3FF) << 10) | (n2 & 0x3FF)) + 0x10000;
933933
bufsize--;
934934
len -= 4;
935-
#ifdef PHP_HAVE_BUILTIN_USUB_OVERFLOW
935+
#if defined(PHP_HAVE_BUILTIN_USUB_OVERFLOW) && PHP_HAVE_BUILTIN_USUB_OVERFLOW
936936
if (__builtin_usub_overflow(n_chars, 2, &n_chars)) {
937937
break;
938938
}

0 commit comments

Comments
 (0)