mirror of https://github.com/AxioDL/nod.git
MSVC AES-NI support
This commit is contained in:
parent
01f269e8e2
commit
83f29da294
|
@ -1,6 +1,14 @@
|
|||
#ifndef __NOD_UTIL_HPP__
|
||||
#define __NOD_UTIL_HPP__
|
||||
|
||||
#if _WIN32 && UNICODE
|
||||
#include <wctype.h>
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
|
@ -13,16 +21,11 @@ extern LogVisor::LogModule LogModule;
|
|||
|
||||
/* filesystem char type */
|
||||
#if _WIN32 && UNICODE
|
||||
#include <wctype.h>
|
||||
#include <direct.h>
|
||||
#include <sys/stat.h>
|
||||
#define NOD_UCS2 1
|
||||
typedef struct _stat Sstat;
|
||||
static inline int Mkdir(const wchar_t* path, int) {return _wmkdir(path);}
|
||||
static inline int Stat(const wchar_t* path, Sstat* statout) {return _wstat(path, statout);}
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
typedef struct stat Sstat;
|
||||
static inline int Mkdir(const char* path, mode_t mode) {return mkdir(path, mode);}
|
||||
static inline int Stat(const char* path, Sstat* statout) {return stat(path, statout);}
|
||||
|
|
10
lib/aes.cpp
10
lib/aes.cpp
|
@ -478,7 +478,7 @@ void SoftwareAES::encrypt(const uint8_t* iv, const uint8_t* inbuf, uint8_t* outb
|
|||
}
|
||||
}
|
||||
|
||||
#if __AES__
|
||||
#if __AES__ || _MSC_VER >= 1800
|
||||
|
||||
#include <wmmintrin.h>
|
||||
|
||||
|
@ -598,12 +598,18 @@ public:
|
|||
static int HAS_AES_NI = -1;
|
||||
std::unique_ptr<IAES> NewAES()
|
||||
{
|
||||
#if __AES__
|
||||
#if __AES__ || _MSC_VER >= 1800
|
||||
if (HAS_AES_NI == -1)
|
||||
{
|
||||
#if _MSC_VER
|
||||
int info[4];
|
||||
__cpuid(info, 1);
|
||||
HAS_AES_NI = ((info[2] & 0x2000000) != 0);
|
||||
#else
|
||||
unsigned int a,b,c,d;
|
||||
__cpuid(1, a,b,c,d);
|
||||
HAS_AES_NI = ((c & 0x2000000) != 0);
|
||||
#endif
|
||||
}
|
||||
if (HAS_AES_NI)
|
||||
return std::unique_ptr<IAES>(new NiAES);
|
||||
|
|
Loading…
Reference in New Issue