remove print statements
[c11tester.git] / threads-model.h
index 8ba9d9b6d83d34fe7f9f057ad53a3e16356e32d3..057ad9d99a6f7fcc8377a0d7129bf99076a0851c 100644 (file)
@@ -8,11 +8,12 @@
 #include <stdint.h>
 
 #include "mymemory.h"
-#include <threads.h>
+#include "threads.h"
 #include "modeltypes.h"
 #include "stl-model.h"
 #include "context.h"
 #include "classlist.h"
+#include "pthread.h"
 
 struct thread_params {
        thrd_start_t func;
@@ -99,6 +100,11 @@ public:
        bool is_model_thread() const { return model_thread; }
 
        friend void thread_startup();
+#ifdef TLS
+       friend void setup_context();
+       friend void * helper_thread(void *);
+       friend void finalize_helper_thread();
+#endif
 
        /**
         * Intentionally NOT allocated with MODELALLOC or SNAPSHOTALLOC.
@@ -118,6 +124,9 @@ public:
        void operator delete[](void *p, size_t size) {
                Thread_free(p);
        }
+#ifdef TLS
+       void setTLS(char *_tls) { tls = _tls;}
+#endif
 private:
        int create_context();
 
@@ -142,6 +151,15 @@ private:
        void *arg;
        ucontext_t context;
        void *stack;
+#ifdef TLS
+public:
+       char *tls;
+       ucontext_t helpercontext;
+       pthread_mutex_t mutex;
+       pthread_mutex_t mutex2;
+       pthread_t thread;
+private:
+#endif
        thrd_t *user_thread;
        thread_id_t id;
        thread_state state;
@@ -160,7 +178,13 @@ private:
        const bool model_thread;
 };
 
+#ifdef TLS
+uintptr_t get_tls_addr();
+#endif
+
 Thread * thread_current();
+void thread_startup();
+void main_thread_startup();
 
 static inline thread_id_t thrd_to_id(thrd_t t)
 {
@@ -187,4 +211,4 @@ static inline int id_to_int(thread_id_t id)
        return id;
 }
 
-#endif /* __THREADS_MODEL_H__ */
+#endif /* __THREADS_MODEL_H__ */