Untested popcnt code for Windows

This commit is contained in:
dnotestein 2013-09-22 14:10:40 -04:00
parent 5ffbfef0e8
commit 760c94d20f
2 changed files with 16 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include <fc/fwd.hpp>
#include <fc/string.hpp>
#include <fc/platform_independence.hpp>
namespace fc
{

View file

@ -0,0 +1,15 @@
#ifdef _MSC_VER
#include <intrin.h>
#ifdef _M_X64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(unsigned __int64 value)
{
unsigned int lowBits = (unsigned int)value;
int count = __popcnt(lowBits);
unsigned int highBits = (unsigned int)(value >> 32);
count += __popcnt(highBits);
return count;
}
#endif
#endif