mirror of
https://github.com/caozhiyi/CppNet.git
synced 2026-01-19 00:05:14 +08:00
19 lines
346 B
C++
19 lines
346 B
C++
#include "OSInfo.h"
|
|
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
#else
|
|
#include <sysinfoapi.h>
|
|
#endif
|
|
|
|
uint32_t cppnet::GetCpuNum() {
|
|
unsigned count = 1;
|
|
#ifdef __linux__
|
|
count = sysconf(_SC_NPROCESSORS_CONF);
|
|
#else
|
|
SYSTEM_INFO si;
|
|
GetSystemInfo(&si);
|
|
count = si.dwNumberOfProcessors;
|
|
#endif
|
|
return count;
|
|
} |