[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD
From: |
Paolo Bonzini |
Subject: |
[PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD and NetBSD |
Date: |
Thu, 11 Jun 2020 15:44:10 -0400 |
From: David Carlier <devnexen@gmail.com>
getpid is good enough in a mono thread context, however thr_self/_lwp_self
reflects the real current thread identifier from a given process.
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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..916f1be224 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
- [PULL 060/115] target/i386: fix floating-point load-constant rounding, (continued)
- [PULL 060/115] target/i386: fix floating-point load-constant rounding, Paolo Bonzini, 2020/06/11
- [PULL 019/115] vmbus: vmbus implementation, Paolo Bonzini, 2020/06/11
- [PULL 022/115] vmbus: add infrastructure to save/load vmbus requests, Paolo Bonzini, 2020/06/11
- [PULL 057/115] exec: Propagate cpu_memory_rw_debug() error, Paolo Bonzini, 2020/06/11
- [PULL 031/115] hw/i386/vmport: Introduce vmport.h, Paolo Bonzini, 2020/06/11
- [PULL 047/115] i386/kvm: fix a use-after-free when vcpu plug/unplug, Paolo Bonzini, 2020/06/11
- [PULL 040/115] qom: remove index from object_resolve_abs_path(), Paolo Bonzini, 2020/06/11
- [PULL 070/115] chardev/char-socket: Properly make qio connections non blocking, Paolo Bonzini, 2020/06/11
- [PULL 072/115] hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands, Paolo Bonzini, 2020/06/11
- [PULL 068/115] KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd, Paolo Bonzini, 2020/06/11
- [PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD and NetBSD,
Paolo Bonzini <=
- [PULL 079/115] configure: Do not ignore malloc value, Paolo Bonzini, 2020/06/11
- [PULL 075/115] target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES, Paolo Bonzini, 2020/06/11
- [PULL 074/115] i386: Remove unused define's from hax and hvf, Paolo Bonzini, 2020/06/11
- [PULL 077/115] memory: Make 'info mtree' not display disabled regions by default, Paolo Bonzini, 2020/06/11
- [PULL 078/115] qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute, Paolo Bonzini, 2020/06/11
- [PULL 071/115] tests: machine-none-test: Enable MicroBlaze testing, Paolo Bonzini, 2020/06/11
- [PULL 050/115] megasas: use unsigned type for positive numeric fields, Paolo Bonzini, 2020/06/11
- [PULL 084/115] sysemu/tcg: Only declare tcg_allowed when TCG is available, Paolo Bonzini, 2020/06/11
- [PULL 082/115] target/i386: correct fix for pcmpxstrx substring search, Paolo Bonzini, 2020/06/11
- [PULL 081/115] target/i386: fix IEEE x87 floating-point exception raising, Paolo Bonzini, 2020/06/11