1 /* src/native/vm/cldc1.1/java_lang_Thread.c
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
8 This file is part of CACAO.
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.
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.
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
34 #include "native/jni.h"
35 #include "native/native.h"
37 #include "native/include/java_lang_Thread.h"
39 #include "native/vm/java_lang_Thread.h"
41 #include "threads/threads-common.h"
43 #include "toolbox/logging.h"
45 #include "vm/builtin.h"
48 /* native methods implemented by this file ************************************/
50 static JNINativeMethod methods[] = {
51 { "currentThread", "()Ljava/lang/Thread;", (void *) (ptrint) &Java_java_lang_Thread_currentThread },
52 { "setPriority0", "(II)V", (void *) (ptrint) &Java_java_lang_Thread_setPriority0 },
53 { "sleep", "(J)V", (void *) (ptrint) &Java_java_lang_Thread_sleep },
54 { "start0", "()V", (void *) (ptrint) &Java_java_lang_Thread_start0 },
55 { "isAlive", "()Z", (void *) (ptrint) &Java_java_lang_Thread_isAlive },
57 { "activeCount", "()I", (void *) (ptrint) &Java_java_lang_Thread_activeCount },
58 { "setPriority0", "(II)V", (void *) (ptrint) &Java_java_lang_Thread_setPriority0 },
59 { "interrupt0", "()V", (void *) (ptrint) &Java_java_lang_Thread_interrupt0 },
60 { "internalExit", "()V", (void *) (ptrint) &Java_java_lang_Thread_internalExit },
62 { "yield", "()V", (void *) (ptrint) &Java_java_lang_Thread_yield },
66 /* _Jv_java_lang_Thread_init ***************************************************
68 Register native functions.
70 *******************************************************************************/
72 void _Jv_java_lang_Thread_init(void)
76 u = utf_new_char("java/lang/Thread");
78 native_method_register(u, methods, NATIVE_METHODS_COUNT);
83 * Class: java/lang/Thread
84 * Method: currentThread
85 * Signature: ()Ljava/lang/Thread;
87 JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
89 return _Jv_java_lang_Thread_currentThread();
94 * Class: java/lang/Thread
95 * Method: setPriority0
98 JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *this, s4 oldPriority, s4 newPriority)
100 _Jv_java_lang_Thread_setPriority(this, newPriority);
105 * Class: java/lang/Thread
109 JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis)
111 _Jv_java_lang_Thread_sleep(millis);
116 * Class: java/lang/Thread
120 JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *this)
122 _Jv_java_lang_Thread_start(this, 0);
127 * Class: java/lang/Thread
131 JNIEXPORT int32_t JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this)
133 #if defined(ENABLE_THREADS)
137 t = (threadobject *) this->vm_thread;
142 result = threads_thread_is_alive(t);
146 /* If threads are disabled, the only thread running is alive. */
155 * Class: java/lang/Thread
156 * Method: activeCount
159 JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz)
165 * Class: java/lang/Thread
166 * Method: setPriority0
169 JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, struct java_lang_Thread* this, s4 par1, s4 par2)
175 * Class: java/lang/Thread
179 JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, struct java_lang_Thread* this)
185 * Class: java/lang/Thread
186 * Method: internalExit
189 JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, struct java_lang_Thread* this)
196 * Class: java/lang/Thread
200 JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz)
202 #if defined(ENABLE_THREADS)
209 * These are local overrides for various environment variables in Emacs.
210 * Please do not remove this and leave it at the end of the file, where
211 * Emacs will automagically detect them.
212 * ---------------------------------------------------------------------
215 * indent-tabs-mode: t
219 * vim:noexpandtab:sw=4:ts=4: