mirror of
https://github.com/openRuyi-Project/gcc.git
synced 2026-06-16 00:16:04 +00:00
re PR libgcj/13212 (JNI/CNI AttachCurrentThread does not register thread with garbage collector)
boehm-gc PR libgcj/13212: * configure.ac: Check for pthread_getattr_np(). Remove GC_PTHREAD_SYM_VERSION detection. * include/gc.h (GC_register_my_thread, GC_unregister_my_thread, GC_get_thread_stack_base): New declarations. * pthread_support.c (GC_register_my_thread, GC_unregister_my_thread, GC_get_thread_stack_base): New functions. (GC_delete_thread): Don't try to free the first_thread. * misc.c (GC_init_inner): Use GC_get_thread_stack_base() if possible. (pthread_create_, constr): Removed. (pthread_create): Don't rename. * include/gc_ext_config.h.in: Rebuilt. * include/gc_pthread_redirects.h (pthread_create): Define unconditionally. * include/gc_config.h.in: Rebuilt. * configure: Rebuilt. libjava * java/lang/natThread.cc (_Jv_AttachCurrentThread): Attach thread to GC. (_Jv_DetachCurrentThread): Detach thread from GC. * include/boehm-gc.h (_Jv_GCAttachThread, _Jv_GCDetachThread): Declare. * boehm.cc (_Jv_GCAttachThread): New function. (_Jv_GCDetachThread): Likewise. From-SVN: r116313
This commit is contained in:
committed by
Tom Tromey
parent
accabadcf3
commit
7ddf92a874
@@ -410,7 +410,8 @@ _Jv_SetCurrentJNIEnv (JNIEnv *env)
|
||||
}
|
||||
|
||||
// Attach the current native thread to an existing (but unstarted) Thread
|
||||
// object. Returns -1 on failure, 0 upon success.
|
||||
// object. Does not register thread with the garbage collector.
|
||||
// Returns -1 on failure, 0 upon success.
|
||||
jint
|
||||
_Jv_AttachCurrentThread(java::lang::Thread* thread)
|
||||
{
|
||||
@@ -427,6 +428,8 @@ _Jv_AttachCurrentThread(java::lang::Thread* thread)
|
||||
java::lang::Thread*
|
||||
_Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
|
||||
{
|
||||
// Register thread with GC before attempting any allocations.
|
||||
_Jv_GCAttachThread ();
|
||||
java::lang::Thread *thread = _Jv_ThreadCurrent ();
|
||||
if (thread != NULL)
|
||||
return thread;
|
||||
@@ -461,6 +464,7 @@ _Jv_DetachCurrentThread (void)
|
||||
return -1;
|
||||
|
||||
_Jv_ThreadUnRegister ();
|
||||
_Jv_GCDetachThread ();
|
||||
// Release the monitors.
|
||||
t->finish_ ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user