Merged with tip.
[cacao.git] / src / threads / posix / thread-posix.c
index c4dee854389046808b54bb4639b9440361d814f8..defe4220e711761f2d8aad96266ddc0c50bd6428 100644 (file)
 
 #include "arch.h"
 
-#if !defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
-# include "machine-instr.h"
-#else
-# include "threads/posix/generic-primitives.h"
-#endif
-
 #include "mm/gc-common.h"
 #include "mm/memory.h"
 
@@ -238,12 +232,6 @@ static Condition* cond_join;
 static sem_t suspend_ack;
 #endif
 
-/* mutexes used by the fake atomic instructions                               */
-#if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
-mutex_t _cas_lock = MUTEX_INITIALIZER;
-mutex_t _mb_lock = MUTEX_INITIALIZER;
-#endif
-
 
 /* threads_sem_init ************************************************************
  
@@ -487,6 +475,10 @@ void threads_impl_thread_init(threadobject *t)
 
        t->suspendmutex = Mutex_new();
        t->suspendcond = Condition_new();
+
+#if defined(ENABLE_TLH)
+       tlh_init(&(t->tlh));
+#endif
 }
 
 /* threads_impl_thread_clear ***************************************************
@@ -575,6 +567,11 @@ void threads_impl_thread_reuse(threadobject *t)
 
 /*     not really needed */
        t->flc_object = NULL;
+
+#if defined(ENABLE_TLH)
+       tlh_destroy(&(t->tlh));
+       tlh_init(&(t->tlh));
+#endif
 }
 
 
@@ -1629,6 +1626,17 @@ void threads_yield(void)
        sched_yield();
 }
 
+#if defined(ENABLE_TLH)
+
+void threads_tlh_add_frame() {
+       tlh_add_frame(&(THREADOBJECT->tlh));
+}
+
+void threads_tlh_remove_frame() {
+       tlh_remove_frame(&(THREADOBJECT->tlh));
+}
+
+#endif
 
 /*
  * These are local overrides for various environment variables in Emacs.