1 /* src/native/vm/gnu/java_lang_VMThread.c
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 #include "native/jni.h"
33 #include "native/llni.h"
34 #include "native/native.h"
36 #include "native/include/java_lang_ThreadGroup.h"
37 #include "native/include/java_lang_Object.h" /* java_lang_Thread.h */
38 #include "native/include/java_lang_Throwable.h" /* java_lang_Thread.h */
39 #include "native/include/java_lang_VMThread.h"
40 #include "native/include/java_lang_Thread.h"
42 #include "native/include/java_lang_VMThread.h"
44 #include "native/vm/java_lang_Thread.h"
46 #include "threads/threads-common.h"
48 #include "vmcore/utf8.h"
51 /* native methods implemented by this file ************************************/
53 static JNINativeMethod methods[] = {
54 { "countStackFrames", "()I", (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames },
55 { "start", "(J)V", (void *) (intptr_t) &Java_java_lang_VMThread_start },
56 { "interrupt", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_interrupt },
57 { "isInterrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted },
58 { "suspend", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_suspend },
59 { "resume", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_resume },
60 { "nativeSetPriority", "(I)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority },
61 { "nativeStop", "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop },
62 { "currentThread", "()Ljava/lang/Thread;", (void *) (intptr_t) &Java_java_lang_VMThread_currentThread },
63 { "yield", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_yield },
64 { "interrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_interrupted },
65 { "holdsLock", "(Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock },
66 { "getState", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_VMThread_getState },
70 /* _Jv_java_lang_VMThread_init *************************************************
72 Register native functions.
74 *******************************************************************************/
76 void _Jv_java_lang_VMThread_init(void)
80 u = utf_new_char("java/lang/VMThread");
82 native_method_register(u, methods, NATIVE_METHODS_COUNT);
87 * Class: java/lang/VMThread
88 * Method: countStackFrames
91 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
93 java_lang_Thread *thread;
95 LLNI_field_get_ref(this, thread, thread);
97 return _Jv_java_lang_Thread_countStackFrames(thread);
102 * Class: java/lang/VMThread
106 JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize)
108 java_lang_Thread *thread;
110 LLNI_field_get_ref(this, thread, thread);
112 _Jv_java_lang_Thread_start(thread, stacksize);
117 * Class: java/lang/VMThread
121 JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
123 java_lang_Thread *thread;
125 LLNI_field_get_ref(this, thread, thread);
127 _Jv_java_lang_Thread_interrupt(thread);
132 * Class: java/lang/VMThread
133 * Method: isInterrupted
136 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
138 java_lang_Thread *thread;
140 LLNI_field_get_ref(this, thread, thread);
142 return _Jv_java_lang_Thread_isInterrupted(thread);
147 * Class: java/lang/VMThread
151 JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
153 java_lang_Thread *thread;
155 LLNI_field_get_ref(this, thread, thread);
157 _Jv_java_lang_Thread_suspend(thread);
162 * Class: java/lang/VMThread
166 JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
168 java_lang_Thread *thread;
170 LLNI_field_get_ref(this, thread, thread);
172 _Jv_java_lang_Thread_resume(thread);
177 * Class: java/lang/VMThread
178 * Method: nativeSetPriority
181 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
183 java_lang_Thread *thread;
185 LLNI_field_get_ref(this, thread, thread);
187 _Jv_java_lang_Thread_setPriority(thread, priority);
192 * Class: java/lang/VMThread
194 * Signature: (Ljava/lang/Throwable;)V
196 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
198 java_lang_Thread *thread;
200 LLNI_field_get_ref(this, thread, thread);
202 _Jv_java_lang_Thread_stop(thread, t);
207 * Class: java/lang/VMThread
208 * Method: currentThread
209 * Signature: ()Ljava/lang/Thread;
211 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
213 return _Jv_java_lang_Thread_currentThread();
218 * Class: java/lang/VMThread
222 JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
224 _Jv_java_lang_Thread_yield();
229 * Class: java/lang/VMThread
230 * Method: interrupted
233 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
235 return _Jv_java_lang_Thread_interrupted();
240 * Class: java/lang/VMThread
242 * Signature: (Ljava/lang/Object;)Z
244 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
246 return _Jv_java_lang_Thread_holdsLock(o);
251 * Class: java/lang/VMThread
253 * Signature: ()Ljava/lang/String;
255 JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
257 java_lang_Thread *thread;
259 LLNI_field_get_ref(this, thread, thread);
261 return _Jv_java_lang_Thread_getState(thread);
266 * These are local overrides for various environment variables in Emacs.
267 * Please do not remove this and leave it at the end of the file, where
268 * Emacs will automagically detect them.
269 * ---------------------------------------------------------------------
272 * indent-tabs-mode: t