Added seeder API. Also overhauled compile-time detection of features.
[BearSSL] / src / symcipher / aes_x86ni_ctr.c
index 41c31b2..292d044 100644 (file)
  * SOFTWARE.
  */
 
+#define BR_ENABLE_INTRINSICS   1
 #include "inner.h"
 
 #if BR_AES_X86NI
 
-#if BR_AES_X86NI_GCC
-#if BR_AES_X86NI_GCC_OLD
-#pragma GCC target("sse2,sse4.1,aes,pclmul")
-#endif
-#include <smmintrin.h>
-#include <wmmintrin.h>
-#define bswap32   __builtin_bswap32
-#endif
-
-#if BR_AES_X86NI_MSC
-#include <stdlib.h>
-#include <intrin.h>
-#define bswap32   _byteswap_ulong
-#endif
+/* see bearssl_block.h */
+const br_block_ctr_class *
+br_aes_x86ni_ctr_get_vtable(void)
+{
+       return br_aes_x86ni_supported() ? &br_aes_x86ni_ctr_vtable : NULL;
+}
 
 /* see bearssl_block.h */
 void
@@ -50,6 +43,8 @@ br_aes_x86ni_ctr_init(br_aes_x86ni_ctr_keys *ctx,
        ctx->num_rounds = br_aes_x86ni_keysched_enc(ctx->skey.skni, key, len);
 }
 
+BR_TARGETS_X86_UP
+
 /* see bearssl_block.h */
 BR_TARGET("sse2,sse4.1,aes")
 uint32_t
@@ -190,6 +185,8 @@ br_aes_x86ni_ctr_run(const br_aes_x86ni_ctr_keys *ctx,
        return cc;
 }
 
+BR_TARGETS_X86_DOWN
+
 /* see bearssl_block.h */
 const br_block_ctr_class br_aes_x86ni_ctr_vtable = {
        sizeof(br_aes_x86ni_ctr_keys),
@@ -202,13 +199,6 @@ const br_block_ctr_class br_aes_x86ni_ctr_vtable = {
                &br_aes_x86ni_ctr_run
 };
 
-/* see bearssl_block.h */
-const br_block_ctr_class *
-br_aes_x86ni_ctr_get_vtable(void)
-{
-       return br_aes_x86ni_supported() ? &br_aes_x86ni_ctr_vtable : NULL;
-}
-
 #else
 
 /* see bearssl_block.h */