mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-29 04:07:49 +02:00
suppress USE_AVX, make it autodetectable on runtime
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
7e874eaa7c
commit
07ff165a8f
10 changed files with 17 additions and 41 deletions
|
@ -29,6 +29,7 @@ namespace cpu
|
|||
|
||||
void Detect()
|
||||
{
|
||||
__builtin_cpu_init();
|
||||
#if defined(__AES__) || defined(__AVX__)
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
|
@ -37,11 +38,13 @@ namespace cpu
|
|||
if (info[0] >= 0x00000001) {
|
||||
__cpuid(0x00000001, info[0], info[1], info[2], info[3]);
|
||||
#ifdef __AES__
|
||||
aesni = info[2] & bit_AES; // AESNI
|
||||
if (__builtin_cpu_supports("aes")) {
|
||||
aesni = info[2] & bit_AES; // AESNI
|
||||
}
|
||||
#endif // __AES__
|
||||
#ifdef __AVX__
|
||||
avx = info[2] & bit_AVX; // AVX
|
||||
#endif // __AVX__
|
||||
if (__builtin_cpu_supports("avx")) {
|
||||
avx = info[2] & bit_AVX; // AVX
|
||||
}
|
||||
}
|
||||
#endif // defined(__x86_64__) || defined(__i386__)
|
||||
|
||||
|
@ -51,12 +54,10 @@ namespace cpu
|
|||
LogPrint(eLogInfo, "AESNI enabled");
|
||||
}
|
||||
#endif // __AES__
|
||||
#ifdef __AVX__
|
||||
if(avx)
|
||||
{
|
||||
LogPrint(eLogInfo, "AVX enabled");
|
||||
}
|
||||
#endif // __AVX__
|
||||
#endif // defined(__AES__) || defined(__AVX__)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,6 +631,9 @@ namespace crypto
|
|||
static const uint64_t ipads[] = { IPAD, IPAD, IPAD, IPAD };
|
||||
static const uint64_t opads[] = { OPAD, OPAD, OPAD, OPAD };
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#pragma GCC target("avx")
|
||||
#endif
|
||||
void HMACMD5Digest (uint8_t * msg, size_t len, const MACKey& key, uint8_t * digest)
|
||||
// key is 32 bytes
|
||||
// digest is 16 bytes
|
||||
|
@ -638,7 +641,6 @@ namespace crypto
|
|||
{
|
||||
uint64_t buf[256];
|
||||
uint64_t hash[12]; // 96 bytes
|
||||
#ifdef __AVX__
|
||||
if(i2p::cpu::avx)
|
||||
{
|
||||
__asm__
|
||||
|
@ -661,7 +663,6 @@ namespace crypto
|
|||
);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// ikeypad
|
||||
buf[0] = key.GetLL ()[0] ^ IPAD;
|
||||
|
|
|
@ -825,10 +825,12 @@ namespace data
|
|||
return key;
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#pragma GCC target("avx")
|
||||
#endif
|
||||
XORMetric operator^(const IdentHash& key1, const IdentHash& key2)
|
||||
{
|
||||
XORMetric m;
|
||||
#ifdef __AVX__
|
||||
if(i2p::cpu::avx)
|
||||
{
|
||||
__asm__
|
||||
|
@ -843,7 +845,6 @@ namespace data
|
|||
);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const uint64_t * hash1 = key1.GetLL (), * hash2 = key2.GetLL ();
|
||||
m.metric_ll[0] = hash1[0] ^ hash2[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue