diff src/os/bsd/vm/osThread_bsd.hpp @ 6093:960a442eae91

7161732: Improve handling of thread_id in OSThread Reviewed-by: dholmes, kamg
author rbackman
date Tue, 22 May 2012 10:11:53 +0200
parents 0105f367a14c
children 0af5da0c9d9d
line wrap: on
line diff
--- a/src/os/bsd/vm/osThread_bsd.hpp	Fri May 18 09:15:15 2012 -0700
+++ b/src/os/bsd/vm/osThread_bsd.hpp	Tue May 22 10:11:53 2012 +0200
@@ -42,26 +42,19 @@
 #ifdef _ALLBSD_SOURCE
 
 #ifdef __APPLE__
-  thread_t  _thread_id;
+  typedef thread_t thread_id_t;
 #else
-  pthread_t _thread_id;
+  typedef pthread_t thread_id_t;
+#endif
+
+#else
+  typedef pid_t thread_id_t;
 #endif
 
   // _pthread_id is the pthread id, which is used by library calls
   // (e.g. pthread_kill).
   pthread_t _pthread_id;
 
-#else
-  // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
-  // thread has a unique thread_id (BsdThreads or NPTL). It can be used
-  // to access /proc.
-  pid_t     _thread_id;
-
-  // _pthread_id is the pthread id, which is used by library calls
-  // (e.g. pthread_kill).
-  pthread_t _pthread_id;
-#endif
-
   sigset_t _caller_sigmask; // Caller's signal mask
 
  public:
@@ -70,28 +63,11 @@
   sigset_t  caller_sigmask() const       { return _caller_sigmask; }
   void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
 
-#ifdef _ALLBSD_SOURCE
-#ifdef __APPLE__
-  static size_t thread_id_size()         { return sizeof(thread_t); }
-  thread_t thread_id() const {
-    return _thread_id;
-  }
-#else
-  static size_t thread_id_size()         { return sizeof(pthread_t); }
-  pthread_t thread_id() const {
-    return _thread_id;
-  }
-#endif
-#else
-  static size_t thread_id_size()         { return sizeof(pid_t); }
-  pid_t thread_id() const {
-    return _thread_id;
-  }
-#endif
 #ifndef PRODUCT
   // Used for debugging, return a unique integer for each thread.
   intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
 #endif
+
 #ifdef ASSERT
   // We expect no reposition failures so kill vm if we get one.
   //
@@ -99,21 +75,7 @@
     return false;
   }
 #endif // ASSERT
-#ifdef _ALLBSD_SOURCE
-#ifdef __APPLE__
-  void set_thread_id(thread_t id) {
-    _thread_id = id;
-  }
-#else
-  void set_thread_id(pthread_t id) {
-    _thread_id = id;
-  }
-#endif
-#else
-  void set_thread_id(pid_t id) {
-    _thread_id = id;
-  }
-#endif
+
   pthread_t pthread_id() const {
     return _pthread_id;
   }