Alignment fix

This commit is contained in:
Sean Parkinson
2017-07-25 15:41:33 +10:00
parent b23f983604
commit e8e1504d9f
2 changed files with 32 additions and 5 deletions

View File

@@ -399,8 +399,8 @@ static INLINE void wc_Chacha_wordtobyte(word32 output[CHACHA_CHUNK_WORDS],
static void chacha_encrypt_avx(ChaCha* ctx, const byte* m, byte* c,
word32 bytes)
{
word32 X[4*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
word32 x[2*CHACHA_CHUNK_WORDS];
ALIGN128 word32 X[4*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
ALIGN128 word32 x[2*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
byte* output;
word32 i;
word32 cnt = 0;
@@ -664,8 +664,8 @@ static void chacha_encrypt_avx(ChaCha* ctx, const byte* m, byte* c,
static void chacha_encrypt_avx2(ChaCha* ctx, const byte* m, byte* c,
word32 bytes)
{
word32 X[8*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
word32 x[4*CHACHA_CHUNK_WORDS];
ALIGN256 word32 X[8*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
ALIGN256 word32 x[4*CHACHA_CHUNK_WORDS]; /* used to make sure aligned */
byte* output;
word32 i;
word32 cnt = 0;

View File

@@ -510,7 +510,7 @@
#endif
#endif
#if !defined(ALIGN32)
#if !defined(ALIGN32)
#if defined(__GNUC__)
#define ALIGN32 __attribute__ ( (aligned (32)))
#elif defined(_MSC_VER)
@@ -521,6 +521,27 @@
#define ALIGN32
#endif
#endif /* !ALIGN32 */
#if defined(__GNUC__)
#define ALIGN128 __attribute__ ( (aligned (128)))
#elif defined(_MSC_VER)
/* disable align warning, we want alignment ! */
#pragma warning(disable: 4324)
#define ALIGN128 __declspec (align (128))
#else
#define ALIGN128
#endif
#if defined(__GNUC__)
#define ALIGN256 __attribute__ ( (aligned (256)))
#elif defined(_MSC_VER)
/* disable align warning, we want alignment ! */
#pragma warning(disable: 4324)
#define ALIGN256 __declspec (align (256))
#else
#define ALIGN256
#endif
#else
#ifndef ALIGN16
#define ALIGN16
@@ -528,6 +549,12 @@
#ifndef ALIGN32
#define ALIGN32
#endif
#ifndef ALIGN128
#define ALIGN128
#endif
#ifndef ALIGN256
#define ALIGN256
#endif
#endif /* WOLFSSL_AESNI || WOLFSSL_ARMASM */