mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
this seems to work for OSX, and improved linux version with fallback.
This commit is contained in:
parent
1b246cd380
commit
ce8d5c66ab
1 changed files with 11 additions and 2 deletions
|
@ -866,9 +866,18 @@ int num_CPUs(void) {
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
return sysinfo.dwNumberOfProcessors;
|
return sysinfo.dwNumberOfProcessors;
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
#elif defined(__linux__) && defined(_SC_NPROCESSORS_ONLN)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
int count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
if (count <= 0)
|
||||||
|
count = 1;
|
||||||
|
return count;
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "sys/sysctl.h"
|
||||||
|
uint32 logicalcores = 0;
|
||||||
|
size_t size = sizeof( logicalcores );
|
||||||
|
sysctlbyname( "hw.logicalcpu", &logicalcores, &size, NULL, 0 );
|
||||||
|
return logicalcores;
|
||||||
#else
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue