boehm.cc (_Jv_SuspendThread): Don't ifdef the function declaration, just the contents.
authorKeith Seitz <keiths@redhat.com>
Fri, 21 Jul 2006 23:45:03 +0000 (23:45 +0000)
committerKeith Seitz <kseitz@gcc.gnu.org>
Fri, 21 Jul 2006 23:45:03 +0000 (23:45 +0000)
        * boehm.cc (_Jv_SuspendThread): Don't ifdef the function declaration,
        just the contents.
        (_Jv_ResumeThread): Likewise.
        * posix-threads.cc: Revert 2006-06-19 _Jv_ThreadDebugSuspend,
        _Jv_ThreadDebugResume, _Jv_ThreadDebugSuspendCount patch. Moving
        to JVMTI instead.
        * include/posix-threads.h: Likewise.
        * win32-threads.cc: Likewise.
        * include/win32-threads.h: Likewise.
        * jvmti.cc (_Jv_JVMTI_SuspentThread): New function.
        (_Jv_JVMTI_ResumeThread): New function.
        (_Jv_JVMTI_Interface): Define SuspendThread and ResumeThread.

From-SVN: r115655

libjava/ChangeLog
libjava/boehm.cc
libjava/include/posix-threads.h
libjava/include/win32-threads.h
libjava/jvmti.cc
libjava/posix-threads.cc
libjava/win32-threads.cc

index de606684670325d6385f29abc5ad5abcae7d7227..ec00d96dda258fd55818858def669c2fa0bac242 100644 (file)
@@ -1,3 +1,18 @@
+2006-07-21  Keith Seitz  <keiths@redhat.com>
+
+       * boehm.cc (_Jv_SuspendThread): Don't ifdef the function declaration,
+       just the contents.
+       (_Jv_ResumeThread): Likewise.
+       * posix-threads.cc: Revert 2006-06-19 _Jv_ThreadDebugSuspend,
+       _Jv_ThreadDebugResume, _Jv_ThreadDebugSuspendCount patch. Moving
+       to JVMTI instead.
+       * include/posix-threads.h: Likewise.
+       * win32-threads.cc: Likewise.
+       * include/win32-threads.h: Likewise.
+       * jvmti.cc (_Jv_JVMTI_SuspentThread): New function.
+       (_Jv_JVMTI_ResumeThread): New function.
+       (_Jv_JVMTI_Interface): Define SuspendThread and ResumeThread.
+
 2006-07-21  David Daney  <ddaney@avtrex.com>
 
        PR libgcj/28426
index 3b013dae3d6bfa8ae3d1b4111c64e2874c7ddc87..6a5603d78a5fde9aaa500554239d537546d3e082 100644 (file)
@@ -678,19 +678,20 @@ _Jv_RegisterLibForGc (const void *p __attribute__ ((__unused__)))
 #endif
 }
 
-#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
-  && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
-
 void
 _Jv_SuspendThread (_Jv_Thread_t *thread)
 {
+#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
+     && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
   GC_suspend_thread (_Jv_GetPlatformThreadID (thread));
+#endif
 }
 
 void
 _Jv_ResumeThread (_Jv_Thread_t *thread)
 {
+#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
+     && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
   GC_resume_thread (_Jv_GetPlatformThreadID (thread));
-}
-
 #endif
+}
index 8d69652e9e147c8c2e6e16f4373863dcd7a09f08..1f06fc3be1894e35b18cd75f8a86ec42efcc8a8a 100644 (file)
@@ -374,18 +374,4 @@ void _Jv_ThreadWait (void);
 
 void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
 
-// Increases a thread's suspend count. If the thread's previous
-// suspend count was zero, i.e., it is not suspended, this function
-// will suspend the thread. This function may be used to suspend
-// any thread from any other thread (or suspend itself).
-void _Jv_ThreadDebugSuspend (_Jv_Thread_t *data);
-
-// Decreases a thread's suspend count. If the thread's new thread
-// count is zero, the thread is resumed. This function may be used
-// by any thread to resume any other thread.
-void _Jv_ThreadDebugResume (_Jv_Thread_t *data);
-
-// Get the suspend count for a thread
-jint _Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data);
-
 #endif /* __JV_POSIX_THREADS__ */
index 27f7b65bf5aefcfb2beb8ebc8b8b07df813f4cdb..4b3068331565ad12800ec9c9f409b39924a2ded5 100644 (file)
@@ -193,20 +193,6 @@ void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
 // See java/lang/natWin32Process.cc (waitFor) for an example.
 HANDLE _Jv_Win32GetInterruptEvent (void);
 
