mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-17 05:41:41 +02:00
Merge pull request #6 from jquesnelle/aesni-check
Checks cpuid to see if AES-NI instructions are supported
This commit is contained in:
+20
@@ -21,6 +21,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <intrin.h>
|
||||
|
||||
void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
{
|
||||
@@ -29,6 +30,7 @@ void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <cpuid.h>
|
||||
|
||||
void thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id)
|
||||
{
|
||||
@@ -172,8 +174,26 @@ cryptonight_ctx* minethd_alloc_ctx()
|
||||
return nullptr; //Should never happen
|
||||
}
|
||||
|
||||
static bool check_for_aesni()
|
||||
{
|
||||
constexpr int AESNI_BIT = 1 << 25;
|
||||
int cpu_info[4];
|
||||
#ifdef _WIN32
|
||||
__cpuid(cpu_info, 1);
|
||||
#else
|
||||
__cpuid(1, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
|
||||
#endif
|
||||
return (cpu_info[2] & AESNI_BIT) != 0;
|
||||
}
|
||||
|
||||
bool minethd::self_test()
|
||||
{
|
||||
if (!check_for_aesni())
|
||||
{
|
||||
printer::inst()->print_msg(L0, "Your CPU does not support the AES-NI instruction set");
|
||||
return false;
|
||||
}
|
||||
|
||||
alloc_msg msg = { 0 };
|
||||
size_t res;
|
||||
bool fatal = false;
|
||||
|
||||
Reference in New Issue
Block a user