]> git.sesse.net Git - vlc/commitdiff
Linux: vlc_threadid() returns TID instead of kludging pthread_self()
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 31 Jan 2009 16:45:20 +0000 (18:45 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 31 Jan 2009 16:45:20 +0000 (18:45 +0200)
src/misc/threads.c

index 1be52c85a2b503609de39d0935715dd0e6a36777..f5b0d7eb456799347313ca724c526878d7467c3d 100644 (file)
@@ -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 ();