qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for 4.0] linux-user: conditionally define gettid as


From: Daniel P . Berrangé
Subject: [Qemu-devel] [PATCH for 4.0] linux-user: conditionally define gettid as it is present in new glibc
Date: Tue, 19 Mar 2019 17:07:02 +0000

The glibc-2.29.9000-6.fc31.x86_64 package finally includes the gettid
function as part of unistd.h when __USE_GNU is defined. This clashes
with linux-user code which unconditionally defines this function
itself.

/home/berrange/src/virt/qemu/linux-user/syscall.c:253:16: error: static 
declaration of ‘gettid’ follows non-static declaration
  253 | _syscall0(int, gettid)
      |                ^~~~~~
/home/berrange/src/virt/qemu/linux-user/syscall.c:184:13: note: in definition 
of macro ‘_syscall0’
  184 | static type name (void)   \
      |             ^~~~
In file included from /usr/include/unistd.h:1170,
                 from /home/berrange/src/virt/qemu/include/qemu/osdep.h:107,
                 from /home/berrange/src/virt/qemu/linux-user/syscall.c:20:
/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ 
was here
   34 | extern __pid_t gettid (void) __THROW;
      |                ^~~~~~
  CC      aarch64-linux-user/linux-user/signal.o
make[1]: *** [/home/berrange/src/virt/qemu/rules.mak:69: linux-user/syscall.o] 
Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:449: subdir-aarch64-linux-user] Error 2

We need to probe for its existance and conditionally define our
own wrapper.

Signed-off-by: Daniel P. Berrangé <address@hidden>
---
 configure            | 19 +++++++++++++++++++
 linux-user/syscall.c |  6 ++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 7071f52584..fe980328b2 100755
--- a/configure
+++ b/configure
@@ -4270,6 +4270,22 @@ if compile_prog "" "" ; then
   splice=yes
 fi
 
+# Check if glibc exposes gettid yet
+gettid=no
+cat > $TMPC << EOF
+#include <unistd.h>
+
+int main(void)
+{
+    gettid();
+    return 0;
+}
+EOF
+if compile_prog "" "" ; then
+  gettid=yes
+fi
+
+
 ##########################################
 # libnuma probe
 
@@ -6651,6 +6667,9 @@ fi
 if test "$splice" = "yes" ; then
   echo "CONFIG_SPLICE=y" >> $config_host_mak
 fi
+if test "$gettid" = "yes" ; then
+  echo "CONFIG_GETTID=y" >> $config_host_mak
+fi
 if test "$eventfd" = "yes" ; then
   echo "CONFIG_EVENTFD=y" >> $config_host_mak
 fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 208fd1813d..70eb0d64f4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -249,14 +249,16 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 
arg4,type5 arg5, \
 #define TARGET_NR__llseek TARGET_NR_llseek
 #endif
 
-#ifdef __NR_gettid
+#ifndef CONFIG_GETTID
+# ifdef __NR_gettid
 _syscall0(int, gettid)
-#else
+# else
 /* This is a replacement for the host gettid() and must return a host
    errno. */
 static int gettid(void) {
     return -ENOSYS;
 }
+# endif
 #endif
 
 /* For the 64-bit guest on 32-bit host case we must emulate
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]