* src/threads/native/lock.c: Implemented Sable extension to tasuki lock.
[cacao.git] / src / threads / threads-common.h
index abcb13cfdf4202218c11ba1806a591604a2c41f8..f744afbbd2a1e641291ac17638a012c3a5b8886b 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.h 8222 2007-07-22 20:07:55Z twisti $
-
 */
 
 
@@ -35,7 +33,7 @@
 
 #include "vm/global.h"
 
-#include "native/jni.h"
+#include "native/llni.h"
 
 #if defined(ENABLE_THREADS)
 # include "threads/native/threads.h"
 
 /* thread states **************************************************************/
 
-#define THREAD_STATE_NEW              1
-#define THREAD_STATE_RUNNABLE         2
-#define THREAD_STATE_BLOCKED          3
-#define THREAD_STATE_WAITING          4
-#define THREAD_STATE_TIMED_WAITING    5
-#define THREAD_STATE_TERMINATED       6
+#define THREAD_STATE_NEW              0
+#define THREAD_STATE_RUNNABLE         1
+#define THREAD_STATE_BLOCKED          2
+#define THREAD_STATE_WAITING          3
+#define THREAD_STATE_TIMED_WAITING    4
+#define THREAD_STATE_TERMINATED       5
 
 
 /* thread priorities **********************************************************/
 #define MAX_PRIORITY     10
 
 
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define DEBUGTHREADS(message, thread) \
+       do { \
+               if (opt_DebugThreads) { \
+                       printf("[Thread %-16s: ", message); \
+                       threads_thread_print_info(thread); \
+                       printf("]\n"); \
+               } \
+       } while (0)
+#else
+# define DEBUGTHREADS(message, thread)
+#endif
+
+
 #if defined(__LINUX__)
 /* XXX Remove for exact-GC. */
 extern bool threads_pthreads_implementation_nptl;
 #endif
 
 
+/* inline functions ***********************************************************/
+
+/* threads_thread_get_object ***************************************************
+
+   Return the java.lang.Thread object for the given thread.
+
+*******************************************************************************/
+
+static inline java_handle_t *threads_thread_get_object(threadobject *t)
+{
+       return LLNI_WRAP(t->object);
+}
+
+
+/* threads_thread_set_object ***************************************************
+
+   Set the java.lang.Thread object for the given thread.
+
+*******************************************************************************/
+
+static inline void threads_thread_set_object(threadobject *t, java_handle_t *object)
+{
+       t->object = LLNI_DIRECT(object);
+}
+
+
 /* function prototypes ********************************************************/
 
 void          threads_preinit(void);
@@ -85,7 +125,7 @@ threadobject *threads_thread_new(void);
 void          threads_thread_free(threadobject *t);
 
 bool          threads_thread_start_internal(utf *name, functionptr f);
-void          threads_thread_start(java_lang_Thread *object);
+void          threads_thread_start(java_handle_t *object);
 
 void          threads_thread_print_info(threadobject *t);
 
@@ -97,7 +137,7 @@ void          threads_thread_state_timed_waiting(threadobject *t);
 void          threads_thread_state_terminated(threadobject *t);
 utf          *threads_thread_get_state(threadobject *t);
 
-bool          threads_thread_is_alive(threadobject *thread);
+bool          threads_thread_is_alive(threadobject *t);
 
 void          threads_dump(void);
 void          threads_thread_print_stacktrace(threadobject *thread);
@@ -111,6 +151,11 @@ void          threads_impl_preinit(void);
 void          threads_list_lock(void);
 void          threads_list_unlock(void);
 
+#if defined(ENABLE_GC_CACAO)
+void          threads_mutex_gc_lock(void);
+void          threads_mutex_gc_unlock(void);
+#endif
+
 void          threads_mutex_join_lock(void);
 void          threads_mutex_join_unlock(void);