add macos headers

This commit is contained in:
jon-chuang 2023-04-14 10:22:52 +08:00
parent 3fa8837068
commit e524ce99fe

View file

@ -7,6 +7,11 @@
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
#elif defined(__APPLE__) && defined(__MACH__)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#if defined (_WIN32) #if defined (_WIN32)
#include <fcntl.h> #include <fcntl.h>
#include <io.h> #include <io.h>
@ -37,6 +42,7 @@ int32_t get_num_physical_cores() {
} }
} }
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(__APPLE__) && defined(__MACH__)
int32_t num_physical_cores; int32_t num_physical_cores;
size_t len = sizeof(num_physical_cores); size_t len = sizeof(num_physical_cores);
int result = sysctlbyname("hw.perflevel0.physicalcpu", &num_physical_cores, &len, NULL, 0); int result = sysctlbyname("hw.perflevel0.physicalcpu", &num_physical_cores, &len, NULL, 0);