Add thread id retrieval for FreeBSD/DragonFly, OpenBSD and NetBSD
This commit is contained in:
@@ -144,6 +144,12 @@ int iscsi_mt_sem_wait(libiscsi_sem_t* sem)
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#if defined(__NetBSD__)
|
||||
#include <lwp.h>
|
||||
#endif
|
||||
|
||||
iscsi_tid_t iscsi_mt_get_tid(void)
|
||||
{
|
||||
@@ -151,6 +157,15 @@ iscsi_tid_t iscsi_mt_get_tid(void)
|
||||
iscsi_tid_t tid;
|
||||
pthread_threadid_np(NULL, &tid);
|
||||
return tid;
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
int tid = pthread_getthreadid_np();
|
||||
return tid;
|
||||
#elif defined(__OpenBSD__)
|
||||
pid_t tid = getthrid();
|
||||
return tid;
|
||||
#elif defined(__NetBSD__)
|
||||
lwpid_t tid = _lwp_self();
|
||||
return tid;
|
||||
#elif defined(SYS_gettid)
|
||||
pid_t tid = syscall(SYS_gettid);
|
||||
return tid;
|
||||
|
||||
Reference in New Issue
Block a user