qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] util/oslib: Returns real thread identifier on FreeBSD and NetBSD
@ 2020-05-23  7:23 David CARLIER
  2020-05-26  5:40 ` Thomas Huth
  0 siblings, 1 reply; 8+ messages in thread
From: David CARLIER @ 2020-05-23  7:23 UTC (permalink / raw)
  To: qemu-devel, bauerchen

Hi this is my first contribution hope it s useful . Regards.
From ca7fcd85e0453f7173ce73732905463bc259ee32 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Sat, 23 May 2020 08:17:51 +0100
Subject: [PATCH] util/oslib: returns real thread identifier on FreeBSD and
 NetBSD

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 util/oslib-posix.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 062236a1ab..4d28dfd8f5 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
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-05 16:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23  7:23 [PATCH 1/1] util/oslib: Returns real thread identifier on FreeBSD and NetBSD David CARLIER
2020-05-26  5:40 ` Thomas Huth
2020-05-26  7:29   ` David CARLIER
2020-05-26 13:15     ` Kamil Rytarowski
2020-06-03  5:12     ` Philippe Mathieu-Daudé
2020-06-03  6:14       ` David CARLIER
2020-06-03 15:07         ` Li-Wen Hsu
2020-06-05 16:24           ` David CARLIER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).