[FreeBSD] add get thread id
authorFneufneu <fneufneu@xbmc.org>
Mon, 7 May 2012 09:58:34 +0000 (11:58 +0200)
committerFneufneu <fneufneu@xbmc.org>
Mon, 7 May 2012 09:58:34 +0000 (11:58 +0200)
xbmc/threads/platform/pthreads/ThreadImpl.cpp

index 30e9270..71b2099 100644 (file)
 #include <sys/syscall.h>
 #include <sys/resource.h>
 #include <string.h>
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#if __FreeBSD_version < 900031
+#include <sys/thr.h>
+#else
+#include <pthread_np.h>
+#endif
+#endif
 
 void CThread::Create(bool bAutoDelete, unsigned stacksize)
 {
@@ -59,7 +67,17 @@ void CThread::TermHandler()
 
 void CThread::SetThreadInfo()
 {
+#ifdef __FreeBSD__
+#if __FreeBSD_version < 900031
+  long lwpid;
+  thr_self(&lwpid);
+  m_ThreadOpaque.LwpId = lwpid;
+#else
+  m_ThreadOpaque.LwpId = pthread_getthreadid_np();
+#endif
+#else
   m_ThreadOpaque.LwpId = syscall(SYS_gettid);
+#endif
 
   // start thread with nice level of appication
   int appNice = getpriority(PRIO_PROCESS, getpid());