[PATCH] Fix compiler warnings seen with clang-powerpc64le target

Jussi Kivilinna jussi.kivilinna at iki.fi
Wed Jan 4 11:13:31 CET 2023


* cipher/rijndael-ppc-common.h (asm_sbox_be): New.
* cipher/rijndael-ppc.c (_gcry_aes_sbox4_ppc8): Use 'asm_sbox_be'
instead of 'vec_sbox_be' since this instrinsics has different
prototype definition on GCC and Clang ('vector uchar' vs 'vector
ulong long').
* cipher/sha256-ppc.c (vec_ror_u32): Remove unused function.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/rijndael-ppc-common.h | 10 ++++++++++
 cipher/rijndael-ppc.c        |  4 ++--
 cipher/sha256-ppc.c          |  7 -------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/cipher/rijndael-ppc-common.h b/cipher/rijndael-ppc-common.h
index e4a90934..fc8ee526 100644
--- a/cipher/rijndael-ppc-common.h
+++ b/cipher/rijndael-ppc-common.h
@@ -256,6 +256,16 @@ asm_xor(block a, block b)
   return res;
 }
 
+static ASM_FUNC_ATTR_INLINE block
+asm_sbox_be(block b)
+{
+  block o;
+  __asm__ volatile ("vsbox %0, %1\n\t"
+		    : "=v" (o)
+		    : "v" (b));
+  return o;
+}
+
 static ASM_FUNC_ATTR_INLINE block
 asm_cipher_be(block b, block rk)
 {
diff --git a/cipher/rijndael-ppc.c b/cipher/rijndael-ppc.c
index 9db1c811..19f6a7e1 100644
--- a/cipher/rijndael-ppc.c
+++ b/cipher/rijndael-ppc.c
@@ -106,9 +106,9 @@ _gcry_aes_sbox4_ppc8(u32 fourbytes)
 {
   vec_u32 vec_fourbyte = { fourbytes, fourbytes, fourbytes, fourbytes };
 #ifdef WORDS_BIGENDIAN
-  return ((vec_u32)vec_sbox_be((block)vec_fourbyte))[1];
+  return ((vec_u32)asm_sbox_be((block)vec_fourbyte))[1];
 #else
-  return ((vec_u32)vec_sbox_be((block)vec_fourbyte))[2];
+  return ((vec_u32)asm_sbox_be((block)vec_fourbyte))[2];
 #endif
 }
 
diff --git a/cipher/sha256-ppc.c b/cipher/sha256-ppc.c
index a9b59714..c49d9ff2 100644
--- a/cipher/sha256-ppc.c
+++ b/cipher/sha256-ppc.c
@@ -86,13 +86,6 @@ vec_merge_idx0_elems(vector4x_u32 v0, vector4x_u32 v1,
 }
 
 
-static ASM_FUNC_ATTR_INLINE vector4x_u32
-vec_ror_u32(vector4x_u32 v, unsigned int shift)
-{
-  return (v >> (shift & 31)) ^ (v << ((32 - shift) & 31));
-}
-
-
 static ASM_FUNC_ATTR_INLINE vector4x_u32
 vec_vshasigma_u32(vector4x_u32 v, unsigned int a, unsigned int b)
 {
-- 
2.37.2




More information about the Gcrypt-devel mailing list