Merged revisions 7797-7917 via svnmerge from
[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 7912 2007-05-18 13:12:09Z twisti $
26
27 */
28
29
30 #include "config.h"
31 #include "vm/types.h"
32
33 #include "native/jni.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 #if defined(ENABLE_THREADS)
47 # include "threads/native/threads.h"
48 #endif
49
50
51 /* native methods implemented by this file ************************************/
52
53 static JNINativeMethod methods[] = {
54         { "countStackFrames",  "()I",                      (void *) (ptrint) &Java_java_lang_VMThread_countStackFrames  },
55         { "start",             "(J)V",                     (void *) (ptrint) &Java_java_lang_VMThread_start             },
56         { "interrupt",         "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_interrupt         },
57         { "isInterrupted",     "()Z",                      (void *) (ptrint) &Java_java_lang_VMThread_isInterrupted     },
58         { "suspend",           "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_suspend           },
59         { "resume",            "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_resume            },
60         { "nativeSetPriority", "(I)V",                     (void *) (ptrint) &Java_java_lang_VMThread_nativeSetPriority },
61         { "nativeStop",        "(Ljava/lang/Throwable;)V", (void *) (ptrint) &Java_java_lang_VMThread_nativeStop        },
62         { "currentThread",     "()Ljava/lang/Thread;",     (void *) (ptrint) &Java_java_lang_VMThread_currentThread     },
63         { "yield",             "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_yield             },
64         { "interrupted",       "()Z",                      (void *) (ptrint) &Java_java_lang_VMThread_interrupted       },
65         { "holdsLock",         "(Ljava/lang/Object;)Z",    (void *) (ptrint) &Java_java_lang_VMThread_holdsLock         },
66         { "getState",          "()Ljava/lang/String;",     (void *) (ptrint) &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 s4 JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this)
92 {
93     return _Jv_java_lang_Thread_countStackFrames(this->thread);
94 }
95
96
97 /*
98  * Class:     java/lang/VMThread
99  * Method:    start
100  * Signature: (J)V
101  */
102 JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, s8 stacksize)
103 {
104         _Jv_java_lang_Thread_start(this->thread, stacksize);
105 }
106
107
108 /*
109  * Class:     java/lang/VMThread
110  * Method:    interrupt
111  * Signature: ()V
112  */
113 JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this)
114 {
115         _Jv_java_lang_Thread_interrupt(this->thread);
116 }
117
118
119 /*
120  * Class:     java/lang/VMThread
121  * Method:    isInterrupted
122  * Signature: ()Z
123  */
124 JNIEXPORT s4 JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this)
125 {
126         return _Jv_java_lang_Thread_isInterrupted(this->thread);
127 }
128
129
130 /*
131  * Class:     java/lang/VMThread
132  * Method:    suspend
133  * Signature: ()V
134  */
135 JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this)
136 {
137         _Jv_java_lang_Thread_suspend(this->thread);
138 }
139
140
141 /*
142  * Class:     java/lang/VMThread
143  * Method:    resume
144  * Signature: ()V
145  */
146 JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this)
147 {
148         _Jv_java_lang_Thread_resume(this->thread);
149 }
150
151
152 /*
153  * Class:     java/lang/VMThread
154  * Method:    nativeSetPriority
155  * Signature: (I)V
156  */
157 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, s4 priority)
158 {
159         _Jv_java_lang_Thread_setPriority(this->thread, priority);
160 }
161
162
163 /*
164  * Class:     java/lang/VMThread
165  * Method:    nativeStop
166  * Signature: (Ljava/lang/Throwable;)V
167  */
168 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
169 {
170         _Jv_java_lang_Thread_stop(this->thread, t);
171 }
172
173
174 /*
175  * Class:     java/lang/VMThread
176  * Method:    currentThread
177  * Signature: ()Ljava/lang/Thread;
178  */
179 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
180 {
181         return _Jv_java_lang_Thread_currentThread();
182 }
183
184
185 /*
186  * Class:     java/lang/VMThread
187  * Method:    yield
188  * Signature: ()V
189  */
190 JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
191 {
192         _Jv_java_lang_Thread_yield();
193 }
194
195
196 /*
197  * Class:     java/lang/VMThread
198  * Method:    interrupted
199  * Signature: ()Z
200  */
201 JNIEXPORT s4 JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
202 {
203         return _Jv_java_lang_Thread_interrupted();
204 }
205
206
207 /*
208  * Class:     java/lang/VMThread
209  * Method:    holdsLock
210  * Signature: (Ljava/lang/Object;)Z
211  */
212 JNIEXPORT s4 JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
213 {
214         return _Jv_java_lang_Thread_holdsLock(o);
215 }
216
217
218 /*
219  * Class:     java/lang/VMThread
220  * Method:    getState
221  * Signature: ()Ljava/lang/String;
222  */
223 JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this)
224 {
225         return _Jv_java_lang_Thread_getState(this->thread);
226 }
227
228
229 /*
230  * These are local overrides for various environment variables in Emacs.
231  * Please do not remove this and leave it at the end of the file, where
232  * Emacs will automagically detect them.
233  * ---------------------------------------------------------------------
234  * Local variables:
235  * mode: c
236  * indent-tabs-mode: t
237  * c-basic-offset: 4
238  * tab-width: 4
239  * End:
240  */