mirror of
https://gitee.com/RubyMetric/chsrc.git
synced 2025-12-26 05:02:46 +00:00
Get CPU cores
This commit is contained in:
parent
6831cfaede
commit
eac38ffc4a
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue