From dee39ab4ba9d1014ef9e0915d40d7813c4cc4bd6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 18 Dec 2024 14:51:20 +0100 Subject: [PATCH] Fix altivec compat with old compilers --- src/aegis128l/aegis128l_altivec.c | 6 +++--- src/aegis128x2/aegis128x2_altivec.c | 6 +++--- src/aegis128x4/aegis128x4_altivec.c | 6 +++--- src/aegis256/aegis256_altivec.c | 6 +++--- src/aegis256x2/aegis256x2_altivec.c | 6 +++--- src/aegis256x4/aegis256x4_altivec.c | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/aegis128l/aegis128l_altivec.c b/src/aegis128l/aegis128l_altivec.c index 35add00..ec52698 100644 --- a/src/aegis128l/aegis128l_altivec.c +++ b/src/aegis128l/aegis128l_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 16 @@ -26,9 +26,9 @@ typedef vector unsigned char aes_block_t; # define AES_BLOCK_AND(A, B) vec_and((A), (B)) # define AES_BLOCK_LOAD(A) vec_xl_be(0, (const unsigned char *) (A)) # define AES_BLOCK_LOAD_64x2(A, B) \ - vec_revb(vec_insert((A), vec_promote((unsigned long long) (B), 1), 0)) + ((aes_block_t) vec_revb(vec_insert((A), vec_promote((unsigned long long) (B), 1), 0))) # define AES_BLOCK_STORE(A, B) vec_xst_be((B), 0, (unsigned char *) (A)) -# define AES_ENC(A, B) vec_cipher_be((A), (B)) +# define AES_ENC(A, B) ((aes_block_t) vec_cipher_be((A), (B))) static inline void aegis128l_update(aes_block_t *const state, const aes_block_t d1, const aes_block_t d2) diff --git a/src/aegis128x2/aegis128x2_altivec.c b/src/aegis128x2/aegis128x2_altivec.c index 6422379..a9cfd4f 100644 --- a/src/aegis128x2/aegis128x2_altivec.c +++ b/src/aegis128x2/aegis128x2_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 32 @@ -46,8 +46,8 @@ AES_BLOCK_LOAD(const uint8_t *a) static inline aes_block_t AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b) { - const vector unsigned char t = - vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0)); + const vector unsigned char t = ((vector unsigned char) vec_revb( + vec_insert(a, vec_promote((unsigned long long) (b), 1), 0))); return (aes_block_t) { t, t }; } static inline void diff --git a/src/aegis128x4/aegis128x4_altivec.c b/src/aegis128x4/aegis128x4_altivec.c index dbe33dc..a479e90 100644 --- a/src/aegis128x4/aegis128x4_altivec.c +++ b/src/aegis128x4/aegis128x4_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 64 @@ -51,8 +51,8 @@ AES_BLOCK_LOAD(const uint8_t *a) static inline aes_block_t AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b) { - const vector unsigned char t = - vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0)); + const vector unsigned char t = ((vector unsigned char) vec_revb( + vec_insert(a, vec_promote((unsigned long long) (b), 1), 0))); return (aes_block_t) { t, t, t, t }; } static inline void diff --git a/src/aegis256/aegis256_altivec.c b/src/aegis256/aegis256_altivec.c index 0fb195e..e5b3161 100644 --- a/src/aegis256/aegis256_altivec.c +++ b/src/aegis256/aegis256_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 16 @@ -26,9 +26,9 @@ typedef vector unsigned char aes_block_t; # define AES_BLOCK_AND(A, B) vec_and((A), (B)) # define AES_BLOCK_LOAD(A) vec_xl_be(0, (const unsigned char *) (A)) # define AES_BLOCK_LOAD_64x2(A, B) \ - vec_revb(vec_insert((A), vec_promote((unsigned long long) (B), 1), 0)) + ((aes_block_t) vec_revb(vec_insert((A), vec_promote((unsigned long long) (B), 1), 0))) # define AES_BLOCK_STORE(A, B) vec_xst_be((B), 0, (unsigned char *) (A)) -# define AES_ENC(A, B) vec_cipher_be((A), (B)) +# define AES_ENC(A, B) ((aes_block_t) vec_cipher_be((A), (B))) static inline void aegis256_update(aes_block_t *const state, const aes_block_t d) diff --git a/src/aegis256x2/aegis256x2_altivec.c b/src/aegis256x2/aegis256x2_altivec.c index d34901d..446fad8 100644 --- a/src/aegis256x2/aegis256x2_altivec.c +++ b/src/aegis256x2/aegis256x2_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 32 @@ -46,8 +46,8 @@ AES_BLOCK_LOAD(const uint8_t *a) static inline aes_block_t AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b) { - const vector unsigned char t = - vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0)); + const vector unsigned char t = ((vector unsigned char) vec_revb( + vec_insert(a, vec_promote((unsigned long long) (b), 1), 0))); return (aes_block_t) { t, t }; } static inline void diff --git a/src/aegis256x4/aegis256x4_altivec.c b/src/aegis256x4/aegis256x4_altivec.c index 84d2db2..1530075 100644 --- a/src/aegis256x4/aegis256x4_altivec.c +++ b/src/aegis256x4/aegis256x4_altivec.c @@ -15,7 +15,7 @@ # ifdef __clang__ # pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function) # elif defined(__GNUC__) -# pragma GCC target("+altivec+crypto") +# pragma GCC target("altivec,crypto") # endif # define AES_BLOCK_LENGTH 64 @@ -51,8 +51,8 @@ AES_BLOCK_LOAD(const uint8_t *a) static inline aes_block_t AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b) { - const vector unsigned char t = - vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0)); + const vector unsigned char t = ((vector unsigned char) vec_revb( + vec_insert(a, vec_promote((unsigned long long) (b), 1), 0))); return (aes_block_t) { t, t, t, t }; } static inline void