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