On 2014-06-30, Anthony J. Bentley <[email protected]> wrote: > -+#include <sys/param.h> > - #include <sys/sysctl.h> > - #endif > - > -@@ -337,9 +338,16 @@ uint GetCPUCoreCount() > - int ncpu = 0; > - size_t len = sizeof(ncpu); > - > -+#if defined(__OpenBSD__) > -+ int mib[2]; > -+ mib[0] = CTL_HW; > -+ mib[1] = HW_NCPU; > -+ sysctl(mib, 2, &ncpu, &len, NULL, 0); > -+#else > - if (sysctlbyname("hw.availcpu", &ncpu, &len, NULL, 0) < 0) { > - sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0); > - } > -+#endif > - > - if (ncpu > 0) count = ncpu; > - #elif defined(_SC_NPROCESSORS_ONLN) > >
For future reference, if you see patches like this where it's using a sysctl to check the number of cpus but also has an option to use sysconf(_SC_NPROCESSORS_ONLN);, you can just remove the sysctl parts as sysconf works fine.
