[vlc-devel] commit: Linux: vlc_threadid() returns TID instead of kludging pthread_self( ) ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 31 17:49:29 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jan 31 18:45:20 2009 +0200| [bb677d45484e66e37778c1d184564924c195addc] | committer: Rémi Denis-Courmont 

Linux: vlc_threadid() returns TID instead of kludging pthread_self()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bb677d45484e66e37778c1d184564924c195addc
---

 src/misc/threads.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index 1be52c8..f5b0d7e 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -41,6 +41,9 @@
 
 #if defined( LIBVLC_USE_PTHREAD )
 # include <sched.h>
+# ifdef __linux__
+#  include <sys/syscall.h> /* SYS_gettid */
+# endif
 #else
 static vlc_threadvar_t cancel_key;
 #endif
@@ -68,11 +71,16 @@ void vlc_trace (const char *fn, const char *file, unsigned line)
 
 static inline unsigned long vlc_threadid (void)
 {
-#if defined(LIBVLC_USE_PTHREAD)
+#if defined (LIBVLC_USE_PTHREAD)
+# if defined (__linux__)
+     return syscall (SYS_gettid);
+
+# else
      union { pthread_t th; unsigned long int i; } v = { };
      v.th = pthread_self ();
      return v.i;
 
+#endif
 #elif defined (WIN32)
      return GetCurrentThreadId ();
 




More information about the vlc-devel mailing list