Skip to content

[sanitizer_common] Use HW_NCPUONLINE sysctl on NetBSD in GetNumberOfC… #134704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Apr 7, 2025

…PUs()

@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Brad Smith (brad0)

Changes

…PUs()


Full diff: https://github.com/llvm/llvm-project/pull/134704.diff

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp (+4)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index e5e79d4e0521c..5fa24f289da73 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

Copy link

github-actions bot commented Apr 7, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@brad0 brad0 force-pushed the compiler_rt_sanitizer_linux_libcdep branch from fba4a80 to 2dfb095 Compare April 7, 2025 18:51
@brad0 brad0 requested a review from devnexen April 7, 2025 18:53
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brad0 brad0 merged commit 8f5a3ec into llvm:main Apr 7, 2025
8 of 9 checks passed
@brad0 brad0 deleted the compiler_rt_sanitizer_linux_libcdep branch April 7, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants