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
25 $Id: java_lang_VMThread.c 8284 2007-08-10 08:58:39Z michi $
34 #include "native/jni.h"
35 #include "native/llni.h"
36 #include "native/native.h"
38 #include "native/include/java_lang_ThreadGroup.h"
39 #include "native/include/java_lang_Object.h" /* java_lang_Thread.h */
40 #include "native/include/java_lang_Throwable.h" /* java_lang_Thread.h */
41 #include "native/include/java_lang_VMThread.h"
42 #include "native/include/java_lang_Thread.h"
44 #include "native/include/java_lang_VMThread.h"
46 #include "native/vm/java_lang_Thread.h"
48 #include "threads/threads-common.h"
50 #include "vmcore/utf8.h"
53 /* native methods implemented by this file ************************************/
55 static JNINativeMethod methods[] = {
56 { "countStackFrames", "()I", (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames },
57 { "start", "(J)V", (void *) (intptr_t) &Java_java_lang_VMThread_start },
58 { "interrupt", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_interrupt },
59 { "isInterrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted },
60 { "suspend", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_suspend },
61 { "resume", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_resume },
62 { "nativeSetPriority", "(I)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority },
63 { "nativeStop", "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop },
64 { "currentThread", "()Ljava/lang/Thread;", (void *) (intptr_t) &Java_java_lang_VMThread_currentThread },
65 { "yield", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_yield },
66 { "interrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_interrupted },
67 { "holdsLock", "(Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock },
68 { "getState", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_VMThread_getState },
72 /* _Jv_java_lang_VMThread_init *************************************************
74 Register native functions.
76 *******************************************************************************/
78 void _Jv_java_lang_VMThread_init(void)
82 u = utf_new_char("java/lang/VMThread");
84 native_method_register(u, methods, NATIVE_METHODS_COUNT);
89 * Class: java/lang/VMThread
90 * Method: countStackFrames
93 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
95 java_lang_Thread *thread;
97 LLNI_field_get_ref(this, thread, thread);
99 return _Jv_java_lang_Thread_countStackFrames(thread);
104 * Class: java/lang/VMThread
108 JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize)
110 java_lang_Thread *thread;
112 LLNI_field_get_ref(this, thread, thread);
114 _Jv_java_lang_Thread_start(thread, stacksize);
119 * Class: java/lang/VMThread
123 JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
125 java_lang_Thread *thread;
127 LLNI_field_get_ref(this, thread, thread);
129 _Jv_java_lang_Thread_interrupt(thread);
134 * Class: java/lang/VMThread
135 * Method: isInterrupted
138 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
140 java_lang_Thread *thread;
142 LLNI_field_get_ref(this, thread, thread);
144 return _Jv_java_lang_Thread_isInterrupted(thread);
149 * Class: java/lang/VMThread
153 JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
155 java_lang_Thread *thread;
157 LLNI_field_get_ref(this, thread, thread);
159 _Jv_java_lang_Thread_suspend(thread);
164 * Class: java/lang/VMThread
168 JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
170 java_lang_Thread *thread;
172 LLNI_field_get_ref(this, thread, thread);
174 _Jv_java_lang_Thread_resume(thread);
179 * Class: java/lang/VMThread
180 * Method: nativeSetPriority
183 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
185 java_lang_Thread *thread;
187 LLNI_field_get_ref(this, thread, thread);
189 _Jv_java_lang_Thread_setPriority(thread, priority);
194 * Class: java/lang/VMThread
196 * Signature: (Ljava/lang/Throwable;)V
198 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
200 java_lang_Thread *thread;
202 LLNI_field_get_ref(this, thread, thread);
204 _Jv_java_lang_Thread_stop(thread, t);
209 * Class: java/lang/VMThread
210 * Method: currentThread
211 * Signature: ()Ljava/lang/Thread;
213 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
215 return _Jv_java_lang_Thread_currentThread();
220 * Class: java/lang/VMThread
224 JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
226 _Jv_java_lang_Thread_yield();
231 * Class: java/lang/VMThread
232 * Method: interrupted
235 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
237 return _Jv_java_lang_Thread_interrupted();
242 * Class: java/lang/VMThread
244 * Signature: (Ljava/lang/Object;)Z
246 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
248 return _Jv_java_lang_Thread_holdsLock(o);
253 * Class: java/lang/VMThread
255 * Signature: ()Ljava/lang/String;
257 JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
259 java_lang_Thread *thread;
261 LLNI_field_get_ref(this, thread, thread);
263 return _Jv_java_lang_Thread_getState(thread);
268 * These are local overrides for various environment variables in Emacs.
269 * Please do not remove this and leave it at the end of the file, where
270 * Emacs will automagically detect them.
271 * ---------------------------------------------------------------------
274 * indent-tabs-mode: t