ReactOS 0.4.16-dev-2122-g1628f5e
twidbits.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FORCEINLINE ULONG CountNumberOfBits (_In_ UINT32 n)
 Return the number of bits set in a 32-bit integer.
 

Function Documentation

◆ CountNumberOfBits()

FORCEINLINE ULONG CountNumberOfBits ( _In_ UINT32  n)

Return the number of bits set in a 32-bit integer.

Note
Equivalent to __popcnt().

Definition at line 22 of file twidbits.h.

24{
25#ifdef HAVE___BUILTIN_POPCOUNT
26 return __popcnt(n);
27#else
28 n -= ((n >> 1) & 0x55555555);
29 n = (((n >> 2) & 0x33333333) + (n & 0x33333333));
30#if 0
31 n = (((n >> 4) + n) & 0x0f0f0f0f);
32 n += (n >> 8);
33 n += (n >> 16);
34 return (n & 0x3f);
35#else
36 return (((n >> 4) + n) & 0x0f0f0f0f) * 0x01010101 >> 24;
37#endif
38#endif /* HAVE___BUILTIN_POPCOUNT */
39}
GLdouble n
Definition: glext.h:7729
__INTRIN_INLINE unsigned int __popcnt(unsigned int value)
Definition: intrin_x86.h:1458

Referenced by PixelBitmasksToBpp().