diff options
author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-12-30 12:18:39 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-12-30 12:18:39 +0000 |
commit | e301621d196adef738c6cb5f5f4ee8a17a4ab0c0 (patch) | |
tree | 45acacc07816160e269cf47dd6cdeccef9036f29 /libjava/java | |
parent | 4c2f5b4fd3e2b691c7a14a5860dae341d33455b3 (diff) | |
download | gcc-e301621d196adef738c6cb5f5f4ee8a17a4ab0c0.zip gcc-e301621d196adef738c6cb5f5f4ee8a17a4ab0c0.tar.gz gcc-e301621d196adef738c6cb5f5f4ee8a17a4ab0c0.tar.bz2 |
For boehm-gc:
* configure.in: Rename THREADLIB to THREADLIBS.
* Makefile.am (LINK): Add $(THREADLIBS) to libtool command line. This
ensures that we link the correct version of the linuxthreads semaphore
functions.
* Makefile.in: Rebuilt.
* configure: Rebuilt.
* linux_thread.c (GC_thr_init, GC_suspend_handler): Add SIGABRT to the
list of signals which are not blocked during suspend in the NO_SIGNALS
case.
For libjava:
* Makefile.am (libgcj_la_LIBADD): Add $(THREADLIBS). This ensures that
the correct versions of various linuxthreads functions get linked.
* Makefile.in: Rebuilt.
* java/lang/natThread.cc (finalize_native): New static function. Call
_Jv_ThreadDestroyData.
(initialize_native): Register finalizer for "data".
* include/posix-threads.h (_Jv_ThreadInitData): New simpler prototype.
(_Jv_ThreadDestroyData): New prototype.
* include/win32-threads.h: Ditto.
* include/no-threads.h: Ditto.
* posix-threads.cc (_Jv_ThreadInitData): Implement new prototype.
(_Jv_ThreadDestroyData): New function. Free native thread "data" and
move mutex and condition variable destroy code from:
(really_start): ...here.
(_Jv_ThreadStart): Set PTHREAD_CREATE_DETACHED.
* win32-threads.cc (_Jv_ThreadInitData): Implement new prototype.
(_Jv_ThreadDestroyData): Implemented.
* nogc.cc (_Jv_AllocObject): Use "void *" not "ptr_t".
(_Jv_AllocArray): Ditto.
From-SVN: r38557
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/natThread.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc index 2b9afb5..796713a 100644 --- a/libjava/java/lang/natThread.cc +++ b/libjava/java/lang/natThread.cc @@ -50,26 +50,39 @@ struct natThread JNIEnv *jni_env; }; +static void finalize_native (jobject ptr); + // This is called from the constructor to initialize the native side // of the Thread. void java::lang::Thread::initialize_native (void) { - // FIXME: this must interact with the GC in some logical way. At - // the very least we must register a finalizer to clean up. This - // isn't easy to do. If the Thread object resurrects itself in its - // own finalizer then we will need to reinitialize this structure at - // any "interesting" point. natThread *nt = (natThread *) _Jv_AllocBytes (sizeof (natThread)); + + // The native thread data is kept in a Object field, not a rawdata, so that + // the GC allocator can be used and a finalizer run after the thread becomes + // unreachable. Note that this relies on the GC's ability to finalize + // non-Java objects. FIXME? data = reinterpret_cast<jobject> (nt); + + // Register a finalizer to clean up the native thread resources. + _Jv_RegisterFinalizer (data, finalize_native); + _Jv_MutexInit (&nt->join_mutex); _Jv_CondInit (&nt->join_cond); - _Jv_ThreadInitData (&nt->thread, this); + nt->thread = _Jv_ThreadInitData (this); // FIXME: if JNI_ENV is set we will want to free it. It is // malloc()d. nt->jni_env = NULL; } +static void +finalize_native (jobject ptr) +{ + natThread *nt = (natThread *) ptr; + _Jv_ThreadDestroyData (nt->thread); +} + jint java::lang::Thread::countStackFrames (void) { |