Untested popcnt code for Windows
This commit is contained in:
parent
5ffbfef0e8
commit
760c94d20f
2 changed files with 16 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <fc/fwd.hpp>
|
||||
#include <fc/string.hpp>
|
||||
#include <fc/platform_independence.hpp>
|
||||
|
||||
namespace fc
|
||||
{
|
||||
|
|
|
|||
15
include/fc/platform_independence.hpp
Normal file
15
include/fc/platform_independence.hpp
Normal 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
|
||||
Loading…
Reference in a new issue