about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-06-08 18:29:24 +0000
committerUlrich Drepper <drepper@redhat.com>2007-06-08 18:29:24 +0000
commit7d0e41cebe87f807c70c65b9b8cb001edca66465 (patch)
tree7bc3921e4c7778fd578635d43025767c13b24081
parent47779a7d3cdbbe02a9e060770e0069aa40a73267 (diff)
downloadglibc-7d0e41cebe87f807c70c65b9b8cb001edca66465.tar.gz
glibc-7d0e41cebe87f807c70c65b9b8cb001edca66465.tar.xz
glibc-7d0e41cebe87f807c70c65b9b8cb001edca66465.zip
(__sched_cpucount): Allow using special instruction for counting bits.
-rw-r--r--posix/sched_cpucount.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/posix/sched_cpucount.c b/posix/sched_cpucount.c
index d7f6b7b49f..fd2687d8af 100644
--- a/posix/sched_cpucount.c
+++ b/posix/sched_cpucount.c
@@ -30,22 +30,26 @@ __sched_cpucount (size_t setsize, cpu_set_t *setp)
       if (l == 0)
 	continue;
 
-#if LONG_BIT > 32
+#ifdef POPCNT
+      s += POPCNT (l);
+#else
+# if LONG_BIT > 32
       l = (l & 0x5555555555555555ul) + ((l >> 1) & 0x5555555555555555ul);
       l = (l & 0x3333333333333333ul) + ((l >> 2) & 0x3333333333333333ul);
       l = (l & 0x0f0f0f0f0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0f0f0f0f0ful);
       l = (l & 0x00ff00ff00ff00fful) + ((l >> 8) & 0x00ff00ff00ff00fful);
       l = (l & 0x0000ffff0000fffful) + ((l >> 16) & 0x0000ffff0000fffful);
       l = (l & 0x00000000fffffffful) + ((l >> 32) & 0x00000000fffffffful);
-#else
+# else
       l = (l & 0x55555555ul) + ((l >> 1) & 0x55555555ul);
       l = (l & 0x33333333ul) + ((l >> 2) & 0x33333333ul);
       l = (l & 0x0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0ful);
       l = (l & 0x00ff00fful) + ((l >> 8) & 0x00ff00fful);
       l = (l & 0x0000fffful) + ((l >> 16) & 0x0000fffful);
-#endif
+# endif
 
       s += l;
+#endif
     }
 
   return s;