selftests: kvm: Fix a compile error in selftests/kvm/rseq_test.c
authorJinrong Liang <cloudliang@tencent.com>
Tue, 2 Aug 2022 07:12:40 +0000 (15:12 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 22 Sep 2022 21:02:20 +0000 (17:02 -0400)
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>
tools/testing/selftests/kvm/rseq_test.c

index fac248a436667a38f2d43dc2bb6e63bb9cfea482..6f88da7e60be63844a4c0f18f4ee0f84c5d1c0da 100644 (file)
@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
        ucall_init(vm, NULL);
 
        pthread_create(&migration_thread, NULL, migration_worker,
-                      (void *)(unsigned long)gettid());
+                      (void *)(unsigned long)syscall(SYS_gettid));
 
        for (i = 0; !done; i++) {
                vcpu_run(vcpu);