* src/vm/class.c [ENABLE_JAVASE] (arrayclass_java_lang_Object): Added
[cacao.git] / src / threads / native / threads.h
index 065e1e516b74fdf2f8bd6307745cece47c62a7fc..e1b8f038437bbf278ac3d4f057324eb13150e374 100644 (file)
    Contact: cacao@cacaojvm.org
 
    Authors: Stefan Ring
-                       Edwin Steiner
+            Edwin Steiner
+            Christian Thalinger
 
-   Changes: Christian Thalinger
-
-   $Id: threads.h 5806 2006-10-19 10:10:23Z twisti $
+   $Id: threads.h 6251 2006-12-27 23:15:56Z twisti $
 
 */
 
@@ -53,19 +52,18 @@ typedef struct threads_table_t       threads_table_t;
 
 #include "mm/memory.h"
 #include "native/jni.h"
-#include "native/include/java_lang_Object.h" /* required by java/lang/VMThread*/
 #include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_VMThread.h"
 #include "vm/global.h"
 
 #include "threads/native/lock.h"
 
+#if defined(ENABLE_INTRP)
+#include "vm/jit/intrp/intrp.h"
+#endif
+
 #if defined(__DARWIN__)
 # include <mach/mach.h>
 
-/* We need to emulate recursive mutexes. */
-# define MUTEXSIM
-
 typedef struct {
        pthread_mutex_t mutex;
        pthread_cond_t cond;
@@ -97,7 +95,7 @@ extern __thread threadobject *threads_current_threadobject;
 
 #define THREADSPECIFIC
 #define THREADOBJECT \
-       ((threadobject *)pthread_getspecific(threads_current_threadobject_key))
+       ((threadobject *) pthread_getspecific(threads_current_threadobject_key))
 
 extern pthread_key_t threads_current_threadobject_key;
 
@@ -132,17 +130,18 @@ struct threads_table_t {
 
 /* threadobject ****************************************************************
 
-   Every java.lang.VMThread object is actually an instance of this
+   Every java.lang.Thread object is actually an instance of this
    structure.
 
 *******************************************************************************/
 
 #define THREAD_FLAG_JAVA        0x01    /* a normal Java thread               */
 #define THREAD_FLAG_INTERNAL    0x02    /* CACAO internal thread              */
+#define THREAD_FLAG_DAEMON      0x04    /* daemon thread                      */
 
 
 struct threadobject {
-       java_lang_VMThread    o;            /* the java.lang.VMThread object      */
+       java_lang_Thread      o;            /* the java.lang.Thread object        */
 
        lock_execution_env_t  ee;           /* data for the lock implementation   */
 
@@ -152,7 +151,7 @@ struct threadobject {
        ptrint                thinlock;     /* pre-computed thin lock value       */
 
        s4                    index;        /* thread index, starting with 1      */
-       u1                    flags;        /* flag field                         */
+       u4                    flags;        /* flag field                         */
 
        pthread_t             tid;          /* pthread id                         */
 
@@ -178,7 +177,7 @@ struct threadobject {
        localref_table       *_localref_table;   /* JNI local references          */
 
 #if defined(ENABLE_INTRP)
-       u1                   *_global_sp;        /* stack pointer for interpreter */
+       Cell                 *_global_sp;        /* stack pointer for interpreter */
 #endif
 
        dumpinfo_t            dumpinfo;     /* dump memory info structure         */
@@ -201,9 +200,9 @@ threadobject *threads_get_current_threadobject(void);
 void threads_preinit(void);
 bool threads_init(void);
 
-void threads_init_threadobject(java_lang_VMThread *);
+void threads_start_thread(threadobject *thread, functionptr function);
 
-void threads_start_thread(java_lang_Thread *t, functionptr function);
+void threads_set_thread_priority(pthread_t tid, int priority);
 
 bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
 bool threads_detach_thread(threadobject *thread);
@@ -215,44 +214,15 @@ void threads_yield(void);
 
 bool threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
 
-void threads_thread_interrupt(java_lang_VMThread *);
+void threads_thread_interrupt(threadobject *thread);
 bool threads_check_if_interrupted_and_reset(void);
-bool threads_thread_has_been_interrupted(java_lang_VMThread *);
-
-void threads_java_lang_Thread_set_priority(java_lang_Thread *t, s4 priority);
+bool threads_thread_has_been_interrupted(threadobject *thread);
 
 void threads_cast_stopworld(void);
 void threads_cast_startworld(void);
 
 void threads_dump(void);
 
-/******************************************************************************/
-/* Recursive Mutex Implementation for Darwin                                  */
-/******************************************************************************/
-
-#if defined(MUTEXSIM)
-
-/* We need this for older MacOSX (10.1.x) */
-
-typedef struct {
-       pthread_mutex_t mutex;
-       pthread_t owner;
-       int count;
-} pthread_mutex_rec_t;
-
-void pthread_mutex_init_rec(pthread_mutex_rec_t *m);
-void pthread_mutex_destroy_rec(pthread_mutex_rec_t *m);
-void pthread_mutex_lock_rec(pthread_mutex_rec_t *m);
-void pthread_mutex_unlock_rec(pthread_mutex_rec_t *m);
-
-#else /* !defined(MUTEXSIM) */
-
-#define pthread_mutex_lock_rec pthread_mutex_lock
-#define pthread_mutex_unlock_rec pthread_mutex_unlock
-#define pthread_mutex_rec_t pthread_mutex_t
-
-#endif /* defined(MUTEXSIM) */
-
 #endif /* _THREADS_H */