mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-31 17:36:27 +08:00
FIXes OSX > 10.4 num_Cpus() the good and posix way
sysconf() is part of IEEE Std 1003.1-1988 (POSIX.1).
Fortunately, it *is* available to OSX `>=10.5`.
At least on `~10.14`, the old unposix `sysctl` osx way was lost, at least in portable environments.
This fixes it, but will not be compatible with OSX > 10.4.
So i'm sorry but here we loose compatibility with Macs olders than 2005. (🤣)
This commit is contained in:
parent
45c27573b3
commit
38e4e8d80c
1 changed files with 2 additions and 14 deletions
|
@ -9,7 +9,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// ensure gmtime_r is available even with -std=c99; must be included before
|
// 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
|
#define _POSIX_C_SOURCE 200112L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -807,24 +807,12 @@ int num_CPUs(void) {
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
return sysinfo.dwNumberOfProcessors;
|
return sysinfo.dwNumberOfProcessors;
|
||||||
#elif defined(__linux__) && defined(_SC_NPROCESSORS_ONLN)
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
int count = sysconf(_SC_NPROCESSORS_ONLN);
|
int count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
count = 1;
|
count = 1;
|
||||||
return count;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue