mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Support FreeBSD's API for querying the ELF aux vector.
We use this for detecting the Arm crypto extension and using it to enable accelerated AES and/or SHA-{1,2}. Previously, I had code that called glibc's getauxval(3) function, conditioned on #ifdef __linux__. Now, instead, I do an autoconf test to query the presence of getauxval itself (so that any other system with the same API can still work), and alongside it, also check for the analogous FreeBSD libc function elf_aux_info(3). As a result, building on Arm FreeBSD now gets the accelerated-crypto autodetection.
This commit is contained in:
parent
e5caabaded
commit
65383082bf
@ -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 <time.h>]])
|
||||
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], [
|
||||
|
@ -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 <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_AUXV_H
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASM_HWCAP_H
|
||||
#include <asm/hwcap.h>
|
||||
#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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user