2017-07-18 14:21:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace utils
|
|
|
|
{
|
|
|
|
inline std::array<u32, 4> get_cpuid(u32 func, u32 subfunc)
|
|
|
|
{
|
|
|
|
int regs[4];
|
2017-12-16 01:19:21 +01:00
|
|
|
#ifdef _MSC_VER
|
2017-07-18 14:21:29 +02:00
|
|
|
__cpuidex(regs, func, subfunc);
|
2017-12-16 01:19:21 +01:00
|
|
|
#else
|
2017-07-18 14:21:29 +02:00
|
|
|
__asm__ volatile("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) : "a" (func), "c" (subfunc));
|
2017-12-16 01:19:21 +01:00
|
|
|
#endif
|
2017-07-18 14:21:29 +02:00
|
|
|
return {0u+regs[0], 0u+regs[1], 0u+regs[2], 0u+regs[3]};
|
|
|
|
}
|
|
|
|
|
2017-11-09 18:33:18 +01:00
|
|
|
bool has_ssse3();
|
2017-07-18 14:21:29 +02:00
|
|
|
|
2017-11-09 18:33:18 +01:00
|
|
|
bool has_avx();
|
2017-07-18 14:21:29 +02:00
|
|
|
|
2017-12-16 01:19:21 +01:00
|
|
|
bool has_avx2();
|
|
|
|
|
2017-11-09 18:33:18 +01:00
|
|
|
bool has_rtm();
|
2017-07-18 19:03:47 +02:00
|
|
|
|
2017-12-16 01:19:21 +01:00
|
|
|
bool has_512();
|
|
|
|
|
2018-01-16 12:32:57 +01:00
|
|
|
bool has_xop();
|
|
|
|
|
2017-07-18 19:03:47 +02:00
|
|
|
inline bool transaction_enter()
|
|
|
|
{
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
const auto status = _xbegin();
|
|
|
|
|
|
|
|
if (status == _XBEGIN_STARTED)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(status & _XABORT_RETRY))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-07-18 14:21:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string get_system_info();
|
|
|
|
}
|