Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
6082:4b37c0dafe3a | 6093:960a442eae91 |
---|---|
40 private: | 40 private: |
41 | 41 |
42 #ifdef _ALLBSD_SOURCE | 42 #ifdef _ALLBSD_SOURCE |
43 | 43 |
44 #ifdef __APPLE__ | 44 #ifdef __APPLE__ |
45 thread_t _thread_id; | 45 typedef thread_t thread_id_t; |
46 #else | 46 #else |
47 pthread_t _thread_id; | 47 typedef pthread_t thread_id_t; |
48 #endif | |
49 | |
50 #else | |
51 typedef pid_t thread_id_t; | |
48 #endif | 52 #endif |
49 | 53 |
50 // _pthread_id is the pthread id, which is used by library calls | 54 // _pthread_id is the pthread id, which is used by library calls |
51 // (e.g. pthread_kill). | 55 // (e.g. pthread_kill). |
52 pthread_t _pthread_id; | 56 pthread_t _pthread_id; |
53 | |
54 #else | |
55 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each | |
56 // thread has a unique thread_id (BsdThreads or NPTL). It can be used | |
57 // to access /proc. | |
58 pid_t _thread_id; | |
59 | |
60 // _pthread_id is the pthread id, which is used by library calls | |
61 // (e.g. pthread_kill). | |
62 pthread_t _pthread_id; | |
63 #endif | |
64 | 57 |
65 sigset_t _caller_sigmask; // Caller's signal mask | 58 sigset_t _caller_sigmask; // Caller's signal mask |
66 | 59 |
67 public: | 60 public: |
68 | 61 |
69 // Methods to save/restore caller's signal mask | 62 // Methods to save/restore caller's signal mask |
70 sigset_t caller_sigmask() const { return _caller_sigmask; } | 63 sigset_t caller_sigmask() const { return _caller_sigmask; } |
71 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } | 64 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } |
72 | 65 |
73 #ifdef _ALLBSD_SOURCE | |
74 #ifdef __APPLE__ | |
75 static size_t thread_id_size() { return sizeof(thread_t); } | |
76 thread_t thread_id() const { | |
77 return _thread_id; | |
78 } | |
79 #else | |
80 static size_t thread_id_size() { return sizeof(pthread_t); } | |
81 pthread_t thread_id() const { | |
82 return _thread_id; | |
83 } | |
84 #endif | |
85 #else | |
86 static size_t thread_id_size() { return sizeof(pid_t); } | |
87 pid_t thread_id() const { | |
88 return _thread_id; | |
89 } | |
90 #endif | |
91 #ifndef PRODUCT | 66 #ifndef PRODUCT |
92 // Used for debugging, return a unique integer for each thread. | 67 // Used for debugging, return a unique integer for each thread. |
93 intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } | 68 intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } |
94 #endif | 69 #endif |
70 | |
95 #ifdef ASSERT | 71 #ifdef ASSERT |
96 // We expect no reposition failures so kill vm if we get one. | 72 // We expect no reposition failures so kill vm if we get one. |
97 // | 73 // |
98 bool valid_reposition_failure() { | 74 bool valid_reposition_failure() { |
99 return false; | 75 return false; |
100 } | 76 } |
101 #endif // ASSERT | 77 #endif // ASSERT |
102 #ifdef _ALLBSD_SOURCE | 78 |
103 #ifdef __APPLE__ | |
104 void set_thread_id(thread_t id) { | |
105 _thread_id = id; | |
106 } | |
107 #else | |
108 void set_thread_id(pthread_t id) { | |
109 _thread_id = id; | |
110 } | |
111 #endif | |
112 #else | |
113 void set_thread_id(pid_t id) { | |
114 _thread_id = id; | |
115 } | |
116 #endif | |
117 pthread_t pthread_id() const { | 79 pthread_t pthread_id() const { |
118 return _pthread_id; | 80 return _pthread_id; |
119 } | 81 } |
120 void set_pthread_id(pthread_t tid) { | 82 void set_pthread_id(pthread_t tid) { |
121 _pthread_id = tid; | 83 _pthread_id = tid; |