* src/util/threads.h (virThreadID): New prototype.
* src/util/threads-pthread.c (virThreadID): New function.
* src/util/threads-win32.c (virThreadID): Likewise.
* src/libvirt_private.syms (threads.h): Export it.
* daemon/event.c (virEventInterruptLocked): Use it to avoid
warning on BSD systems.
if (!eventLoop.running ||
virThreadIsSelf(&eventLoop.leader)) {
- VIR_DEBUG("Skip interrupt, %d %d", eventLoop.running, (int)eventLoop.leader.thread);
+ VIR_DEBUG("Skip interrupt, %d %d", eventLoop.running,
+ virThreadID(&eventLoop.leader));
return 0;
}
virMutexLock;
virMutexUnlock;
virThreadCreate;
+virThreadID;
virThreadIsSelf;
virThreadJoin;
virThreadSelf;
#include <config.h>
#include <unistd.h>
+#include <inttypes.h>
#if HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
#endif
return pthread_equal(pthread_self(), thread->thread) ? true : false;
}
+/* For debugging use only; this result is not guaranteed unique on BSD
+ * systems when pthread_t is a 64-bit pointer. */
int virThreadSelfID(void)
{
#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid)
#endif
}
+/* For debugging use only; this result is not guaranteed unique on BSD
+ * systems when pthread_t is a 64-bit pointer, nor does it match the
+ * thread id of virThreadSelfID on Linux. */
+int virThreadID(virThreadPtr thread)
+{
+ return (int)(uintptr_t)thread->thread;
+}
+
void virThreadJoin(virThreadPtr thread)
{
pthread_join(thread->thread, NULL);
return self.thread == thread->thread ? true : false;
}
+/* For debugging use only; see comments in threads-pthread.c. */
int virThreadSelfID(void)
{
return (int)GetCurrentThreadId();
}
+/* For debugging use only; see comments in threads-pthread.c. */
+int virThreadID(virThreadPtr thread)
+{
+ return (int)thread->thread;
+}
+
void virThreadJoin(virThreadPtr thread)
{
void virThreadSelf(virThreadPtr thread);
bool virThreadIsSelf(virThreadPtr thread);
void virThreadJoin(virThreadPtr thread);
+
+/* These next two functions are for debugging only, since they are not
+ * guaranteed to give unique values for distinct threads on all
+ * architectures, nor are the two functions guaranteed to give the same
+ * value for the same thread. */
int virThreadSelfID(void);
+int virThreadID(virThreadPtr thread);
int virMutexInit(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
int virMutexInitRecursive(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;