Fix saving lists of arrays with recent versions of numpy
[qpms.git] / qpms / oshacks.h
blob2ef8815740862a2a8c615a84b1d384e3447639fb
1 /*! \file oshacks.h
2 * \brief Some platform-dependent functions.
3 */
4 #ifndef _QPMS_OSHACKS_H
5 #define _QPMS_OSHACKS_H
6 #include <unistd.h>
8 #ifdef _SC_NPROCESSORS_ONLN
9 static inline long get_ncpus(void) {
10 return sysconf(_SC_NPROCESSORS_ONLN);
12 #elif (0)
13 #include <sys/types.h>
14 #include <sys/sysctl.h>
15 static inline long get_ncpus(void) {
16 int32_t ncpu;
17 size_t len = sizeof(ncpu);
18 sysctlbyname("hw.physicalcpu", &ncpu, &len, NULL, 0);
19 return ncpu;
21 #else
22 static inline long get_ncpus(void) { return -1; }
23 #endif
26 #endif // _QPMS_OSHACKS_H