From 45cb4b144f220bc5784ec28400180ac4a25b20ae Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 8 Oct 2017 21:02:09 +0200 Subject: [PATCH] Add bit counter. --- server/TracyView.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index d2d95e7f..73d6da77 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -24,6 +24,19 @@ # include "../nfd/nfd.h" #endif +#ifdef _MSC_VER +# include +# define CountBits __popcnt64 +#else +static int CountBits( uint64_t i ) +{ + i = i - ( (i >> 1) & 0x5555555555555555 ); + i = ( i & 0x3333333333333333 ) + ( (i >> 2) & 0x3333333333333333 ); + i = ( (i + (i >> 4) ) & 0x0F0F0F0F0F0F0F0F ); + return ( i * (0x0101010101010101) ) >> 56; +} +#endif + namespace tracy {