All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
@ 2020-05-24 12:09 David CARLIER
  2020-05-26  7:21 ` Thomas Huth
  0 siblings, 1 reply; 8+ messages in thread
From: David CARLIER @ 2020-05-24 12:09 UTC (permalink / raw)
  To: qemu-devel, armbru

Hi here porting qemu_getauxval to FreeBSD. Thanks. Regards.

From 5be5e56a59631b28ed7b738d251dda252ba9b03e Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
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 <devnexen@gmail.com>
---
 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
diff --git a/util/getauxval.c b/util/getauxval.c
index 36afdfb9e6..373ed3899f 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -33,7 +33,13 @@

 unsigned long qemu_getauxval(unsigned long key)
 {
+#if defined(__linux__)
     return getauxval(key);
+#elif defined(__FreeBSD__)
+    unsigned long aux = 0;
+    elf_aux_info(key, &aux, sizeof(aux));
+    return aux;
+#endif
 }
 #elif defined(__linux__)
 #include "elf.h"
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-05-24 12:09 [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature David CARLIER
@ 2020-05-26  7:21 ` Thomas Huth
  2020-05-26  7:37   ` David CARLIER
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Huth @ 2020-05-26  7:21 UTC (permalink / raw)
  To: David CARLIER, qemu-devel, armbru

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 <devnexen@gmail.com>
> 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 <devnexen@gmail.com>
> ---
>  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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-05-26  7:21 ` Thomas Huth
@ 2020-05-26  7:37   ` David CARLIER
  0 siblings, 0 replies; 8+ messages in thread
From: David CARLIER @ 2020-05-26  7:37 UTC (permalink / raw)
  To: Thomas Huth; +Cc: qemu-devel, armbru

From 316cbdea0434a523c78d3f18fe7e6697577e4aae Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Tue, 26 May 2020 08:33:12 +0100
Subject: [PATCH] util/getauxval: Porting to FreeBSD the getauxval feature

FreeBSD has a similar API for auxiliary vector.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 configure        | 5 +++++
 util/getauxval.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/configure b/configure
index 2fc05c4465..2c93867080 100755
--- a/configure
+++ b/configure
@@ -5824,7 +5824,12 @@ getauxval=no
 cat > $TMPC << EOF
 #include <sys/auxv.h>
 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
 }
 EOF
 if compile_prog "" "" ; then
diff --git a/util/getauxval.c b/util/getauxval.c
index 36afdfb9e6..373ed3899f 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -33,7 +33,13 @@

 unsigned long qemu_getauxval(unsigned long key)
 {
+#if defined(__linux__)
     return getauxval(key);
+#elif defined(__FreeBSD__)
+    unsigned long aux = 0;
+    elf_aux_info(key, &aux, sizeof(aux));
+    return aux;
+#endif
 }
 #elif defined(__linux__)
 #include "elf.h"
-- 
2.27.0.rc0

On Tue, 26 May 2020 at 08:21, Thomas Huth <thuth@redhat.com> wrote:
>
> 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 <devnexen@gmail.com>
> > 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 <devnexen@gmail.com>
> > ---
> >  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
>


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-06-12  8:46   ` David CARLIER
  2020-06-12  9:15     ` Laurent Vivier
@ 2020-06-12  9:45     ` Paolo Bonzini
  1 sibling, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2020-06-12  9:45 UTC (permalink / raw)
  To: David CARLIER, Laurent Vivier; +Cc: qemu-trivial, Thomas Huth, qemu-devel

