threads: add parent info + get_parent() method
[c11tester.git] / threads.h
index 69bd115c4a88243657ce8f92088962f97249dccb..345f42077a2372510d5922cd31d26420ed274cd7 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -5,6 +5,8 @@
 
 #include "libthreads.h"
 
+typedef int thread_id_t;
+
 #define THREAD_ID_T_NONE       -1
 
 typedef enum thread_state {
@@ -29,8 +31,10 @@ public:
        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; }
 private:
        int create_context();
+       Thread *parent;
 
        void (*start_routine)();
        void *arg;
@@ -48,4 +52,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__ */