[*] Major -> AuMin/AuMax was returning a reference???

[*] Added arch x64 check around _mm_popcnt_u64. might export msvc only symbol from CpuId w/ the has smid requirement for this one op
This commit is contained in:
Reece Wilson 2022-01-27 20:52:55 +00:00
parent d8e000b5c3
commit 64b2690159

View File

@ -67,26 +67,6 @@ T AuExchange(T &obj, U &&new_value)
return AURORA_RUNTIME_EXCHANGE(obj, new_value); return AURORA_RUNTIME_EXCHANGE(obj, new_value);
} }
#if !defined(AURORA_RUNTIME_MIN)
#define AURORA_RUNTIME_MIN std::min
#endif
template< class T >
constexpr const T &AuMin(const T &a, const T &b)
{
return AURORA_RUNTIME_MIN(a, b);
}
#if !defined(AURORA_RUNTIME_MAX)
#define AURORA_RUNTIME_MAX std::max
#endif
template< class T >
constexpr const T &AuMax(const T &a, const T &b)
{
return AURORA_RUNTIME_MAX(a, b);
}
#if !defined(AURORA_RUNTIME_MEMCMP) #if !defined(AURORA_RUNTIME_MEMCMP)
#define AURORA_RUNTIME_MEMCMP std::memcmp #define AURORA_RUNTIME_MEMCMP std::memcmp
#endif #endif
@ -664,6 +644,18 @@ auto AuTuplePopFront(const Tuple& tuple)
return AuTuplePopFrontImpl(tuple, std::make_index_sequence<std::tuple_size<Tuple>::value - 1>()); return AuTuplePopFrontImpl(tuple, std::make_index_sequence<std::tuple_size<Tuple>::value - 1>());
} }
template<class T>
constexpr const T AuMin(const T &a, const T &b)
{
return a < b ? a : b;
}
template<class T>
constexpr const T AuMax(const T &a, const T &b)
{
return a > b ? b : a;
}
template<typename T> template<typename T>
static auline bool AuTestBit(T value, AuUInt8 idx) static auline bool AuTestBit(T value, AuUInt8 idx)
{ {
@ -799,14 +791,17 @@ template<typename T>
static AuUInt8 AuPopCnt(T in) static AuUInt8 AuPopCnt(T in)
{ {
#if defined(AURORA_COMPILER_MSVC) #if defined(AURORA_COMPILER_MSVC)
#if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)
if constexpr (sizeof(T) == sizeof(AuUInt64)) #if defined(AURORA_ARCH_X64)
return _mm_popcnt_u64(in); if constexpr (sizeof(T) == sizeof(AuUInt64))
else if constexpr (sizeof(T) < sizeof(AuUInt32)) return _mm_popcnt_u64(in);
return __popcnt(in); else
else if constexpr (sizeof(T) <= sizeof(AuUInt16)) #endif
return __popcnt16(in); if constexpr (sizeof(T) < sizeof(AuUInt32))
#endif return __popcnt(in);
else if constexpr (sizeof(T) <= sizeof(AuUInt16))
return __popcnt16(in);
#endif
#else #else
if constexpr (sizeof(T) == sizeof(unsigned long long)) if constexpr (sizeof(T) == sizeof(unsigned long long))
return __builtin_popcountll(static_cast<unsigned long long>(value)); return __builtin_popcountll(static_cast<unsigned long long>(value));