X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=src%2Fsymcipher%2Faes_x86ni.c;h=d5408f1360fae82c143051dad3f130cff3df2a07;hp=d2d63693b6170d8a1b056b810ad320a8eb596912;hb=4b6046412bf927d6424f20fc7ee495bb96dbd227;hpb=2f88a673049d1e183d1a8f78e2030bf02362b8bf diff --git a/src/symcipher/aes_x86ni.c b/src/symcipher/aes_x86ni.c index d2d6369..d5408f1 100644 --- a/src/symcipher/aes_x86ni.c +++ b/src/symcipher/aes_x86ni.c @@ -22,6 +22,7 @@ * SOFTWARE. */ +#define BR_ENABLE_INTRINSICS 1 #include "inner.h" /* @@ -31,22 +32,6 @@ #if BR_AES_X86NI -#if BR_AES_X86NI_GCC -#if BR_AES_X86NI_GCC_OLD -#pragma GCC push_options -#pragma GCC target("sse2,sse4.1,aes,pclmul") -#endif -#include -#include -#if BR_AES_X86NI_GCC_OLD -#pragma GCC pop_options -#endif -#endif - -#if BR_AES_X86NI_MSC -#include -#endif - /* see inner.h */ int br_aes_x86ni_supported(void) @@ -56,35 +41,10 @@ br_aes_x86ni_supported(void) * 19 SSE4.1 (used for _mm_insert_epi32(), for AES-CTR) * 25 AES-NI */ -#define MASK 0x02080000 - -#if BR_AES_X86NI_GCC - unsigned eax, ebx, ecx, edx; - - if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) { - return (ecx & MASK) == MASK; - } else { - return 0; - } -#elif BR_AES_X86NI_MSC - int info[4]; - - __cpuid(info, 1); - return ((uint32_t)info[2] & MASK) == MASK; -#else - return 0; -#endif - -#undef MASK + return br_cpuid(0, 0, 0x02080000, 0); } -/* - * Per-function attributes appear unreliable on old GCC, so we use the - * pragma for all remaining functions in this file. - */ -#if BR_AES_X86NI_GCC_OLD -#pragma GCC target("sse2,sse4.1,aes,pclmul") -#endif +BR_TARGETS_X86_UP BR_TARGET("sse2,aes") static inline __m128i @@ -275,4 +235,6 @@ br_aes_x86ni_keysched_dec(unsigned char *skni, const void *key, size_t len) return num_rounds; } +BR_TARGETS_X86_DOWN + #endif