433d6e6b0870c25b7ee4f8006ef0000d3a9773dc
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Thread.c
1 /* src/native/vm/cldc1.1/java_lang_Thread.c
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
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_Thread.h"
37
38 #include "native/vm/java_lang_Thread.h"
39
40 #include "threads/threads-common.h"
41
42 #include "toolbox/logging.h"
43
44 #include "vm/builtin.h"
45
46
47 /* native methods implemented by this file ************************************/
48  
49 static JNINativeMethod methods[] = {
50         { "currentThread", "()Ljava/lang/Thread;", (void *) (ptrint) &Java_java_lang_Thread_currentThread },
51         { "setPriority0",  "(II)V",                (void *) (ptrint) &Java_java_lang_Thread_setPriority0  },
52         { "sleep",         "(J)V",                 (void *) (ptrint) &Java_java_lang_Thread_sleep         },
53         { "start0",        "()V",                  (void *) (ptrint) &Java_java_lang_Thread_start0        },
54         { "isAlive",       "()Z",                  (void *) (ptrint) &Java_java_lang_Thread_isAlive       },
55 #if 0
56         { "activeCount",   "()I",                  (void *) (ptrint) &Java_java_lang_Thread_activeCount   },
57         { "setPriority0",  "(II)V",                (void *) (ptrint) &Java_java_lang_Thread_setPriority0  },
58         { "interrupt0",    "()V",                  (void *) (ptrint) &Java_java_lang_Thread_interrupt0    },
59         { "internalExit",  "()V",                  (void *) (ptrint) &Java_java_lang_Thread_internalExit  },
60 #endif
61         { "yield",         "()V",                  (void *) (ptrint) &Java_java_lang_Thread_yield         },
62 };
63
64
65 /* _Jv_java_lang_Thread_init ***************************************************
66  
67    Register native functions.
68  
69 *******************************************************************************/
70  
71 void _Jv_java_lang_Thread_init(void)
72 {
73         utf *u;
74  
75         u = utf_new_char("java/lang/Thread");
76  
77         native_method_register(u, methods, NATIVE_METHODS_COUNT);
78 }
79
80
81 /*
82  * Class:     java/lang/Thread
83  * Method:    currentThread
84  * Signature: ()Ljava/lang/Thread;
85  */
86 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
87 {
88         return _Jv_java_lang_Thread_currentThread();
89 }
90
91
92 /*
93  * Class:     java/lang/Thread
94  * Method:    setPriority0
95  * Signature: (II)V
96  */
97 JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *this, s4 oldPriority, s4 newPriority)
98 {
99         _Jv_java_lang_Thread_setPriority(this, newPriority);
100 }
101
102
103 /*
104  * Class:     java/lang/Thread
105  * Method:    sleep
106  * Signature: (J)V
107  */
108 JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis)
109 {
110         _Jv_java_lang_Thread_sleep(millis);
111 }
112
113
114 /*
115  * Class:     java/lang/Thread
116  * Method:    start0
117  * Signature: ()V
118  */
119 JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *this)
120 {
121         _Jv_java_lang_Thread_start(this, 0);
122 }
123
124
125 /*
126  * Class:     java/lang/Thread
127  * Method:    isAlive
128  * Signature: ()Z
129  */
130 JNIEXPORT s4 JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this)
131 {
132         return _Jv_java_lang_Thread_isAlive(this);
133 }
134
135
136 #if 0
137 /*
138  * Class:     java/lang/Thread
139  * Method:    activeCount
140  * Signature: ()I
141  */
142 JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz)
143 {
144 }
145
146
147 /*
148  * Class:     java/lang/Thread
149  * Method:    setPriority0
150  * Signature: (II)V
151  */
152 JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, struct java_lang_Thread* this, s4 par1, s4 par2)
153 {
154 }
155
156
157 /*
158  * Class:     java/lang/Thread
159  * Method:    interrupt0
160  * Signature: ()V
161  */
162 JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, struct java_lang_Thread* this)
163 {
164 }
165
166
167 /*
168  * Class:     java/lang/Thread
169  * Method:    internalExit
170  * Signature: ()V
171  */
172 JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, struct java_lang_Thread* this)
173 {
174 }
175 #endif
176
177
178 /*
179  * Class:     java/lang/Thread
180  * Method:    yield
181  * Signature: ()V
182  */
183 JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz)
184 {
185 #if defined(ENABLE_THREADS)
186         threads_yield();
187 #endif
188 }
189
190
191 /*
192  * These are local overrides for various environment variables in Emacs.
193  * Please do not remove this and leave it at the end of the file, where
194  * Emacs will automagically detect them.
195  * ---------------------------------------------------------------------
196  * Local variables:
197  * mode: c
198  * indent-tabs-mode: t
199  * c-basic-offset: 4
200  * tab-width: 4
201  * End:
202  * vim:noexpandtab:sw=4:ts=4:
203  */