From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 157591F566 for ; Sat, 9 Sep 2023 12:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1694260903; bh=a7aAwtbsRzcJtDel/AD/niAkrDwVfwqTitnNRpOPrBM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oCoFxQS3uwAsLzkAvjsmGMjHEmZsG69B8uMCLdQ/TjOwQsZhY4GlZWGzxxEt5sqE7 PoYlHGxr/2/q9ahvoSIacWG8hBJ2DObHbhseOobIORWA9ISkx51yauVBKOuthoa9Sq 5mZ6+12hvzsLHfpxNxS6IY0ZUZJnPx+R/KjCSnDQ= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/8] ipc: define _SC_NPROCESSORS_ONLN for NetBSD Date: Sat, 9 Sep 2023 12:01:36 +0000 Message-ID: <20230909120142.1041752-3-e@80x24.org> In-Reply-To: <20230909120142.1041752-1-e@80x24.org> References: <20230909120142.1041752-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll reorganize this into a hash table for ease-of-reading. --- lib/PublicInbox/IPC.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 528b9133..39021f42 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)) {