aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog15
-rw-r--r--libjava/boehm.cc11
-rw-r--r--libjava/include/posix-threads.h14
-rw-r--r--libjava/include/win32-threads.h14
-rw-r--r--libjava/jvmti.cc52
-rw-r--r--libjava/posix-threads.cc16
-rw-r--r--libjava/win32-threads.cc16
7 files changed, 71 insertions, 67 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index de606684670..ec00d96dda2 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -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
diff --git a/libjava/boehm.cc b/libjava/boehm.cc
index 3b013dae3d6..6a5603d78a5 100644
--- a/libjava/boehm.cc
+++ b/libjava/boehm.cc
@@ -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
+}
diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h
index 8d69652e9e1..1f06fc3be18 100644
--- a/libjava/include/posix-threads.h
+++ b/libjava/include/posix-threads.h
@@ -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__ */
diff --git a/libjava/include/win32-threads.h b/libjava/include/win32-threads.h
index 27f7b65bf5a..4b306833156 100644
--- a/libjava/include/win32-threads.h
+++ b/libjava/include/win32-threads.h
@@ -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
diff --git a/libjava/jvmti.cc b/libjava/jvmti.cc
index 16a28f179f7..8c2b294bc38 100644
--- a/libjava/jvmti.cc
+++ b/libjava/jvmti.cc
@@ -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
diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc
index 7d35e518689..48501628ad0 100644
--- a/libjava/posix-threads.cc
+++ b/libjava/posix-threads.cc
@@ -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"
diff --git a/libjava/win32-threads.cc b/libjava/win32-threads.cc
index e715102f226..04d2d34ea92 100644
--- a/libjava/win32-threads.cc
+++ b/libjava/win32-threads.cc
@@ -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;
-}
-