Convert over to using elf_aux_info().
Index: Makefile =================================================================== RCS file: /cvs/ports/emulators/qemu/Makefile,v retrieving revision 1.242 diff -u -p -u -p -r1.242 Makefile --- Makefile 26 Jul 2024 11:49:01 -0000 1.242 +++ Makefile 1 Sep 2024 04:31:43 -0000 @@ -8,6 +8,7 @@ COMMENT-ga= QEMU guest agent VERSION= 9.0.2 DISTNAME= qemu-${VERSION} +REVISION= 0 CATEGORIES= emulators SITES= https://download.qemu.org/ EXTRACT_SUFX= .tar.xz Index: patches/patch-meson_build =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-meson_build,v retrieving revision 1.13 diff -u -p -u -p -r1.13 patch-meson_build --- patches/patch-meson_build 28 May 2024 13:57:37 -0000 1.13 +++ patches/patch-meson_build 1 Sep 2024 04:31:43 -0000 @@ -1,3 +1,6 @@ +- util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD + 27fca0a0d560ae704457c5f89e0be658afef034d + - localstatedir does not belong under prefix - Remove hardcoding of optimization @@ -13,7 +16,22 @@ Index: meson.build config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) -@@ -4226,9 +4226,6 @@ else +@@ -2743,6 +2743,14 @@ config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_ + return getauxval(AT_HWCAP) == 0; + }''')) + ++config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' ++ #include <sys/auxv.h> ++ int main(void) { ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++ return hwcap; ++ }''')) ++ + config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' + #include <linux/usbdevice_fs.h> + +@@ -4226,9 +4234,6 @@ else summary_info += {'Objective-C compiler': false} endif option_cflags = (get_option('debug') ? ['-g'] : []) Index: patches/patch-util_cpuinfo-aarch64_c =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-util_cpuinfo-aarch64_c,v retrieving revision 1.1 diff -u -p -u -p -r1.1 patch-util_cpuinfo-aarch64_c --- patches/patch-util_cpuinfo-aarch64_c 15 Jul 2024 11:13:29 -0000 1.1 +++ patches/patch-util_cpuinfo-aarch64_c 1 Sep 2024 04:31:43 -0000 @@ -1,14 +1,22 @@ -util/cpuinfo-aarch64: Add OpenBSD support -ab089908b42f22e7edfa0d40db963c136ab35419 +- util/cpuinfo-aarch64: Add OpenBSD support + ab089908b42f22e7edfa0d40db963c136ab35419 +- util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD + 27fca0a0d560ae704457c5f89e0be658afef034d Index: util/cpuinfo-aarch64.c --- util/cpuinfo-aarch64.c.orig +++ util/cpuinfo-aarch64.c -@@ -20,6 +20,12 @@ +@@ -17,9 +17,18 @@ + # define HWCAP2_BTI 0 /* added in glibc 2.32 */ + # endif + #endif ++#ifdef CONFIG_ELF_AUX_INFO ++#include <sys/auxv.h> ++#endif #ifdef CONFIG_DARWIN # include <sys/sysctl.h> #endif -+#ifdef __OpenBSD__ ++#ifdef __OpenBSD__ && !defined(CONFIG_ELF_AUX_INFO) +# include <machine/armreg.h> +# include <machine/cpu.h> +# include <sys/types.h> @@ -17,12 +25,21 @@ Index: util/cpuinfo-aarch64.c unsigned cpuinfo; -@@ -71,6 +77,36 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi +@@ -55,7 +64,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi + + info = CPUINFO_ALWAYS; + +-#ifdef CONFIG_LINUX ++#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) + unsigned long hwcap = qemu_getauxval(AT_HWCAP); + info |= (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); + info |= (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); +@@ -71,6 +80,36 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi info |= sysctl_for_bool("hw.optional.arm.FEAT_AES") * CPUINFO_AES; info |= sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMULL; info |= sysctl_for_bool("hw.optional.arm.FEAT_BTI") * CPUINFO_BTI; +#endif -+#ifdef __OpenBSD__ ++#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO) + int mib[2]; + uint64_t isar0; + uint64_t pfr1; Index: patches/patch-util_cpuinfo-ppc_c =================================================================== RCS file: /cvs/ports/emulators/qemu/patches/patch-util_cpuinfo-ppc_c,v retrieving revision 1.1 diff -u -p -u -p -r1.1 patch-util_cpuinfo-ppc_c --- patches/patch-util_cpuinfo-ppc_c 15 Jul 2024 11:13:29 -0000 1.1 +++ patches/patch-util_cpuinfo-ppc_c 1 Sep 2024 04:31:43 -0000 @@ -1,18 +1,19 @@ -util/cpuinfo-ppc: Fix building on OpenBSD -272d3decc19aebe87955f4ec6d0c6cc8790471f1 +- util/cpuinfo-ppc: Fix building on OpenBSD + 272d3decc19aebe87955f4ec6d0c6cc8790471f1 +- util/cpuinfo-ppc: Add FreeBSD support + 6527cee257e3c8e7add941a06118009c83ba9e75 +- util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD + 27fca0a0d560ae704457c5f89e0be658afef034d Index: util/cpuinfo-ppc.c --- util/cpuinfo-ppc.c.orig +++ util/cpuinfo-ppc.c -@@ -6,11 +6,13 @@ +@@ -6,11 +6,21 @@ #include "qemu/osdep.h" #include "host/cpuinfo.h" -#include <asm/cputable.h> -#ifdef CONFIG_GETAUXVAL --# include <sys/auxv.h> --#else --# include "elf.h" +#ifdef CONFIG_LINUX +# include <asm/cputable.h> +# ifdef CONFIG_GETAUXVAL @@ -20,10 +21,20 @@ Index: util/cpuinfo-ppc.c +# else +# include "elf.h" +# endif ++#endif ++#if defined(CONFIG_ELF_AUX_INFO) + # include <sys/auxv.h> +-#else +-# include "elf.h" ++# include <machine/cpu.h> ++# ifndef PPC_FEATURE2_ARCH_3_1 ++# define PPC_FEATURE2_ARCH_3_1 0 ++# endif ++# define PPC_FEATURE2_VEC_CRYPTO PPC_FEATURE2_HAS_VEC_CRYPTO #endif unsigned cpuinfo; -@@ -19,16 +21,17 @@ unsigned cpuinfo; +@@ -19,16 +29,17 @@ unsigned cpuinfo; unsigned __attribute__((constructor)) cpuinfo_init(void) { unsigned info = cpuinfo; @@ -37,14 +48,14 @@ Index: util/cpuinfo-ppc.c - hwcap2 = qemu_getauxval(AT_HWCAP2); info = CPUINFO_ALWAYS; -+#ifdef CONFIG_LINUX ++#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) + unsigned long hwcap = qemu_getauxval(AT_HWCAP); + unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); + /* Version numbers are monotonic, and so imply all lower versions. */ if (hwcap2 & PPC_FEATURE2_ARCH_3_1) { info |= CPUINFO_V3_1 | CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06; -@@ -58,6 +61,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi +@@ -58,6 +69,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(voi } } } Index: patches/patch-util_getauxval_c =================================================================== RCS file: patches/patch-util_getauxval_c diff -N patches/patch-util_getauxval_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-util_getauxval_c 1 Sep 2024 04:31:43 -0000 @@ -0,0 +1,15 @@ +util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD +27fca0a0d560ae704457c5f89e0be658afef034d + +Index: util/getauxval.c +--- util/getauxval.c.orig ++++ util/getauxval.c +@@ -98,7 +98,7 @@ unsigned long qemu_getauxval(unsigned long type) + return 0; + } + +-#elif defined(__FreeBSD__) ++#elif defined(CONFIG_ELF_AUX_INFO) + #include <sys/auxv.h> + + unsigned long qemu_getauxval(unsigned long type)