* m4/ac_pthreads_implementation.m4: Reverted rev7996.
[cacao.git] / src / threads / threads-common.h
index e07c3d416c632a9a16335a5d7519300ec4c28d6d..39b1f2782ab843b443a19ab64e0c00c3c6697244 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.h 7894 2007-05-10 14:04:05Z twisti $
+   $Id: threads-common.h 7998 2007-06-01 00:29:51Z twisti $
 
 */
 
 
 #if defined(ENABLE_THREADS)
 
-/* typedefs *******************************************************************/
-
-typedef struct threads_table_entry_t threads_table_entry_t;
-typedef struct threads_table_t       threads_table_t;
-
-
 /* thread states **************************************************************/
 
-#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
+#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
 
 
 /* thread priorities **********************************************************/
@@ -73,57 +67,36 @@ typedef struct threads_table_t       threads_table_t;
 #define MAX_PRIORITY     10
 
 
-/* threads_table_entry_t *******************************************************
-
-   An entry in the global threads table.
-
-*******************************************************************************/
-
-struct threads_table_entry_t {
-       threadobject *thread;              /* an existing thread                  */
-       s4            next;                /* next free or used index             */
-};
-
-
-/* threads_table_t *************************************************************
-
-   Struct for the global threads table.
-
-*******************************************************************************/
-
-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           */
-       s4                     used;       /* number of thread entries            */
-       s4                     daemons;    /* number of daemon thread entries     */
-};
+#if defined(__LINUX__)
+/* XXX Remove for exact-GC. */
+extern bool threads_pthreads_implementation_nptl;
+#endif
 
 
 /* function prototypes ********************************************************/
 
 void          threads_preinit(void);
 
-s4            threads_table_add(threadobject *thread);
-void          threads_table_remove(threadobject *thread);
-s4            threads_table_get_threads(void);
-s4            threads_table_get_non_daemons(void);
-threadobject *threads_table_first(void);
-threadobject *threads_table_next(threadobject *thread);
+threadobject *threads_list_first(void);
+threadobject *threads_list_next(threadobject *t);
+s4            threads_list_get_non_daemons(void);
 
-#if !defined(NDEBUG)
-void          threads_table_dump(void);
-#endif
+threadobject *threads_thread_new(void);
+void          threads_thread_free(threadobject *t);
 
-threadobject *threads_create_thread(void);
 bool          threads_thread_start_internal(utf *name, functionptr f);
 void          threads_thread_start(java_lang_Thread *object);
 
 void          threads_thread_print_info(threadobject *t);
 
 ptrint        threads_get_current_tid(void);
-utf          *threads_thread_get_state(threadobject *thread);
+
+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);
+
 bool          threads_thread_is_alive(threadobject *thread);
 
 void          threads_dump(void);
@@ -135,12 +108,12 @@ void          threads_print_stacktrace(void);
 
 void          threads_impl_preinit(void);
 
-void          threads_impl_table_init(void);
-void          threads_table_lock(void);
-void          threads_table_unlock(void);
+void          threads_list_lock(void);
+void          threads_list_unlock(void);
 
 void          threads_set_current_threadobject(threadobject *thread);
-void          threads_init_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);
 
 #endif /* ENABLE_THREADS */