Skip to content

Commit a5fa1bd

Browse files
authored
Merge pull request #4376 from brad0/bsd_elf_aux_info
Extend elf_aux_info() support for RISC-V on FreeBSD and OpenBSD Signed-off-by: Stefan Weil <[email protected]>
2 parents f657ec2 + 92b2f37 commit a5fa1bd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ fi
221221
# additional checks for RVV targets
222222
if test x$check_for_rvv = x1; then
223223
AC_MSG_NOTICE([checking how to detect RVV availability])
224-
AC_CHECK_FUNCS([getauxval])
224+
AC_CHECK_FUNCS([getauxval elf_aux_info])
225225
226-
if test $ac_cv_func_getauxval = no; then
226+
if test $ac_cv_func_getauxval = no && test $ac_cv_func_elf_aux_info = no; then
227227
AC_MSG_WARN([RVV is available, but we don't know how to check for it. Will not be able to use RVV.])
228228
fi
229229
fi

src/arch/simddetect.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
#endif
6767

6868
#if defined(HAVE_RVV)
69-
# if defined(HAVE_GETAUXVAL)
69+
# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
7070
# include <sys/auxv.h>
7171
# define HWCAP_RV(letter) (1ul << ((letter) - 'A'))
7272
# endif
@@ -244,6 +244,10 @@ SIMDDetect::SIMDDetect() {
244244
# if defined(HAVE_GETAUXVAL)
245245
const unsigned long hwcap = getauxval(AT_HWCAP);
246246
rvv_available_ = hwcap & HWCAP_RV('V');
247+
# elif defined(HAVE_ELF_AUX_INFO)
248+
unsigned long hwcap = 0;
249+
elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
250+
rvv_available_ = hwcap & HWCAP_RV('V');
247251
# endif
248252
#endif
249253

0 commit comments

Comments
 (0)