4ce14308d2f3bc5ace479b48c51cc28e7c9dc6b1
[cacao.git] / src / native / vm / gnu / java_lang_VMThread.c
1 /* src/native/vm/gnu/java_lang_VMThread.c
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    $Id: java_lang_VMThread.c 8284 2007-08-10 08:58:39Z michi $
26
27 */
28
29
30 #include "config.h"
31
32 #include <stdint.h>
33
34 #include "native/jni.h"
35 #include "native/llni.h"
36 #include "native/native.h"
37
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"
43
44 #include "native/include/java_lang_VMThread.h"
45
46 #include "native/vm/java_lang_Thread.h"
47
48 #include "threads/threads-common.h"
49
50 #include "vmcore/utf8.h"
51
52
53 /* native methods implemented by this file ************************************/
54
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          },
69 };
70
71
72 /* _Jv_java_lang_VMThread_init *************************************************
73
74    Register native functions.
75
76 *******************************************************************************/
77
78 void _Jv_java_lang_VMThread_init(void)
79 {
80         utf *u;
81
82         u = utf_new_char("java/lang/VMThread");
83
84         native_method_register(u, methods, NATIVE_METHODS_COUNT);
85 }
86
87
88 /*
89  * Class:     java/lang/VMThread
90  * Method:    countStackFrames
91  * Signature: ()I
92  */
93 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
94 {
95         java_lang_Thread *thread;
96
97         LLNI_field_get_ref(this, thread, thread);
98
99         return _Jv_java_lang_Thread_countStackFrames(thread);
100 }
101
102
103 /*
104  * Class:     java/lang/VMThread
105  * Method:    start
106  * Signature: (J)V
107  */
108 JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize)
109 {
110         java_lang_Thread *thread;
111
112         LLNI_field_get_ref(this, thread, thread);
113
114         _Jv_java_lang_Thread_start(thread, stacksize);
115 }
116
117
118 /*
119  * Class:     java/lang/VMThread
120  * Method:    interrupt
121  * Signature: ()V
122  */
123 JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
124 {
125         java_lang_Thread *thread;
126
127         LLNI_field_get_ref(this, thread, thread);
128
129         _Jv_java_lang_Thread_interrupt(thread);
130 }
131
132
133 /*
134  * Class:     java/lang/VMThread
135  * Method:    isInterrupted
136  * Signature: ()Z
137  */
138 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
139 {
140         java_lang_Thread *thread;
141
142         LLNI_field_get_ref(this, thread, thread);
143
144         return _Jv_java_lang_Thread_isInterrupted(thread);
145 }
146
147
148 /*
149  * Class:     java/lang/VMThread
150  * Method:    suspend
151  * Signature: ()V
152  */
153 JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
154 {
155         java_lang_Thread *thread;
156
157         LLNI_field_get_ref(this, thread, thread);
158
159         _Jv_java_lang_Thread_suspend(thread);
160 }
161
162
163 /*
164  * Class:     java/lang/VMThread
165  * Method:    resume
166  * Signature: ()V
167  */
168 JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
169 {
170         java_lang_Thread *thread;
171
172         LLNI_field_get_ref(this, thread, thread);
173
174         _Jv_java_lang_Thread_resume(thread);
175 }
176
177
178 /*
179  * Class:     java/lang/VMThread
180  * Method:    nativeSetPriority
181  * Signature: (I)V
182  */
183 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority)
184 {
185         java_lang_Thread *thread;
186
187         LLNI_field_get_ref(this, thread, thread);
188
189         _Jv_java_lang_Thread_setPriority(thread, priority);
190 }
191
192
193 /*
194  * Class:     java/lang/VMThread
195  * Method:    nativeStop
196  * Signature: (Ljava/lang/Throwable;)V
197  */
198 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
199 {
200         java_lang_Thread *thread;
201
202         LLNI_field_get_ref(this, thread, thread);
203
204         _Jv_java_lang_Thread_stop(thread, t);
205 }
206
207
208 /*
209  * Class:     java/lang/VMThread
210  * Method:    currentThread
211  * Signature: ()Ljava/lang/Thread;
212  */
213 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
214 {
215         return _Jv_java_lang_Thread_currentThread();
216 }
217
218
219 /*
220  * Class:     java/lang/VMThread
221  * Method:    yield
222  * Signature: ()V
223  */
224 JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
225 {
226         _Jv_java_lang_Thread_yield();
227 }
228
229
230 /*
231  * Class:     java/lang/VMThread
232  * Method:    interrupted
233  * Signature: ()Z
234  */
235 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
236 {
237         return _Jv_java_lang_Thread_interrupted();
238 }
239
240
241 /*
242  * Class:     java/lang/VMThread
243  * Method:    holdsLock
244  * Signature: (Ljava/lang/Object;)Z
245  */
246 JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
247 {
248         return _Jv_java_lang_Thread_holdsLock(o);
249 }
250
251
252 /*
253  * Class:     java/lang/VMThread
254  * Method:    getState
255  * Signature: ()Ljava/lang/String;
256  */
257 JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
258 {
259         java_lang_Thread *thread;
260
261         LLNI_field_get_ref(this, thread, thread);
262
263         return _Jv_java_lang_Thread_getState(thread);
264 }
265
266
267 /*
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  * ---------------------------------------------------------------------
272  * Local variables:
273  * mode: c
274  * indent-tabs-mode: t
275  * c-basic-offset: 4
276  * tab-width: 4
277  * End:
278  */