From 8e4ccd355cab105ceb8505592327e515fba60927 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Thu, 1 Sep 2016 21:24:03 +0000 Subject: [PATCH] refactor ALIGN16 macro to types.h --- wolfssl/wolfcrypt/aes.h | 15 --------------- wolfssl/wolfcrypt/sha256.h | 16 ---------------- wolfssl/wolfcrypt/types.h | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/wolfssl/wolfcrypt/aes.h b/wolfssl/wolfcrypt/aes.h index 8d91f4367..c812741eb 100644 --- a/wolfssl/wolfcrypt/aes.h +++ b/wolfssl/wolfcrypt/aes.h @@ -46,23 +46,8 @@ #include #include -#if !defined (ALIGN16) - #if defined (__GNUC__) - #define ALIGN16 __attribute__ ( (aligned (16))) - #elif defined(_MSC_VER) - /* disable align warning, we want alignment ! */ - #pragma warning(disable: 4324) - #define ALIGN16 __declspec (align (16)) - #else - #define ALIGN16 - #endif -#endif - #endif /* WOLFSSL_AESNI */ -#if !defined (ALIGN16) - #define ALIGN16 -#endif #endif /* HAVE_FIPS */ #ifdef __cplusplus diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index faaa4a196..503db7f2a 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -54,22 +54,6 @@ enum { #ifndef WOLFSSL_TI_HASH -#ifdef WOLFSSL_ARMASM /* slight performance increase with aligned memory */ -#if !defined (ALIGN16) - #if defined (__GNUC__) - #define ALIGN16 __attribute__ ( (aligned (16))) - #elif defined(_MSC_VER) - /* disable align warning, we want alignment ! */ - #pragma warning(disable: 4324) - #define ALIGN16 __declspec (align (16)) - #else - #define ALIGN16 - #endif -#endif -#else /* not using ARM ASM*/ - #define ALIGN16 -#endif /* WOLFSSL_ARMASM */ - /* Sha256 digest */ typedef struct Sha256 { word32 buffLen; /* in bytes */ diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index fee056a90..d67453601 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -386,6 +386,26 @@ #define INVALID_DEVID -2 + /* AESNI requires alignment and ARMASM gains some performance from it */ + #if defined(WOLFSSL_AESNI) || defined(WOLFSSL_ARMASM) + #if !defined (ALIGN16) + #if defined (__GNUC__) + #define ALIGN16 __attribute__ ( (aligned (16))) + #elif defined(_MSC_VER) + /* disable align warning, we want alignment ! */ + #pragma warning(disable: 4324) + #define ALIGN16 __declspec (align (16)) + #else + #define ALIGN16 + #endif + #endif + #else + #ifndef ALIGN16 + #define ALIGN16 + #endif + #endif /* WOLFSSL_AESNI or WOLFSSL_ARMASM */ + + #ifdef __cplusplus } /* extern "C" */ #endif