* src/vm/jit/s390/codegen.h (N_BRANCH_MIN, N_BRANCH_MAX): Fix (muliply by 2).
[cacao.git] / src / threads / threads-common.h
index dcd0fd79add7c14488e7c7ee98e3d256d64ab9bb..d1412c786eeeceea2755e4541d430d6bd700b4d6 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.h 7830 2007-04-26 11:14:39Z twisti $
-
 */
 
 
 
 #if defined(ENABLE_THREADS)
 
-/* typedefs *******************************************************************/
-
-typedef union  threads_table_entry_t threads_table_entry_t;
-typedef struct threads_table_t       threads_table_t;
-
-
 /* thread states **************************************************************/
 
 #define THREAD_STATE_NEW              0
@@ -73,46 +65,53 @@ typedef struct threads_table_t       threads_table_t;
 #define MAX_PRIORITY     10
 
 
-/* threads_table_entry_t *******************************************************
-
-   An entry in the global threads table.
+/* 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
 
-union threads_table_entry_t {
-       threadobject       *thread;        /* an existing thread                  */
-       ptrint              nextfree;      /* next free index                     */
-};
 
+#if defined(__LINUX__)
+/* XXX Remove for exact-GC. */
+extern bool threads_pthreads_implementation_nptl;
+#endif
 
-/* threads_table_t *************************************************************
 
-   Struct for the global threads table.
+/* function prototypes ********************************************************/
 
-*******************************************************************************/
+void          threads_preinit(void);
 
-struct threads_table_t {
-       threads_table_entry_t *table;      /* the table, threads[0] is the head   */
-                                          /* of the free list. Real entries      */
-                                                                          /* start at threads[1].                */
-       s4                     size;       /* current size of the table           */
-};
+threadobject *threads_list_first(void);
+threadobject *threads_list_next(threadobject *t);
+s4            threads_list_get_non_daemons(void);
 
+threadobject *threads_thread_new(void);
+void          threads_thread_free(threadobject *t);
 
-/* function prototypes ********************************************************/
+bool          threads_thread_start_internal(utf *name, functionptr f);
+void          threads_thread_start(java_handle_t *object);
 
-void          threads_preinit(void);
+void          threads_thread_print_info(threadobject *t);
 
-s4            threads_table_add(threadobject *thread);
-void          threads_table_remove(threadobject *thread);
+ptrint        threads_get_current_tid(void);
 
-threadobject *threads_create_thread(void);
-threadobject *threads_thread_create_internal(utf *name);
-void          threads_start_javathread(java_lang_Thread *object);
+void          threads_thread_state_runnable(threadobject *t);
+void          threads_thread_state_waiting(threadobject *t);
+void          threads_thread_state_timed_waiting(threadobject *t);
+void          threads_thread_state_terminated(threadobject *t);
+utf          *threads_thread_get_state(threadobject *t);
 
-ptrint        threads_get_current_tid(void);
-utf          *threads_thread_get_state(threadobject *thread);
-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);
@@ -123,7 +122,18 @@ void          threads_print_stacktrace(void);
 
 void          threads_impl_preinit(void);
 
-void          threads_init_threadobject(threadobject *thread);
+void          threads_list_lock(void);
+void          threads_list_unlock(void);
+
+void          threads_mutex_join_lock(void);
+void          threads_mutex_join_unlock(void);
+
+void          threads_set_current_threadobject(threadobject *thread);
+void          threads_impl_thread_new(threadobject *t);
+void          threads_impl_thread_free(threadobject *t);
+void          threads_impl_thread_start(threadobject *thread, functionptr f);
+
+void          threads_yield(void);
 
 #endif /* ENABLE_THREADS */