runtime/internal/lib/internal/cpu: use __cpuid_count

This commit is contained in:
visualfc
2025-08-20 16:53:53 +08:00
parent cbac24cf97
commit 56733e1dbd

View File

@@ -1,19 +1,12 @@
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#include <cpuid.h>
void llgo_getcpuid(unsigned int eax, unsigned int ecx, void llgo_getcpuid(unsigned int eax, unsigned int ecx,
unsigned int *a, unsigned int *b, unsigned int *a, unsigned int *b,
unsigned int *c, unsigned int *d) unsigned int *c, unsigned int *d)
{ {
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__( __cpuid_count(eax, ecx, *a, *b, *c, *d);
"pushq %%rbp\n\t"
"movq %%rsp, %%rbp\n\t"
"andq $-16, %%rsp\n\t" // 16-byte align stack
"cpuid\n\t"
"movq %%rbp, %%rsp\n\t"
"popq %%rbp\n\t"
: "=a"(*a), "=b"(*b), "=c"(*c), "=d"(*d)
: "a"(eax), "c"(ecx)
: "memory");
#endif #endif
} }
#else #else