diff mbox series

[FFmpeg-devel] avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD

Message ID YGi4sJx3trG3Yn7c@humpty.home.comstyle.com
State Accepted
Commit c8fb68ec52194d3de2f24a6850cd795d98eb2f2f
Headers show
Series [FFmpeg-devel] avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Brad Smith April 3, 2021, 6:49 p.m. UTC
avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD

Signed-off-by: Brad Smith <brad@comstyle.com>
---
 libavutil/cpu.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Brad Smith April 10, 2021, 8:09 p.m. UTC | #1
ping.

On 4/3/2021 2:49 PM, Brad Smith wrote:
> avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
>
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
>   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);
Brad Smith April 16, 2021, 10:10 p.m. UTC | #2
ping.

On 4/3/2021 2:49 PM, Brad Smith wrote:
> avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
>
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
>   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);
Marton Balint April 18, 2021, 8:50 p.m. UTC | #3
On Fri, 16 Apr 2021, Brad Smith wrote:

> ping.

Will apply, thanks.

Marton

>
> On 4/3/2021 2:49 PM, Brad Smith wrote:
>> avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
>>
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>> ---
>>   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);
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

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);