On 12/06/20 10:46, David CARLIER wrote:
> From d7f9d40777d1ed7c9450b0be4f957da2993dfc72 Mon Sep 17 00:00:00 2001
> From: David Carlier <devnexen@gmail.com>
> Date: Fri, 12 Jun 2020 09:39:17 +0100
> Subject: [PATCH] util/getauxval: Porting to FreeBSD getauxval feature
> 
> FreeBSD has a similar API for auxiliary vector.
> 
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
>  util/getauxval.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/util/getauxval.c b/util/getauxval.c
> index 36afdfb9e6..b124107d61 100644
> --- a/util/getauxval.c
> +++ b/util/getauxval.c
> @@ -98,6 +98,16 @@ unsigned long qemu_getauxval(unsigned long type)
>      return 0;
>  }
> 
> +#elif defined(__FreeBSD__)
> +#include <sys/auxv.h>
> +
> +unsigned long qemu_getauxval(unsigned long type)
> +{
> +    unsigned long aux = 0;
> +    elf_aux_info(type, &aux, sizeof(aux));
> +    return aux;
> +}
> +
>  #else
> 
>  unsigned long qemu_getauxval(unsigned long type)
> 

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-06-12  8:46   ` David CARLIER
@ 2020-06-12  9:15     ` Laurent Vivier
  2020-06-12  9:45     ` Paolo Bonzini
  1 sibling, 0 replies; 8+ messages in thread
From: Laurent Vivier @ 2020-06-12  9:15 UTC (permalink / raw)
  To: David CARLIER; +Cc: qemu-trivial, Paolo Bonzini, Thomas Huth, qemu-devel

Le 12/06/2020 à 10:46, David CARLIER a écrit :
> From d7f9d40777d1ed7c9450b0be4f957da2993dfc72 Mon Sep 17 00:00:00 2001
> From: David Carlier <devnexen@gmail.com>
> Date: Fri, 12 Jun 2020 09:39:17 +0100
> Subject: [PATCH] util/getauxval: Porting to FreeBSD getauxval feature
> 
> FreeBSD has a similar API for auxiliary vector.
> 
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
>  util/getauxval.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/util/getauxval.c b/util/getauxval.c
> index 36afdfb9e6..b124107d61 100644
> --- a/util/getauxval.c
> +++ b/util/getauxval.c
> @@ -98,6 +98,16 @@ unsigned long qemu_getauxval(unsigned long type)
>      return 0;
>  }
> 
> +#elif defined(__FreeBSD__)
> +#include <sys/auxv.h>
> +
> +unsigned long qemu_getauxval(unsigned long type)
> +{
> +    unsigned long aux = 0;
> +    elf_aux_info(type, &aux, sizeof(aux));
> +    return aux;
> +}
> +
>  #else
> 
>  unsigned long qemu_getauxval(unsigned long type)
> 

When you send a new version of a patch, add the version number in the
subject ("[PATCH v2]") and don't reply to the previous one.

https://wiki.qemu.org/Contribute/SubmitAPatch#When_resending_patches_add_a_version_tag

Anyway:

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-06-12  7:13 ` Laurent Vivier
@ 2020-06-12  8:46   ` David CARLIER
  2020-06-12  9:15     ` Laurent Vivier
  2020-06-12  9:45     ` Paolo Bonzini
  0 siblings, 2 replies; 8+ messages in thread
From: David CARLIER @ 2020-06-12  8:46 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, Paolo Bonzini, Thomas Huth, qemu-devel

From d7f9d40777d1ed7c9450b0be4f957da2993dfc72 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Fri, 12 Jun 2020 09:39:17 +0100
Subject: [PATCH] util/getauxval: Porting to FreeBSD getauxval feature

FreeBSD has a similar API for auxiliary vector.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 util/getauxval.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/util/getauxval.c b/util/getauxval.c
index 36afdfb9e6..b124107d61 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -98,6 +98,16 @@ unsigned long qemu_getauxval(unsigned long type)
     return 0;
 }

+#elif defined(__FreeBSD__)
+#include <sys/auxv.h>
+
+unsigned long qemu_getauxval(unsigned long type)
+{
+    unsigned long aux = 0;
+    elf_aux_info(type, &aux, sizeof(aux));
+    return aux;
+}
+
 #else

 unsigned long qemu_getauxval(unsigned long type)
-- 
2.27.0

On Fri, 12 Jun 2020 at 08:13, Laurent Vivier <laurent@vivier.eu> wrote:
>
> Le 11/06/2020 à 23:10, David CARLIER a écrit :
> >
> Hi,
>
> please don't put your patch in attachements, you can use "git
> send-email" if your emailer doesn't allow it.
>
> https://wiki.qemu.org/Contribute/SubmitAPatch#Do_not_send_as_an_attachment
>
> I think your patch is not correct, you put a "#if defined(__linux__)" in
> a block that is followed by "#elif defined(__linux__)" and there is no
> return value if none of the "defined()" is true.
>
> I think you should not modify the configure and add directly a "#if
> defined(__FreeBSD__)" at the beginning of getauxval.c to define your
> function.
>
> Thanks,
> Laurent


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
  2020-06-11 21:10 David CARLIER
@ 2020-06-12  7:13 ` Laurent Vivier
  2020-06-12  8:46   ` David CARLIER
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Vivier @ 2020-06-12  7:13 UTC (permalink / raw)
  To: David CARLIER, qemu-trivial, qemu-devel, Thomas Huth, Paolo Bonzini

Le 11/06/2020 à 23:10, David CARLIER a écrit :
> 
Hi,

please don't put your patch in attachements, you can use "git
send-email" if your emailer doesn't allow it.

https://wiki.qemu.org/Contribute/SubmitAPatch#Do_not_send_as_an_attachment

I think your patch is not correct, you put a "#if defined(__linux__)" in
a block that is followed by "#elif defined(__linux__)" and there is no
return value if none of the "defined()" is true.

I think you should not modify the configure and add directly a "#if
defined(__FreeBSD__)" at the beginning of getauxval.c to define your
function.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature
@ 2020-06-11 21:10 David CARLIER
  2020-06-12  7:13 ` Laurent Vivier
  0 siblings, 1 reply; 8+ messages in thread
