/* src/threads/threads-common.c - machine independent thread functions Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, Institut f. Computersprachen - TU Wien This file is part of CACAO. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. $Id: signal.c 7246 2007-01-29 18:49:05Z twisti $ */ #include "config.h" #include "vm/types.h" #include "native/jni.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_Thread.h" #if defined(WITH_CLASSPATH_GNU) # include "native/include/java_lang_VMThread.h" #endif #include "threads/threads-common.h" #include "threads/native/threads.h" #include "vm/builtin.h" #include "vm/stringlocal.h" #include "vmcore/class.h" #include "vmcore/utf8.h" /* threads_create_thread ******************************************************* Creates a thread object with the given name. *******************************************************************************/ threadobject *threads_create_thread(utf *name) { threadobject *thread; java_lang_Thread *t; #if defined(WITH_CLASSPATH_GNU) java_lang_VMThread *vmt; #endif /* create the vm internal thread object */ thread = NEW(threadobject); if (thread == NULL) return NULL; /* create the java thread object */ t = (java_lang_Thread *) builtin_new(class_java_lang_Thread); if (t == NULL) return NULL; #if defined(WITH_CLASSPATH_GNU) vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread); if (vmt == NULL) return NULL; vmt->thread = t; vmt->vmdata = (java_lang_Object *) thread; t->vmThread = vmt; #elif defined(WITH_CLASSPATH_CLDC1_1) t->vm_thread = (java_lang_Object *) thread; #endif thread->object = t; thread->flags = THREAD_FLAG_DAEMON; /* set java.lang.Thread fields */ t->name = javastring_new(name); #if defined(ENABLE_JAVASE) t->daemon = true; #endif t->priority = NORM_PRIORITY; /* return the thread object */ return thread; } /* threads_get_current_tid ***************************************************** Return the tid of the current thread. RETURN VALUE: the current tid *******************************************************************************/ ptrint threads_get_current_tid(void) { threadobject *thread; thread = THREADOBJECT; /* this may happen during bootstrap */ if (thread == NULL) return 0; return (ptrint) thread->tid; } /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where * Emacs will automagically detect them. * --------------------------------------------------------------------- * Local variables: * mode: c * indent-tabs-mode: t * c-basic-offset: 4 * tab-width: 4 * End: * vim:noexpandtab:sw=4:ts=4: */