Skip to content

Commit 7693a01

Browse files
dixyescmb69
authored andcommitted
Use IsProcessorFeaturePresent instead
1 parent 3dc54b5 commit 7693a01

File tree

1 file changed

+1
-51
lines changed

1 file changed

+1
-51
lines changed

ext/standard/crc32.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,56 +39,6 @@ static unsigned long getauxval(unsigned long key) {
3939
return 0;
4040
return ret;
4141
}
42-
# elif defined(PHP_WIN32)
43-
/*
44-
get crc32 support info
45-
this is undocumented, to be confirmed
46-
read id_aa64isar0_el1 from registry HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\x\CP 4030
47-
*/
48-
int winaa64_support_crc32c() {
49-
const WCHAR cpus_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\";
50-
HKEY cpus_handle;
51-
if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_LOCAL_MACHINE, cpus_key, 0, KEY_ENUMERATE_SUB_KEYS, &cpus_handle)) {
52-
return 0;
53-
}
54-
DWORD cpu_index = 0;
55-
WCHAR cpu_num[256] = { 0 };
56-
uint64_t CP4030 = 0;
57-
WCHAR cpu_key[(sizeof(cpus_key) / sizeof(*cpus_key)) + 256] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\";
58-
while (ERROR_SUCCESS == RegEnumKeyW(cpus_handle, cpu_index++, cpu_num, 255)) {
59-
if (0 != wcscpy_s(&cpu_key[sizeof(cpus_key) / sizeof(*cpus_key) - 1], 256, cpu_num)) {
60-
break;
61-
}
62-
HKEY cpu_handle;
63-
if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_LOCAL_MACHINE, cpu_key, 0, KEY_READ, &cpu_handle)) {
64-
break;
65-
}
66-
DWORD value_type;
67-
uint64_t value;
68-
DWORD value_size = sizeof(value);
69-
if (ERROR_SUCCESS != RegQueryValueExW(cpu_handle, L"CP 4030", NULL, &value_type, (LPBYTE)&value, &value_size)) {
70-
RegCloseKey(cpu_handle);
71-
break;
72-
}
73-
74-
if (REG_QWORD != value_type) {
75-
RegCloseKey(cpu_handle);
76-
break;
77-
}
78-
//wprintf(L"cp4030 for cpu[%d] \"%s\" is %016zx\n", cpu_index-1, cpu_num, value);
79-
// save any bits not set
80-
CP4030 |= ~value;
81-
82-
RegCloseKey(cpu_handle);
83-
}
84-
//printf("rev CP4030 is %016zx\n", CP4030);
85-
RegCloseKey(cpus_handle);
86-
if (CP4030 & 0x10000 /* crc32: bit 16-19 (only bit 16 used) */) {
87-
//printf("not supported by at least one cpu\n");
88-
return 0;
89-
}
90-
return 1;
91-
}
9242
# endif
9343

9444
static inline int has_crc32_insn() {
@@ -108,7 +58,7 @@ static inline int has_crc32_insn() {
10858
res = 0;
10959
return res;
11060
# elif defined(WIN32)
111-
res = winaa64_support_crc32c();
61+
res = (int)IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
11262
return res;
11363
# else
11464
res = 0;

0 commit comments

Comments
 (0)