mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 22:04:51 +02:00
8022616: u4 should not be used as a type for thread_id
Usage of u4 as a type for thread_id cause a compilation error on platform, where thread_id is a pointer Reviewed-by: sla, sspitsyn, minqi
This commit is contained in:
parent
ae3d003298
commit
13b13b1aed
3 changed files with 33 additions and 18 deletions
|
@ -691,18 +691,12 @@ static void *java_start(Thread *thread) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// thread_id is mach thread on macos, which pthreads graciously caches and provides for us
|
||||
mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
|
||||
guarantee(thread_id != 0, "thread id missing from pthreads");
|
||||
osthread->set_thread_id(thread_id);
|
||||
osthread->set_thread_id(os::Bsd::gettid());
|
||||
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
|
||||
#ifdef __APPLE__
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id());
|
||||
guarantee(unique_thread_id != 0, "unique thread id was not found");
|
||||
osthread->set_unique_thread_id(unique_thread_id);
|
||||
#else
|
||||
// thread_id is pthread_id on BSD
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
#endif
|
||||
// initialize signal mask for this thread
|
||||
os::Bsd::hotspot_sigmask(thread);
|
||||
|
@ -859,18 +853,13 @@ bool os::create_attached_thread(JavaThread* thread) {
|
|||
return false;
|
||||
}
|
||||
|
||||
osthread->set_thread_id(os::Bsd::gettid());
|
||||
|
||||
// Store pthread info into the OSThread
|
||||
#ifdef __APPLE__
|
||||
// thread_id is mach thread on macos, which pthreads graciously caches and provides for us
|
||||
mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
|
||||
guarantee(thread_id != 0, "just checking");
|
||||
osthread->set_thread_id(thread_id);
|
||||
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id());
|
||||
guarantee(unique_thread_id != 0, "just checking");
|
||||
osthread->set_unique_thread_id(unique_thread_id);
|
||||
#else
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
#endif
|
||||
osthread->set_pthread_id(::pthread_self());
|
||||
|
||||
|
@ -1137,6 +1126,30 @@ size_t os::lasterror(char *buf, size_t len) {
|
|||
return n;
|
||||
}
|
||||
|
||||
// Information of current thread in variety of formats
|
||||
pid_t os::Bsd::gettid() {
|
||||
int retval = -1;
|
||||
|
||||
#ifdef __APPLE__ //XNU kernel
|
||||
// despite the fact mach port is actually not a thread id use it
|
||||
// instead of syscall(SYS_thread_selfid) as it certainly fits to u4
|
||||
retval = ::pthread_mach_thread_np(::pthread_self());
|
||||
guarantee(retval != 0, "just checking");
|
||||
return retval;
|
||||
|
||||
#elif __FreeBSD__
|
||||
retval = syscall(SYS_thr_self);
|
||||
#elif __OpenBSD__
|
||||
retval = syscall(SYS_getthrid);
|
||||
#elif __NetBSD__
|
||||
retval = (pid_t) syscall(SYS__lwp_self);
|
||||
#endif
|
||||
|
||||
if (retval == -1) {
|
||||
return getpid();
|
||||
}
|
||||
}
|
||||
|
||||
intx os::current_thread_id() {
|
||||
#ifdef __APPLE__
|
||||
return (intx)::pthread_mach_thread_np(::pthread_self());
|
||||
|
@ -1144,6 +1157,7 @@ intx os::current_thread_id() {
|
|||
return (intx)::pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
int os::current_process_id() {
|
||||
|
||||
// Under the old bsd thread library, bsd gives each thread
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue