mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
7161732: Improve handling of thread_id in OSThread
Reviewed-by: dholmes, kamg
This commit is contained in:
parent
5ea3d5b1ea
commit
be3945d9ff
11 changed files with 44 additions and 99 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue