]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Add support for elf_aux_info() on OpenBSD
authorBrad Smith <brad@comstyle.com>
Mon, 2 Sep 2024 02:52:53 +0000 (22:52 -0400)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 7 Sep 2024 07:41:05 +0000 (09:41 +0200)
Signed-off-by: Brad Smith <brad@comstyle.com>
configure.ac
fat-arm64.c
fat-ppc.c

index 4f27e663a00d9191c3b3b70cd679318e06a1feac..1f53a89039143ba0c5d8aca396fbc37e10959f57 100644 (file)
@@ -212,7 +212,7 @@ LSH_FUNC_ALLOCA
 
 # getenv_secure is used for fat overrides,
 # getline is used in the testsuite
-AC_CHECK_FUNCS(secure_getenv getline)
+AC_CHECK_FUNCS(secure_getenv getline elf_aux_info)
 
 ASM_WORDS_BIGENDIAN=unknown
 AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1)
index 45cce0ccf004f1be1b150ec8a993dcc194ce05af..36136078ff8a7fb53f1ece165b037ef209169421 100644 (file)
@@ -51,6 +51,8 @@
 #if USE_GETAUXVAL
 # include <asm/hwcap.h>
 # include <sys/auxv.h>
+#elif defined(HAVE_ELF_AUX_INFO)
+# include <sys/auxv.h>
 #elif defined(__OpenBSD__)
 # include <sys/sysctl.h>
 # include <machine/cpu.h>
@@ -133,8 +135,15 @@ get_arm64_features (struct arm64_features *features)
       }
   else
     {
+#if USE_GETAUXVAL || defined(HAVE_ELF_AUX_INFO)
+      unsigned long hwcap = 0;
+
 #if USE_GETAUXVAL
-      unsigned long hwcap = getauxval(AT_HWCAP);
+      hwcap = getauxval(AT_HWCAP);
+#elif defined(HAVE_ELF_AUX_INFO)
+      elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+#endif
+
       features->have_aes
        = ((hwcap & (HWCAP_ASIMD | HWCAP_AES)) == (HWCAP_ASIMD | HWCAP_AES));
       features->have_pmull
index aaccc116f39f090d2a3b1130bd2cd6a39b656375..c4dae3a10cee325c644413548e1f67655695effd 100644 (file)
--- a/fat-ppc.c
+++ b/fat-ppc.c
 #  include <asm/cputable.h>
 #  include <sys/auxv.h>
 # endif
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
 # include <machine/cpu.h>
 # ifdef PPC_FEATURE2_HAS_VEC_CRYPTO
 # define PPC_FEATURE2_VEC_CRYPTO PPC_FEATURE2_HAS_VEC_CRYPTO
 # endif
-# if __FreeBSD__ >= 12
+# ifdef HAVE_ELF_AUX_INFO
 #  include <sys/auxv.h>
-# else
+# elif !defined(__OpenBSD__)
 #  include <sys/sysctl.h>
 # endif
 #endif
@@ -129,11 +129,11 @@ get_ppc_features (struct ppc_features *features)
 # if USE_GETAUXVAL
       hwcap = getauxval(AT_HWCAP);
       hwcap2 = getauxval(AT_HWCAP2);
-# elif defined(__FreeBSD__)
-#  if __FreeBSD__ >= 12
+# elif defined(__FreeBSD__) || defined(__OpenBSD__)
+#  ifdef HAVE_ELF_AUX_INFO
       elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
       elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
-#  else
+#  elif !defined(__OpenBSD__)
       size_t len;
       len = sizeof(hwcap);
       sysctlbyname("hw.cpu_features", &hwcap, &len, NULL, 0);