Mercurial > hg > graal-jvmci-8
diff src/os/bsd/vm/os_bsd.cpp @ 4961:0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
Summary: Change OSThread to use mach thread_t
Reviewed-by: phh, dcubed
author | sla |
---|---|
date | Sun, 19 Feb 2012 13:11:39 +0100 |
parents | 86ce3208eb18 |
children | 897b7d18bebc 4e0a9aaec0e9 |
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp Fri Feb 17 15:55:27 2012 -0800 +++ b/src/os/bsd/vm/os_bsd.cpp Sun Feb 19 13:11:39 2012 +0100 @@ -998,8 +998,13 @@ } #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 @@ // 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 @@ 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 @@ struct thread_basic_info tinfo; mach_msg_type_number_t tcount = THREAD_INFO_MAX; kern_return_t kr; - mach_port_t mach_thread; - - mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id()); + thread_t mach_thread; + + 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;