snapshot: don't export page-aligning functions
[c11tester.git] / threads.h
index 44e1013768e911c6aaec6aa8564fd2a629b94cc7..0e0293ad817332e867db1e7b92c490da3c3f9b19 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -1,10 +1,16 @@
+/** @file threads.h
+ *  @brief Model Checker Thread class.
+ */
+
 #ifndef __THREADS_H__
 #define __THREADS_H__
 
 #include <ucontext.h>
-
+#include "mymemory.h"
 #include "libthreads.h"
 
+typedef int thread_id_t;
+
 #define THREAD_ID_T_NONE       -1
 
 typedef enum thread_state {
@@ -14,24 +20,35 @@ typedef enum thread_state {
        THREAD_COMPLETED
 } thread_state;
 
+class ModelAction;
+
 class Thread {
 public:
-       void * operator new(size_t size);
-       void operator delete(void *ptr);
-       Thread(thrd_t *t, void (*func)(), void *a);
-       Thread(thrd_t *t);
+       Thread(thrd_t *t, void (*func)(void *), void *a);
        ~Thread();
        void complete();
-       int swap(Thread *t);
+
+       static int swap(ucontext_t *ctxt, Thread *t);
+       static int swap(Thread *t, ucontext_t *ctxt);
 
        thread_state get_state() { return state; }
        void set_state(thread_state s) { state = s; }
        thread_id_t get_id();
        thrd_t get_thrd_t() { return *user_thread; }
+       Thread * get_parent() { return parent; }
+
+       void set_creation(ModelAction *act) { creation = act; }
+       ModelAction * get_creation() { return creation; }
+
+       friend void thread_startup();
+
+       SNAPSHOTALLOC
 private:
        int create_context();
+       Thread *parent;
+       ModelAction *creation;
 
-       void (*start_routine)();
+       void (*start_routine)(void *);
        void *arg;
        ucontext_t context;
        void *stack;
@@ -47,4 +64,14 @@ static inline thread_id_t thrd_to_id(thrd_t t)
        return t;
 }
 
+static inline thread_id_t int_to_id(int i)
+{
+       return i;
+}
+
+static inline int id_to_int(thread_id_t id)
+{
+       return id;
+}
+
 #endif /* __THREADS_H__ */