From 4402e89a78c0c7b709be91b4033e1dab1c5ecee1 Mon Sep 17 00:00:00 2001 From: kseitz Date: Fri, 1 Sep 2006 17:58:22 +0000 Subject: [PATCH] * jvmti.cc (THREAD_DEFAULT_TO_CURRENT): Encapsulate in do..while loop. (THREAD_CHECK_VALID): Likewise. (THREAD_CHECK_IS_ALIVE): Likewise. (NULL_CHECK): Likewise. (ILLEGAL_ARGUMENT): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116636 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 8 ++++++++ libjava/jvmti.cc | 48 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index b880c56..b19398e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,13 @@ 2006-09-01 Keith Seitz + * jvmti.cc (THREAD_DEFAULT_TO_CURRENT): Encapsulate in do..while loop. + (THREAD_CHECK_VALID): Likewise. + (THREAD_CHECK_IS_ALIVE): Likewise. + (NULL_CHECK): Likewise. + (ILLEGAL_ARGUMENT): Likewise. + +2006-09-01 Keith Seitz + * include/jvm.h (_Jv_JVMTI_Init): Declare. * jvmti.cc (_Jv_JVMTI_Init): New function. * prims.cc (_Jv_CreateJavaVM): Initialize JVMTI. diff --git a/libjava/jvmti.cc b/libjava/jvmti.cc index d2d8f52..37daa36 100644 --- a/libjava/jvmti.cc +++ b/libjava/jvmti.cc @@ -56,25 +56,49 @@ static java::lang::Object *_envListLock = NULL; // Some commonly-used checks -#define THREAD_DEFAULT_TO_CURRENT(jthread) \ - if (jthread == NULL) jthread = java::lang::Thread::currentThread (); +#define THREAD_DEFAULT_TO_CURRENT(jthread) \ + do \ + { \ + if (jthread == NULL) \ + jthread = java::lang::Thread::currentThread (); \ + } \ + while (0) #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; + do \ + { \ + if (!java::lang::Thread::class$.isAssignableFrom (&(jthread->class$))) \ + return JVMTI_ERROR_INVALID_THREAD; \ + } \ + while (0) + +#define THREAD_CHECK_IS_ALIVE(thread) \ + do \ + { \ + if (!thread->isAlive ()) \ + return JVMTI_ERROR_THREAD_NOT_ALIVE; \ + } \ + while (0) // FIXME: if current phase is not set in Phases, // return JVMTI_ERROR_WRONG_PHASE #define REQUIRE_PHASE(Env, Phases) -#define NULL_CHECK(Ptr) \ - if (Ptr == NULL) return JVMTI_ERROR_NULL_POINTER; - -#define ILLEGAL_ARGUMENT(Cond) \ - if ((Cond)) return JVMTI_ERROR_ILLEGAL_ARGUMENT +#define NULL_CHECK(Ptr) \ + do \ + { \ + if (Ptr == NULL) \ + return JVMTI_ERROR_NULL_POINTER; \ + } \ + while (0) + +#define ILLEGAL_ARGUMENT(Cond) \ + do \ + { \ + if ((Cond)) \ + return JVMTI_ERROR_ILLEGAL_ARGUMENT; \ + } \ + while (0) static jvmtiError JNICALL _Jv_JVMTI_SuspendThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread) -- 2.7.4