2 * \brief Some platform-dependent functions.
4 #ifndef _QPMS_OSHACKS_H
5 #define _QPMS_OSHACKS_H
8 #ifdef _SC_NPROCESSORS_ONLN
9 static inline long get_ncpus(void) {
10 return sysconf(_SC_NPROCESSORS_ONLN
);
13 #include <sys/types.h>
14 #include <sys/sysctl.h>
15 static inline long get_ncpus(void) {
17 size_t len
= sizeof(ncpu
);
18 sysctlbyname("hw.physicalcpu", &ncpu
, &len
, NULL
, 0);
22 static inline long get_ncpus(void) { return -1; }
26 #endif // _QPMS_OSHACKS_H