[libc-commits] [libc] 67a0113 - [libc] Replace `__builtin_popcountl` with `cpp::popcount` in `sched_getcpucount` (#131952)

via libc-commits libc-commits at lists.llvm.org
Wed Mar 19 07:35:54 PDT 2025


Author: Iris
Date: 2025-03-19T10:35:50-04:00
New Revision: 67a01131a8d70fcd06c6bd9cea30a8a6262c8c94

URL: https://github.com/llvm/llvm-project/commit/67a01131a8d70fcd06c6bd9cea30a8a6262c8c94
DIFF: https://github.com/llvm/llvm-project/commit/67a01131a8d70fcd06c6bd9cea30a8a6262c8c94.diff

LOG: [libc] Replace `__builtin_popcountl` with `cpp::popcount` in `sched_getcpucount` (#131952)

Closes #128781.

Added: 
    

Modified: 
    libc/src/sched/linux/sched_getcpucount.cpp

Removed: 
    


################################################################################
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;
 }


        


More information about the libc-commits mailing list