26 lines
439 B
C++
26 lines
439 B
C++
#if OS_WINDOWS
|
|
#include <intrin.h>
|
|
|
|
int CPU_Base_Frequency() {
|
|
int cpuInfo[4] = {0};
|
|
|
|
// Call CPUID with EAX = 0x16 (Base CPU Frequency)
|
|
__cpuid(cpuInfo, 0x16);
|
|
|
|
return cpuInfo[0];
|
|
}
|
|
#endif
|
|
|
|
#if OS_IS_UNIX
|
|
#include <cpuid.h>
|
|
|
|
int CPU_Base_Frequency() {
|
|
unsigned int eax, ebx, ecx, edx;
|
|
if (__get_cpuid(0x16, &eax, &ebx, &ecx, &edx)) {
|
|
return eax;
|
|
}
|
|
|
|
return 0; // not found or supported
|
|
}
|
|
#endif
|