Skip to content

[libc] Replace __builtin_popcountl with cpp::popcount in sched_getcpucount #131952

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
Mar 19, 2025

Conversation

el-ev
Copy link
Member

@el-ev el-ev commented Mar 19, 2025

Closes #128781.

@llvmbot llvmbot added the libc label Mar 19, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2025

@llvm/pr-subscribers-libc

Author: Iris (el-ev)

Changes

Closes #128781.


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

1 Files Affected:

  • (modified) libc/src/sched/linux/sched_getcpucount.cpp (+2-1)
diff --git a/libc/src/sched/linux/sched_getcpucount.cpp b/libc/src/sched/linux/sched_getcpucount.cpp
index dbda4b2c789ad..7ae166e3bab59 100644
--- a/libc/src/sched/linux/sched_getcpucount.cpp
+++ b/libc/src/sched/linux/sched_getcpucount.cpp
@@ -8,6 +8,7 @@
 
 #include "src/sched/sched_getcpucount.h"
 
+#include "src/__support/CPP/bit.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
@@ -20,7 +21,7 @@ LLVM_LIBC_FUNCTION(int, __sched_getcpucount,
                    (size_t cpuset_size, const cpu_set_t *mask)) {
   int result = 0;
   for (size_t i = 0; i < cpuset_size / sizeof(long); ++i) {
-    result += __builtin_popcountl(mask->__mask[i]);
+    result += cpp::popcount(mask->__mask[i]);
   }
   return result;
 }

@el-ev el-ev closed this Mar 19, 2025
@el-ev el-ev deleted the replace_popcnt branch March 19, 2025 04:08
@el-ev el-ev restored the replace_popcnt branch March 19, 2025 04:08
@el-ev el-ev reopened this Mar 19, 2025
@el-ev
Copy link
Member Author

el-ev commented Mar 19, 2025

Sorry, I accidentally deleted the branch...

@lntue lntue merged commit 67a0113 into llvm:main Mar 19, 2025
34 of 35 checks passed
@el-ev el-ev deleted the replace_popcnt branch March 19, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] clean up use of __builtin_popcountl in sched_getcpucount
5 participants