Notes on evaluating Δ_n factor in the lattice sums.
[qpms.git] / qpms / oshacks.h
blob3ea658f1033001d1e67a6943c491ecd7526e75fb
1 #ifndef _QPMS_OSHACKS_H
2 #define _QPMS_OSHACKS_H
3 #include <unistd.h>
5 #ifdef _SC_NPROCESSORS_ONLN
6 static inline long get_ncpus(void) {
7 return sysconf(_SC_NPROCESSORS_ONLN);
9 #elif (0)
10 #include <sys/types.h>
11 #include <sys/sysctl.h>
12 static inline long get_ncpus(void) {
13 int32_t ncpu;
14 size_t len = sizeof(ncpu);
15 sysctlbyname("hw.physicalcpu", &ncpu, &len, NULL, 0);
16 return ncpu;
18 #else
19 static inline long get_ncpus(void) { return -1; }
20 #endif
23 #endif // _QPMS_OSHACKS_H