Merge pull request #308 from cjbrigato/patch-1

FIXes # 174 and more (OSX > 10.4 num_Cpus) the good way
This commit is contained in:
Philippe Teuwen 2019-08-05 00:41:20 +02:00 committed by GitHub
commit 6f47e12797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@
//-----------------------------------------------------------------------------
// ensure gmtime_r is available even with -std=c99; must be included before
#if !defined(_WIN32)
#if !defined(_WIN32) && !defined(__APPLE__)
#define _POSIX_C_SOURCE 200112L
#endif
@ -807,24 +807,12 @@ int num_CPUs(void) {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif defined(__linux__) && defined(_SC_NPROCESSORS_ONLN)
#else
#include <unistd.h>
int count = sysconf(_SC_NPROCESSORS_ONLN);
if (count <= 0)
count = 1;
return count;
#elif defined(__APPLE__)
/*
TODO ICEMAN 2019, its commented out until someone finds a better solution
#include "sys/sysctl.h"
uint32_t logicalcores = 0;
size_t size = sizeof( logicalcores );
sysctlbyname( "hw.logicalcpu", &logicalcores, &size, NULL, 0 );
return logicalcores;
*/
return 1;
#else
return 1;
#endif
}