From 6b52a675b7ec13619a64836a7d50ebcb7e0a09d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Matos?= Date: Thu, 14 Nov 2024 13:42:21 +0000 Subject: [PATCH] Use `_SC_NPROCESSORS_ONLN` for CPU detection in BSDs. (#2329) Fixes https://github.com/premake/premake-core/issues/2328. --- src/host/os_getnumcpus.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/host/os_getnumcpus.c b/src/host/os_getnumcpus.c index f9b2fa93..57c478d5 100644 --- a/src/host/os_getnumcpus.c +++ b/src/host/os_getnumcpus.c @@ -46,29 +46,8 @@ int do_getnumcpus() { return 0; } -#elif PLATFORM_SOLARIS | PLATFORM_AIX | PLATFORM_MACOSX +#elif PLATFORM_SOLARIS | PLATFORM_AIX | PLATFORM_MACOSX | PLATFORM_BSD return sysconf(_SC_NPROCESSORS_ONLN); -#elif PLATFORM_BSD - int mib[4]; - int numCPU; - size_t len = sizeof(numCPU); - - /* set the mib for hw.ncpu */ - mib[0] = CTL_HW; - mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU; - - /* get the number of CPUs from the system */ - sysctl(mib, 2, &numCPU, &len, NULL, 0); - - if (numCPU < 1) - { - mib[1] = HW_NCPU; - sysctl(mib, 2, &numCPU, &len, NULL, 0); - if (numCPU < 1) - return 0; - } - - return numCPU; #else #warning do_getnumcpus is not implemented for your platform yet return 0; -- 2.45.2