From patchwork Sat Apr 3 18:49:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 26729 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2F74244A510 for ; Sat, 3 Apr 2021 21:49:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F06E168AA35; Sat, 3 Apr 2021 21:49:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.comstyle.com (speedy.comstyle.com [206.51.28.2]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C797E68AA0D for ; Sat, 3 Apr 2021 21:49:23 +0300 (EEST) Received: from mail.comstyle.com (localhost [127.0.0.1]) by mail.comstyle.com (Postfix) with ESMTP id 4FCQxW4SdTz8PbN for ; Sat, 3 Apr 2021 14:51:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=comstyle.com; h=date:from :to:subject:message-id:mime-version:content-type; s=default; bh= WlDDcuIsxEaoHCDhhpvd1sHcoYI=; b=lTuSZqbbS3tJGT8Az7yyeqzl2zvRIkq4 K2/qlQuT6cFNRJ5ek7+2VO74f0kq8na9cHEOqX6dsYvDFFLVaaRUmwc81RU/QdSJ JlMfvKSYDHvLJotX2vy7pTSSMk3arMsrwo3Zb571Ark/kFf2q59aePKrz4dBBK6K JFRobSlPLU4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=comstyle.com; h=date:from:to :subject:message-id:mime-version:content-type; q=dns; s=default; b= hmypD50nJMJxU04vENMbPIh5hVl6xZa/tfOt8HebVC3ZMByNRyQwAmvMbJnTVSkL fpTx7Ipgxj2yO5zEJEvuOdktTPuAs1TsuETzt0MHrDDZgNmH9PA/MfsKn3502J2F gX9fh5kMCmF/Ovw6t5lQmPerYd02BYbxsBZP+W+lujA= Received: from humpty.home.comstyle.com (bras-base-toroon2719w-grc-39-142-114-123-227.dsl.bell.ca [142.114.123.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id 4FCQxW3sgqz8PbK for ; Sat, 3 Apr 2021 14:51:27 -0400 (EDT) Date: Sat, 3 Apr 2021 14:49:20 -0400 From: Brad Smith To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Content-Disposition: inline Subject: [FFmpeg-devel] [PATCH] avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD Signed-off-by: Brad Smith --- libavutil/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 8e3576a1f3..9d249737df 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -291,6 +291,12 @@ int av_cpu_count(void) DWORD_PTR proc_aff, sys_aff; if (GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff)) nb_cpus = av_popcount64(proc_aff); +#elif HAVE_SYSCTL && defined(HW_NCPUONLINE) + int mib[2] = { CTL_HW, HW_NCPUONLINE }; + size_t len = sizeof(nb_cpus); + + if (sysctl(mib, 2, &nb_cpus, &len, NULL, 0) == -1) + nb_cpus = 0; #elif HAVE_SYSCTL && defined(HW_NCPU) int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof(nb_cpus);