[PATCH 2/8] provide a gettid function

Glauber Costa
2008-03-04T16:21:55Z

Since glibc does not provide a gettid call directly, only through
syscall, we wrap one for kvm

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
qemu/qemu-kvm.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 43e0f2e..8ee3bf8 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -19,6 +19,7 @@ int kvm_irqchip = 1;
#include <libkvm.h>
#include <pthread.h>
#include <sys/utsname.h>
+#include <sys/syscall.h>

extern void perror(const char *s);

@@ -50,6 +51,11 @@ struct vcpu_info {
int thread_id;
} vcpu_info[256];

+static inline unsigned long kvm_get_thread_id(void)
+{
+ return syscall(SYS_gettid);
+}
+
CPUState *qemu_kvm_cpu_env(int index)
{
return vcpu_info[index].env;
--
1.5.0.6