diff --git a/Makefile.linux b/Makefile.linux index f0d69728..0774fdbe 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -58,13 +58,14 @@ endif endif ifeq ($(USE_AESNI),yes) -#check if AES-NI is supported by CPU -ifneq ($(shell $(GREP) -c aes /proc/cpuinfo),0) - machine := $(shell uname -m) - ifeq ($(machine), aarch64) - CXXFLAGS += -DARM64AES - else +ifneq (, $(findstring aarch64, $(SYS))) + CXXFLAGS += -DARM64AES +else + ifeq (, $(findstring arm, $(SYS))) # no arm in dumpmachine + # check if AES-NI is supported by CPU + ifeq ($(shell $(GREP) -c aes /proc/cpuinfo),0) CPU_FLAGS += -maes endif + endif endif endif diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 2abc6ca1..1743e685 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -631,10 +631,6 @@ 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 push_options -#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 @@ -642,6 +638,9 @@ namespace crypto { uint64_t buf[256]; uint64_t hash[12]; // 96 bytes +#if defined(__x86_64__) || defined(__i386__) +#pragma GCC push_options +#pragma GCC target("avx") if(i2p::cpu::avx) { __asm__ @@ -664,6 +663,8 @@ namespace crypto ); } else +#pragma GCC pop_options +#endif { // ikeypad buf[0] = key.GetLL ()[0] ^ IPAD; @@ -695,9 +696,6 @@ namespace crypto // calculate digest MD5((uint8_t *)hash, 96, digest); } -#if defined(__x86_64__) || defined(__i386__) -#pragma GCC pop_options -#endif // AES #ifdef __AES__ diff --git a/libi2pd/Identity.cpp b/libi2pd/Identity.cpp index 10c20a71..a110a15e 100644 --- a/libi2pd/Identity.cpp +++ b/libi2pd/Identity.cpp @@ -825,13 +825,12 @@ namespace data return key; } -#if defined(__x86_64__) || defined(__i386__) -#pragma GCC push_options -#pragma GCC target("avx") -#endif XORMetric operator^(const IdentHash& key1, const IdentHash& key2) { XORMetric m; +#if defined(__x86_64__) || defined(__i386__) +#pragma GCC push_options +#pragma GCC target("avx") if(i2p::cpu::avx) { __asm__ @@ -846,6 +845,8 @@ namespace data ); } else +#pragma GCC pop_options +#endif { const uint64_t * hash1 = key1.GetLL (), * hash2 = key2.GetLL (); m.metric_ll[0] = hash1[0] ^ hash2[0]; @@ -856,9 +857,5 @@ namespace data return m; } -#if defined(__x86_64__) || defined(__i386__) -#pragma GCC pop_options -#endif - } }