Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: threads-common.c 8114 2007-06-20 18:57:41Z twisti $
-
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <unistd.h>
#include "vm/types.h"
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/include/java_lang_Object.h"
#include "native/include/java_lang_String.h"
void threads_preinit(void)
{
threadobject *mainthread;
-#if defined(__LINUX__)
+#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
char *pathbuf;
size_t len;
#endif
void threads_thread_free(threadobject *t)
{
- s4 index;
+ int32_t index;
+ uint32_t state;
/* lock the threads-lists */
list_remove_unsynced(list_threads, t);
- /* Clear memory, but keep the thread-index. */
+ /* Clear memory, but keep the thread-index and the
+ thread-state. */
+
/* ATTENTION: Do this after list_remove, otherwise the linkage
pointers are invalid. */
index = t->index;
+ state = t->state;
MZERO(t, threadobject, 1);
t->index = index;
+ t->state = state;
/* add the thread to the free list */
if (vmt == NULL)
return false;
- vmt->thread = object;
- vmt->vmdata = (java_lang_Object *) t;
+ LLNI_field_set_ref(vmt, thread, object);
+ LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) t);
- object->vmThread = vmt;
+ LLNI_field_set_ref(object, vmThread, vmt);
#elif defined(WITH_CLASSPATH_CLDC1_1)
- object->vm_thread = (java_lang_Object *) t;
+ LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t);
#endif
t->object = object;
/* set java.lang.Thread fields */
#if defined(WITH_CLASSPATH_GNU)
- object->name = (java_lang_String *) javastring_new(name);
+ LLNI_field_set_ref(object, name , (java_lang_String *) javastring_new(name));
#elif defined(WITH_CLASSPATH_CLDC1_1)
/* FIXME: In cldc the name is a char[] */
-/* object->name = (java_chararray *) javastring_new(name); */
- object->name = NULL;
+/* LLNI_field_set_ref(object, name , (java_chararray *) javastring_new(name)); */
+ LLNI_field_set_ref(object, name , NULL);
#endif
#if defined(ENABLE_JAVASE)
- object->daemon = true;
+ LLNI_field_set_val(object, daemon , true);
#endif
- object->priority = NORM_PRIORITY;
+ LLNI_field_set_val(object, priority, NORM_PRIORITY);
/* start the thread */
void threads_thread_start(java_lang_Thread *object)
{
threadobject *thread;
+#if defined(WITH_CLASSPATH_GNU)
+ java_lang_VMThread *vmt;
+#endif
/* Enter the join-mutex, so if the main-thread is currently
waiting to join all threads, the number of non-daemon threads
#if defined(ENABLE_JAVASE)
/* is this a daemon thread? */
- if (object->daemon == true)
+ if (LLNI_field_direct(object, daemon) == true)
thread->flags |= THREAD_FLAG_DAEMON;
#endif
thread->object = object;
#if defined(WITH_CLASSPATH_GNU)
- assert(object->vmThread);
- assert(object->vmThread->vmdata == NULL);
+ LLNI_field_get_ref(object, vmThread, vmt);
+
+ assert(vmt);
+ assert(LLNI_field_direct(vmt, vmdata) == NULL);
- object->vmThread->vmdata = (java_lang_Object *) thread;
+ LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) thread);
#elif defined(WITH_CLASSPATH_CLDC1_1)
- object->vm_thread = (java_lang_Object *) thread;
+ LLNI_field_set_val(object, vm_thread, (java_lang_Object *) thread);
#endif
/* Start the thread. Don't pass a function pointer (NULL) since
if (object != NULL) {
/* get thread name */
-#if defined(ENABLE_JAVASE)
- name = javastring_toutf((java_objectheader *) object->name, false);
-#elif defined(ENABLE_JAVAME_CLDC1_1)
+#if defined(WITH_CLASSPATH_GNU)
+ name = javastring_toutf((java_handle_t *) LLNI_field_direct(object, name), false);
+#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
/* FIXME: In cldc the name is a char[] */
/* name = object->name; */
name = utf_null;
+#else
+# error unknown classpath configuration
#endif
printf("\"");
if (t->flags & THREAD_FLAG_DAEMON)
printf(" daemon");
- printf(" prio=%d", object->priority);
+ printf(" prio=%d", LLNI_field_direct(object, priority));
#if SIZEOF_VOID_P == 8
printf(" t=0x%016lx tid=0x%016lx (%ld)",