+2021-10-10 Paul Eggert <eggert@cs.ucla.edu>
+
+ nproc: port better to OpenBSD
+ Problem reported by Omar Polo in:
+ https://lists.gnu.org/r/emacs-devel/2021-10/msg00692.html
+ * lib/nproc.c (num_processors_ignoring_omp): Prefer HW_NCPUONLINE
+ to HW_NCPU, for OpenBSD. Also, make mib const.
+
2021-10-02 Paul Eggert <eggert@cs.ucla.edu>
timer-time: port better to OpenBSD 6.9
{ /* This works on Mac OS X, FreeBSD, NetBSD, OpenBSD. */
int nprocs;
size_t len = sizeof (nprocs);
- static int mib[2] = { CTL_HW, HW_NCPU };
-
- if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0
- && len == sizeof (nprocs)
- && 0 < nprocs)
- return nprocs;
+ static int const mib[][2] = {
+# ifdef HW_NCPUONLINE
+ { CTL_HW, HW_NCPUONLINE },
+# endif
+ { CTL_HW, HW_NCPU }
+ };
+ for (int i = 0; i < ARRAY_SIZE (mib); i++)
+ {
+ if (sysctl (mib[i], ARRAY_SIZE (mib[i]), &nprocs, &len, NULL, 0) == 0
+ && len == sizeof (nprocs)
+ && 0 < nprocs)
+ return nprocs;
+ }
}
#endif