2017-10-28 21:12:11 +00:00
|
|
|
#ifndef __TRACYPOPCNT_HPP__
|
|
|
|
#define __TRACYPOPCNT_HPP__
|
|
|
|
|
2019-05-28 16:18:54 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#if defined _WIN64 || ( defined __CYGWIN__ && __WORDSIZE == 64 )
|
2017-10-28 21:12:11 +00:00
|
|
|
# include <intrin.h>
|
|
|
|
# define TracyCountBits __popcnt64
|
|
|
|
#else
|
2017-11-11 01:46:41 +00:00
|
|
|
static inline int TracyCountBits( uint64_t i )
|
2017-10-28 21:12:11 +00:00
|
|
|
{
|
|
|
|
i = i - ( (i >> 1) & 0x5555555555555555 );
|
|
|
|
i = ( i & 0x3333333333333333 ) + ( (i >> 2) & 0x3333333333333333 );
|
|
|
|
i = ( (i + (i >> 4) ) & 0x0F0F0F0F0F0F0F0F );
|
|
|
|
return ( i * (0x0101010101010101) ) >> 56;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|