common: rename "CONFIG" to "COMMON"
[cdsspec-compiler.git] / libthreads.h
1 #ifndef __LIBTHREADS_H__
2 #define __LIBTHREADS_H__
3
4 #include <ucontext.h>
5
6 typedef enum thread_state {
7         THREAD_CREATED,
8         THREAD_RUNNING,
9         THREAD_READY,
10         THREAD_COMPLETED
11 } thread_state;
12
13 struct thread {
14         void (*start_routine)();
15         void *arg;
16         ucontext_t context;
17         void *stack;
18         int id;
19         thread_state state;
20 };
21
22 int thread_create(struct thread *t, void (*start_routine)(), void *arg);
23 void thread_join(struct thread *t);
24 int thread_yield(void);
25 struct thread *thread_current(void);
26
27 extern void user_main(void);
28
29 #endif /* __LIBTHREADS_H__ */