mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
(__sched_cpucount): Allow using special instruction for counting bits.
This commit is contained in:
parent
47779a7d3c
commit
7d0e41cebe
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user