1 #ifndef _QPMS_OSHACKS_H
2 #define _QPMS_OSHACKS_H
5 #ifdef _SC_NPROCESSORS_ONLN
6 static inline long get_ncpus(void) {
7 return sysconf(_SC_NPROCESSORS_ONLN
);
10 #include <sys/types.h>
11 #include <sys/sysctl.h>
12 static inline long get_ncpus(void) {
14 size_t len
= sizeof(ncpu
);
15 sysctlbyname("hw.physicalcpu", &ncpu
, &len
, NULL
, 0);
19 static inline long get_ncpus(void) { return -1; }
23 #endif // _QPMS_OSHACKS_H