6 #include "libthreads.h"
8 typedef int thread_id_t;
10 #define THREAD_ID_T_NONE -1
12 typedef enum thread_state {
21 Thread(thrd_t *t, void (*func)(void *), void *a);
25 static int swap(ucontext_t *ctxt, Thread *t);
26 static int swap(Thread *t, ucontext_t *ctxt);
28 thread_state get_state() { return state; }
29 void set_state(thread_state s) { state = s; }
31 thrd_t get_thrd_t() { return *user_thread; }
32 Thread * get_parent() { return parent; }
34 friend void thread_startup();
41 void (*start_routine)(void *);
50 Thread * thread_current();
52 static inline thread_id_t thrd_to_id(thrd_t t)
57 static inline thread_id_t int_to_id(int i)
62 static inline int id_to_int(thread_id_t id)
67 #endif /* __THREADS_H__ */