Make AVX2 code compile in on Mac

Fix problems not seen due to AVX2 define being off.
This commit is contained in:
Sean Parkinson 2017-11-24 08:49:45 +10:00
parent 8c15c65343
commit f1befc0e87
4 changed files with 14 additions and 2 deletions

View File

@ -66,6 +66,8 @@
#if defined(__clang__) && ((__clang_major__ < 3) || \
(__clang_major__ == 3 && __clang_minor__ <= 5))
#define NO_AVX2_SUPPORT
#elif defined(__clang__) && defined(NO_AVX2_SUPPORT)
#undef NO_AVX2_SUPPORT
#endif
#define HAVE_INTEL_AVX1
@ -933,8 +935,8 @@ static void chacha_encrypt_avx2(ChaCha* ctx, const byte* m, byte* c,
: [bytes] "+r" (bytes), [cnt] "+r" (cnt),
[in] "+r" (m), [out] "+r" (c)
: [X] "r" (X), [x] "r" (x), [key] "r" (ctx->X),
[add] "xrm" (add), [eight] "xrm" (eight),
[rotl8] "xrm" (rotl8), [rotl16] "xrm" (rotl16)
[add] "m" (add), [eight] "m" (eight),
[rotl8] "m" (rotl8), [rotl16] "m" (rotl16)
: "ymm0", "ymm1", "ymm2", "ymm3",
"ymm4", "ymm5", "ymm6", "ymm7",
"ymm8", "ymm9", "ymm10", "ymm11",

View File

@ -61,6 +61,8 @@
#if defined(__clang__) && ((__clang_major__ < 3) || \
(__clang_major__ == 3 && __clang_minor__ <= 5))
#define NO_AVX2_SUPPORT
#elif defined(__clang__) && defined(NO_AVX2_SUPPORT)
#undef NO_AVX2_SUPPORT
#endif
#define HAVE_INTEL_AVX1

View File

@ -100,6 +100,8 @@
#if defined(__clang__) && ((__clang_major__ < 3) || \
(__clang_major__ == 3 && __clang_minor__ <= 5))
#define NO_AVX2_SUPPORT
#elif defined(__clang__) && defined(NO_AVX2_SUPPORT)
#undef NO_AVX2_SUPPORT
#endif
#define HAVE_INTEL_AVX1
@ -2286,6 +2288,7 @@ SHA256_NOINLINE static int Transform_Sha256_AVX2_Len(wc_Sha256* sha256,
word32 len)
{
if ((len & WC_SHA256_BLOCK_SIZE) != 0) {
XMEMCPY(sha256->buffer, sha256->data, WC_SHA256_BLOCK_SIZE);
Transform_Sha256_AVX2(sha256);
sha256->data += WC_SHA256_BLOCK_SIZE;
len -= WC_SHA256_BLOCK_SIZE;
@ -2449,6 +2452,7 @@ SHA256_NOINLINE static int Transform_Sha256_AVX2_RORX_Len(wc_Sha256* sha256,
word32 len)
{
if ((len & WC_SHA256_BLOCK_SIZE) != 0) {
XMEMCPY(sha256->buffer, sha256->data, WC_SHA256_BLOCK_SIZE);
Transform_Sha256_AVX2_RORX(sha256);
sha256->data += WC_SHA256_BLOCK_SIZE;
len -= WC_SHA256_BLOCK_SIZE;

View File

@ -137,6 +137,8 @@
#if defined(__clang__) && ((__clang_major__ < 3) || \
(__clang_major__ == 3 && __clang_minor__ <= 5))
#define NO_AVX2_SUPPORT
#elif defined(__clang__) && defined(NO_AVX2_SUPPORT)
#undef NO_AVX2_SUPPORT
#endif
#define HAVE_INTEL_AVX1
@ -2250,6 +2252,7 @@ static int Transform_Sha512_AVX2(wc_Sha512* sha512)
static int Transform_Sha512_AVX2_Len(wc_Sha512* sha512, word32 len)
{
if ((len & WC_SHA512_BLOCK_SIZE) != 0) {
XMEMCPY(sha512->buffer, sha512->data, WC_SHA512_BLOCK_SIZE);
Transform_Sha512_AVX2(sha512);
sha512->data += WC_SHA512_BLOCK_SIZE;
len -= WC_SHA512_BLOCK_SIZE;
@ -2418,6 +2421,7 @@ static int Transform_Sha512_AVX2_RORX(wc_Sha512* sha512)
static int Transform_Sha512_AVX2_RORX_Len(wc_Sha512* sha512, word32 len)
{
if ((len & WC_SHA512_BLOCK_SIZE) != 0) {
XMEMCPY(sha512->buffer, sha512->data, WC_SHA512_BLOCK_SIZE);
Transform_Sha512_AVX2_RORX(sha512);
sha512->data += WC_SHA512_BLOCK_SIZE;
len -= WC_SHA512_BLOCK_SIZE;