[PATCH 1/3] chacha20-ppc: do not generate p9 code when target attr unavailable
Jussi Kivilinna
jussi.kivilinna at iki.fi
Thu Mar 2 12:58:58 CET 2023
* cipher/chacha20-ppc.c (HAVE_FUNC_ATTR_TARGET): New.
(_gcry_chacha20_ppc9_blocks1, _gcry_chacha20_ppc9_blocks4)
(_gcry_chacha20_poly1305_ppc8_blocks4): Use inline functions
only if HAVE_FUNC_ATTR_TARGET is defined.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
cipher/chacha20-ppc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/cipher/chacha20-ppc.c b/cipher/chacha20-ppc.c
index f135a32f..994b6a01 100644
--- a/cipher/chacha20-ppc.c
+++ b/cipher/chacha20-ppc.c
@@ -660,12 +660,15 @@ chacha20_poly1305_ppc_blocks4(u32 *state, byte *dst, const byte *src,
#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
# define FUNC_ATTR_TARGET_P8 __attribute__((target("arch=pwr8")))
# define FUNC_ATTR_TARGET_P9 __attribute__((target("arch=pwr9")))
+# define HAVE_FUNC_ATTR_TARGET 1
#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define FUNC_ATTR_TARGET_P8 __attribute__((target("cpu=power8")))
# define FUNC_ATTR_TARGET_P9 __attribute__((target("cpu=power9")))
+# define HAVE_FUNC_ATTR_TARGET 1
#else
# define FUNC_ATTR_TARGET_P8
# define FUNC_ATTR_TARGET_P9
+# undef HAVE_FUNC_ATTR_TARGET
#endif
@@ -693,7 +696,7 @@ _gcry_chacha20_poly1305_ppc8_blocks4(u32 *state, byte *dst, const byte *src,
poly1305_src);
}
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+#ifdef HAVE_FUNC_ATTR_TARGET
/* Functions targetting POWER9. */
unsigned int ASM_FUNC_ATTR FUNC_ATTR_TARGET_P9 FUNC_ATTR_OPT_O2
_gcry_chacha20_ppc9_blocks1(u32 *state, byte *dst, const byte *src,
--
2.37.2
More information about the Gcrypt-devel
mailing list