]> git.sesse.net Git - ffmpeg/commitdiff
avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
authorBrad Smith <brad@comstyle.com>
Sat, 3 Apr 2021 18:49:20 +0000 (14:49 -0400)
committerMarton Balint <cus@passwd.hu>
Sun, 18 Apr 2021 20:51:14 +0000 (22:51 +0200)
Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
libavutil/cpu.c

index 8e3576a1f305ee72fa211793b5cb7a0b305abbc9..9d249737df4e09f995fcd7125b00f602c45fa64d 100644 (file)
@@ -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);