aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2025-04-07 15:15:12 -0400
committerGitHub <noreply@github.com>2025-04-07 15:15:12 -0400
commit8f5a3ec649a3b46093c8a8140bbd91f21236fde6 (patch)
tree375dc380a6a6dbb4344e388405725612775f0f6c
parent10bef367a5643bc41d0172b02e080645c68f821a (diff)
downloadllvm-8f5a3ec649a3b46093c8a8140bbd91f21236fde6.zip
llvm-8f5a3ec649a3b46093c8a8140bbd91f21236fde6.tar.gz
llvm-8f5a3ec649a3b46093c8a8140bbd91f21236fde6.tar.bz2
[sanitizer_common] Use HW_NCPUONLINE sysctl on NetBSD in GetNumberOfCPUs() (#134704)
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index e5e79d4..ffd2409 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -840,7 +840,11 @@ u32 GetNumberOfCPUs() {
int req[2];
uptr len = sizeof(ncpu);
req[0] = CTL_HW;
+# ifdef HW_NCPUONLINE
+ req[1] = HW_NCPUONLINE;
+# else
req[1] = HW_NCPU;
+# endif
CHECK_EQ(internal_sysctl(req, 2, &ncpu, &len, NULL, 0), 0);
return ncpu;
# elif SANITIZER_SOLARIS