Le 20/03/2019 à 13:36, Daniel P. Berrangé a écrit : > 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 name > 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 > > While we could make our definition conditional and rely on glibc's impl, > this patch simply renames our definition to sys_gettid() which is a > common pattern in this file. > > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com> > --- > > Changed in v3: > - put { on separate line to please checkpatch > > Changed in v2: > - Rename to sys_gettid instead of using conditional compilation > > linux-user/syscall.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 208fd1813d..804695411f 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -250,11 +250,15 @@ static type name (type1 arg1,type2 arg2,type3 > arg3,type4 arg4,type5 arg5, \ > #endif > > #ifdef __NR_gettid > -_syscall0(int, gettid) > +static int sys_gettid(void) > +{ > + return syscall(__NR_gettid); > +}
For other sys_ syscall we have something like #define __NR_sys_gettid __NR_gettid #ifdef __NR_gettid syscall0(int, sys_gettid) ... > #else > /* This is a replacement for the host gettid() and must return a host > errno. */ > -static int gettid(void) { > +static int sys_gettid(void) > +{ > return -ENOSYS; > } Perhaps we can avoid the "#else" as it will put a -ENOSYS in the ->tid of the structures. According to manpage, gettid appeared with linux 2.4.11 I don't think we support a kernel as old as this. Thanks, Laurent