From: David CARLIER @ 2020-06-11 21:10 UTC (permalink / raw)
  To: qemu-trivial, qemu-devel, Thomas Huth, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-util-getauxval-Porting-to-FreeBSD-the-getauxval-feat.patch --]
[-- Type: application/octet-stream, Size: 1257 bytes --]

From 316cbdea0434a523c78d3f18fe7e6697577e4aae Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Tue, 26 May 2020 08:33:12 +0100
Subject: [PATCH] util/getauxval: Porting to FreeBSD the getauxval feature

FreeBSD has a similar API for auxiliary vector.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 configure        | 5 +++++
 util/getauxval.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/configure b/configure
index 2fc05c4465..2c93867080 100755
--- a/configure
+++ b/configure
@@ -5824,7 +5824,12 @@ getauxval=no
 cat > $TMPC << EOF
 #include <sys/auxv.h>
 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
 }
 EOF
 if compile_prog "" "" ; then
diff --git a/util/getauxval.c b/util/getauxval.c
index 36afdfb9e6..373ed3899f 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -33,7 +33,13 @@
 
 unsigned long qemu_getauxval(unsigned long key)
 {
+#if defined(__linux__)
     return getauxval(key);
+#elif defined(__FreeBSD__)
+    unsigned long aux = 0;
+    elf_aux_info(key, &aux, sizeof(aux));
+    return aux;
+#endif
 }
 #elif defined(__linux__)
 #include "elf.h"
-- 
2.27.0.rc0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-12  9:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 12:09 [PATCH 1/1] util/getauxval: Porting to FreeBSD getauxval feature David CARLIER
2020-05-26  7:21 ` Thomas Huth
2020-05-26  7:37   ` David CARLIER
2020-06-11 21:10 David CARLIER
2020-06-12  7:13 ` Laurent Vivier
2020-06-12  8:46   ` David CARLIER
2020-06-12  9:15     ` Laurent Vivier
2020-06-12  9:45     ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.