remove print statements
[c11tester.git] / threads-model.h
index 02f20b030778420d46a247e7a3980f34bf20396b..057ad9d99a6f7fcc8377a0d7129bf99076a0851c 100644 (file)
@@ -13,6 +13,7 @@
 #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,8 +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)
 {