mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
Change OSThread to use mach thread_t Reviewed-by: phh, dcubed
This commit is contained in:
parent
b0b5725863
commit
d856a7745c
6 changed files with 61 additions and 24 deletions
|
@ -998,8 +998,13 @@ static void *java_start(Thread *thread) {
|
|||
}
|
||||
|
||||
#ifdef _ALLBSD_SOURCE
|
||||
#ifdef __APPLE__
|
||||
// thread_id is mach thread on macos
|
||||
osthread->set_thread_id(::mach_thread_self());
|
||||
#else
|
||||
// thread_id is pthread_id on BSD
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
#endif
|
||||
#else
|
||||
// thread_id is kernel thread id (similar to Solaris LWP id)
|
||||
osthread->set_thread_id(os::Bsd::gettid());
|
||||
|
@ -1190,7 +1195,11 @@ bool os::create_attached_thread(JavaThread* thread) {
|
|||
|
||||
// Store pthread info into the OSThread
|
||||
#ifdef _ALLBSD_SOURCE
|
||||
#ifdef __APPLE__
|
||||
osthread->set_thread_id(::mach_thread_self());
|
||||
#else
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
#endif
|
||||
#else
|
||||
osthread->set_thread_id(os::Bsd::gettid());
|
||||
#endif
|
||||
|
@ -1807,7 +1816,13 @@ size_t os::lasterror(char *buf, size_t len) {
|
|||
return n;
|
||||
}
|
||||
|
||||
intx os::current_thread_id() { return (intx)pthread_self(); }
|
||||
intx os::current_thread_id() {
|
||||
#ifdef __APPLE__
|
||||
return (intx)::mach_thread_self();
|
||||
#else
|
||||
return (intx)::pthread_self();
|
||||
#endif
|
||||
}
|
||||
int os::current_process_id() {
|
||||
|
||||
// Under the old bsd thread library, bsd gives each thread
|
||||
|
@ -5152,9 +5167,9 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
|||
struct thread_basic_info tinfo;
|
||||
mach_msg_type_number_t tcount = THREAD_INFO_MAX;
|
||||
kern_return_t kr;
|
||||
mach_port_t mach_thread;
|
||||
thread_t mach_thread;
|
||||
|
||||
mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
|
||||
mach_thread = thread->osthread()->thread_id();
|
||||
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
|
||||
if (kr != KERN_SUCCESS)
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue