aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/cpu.c
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2021-04-03 14:49:20 -0400
committerMarton Balint <cus@passwd.hu>2021-04-18 22:51:14 +0200
commitc8fb68ec52194d3de2f24a6850cd795d98eb2f2f (patch)
treeedd1b2917ab45064626f6cf1e509ad7beefd3c7c /libavutil/cpu.c
parent46f3ae8f672533a380dea7c4e13c84d52014de6c (diff)
downloadffmpeg-c8fb68ec52194d3de2f24a6850cd795d98eb2f2f.tar.gz
avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
Signed-off-by: Brad Smith <brad@comstyle.com> Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/cpu.c')
-rw-r--r--libavutil/cpu.c6
1 files changed, 6 insertions, 0 deletions
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);