diff --git a/configure.ac b/configure.ac index c5bbd454..b20c4fd9 100644 --- a/configure.ac +++ b/configure.ac @@ -169,9 +169,9 @@ AC_CHECK_LIB(X11, XOpenDisplay, [GTK_LIBS="-lX11 $GTK_LIBS" AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])]) -AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent]) +AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent getauxval elf_aux_info]) AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include ]]) -AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h glob.h]) +AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h sys/types.h glob.h]) AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])]) AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [ diff --git a/unix/uxutils.c b/unix/uxutils.c index 7b63842e..467e5bcc 100644 --- a/unix/uxutils.c +++ b/unix/uxutils.c @@ -1,11 +1,35 @@ #include "putty.h" #include "ssh.h" -#if defined __linux__ && (defined __arm__ || defined __aarch64__) && \ - HAVE_SYS_AUXV_H && HAVE_ASM_HWCAP_H +#if defined __arm__ || defined __aarch64__ +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_AUXV_H #include +#endif + +#ifdef HAVE_ASM_HWCAP_H #include +#endif + +#if defined HAVE_GETAUXVAL +/* No code needed: getauxval has just the API we want already */ +#elif defined HAVE_ELF_AUX_INFO +/* Implement the simple getauxval API in terms of FreeBSD elf_aux_info */ +static inline u_long getauxval(int which) +{ + u_long toret; + if (elf_aux_info(which, &toret, sizeof(toret)) != 0) + return 0; /* elf_aux_info didn't work */ + return toret; +} +#else +/* Implement a stub getauxval which returns no capabilities */ +static inline u_long getauxval(int which) { return 0; } +#endif bool platform_aes_hw_available(void) { @@ -40,21 +64,4 @@ bool platform_sha1_hw_available(void) #endif } -#else - -bool platform_aes_hw_available(void) -{ - return false; -} - -bool platform_sha256_hw_available(void) -{ - return false; -} - -bool platform_sha1_hw_available(void) -{ - return false; -} - -#endif +#endif /* defined __arm__ || defined __aarch64__ */