mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 15:50:11 +01:00
util: Fix setting nr_cpus on some BSD variants
Linux, FreeBSD, and DragonFly should have _SC_NOPROCESSORS_ONLN. NetBSD and OpenBSD should have HW_NCPUONLINE. This is what FFmpeg uses on those platforms. FreeBSD sysconf(3) manual page: https://www.freebsd.org/cgi/man.cgi?query=sysconf&sektion=3&apropos=0&manpath=freebsd The FFmpeg patch is at: https://patchwork.ffmpeg.org/project/ffmpeg/patch/YGi4sJx3trG3Yn7c@humpty.home.comstyle.com/ OpenBSD sysctl(2) manual page: https://man.openbsd.org/sysctl.2 Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11228>
This commit is contained in:
parent
44246892a0
commit
5623c75e40
1 changed files with 15 additions and 2 deletions
|
|
@ -565,7 +565,20 @@ util_cpu_detect_once(void)
|
||||||
util_cpu_caps.nr_cpus = MAX2(1, system_info.dwNumberOfProcessors);
|
util_cpu_caps.nr_cpus = MAX2(1, system_info.dwNumberOfProcessors);
|
||||||
}
|
}
|
||||||
#elif defined(PIPE_OS_UNIX)
|
#elif defined(PIPE_OS_UNIX)
|
||||||
# if defined(_SC_NPROCESSORS_ONLN)
|
/* Linux, FreeBSD, DragonFly, and Mac OS X should have
|
||||||
|
* _SC_NOPROCESSORS_ONLN. NetBSD and OpenBSD should have HW_NCPUONLINE.
|
||||||
|
* This is what FFmpeg uses on those platforms.
|
||||||
|
*/
|
||||||
|
# if defined(PIPE_OS_BSD) && defined(HW_NCPUONLINE)
|
||||||
|
{
|
||||||
|
const int mib[] = { CTL_HW, HW_NCPUONLINE };
|
||||||
|
int ncpu;
|
||||||
|
int len = sizeof(ncpu);
|
||||||
|
|
||||||
|
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||||
|
util_cpu_caps.nr_cpus = ncpu;
|
||||||
|
}
|
||||||
|
# elif defined(_SC_NPROCESSORS_ONLN)
|
||||||
util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
if (util_cpu_caps.nr_cpus == ~0)
|
if (util_cpu_caps.nr_cpus == ~0)
|
||||||
util_cpu_caps.nr_cpus = 1;
|
util_cpu_caps.nr_cpus = 1;
|
||||||
|
|
@ -578,7 +591,7 @@ util_cpu_detect_once(void)
|
||||||
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||||
util_cpu_caps.nr_cpus = ncpu;
|
util_cpu_caps.nr_cpus = ncpu;
|
||||||
}
|
}
|
||||||
# endif
|
# endif /* defined(PIPE_OS_BSD) */
|
||||||
#endif /* defined(PIPE_OS_UNIX) */
|
#endif /* defined(PIPE_OS_UNIX) */
|
||||||
|
|
||||||
if (util_cpu_caps.nr_cpus == 0)
|
if (util_cpu_caps.nr_cpus == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue