On 2024-09-07 3:17 p.m., Niels Möller wrote:
Brad Smith brad@comstyle.com writes:
OpenBSD 7.6 will add elf_aux_info(). The sysctl path will be used for previous releases, so yes it is still necessary.
Thanks, makes sense. Merged to the master-updates branch for testing (even though, unfortunately, I have no continuous testing set up for any BSD flavor on any arch).
BTW, this also adds support for FreeBSD/arm64.
I'm considering the below followup patch, to reduce level of #if nesting. Does it look right?
(Also not sure why USE_GETAUXVAL is defined the way it is, duplicated in several places, it should perhaps just be a configure test setting HAVE_GETAUXVAL).
Regards, /Niels
Yes, that looks a little better.
diff --git a/fat-ppc.c b/fat-ppc.c index c4dae3a1..9d50e5b1 100644 --- a/fat-ppc.c +++ b/fat-ppc.c @@ -55,7 +55,7 @@ # endif # ifdef HAVE_ELF_AUX_INFO # include <sys/auxv.h> -# elif !defined(__OpenBSD__) +# elif defined(__FreeBSD__) # include <sys/sysctl.h> # endif #endif @@ -129,17 +129,15 @@ get_ppc_features (struct ppc_features *features) # if USE_GETAUXVAL hwcap = getauxval(AT_HWCAP); hwcap2 = getauxval(AT_HWCAP2); -# elif defined(__FreeBSD__) || defined(__OpenBSD__) -# ifdef HAVE_ELF_AUX_INFO +# elif defined(HAVE_ELF_AUX_INFO) elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2)); -# elif !defined(__OpenBSD__) +# elif defined(__FreeBSD__) size_t len; len = sizeof(hwcap); sysctlbyname("hw.cpu_features", &hwcap, &len, NULL, 0); len = sizeof(hwcap2); sysctlbyname("hw.cpu_features2", &hwcap2, &len, NULL, 0); -# endif # endif features->have_crypto_ext = ((hwcap2 & PPC_FEATURE2_VEC_CRYPTO) == PPC_FEATURE2_VEC_CRYPTO);