Skip to content

Commit

Permalink
Fix build for non-x86
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Nov 27, 2020
1 parent 4e30ab3 commit 3430d85
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Zend/zend_cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,21 @@ static void __zend_cpuid(uint32_t func, uint32_t subfunc, zend_cpu_info *cpuinfo
}
#endif

#if defined(__i386__) || defined(__x86_64__)
/* Function based on compiler-rt implementation. */
static unsigned get_xcr0_eax() {
#if defined(__GNUC__) || defined(__clang__)
# if defined(__GNUC__) || defined(__clang__)
// Check xgetbv; this uses a .byte sequence instead of the instruction
// directly because older assemblers do not include support for xgetbv and
// there is no easy way to conditionally compile based on the assembler used.
unsigned eax, edx;
__asm__(".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0));
return eax;
#elif defined(ZEND_WIN32) && defined(_XCR_XFEATURE_ENABLED_MASK)
# elif defined(ZEND_WIN32) && defined(_XCR_XFEATURE_ENABLED_MASK)
return _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
#else
# else
return 0;
#endif
# endif
}

static zend_bool is_avx_supported() {
Expand All @@ -104,6 +105,11 @@ static zend_bool is_avx_supported() {
}
return 1;
}
#else
static zend_bool is_avx_supported() {
return 0;
}
#endif

void zend_cpu_startup(void)
{
Expand Down

0 comments on commit 3430d85

Please sign in to comment.