Skip to content

Commit 1402ac1

Browse files
committed
Fix build for old gcc.
Only enable ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO for gcc9 later, __builtin_cpu_supports support pclmul later. Also use _mm_move_epi64 instead. Signed-off-by: Frank Du <[email protected]>
1 parent 1b3319a commit 1402ac1

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

Zend/zend_cpuinfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,16 @@ static zend_always_inline int zend_cpu_supports_sse42() {
159159
return __builtin_cpu_supports("sse4.2");
160160
}
161161

162+
/* __builtin_cpu_supports has pclmul from gcc9 */
163+
#if (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
162164
ZEND_NO_SANITIZE_ADDRESS
163165
static zend_always_inline int zend_cpu_supports_pclmul() {
164166
#if PHP_HAVE_BUILTIN_CPU_INIT
165167
__builtin_cpu_init();
166168
#endif
167169
return __builtin_cpu_supports("pclmul");
168170
}
171+
#endif
169172

170173
ZEND_NO_SANITIZE_ADDRESS
171174
static zend_always_inline int zend_cpu_supports_avx() {

Zend/zend_portability.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ extern "C++" {
559559
#endif
560560

561561
/* Do not use for conditional declaration of API functions! */
562-
#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
562+
#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
563+
/* __builtin_cpu_supports has pclmul from gcc9 */
563564
# define ZEND_INTRIN_PCLMUL_FUNC_PROTO 1
564565
#elif defined(ZEND_INTRIN_PCLMUL_RESOLVER)
565566
# define ZEND_INTRIN_PCLMUL_FUNC_PTR 1
@@ -584,7 +585,8 @@ extern "C++" {
584585
#endif
585586

586587
/* Do not use for conditional declaration of API functions! */
587-
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
588+
#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
589+
/* __builtin_cpu_supports has pclmul from gcc9 */
588590
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO 1
589591
#elif defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
590592
# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR 1

ext/standard/crc32_x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ size_t crc32_pclmul_batch(uint32_t *crc, const unsigned char *p, size_t nr, cons
173173

174174
/* barrett reduction */
175175
k = _mm_loadu_si128((__m128i*)consts->uPx);
176-
x1 = _mm_loadu_si64(&x0);
176+
x1 = _mm_move_epi64(x0);
177177
x1 = _mm_srli_si128(x1, 4);
178178
x1 = _mm_clmulepi64_si128(x1, k, 0x00);
179179
x1 = _mm_srli_si128(x1, 4);

ext/standard/crc32_x86.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef enum {
2828
*/
2929
X86_CRC32B,
3030
/*
31-
polynomial: 0x1EDC6F41 witn reversed ordering,
31+
polynomial: 0x1EDC6F41 with reversed ordering,
3232
used by iSCSI, SCTP, Btrfs, ext4, etc
3333
*/
3434
X86_CRC32C,

0 commit comments

Comments
 (0)