Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: kvm: Fix a compile error in selftests/kvm/rseq_test.c

The following warning appears when executing:
make -C tools/testing/selftests/kvm

rseq_test.c: In function ‘main’:
rseq_test.c:237:33: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
(void *)(unsigned long)gettid());
^~~~~~
getgid
/usr/bin/ld: /tmp/ccr5mMko.o: in function `main':
../kvm/tools/testing/selftests/kvm/rseq_test.c:237: undefined reference to `gettid'
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:173: ../kvm/tools/testing/selftests/kvm/rseq_test] Error 1

Use the more compatible syscall(SYS_gettid) instead of gettid() to fix it.
More subsequent reuse may cause it to be wrapped in a lib file.

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
Message-Id: <20220802071240.84626-1-cloudliang@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Jinrong Liang and committed by
Paolo Bonzini
561cafeb b4ac28a3

+1 -1
+1 -1
tools/testing/selftests/kvm/rseq_test.c
··· 227 227 ucall_init(vm, NULL); 228 228 229 229 pthread_create(&migration_thread, NULL, migration_worker, 230 - (void *)(unsigned long)gettid()); 230 + (void *)(unsigned long)syscall(SYS_gettid)); 231 231 232 232 for (i = 0; !done; i++) { 233 233 vcpu_run(vcpu);