aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/oslib-posix.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 062236a..916f1be 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -48,11 +48,13 @@
#ifdef __FreeBSD__
#include <sys/sysctl.h>
#include <sys/user.h>
+#include <sys/thr.h>
#include <libutil.h>
#endif
#ifdef __NetBSD__
#include <sys/sysctl.h>
+#include <lwp.h>
#endif
#include "qemu/mmap-alloc.h"
@@ -84,6 +86,13 @@ int qemu_get_thread_id(void)
{
#if defined(__linux__)
return syscall(SYS_gettid);
+#elif defined(__FreeBSD__)
+ /* thread id is up to INT_MAX */
+ long tid;
+ thr_self(&tid);
+ return (int)tid;
+#elif defined(__NetBSD__)
+ return _lwp_self();
#else
return getpid();
#endif