On Mon, Jul 20, 2020 at 12:18 PM Maamoun TK maamoun.tk@googlemail.com wrote:
fat-ppc.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/fat-ppc.c b/fat-ppc.c index e09b2097..eca689fe 100644 --- a/fat-ppc.c +++ b/fat-ppc.c @@ -39,10 +39,17 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#if defined(__FreeBSD__) && __FreeBSD__ < 12 -#include <sys/sysctl.h> -#else
+#if defined(_AIX) +#include <sys/systemcfg.h> +#elif defined(__linux__) +#include <sys/auxv.h> +#elif defined(__FreeBSD__) +#if __FreeBSD__ >= 12 #include <sys/auxv.h> +#else +#include <sys/sysctl.h> +#endif #endif
#include "nettle-types.h" @@ -64,19 +71,23 @@ struct ppc_features static void get_ppc_features (struct ppc_features *features) { +#if defined(_AIX) && defined(__power_8_andup)
- features->have_crypto_ext = __power_8_andup() != 0 ? 1 : 0;
+#else unsigned long hwcap2 = 0; -#if defined(__FreeBSD__) -#if __FreeBSD__ < 12 +#if defined(__linux__)
- hwcap2 = getauxval(AT_HWCAP2);
+#elif defined(__FreeBSD__) +#if __FreeBSD__ >= 12
- elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
+#else size_t len = sizeof(hwcap2); sysctlbyname("hw.cpu_features2", &hwcap2, &len, NULL, 0); -#else
- elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
#endif -#else
- hwcap2 = getauxval(AT_HWCAP2);
#endif features->have_crypto_ext = (hwcap2 & PPC_FEATURE2_VEC_CRYPTO) == PPC_FEATURE2_VEC_CRYPTO ? 1 : 0; +#endif }
DECLARE_FAT_FUNC(_nettle_aes_encrypt, aes_crypt_internal_func)
2.17.1
Hi Maamon,
One small comment...
You may want to stay flexible enough to detect POWER7, VSX and above. ChaCha is fast as hell even on POWER7 and without 64-bit vectors. In fact, I found ChaCha is profitable down to POWER4 on an old PowerMac.
Jeff