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