Stop doing cpuid repeatedly in runtime

This commit is contained in:
Vitaliy Filippov
2025-08-10 18:03:22 +03:00
parent 1de53ef7e6
commit 29dda5066f
+6 -2
View File
@@ -367,9 +367,13 @@ uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
#ifndef __x86_64__ #ifndef __x86_64__
return crc32c_sw(crc, buf, len); return crc32c_sw(crc, buf, len);
#else #else
int sse42; static int sse42 = 0;
if (!sse42)
{
SSE42(sse42); SSE42(sse42);
return sse42 ? crc32c_hw(crc, buf, len) : crc32c_sw(crc, buf, len); sse42 = sse42 ? 2 : 1;
}
return sse42 == 2 ? crc32c_hw(crc, buf, len) : crc32c_sw(crc, buf, len);
#endif #endif
} }