[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
From: |
Thomas Huth |
Subject: |
Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature |
Date: |
Tue, 26 May 2020 09:21:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
On 24/05/2020 14.09, David CARLIER wrote:
> Hi here porting qemu_getauxval to FreeBSD. Thanks. Regards.
>
> From 5be5e56a59631b28ed7b738d251dda252ba9b03e Mon Sep 17 00:00:00 2001
> From: David Carlier <address@hidden>
> Date: Sun, 24 May 2020 13:03:32 +0100
> Subject: [PATCH] util/getauxval: FreeBSD has a similar auxilary vector API
>
> Signed-off-by: David Carlier <address@hidden>
> ---
> configure | 6 ++++++
> util/getauxval.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/configure b/configure
> index 2fc05c4465..545fd2364f 100755
> --- a/configure
> +++ b/configure
> @@ -5824,7 +5824,13 @@ getauxval=no
> cat > $TMPC << EOF
> #include <sys/auxv.h>
> int main(void) {
> +#if defined(__linux__)
> return getauxval(AT_HWCAP) == 0;
> +#elif defined(__FreeBSD__)
> + unsigned long a = 0;
> + return elf_aux_info(AT_HWCAP, &a, sizeof(a)) == 0;
> +#endif
> + return 1;
> }
> EOF
> if compile_prog "" "" ; then
That configure check looks wrong. On other systems (i.e. non-Linux and
non-FreeBSD), this code snippet will now compile successfully and thus
the configure script sets getauxval=yes. I'd suggest you change it this
way instead:
int main(void) {
+#if defined(__FreeBSD__)
+ unsigned long a = 0;
+ return elf_aux_info(AT_HWCAP, &a, sizeof(a)) == 0;
+#else
return getauxval(AT_HWCAP) == 0;
+#endif
}
... so that it still fails to compile by default on other systems.
Thomas