From: Eric Wong Date: Sat, 9 Sep 2023 12:01:36 +0000 (+0000) Subject: ipc: define _SC_NPROCESSORS_ONLN for NetBSD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ca202556c6ffc4f4fb8acd17d0854fdc0b0a2df;p=thirdparty%2Fpublic-inbox.git ipc: define _SC_NPROCESSORS_ONLN for NetBSD We'll reorganize this into a hash table for ease-of-reading. --- diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 528b91333..39021f425 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -451,12 +451,18 @@ sub DESTROY { ipc_worker_stop($self); } +# _SC_NPROCESSORS_ONLN = 84 on both Linux glibc and musl, +# emitted using: $^X devel/sysdefs-list +my %NPROCESSORS_ONLN = ( + linux => 84, + freebsd => 58, + openbsd => 503, + netbsd => 1002 +); + sub detect_nproc () { - # _SC_NPROCESSORS_ONLN = 84 on both Linux glibc and musl - return POSIX::sysconf(84) if $^O eq 'linux'; - return POSIX::sysconf(58) if $^O eq 'freebsd'; - return POSIX::sysconf(503) if $^O eq 'openbsd'; - # TODO: more OSes + my $n = $NPROCESSORS_ONLN{$^O}; + return POSIX::sysconf($n) if defined $n; # getconf(1) is POSIX, but *NPROCESSORS* vars are not for (qw(_NPROCESSORS_ONLN NPROCESSORS_ONLN)) {