about summary refs log tree commit diff
path: root/posix/sched_cpucount.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix/sched_cpucount.c')
-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;