]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Add AIX to cpu detection
authorMaamoun TK <maamoun.tk@googlemail.com>
Mon, 20 Jul 2020 16:18:35 +0000 (19:18 +0300)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 26 Aug 2020 16:13:51 +0000 (18:13 +0200)
fat-ppc.c

index 7198e2dd39c6f90a56801996f8d952dc45b1ac9c..9b8022d76fcc64a82fe62d8bbe3d3db9ba542cfe 100644 (file)
--- a/fat-ppc.c
+++ b/fat-ppc.c
 #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)