interrupt() / notify() fix.
[cacao.git] / src / threads / native / threads.h
index 8de392338d988032dc19833ec8b5c156b809ac75..f02f38871e9b8a64c9961927611322fedd6654d3 100644 (file)
@@ -1,9 +1,7 @@
 /* src/threads/native/threads.h - native threads header
 
-   Copyright (C) 1996-2005, 2006, 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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -43,7 +41,6 @@ typedef struct threadobject threadobject;
 #include "mm/memory.h"
 #include "native/jni.h"
 #include "native/localref.h"
-#include "native/include/java_lang_Thread.h"
 
 #include "threads/native/lock.h"
 
@@ -109,7 +106,7 @@ extern pthread_key_t threads_current_threadobject_key;
 
 
 struct threadobject {
-       java_lang_Thread     *object;       /* link to java.lang.Thread object    */
+       java_object_t        *object;       /* link to java.lang.Thread object    */
 
        ptrint                thinlock;     /* pre-computed thin lock value       */
 
@@ -123,6 +120,14 @@ struct threadobject {
        mach_port_t           mach_thread;       /* Darwin thread id              */
 #endif
 
+       /* for the sable tasuki lock extension */
+       bool                  flc_bit;
+       struct threadobject  *flc_list;     /* FLC list head for this thread      */
+       struct threadobject  *flc_next;     /* next pointer for FLC list          */
+       java_handle_t        *flc_object;
+       pthread_mutex_t       flc_lock;     /* controlling access to these fields */
+       pthread_cond_t        flc_cond;
+
        /* these are used for the wait/notify implementation                      */
        pthread_mutex_t       waitmutex;
        pthread_cond_t        waitcond;
@@ -140,7 +145,7 @@ struct threadobject {
        u1                   *pc;           /* current PC (used for profiling)    */
 
        java_object_t        *_exceptionptr;     /* current exception             */
-       stackframeinfo       *_stackframeinfo;   /* current native stackframeinfo */
+       stackframeinfo_t     *_stackframeinfo;   /* current native stackframeinfo */
        localref_table       *_localref_table;   /* JNI local references          */
 
 #if defined(ENABLE_INTRP)
@@ -166,19 +171,10 @@ struct threadobject {
 #endif
 
        listnode_t            linkage;      /* threads-list                       */
+       listnode_t            linkage_free; /* free-list                          */
 };
 
 
-/* exception pointer **********************************************************/
-
-#define exceptionptr      (&(THREADOBJECT->_exceptionptr))
-
-
-/* stackframeinfo *************************************************************/
-
-#define STACKFRAMEINFO    (THREADOBJECT->_stackframeinfo)
-
-
 /* native-world flags *********************************************************/
 
 #if defined(ENABLE_GC_CACAO)
@@ -203,6 +199,20 @@ struct threadobject {
 #      define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount)
 #endif
 
+
+/* inline functions ***********************************************************/
+
+inline static stackframeinfo_t *threads_get_current_stackframeinfo(void)
+{
+       return THREADOBJECT->_stackframeinfo;
+}
+
+inline static void threads_set_current_stackframeinfo(stackframeinfo_t *sfi)
+{
+       THREADOBJECT->_stackframeinfo = sfi;
+}
+
+
 /* functions ******************************************************************/
 
 void threads_sem_init(sem_t *sem, bool shared, int value);
@@ -228,7 +238,7 @@ void threads_join_all_threads(void);
 
 void threads_sleep(s8 millis, s4 nanos);
 
-bool threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
+void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
 
 void threads_thread_interrupt(threadobject *thread);
 bool threads_check_if_interrupted_and_reset(void);