-// Increases a thread's suspend count. If the thread's previous
-// suspend count was zero, i.e., it is not suspended, this function
-// will suspend the thread. This function may be used to suspend
-// any thread from any other thread (or suspend itself).
-void _Jv_ThreadDebugSuspend (_Jv_Thread_t *data);
-
-// Decreases a thread's suspend count. If the thread's new thread
-// count is zero, the thread is resumed. This function may be used
-// by any thread to resume any other thread.
-void _Jv_ThreadDebugResume (_Jv_Thread_t *data);
-
-// Get the suspend count for a thread
-jint _Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data);
-
 // Remove defines from <windows.h> that conflict with various things in libgcj code
 
 #undef TRUE
index 16a28f179f771ddd3282b86a471aaf43d0790879..8c2b294bc3819493e02f276f9d42ed332aa9bfc7 100644 (file)
@@ -11,8 +11,56 @@ details.  */
 #include <config.h>
 
 #include <jvm.h>
+#include <java-threads.h>
+#include <java-gc.h>
 #include <jvmti.h>
 
+#include <java/lang/Thread.h>
+
+// Some commonly-used checks
+
+#define THREAD_DEFAULT_TO_CURRENT(jthread)                             \
+  if (jthread == NULL) jthread = java::lang::Thread::currentThread ();
+
+#define THREAD_CHECK_VALID(jthread)                                    \
+  if (!java::lang::Thread::class$.isAssignableFrom (&(jthread->class$))) \
+    return JVMTI_ERROR_INVALID_THREAD;
+
+#define THREAD_CHECK_IS_ALIVE(thread)                          \
+  if (!thread->isAlive ()) return JVMTI_ERROR_THREAD_NOT_ALIVE;
+
+static jvmtiError
+_Jv_JVMTI_SuspendThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread)
+{
+  using namespace java::lang;
+
+  THREAD_DEFAULT_TO_CURRENT (thread);
+  THREAD_CHECK_VALID (thread);
+
+  Thread *t = reinterpret_cast<Thread *> (thread);
+  THREAD_CHECK_IS_ALIVE (t);
+
+  _Jv_Thread_t *data = _Jv_ThreadGetData (t);
+  _Jv_SuspendThread (data);
+  return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError
+_Jv_JVMTI_ResumeThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread)
+{
+  using namespace java::lang;
+
+  THREAD_DEFAULT_TO_CURRENT (thread);
+  THREAD_CHECK_VALID (thread);
+
+  Thread *t = reinterpret_cast<Thread *> (thread);
+  THREAD_CHECK_IS_ALIVE (t);
+
+  _Jv_Thread_t *data = _Jv_ThreadGetData (t);
+  _Jv_ResumeThread (data);
+  return JVMTI_ERROR_NONE;
+}
+
 #define RESERVED NULL
 #define UNIMPLEMENTED NULL
 
@@ -30,8 +78,8 @@ struct _Jv_jvmtiEnv _Jv_JVMTI_Interface =
   UNIMPLEMENTED,               // SetEventNotification
   RESERVED,                    // reserved3
   UNIMPLEMENTED,               // GetAllThreads
-  UNIMPLEMENTED,               // SuspendThread
-  UNIMPLEMENTED,               // ResumeThread
+  _Jv_JVMTI_SuspendThread,     // SuspendThread
+  _Jv_JVMTI_ResumeThread,      // ResumeThread
   UNIMPLEMENTED,               // StopThread
   UNIMPLEMENTED,               // InterruptThread
   UNIMPLEMENTED,               // GetThreadInfo
index 7d35e518689cb5b55a512f133c59d294e6b9fc62..48501628ad01ca397e5408d036e5c00ee788c651 100644 (file)
@@ -505,22 +505,6 @@ _Jv_ThreadWait (void)
   pthread_mutex_unlock (&daemon_mutex);
 }
 
-void
-_Jv_ThreadDebugSuspend (_Jv_Thread_t *data)
-{
-}
-
-void
-_Jv_ThreadDebugResume (_Jv_Thread_t *data)
-{
-}
-
-jint
-_Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data)
-{
-  return -1;
-}
-
 #if defined(SLOW_PTHREAD_SELF)
 
 #include "sysdep/locks.h"
index e715102f2261a34798edb1bf64719e676369d6b6..04d2d34ea92bc58e162a870ddc2a015ab7ec4cc1 100644 (file)
@@ -420,19 +420,3 @@ _Jv_ThreadInterrupt (_Jv_Thread_t *data)
   LeaveCriticalSection (&data->interrupt_mutex);
 }
 
-void
-_Jv_ThreadDebugSuspend (_Jv_Thread_t *data)
-{
-}
-
-void
-_Jv_ThreadDebugResume (_Jv_Thread_t *data)
-{
-}
-
-jint
-_Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data)
-{
-  return -1;
-}
-