Get CPU cores

This commit is contained in:
Aoran Zeng 2024-09-03 20:52:05 +08:00
parent 6831cfaede
commit eac38ffc4a
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -1117,3 +1117,21 @@ chsrc_get_cpuarch ()
}
}
static int
chsrc_get_cpucore ()
{
int cores = 2;
#if XY_On_Windows
SYSTEM_INFO info;
GetSystemInfo (&info);
DWORD num = sysinfo.dwNumberOfProcessors
cores = (int)num;
#else
long num = sysconf(_SC_NPROCESSORS_ONLN);
cores = (int)num;
#endif
return cores;
}