Skip to content

Commit

Permalink
Fix altivec compat with old compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Dec 18, 2024
1 parent 18439cd commit dee39ab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/aegis128l/aegis128l_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/aegis128x2/aegis128x2_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/aegis128x4/aegis128x4_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/aegis256/aegis256_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/aegis256x2/aegis256x2_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/aegis256x4/aegis256x4_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dee39ab

Please sign in to comment.