[PATCH] Use FreeBSD's elf_aux_info for detecting ARM HW features
Jussi Kivilinna
jussi.kivilinna at iki.fi
Tue Apr 9 19:11:04 CEST 2019
* configure.ac: Add function check for 'elf_aux_info'.
* src/hwf-arm.c [HAVE_ELF_AUX_INFO]: Include 'sys/auxv.h'.
[HAVE_ELF_AUX_INFO && !HAVE_GETAUXVAL] (HAVE_GETAUXVAL)
(getauxval): New.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
0 files changed
diff --git a/configure.ac b/configure.ac
index b0d7f8903..b54b212b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1806,7 +1806,7 @@ AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
# Other checks
AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
-AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval)
+AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval elf_aux_info)
AC_CHECK_FUNCS(explicit_bzero getentropy)
GNUPG_CHECK_MLOCK
diff --git a/src/hwf-arm.c b/src/hwf-arm.c
index 0f8f83f61..1d19ea86b 100644
--- a/src/hwf-arm.c
+++ b/src/hwf-arm.c
@@ -24,7 +24,8 @@
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
-#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_GETAUXVAL)
+#if defined(HAVE_SYS_AUXV_H) && (defined(HAVE_GETAUXVAL) || \
+ defined(HAVE_ELF_AUX_INFO))
#include <sys/auxv.h>
#endif
@@ -35,6 +36,30 @@
# error Module build for wrong CPU.
#endif
+
+#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ELF_AUX_INFO) && \
+ !defined(HAVE_GETAUXVAL) && defined(AT_HWCAP)
+#define HAVE_GETAUXVAL
+static unsigned long getauxval(unsigned long type)
+{
+ unsigned long auxval = 0;
+ int err;
+
+ /* FreeBSD provides 'elf_aux_info' function that does the same as
+ * 'getauxval' on Linux. */
+
+ err = elf_aux_info (type, &auxval, sizeof(auxval));
+ if (err)
+ {
+ errno = err;
+ auxval = 0;
+ }
+
+ return auxval;
+}
+#endif
+
+
#undef HAS_SYS_AT_HWCAP
#if defined(__linux__) || \
(defined(HAVE_SYS_AUXV_H) && defined(HAVE_GETAUXVAL))
@@ -49,6 +74,7 @@ struct feature_map_s {
#ifdef __arm__
+/* Note: These macros have same values on Linux and FreeBSD. */
#ifndef AT_HWCAP
# define AT_HWCAP 16
#endif
@@ -88,6 +114,7 @@ static const struct feature_map_s arm_features[] =
#elif defined(__aarch64__)
+/* Note: These macros have same values on Linux and FreeBSD. */
#ifndef AT_HWCAP
# define AT_HWCAP 16
#endif
More information about the Gcrypt-devel
mailing list