schedule: add scheduler, thread_yield(), etc.
[c11tester.git] / libthreads.h
1 #ifndef __LIBTHREADS_H__
2 #define __LIBTHREADS_H__
3
4 #include <stdio.h>
5 #include <ucontext.h>
6
7 #ifdef CONFIG_DEBUG
8 #define DBG() do { printf("Here: %s, L%d\n", __func__, __LINE__); } while (0)
9 #define DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__)
10 #else
11 #define DBG()
12 #define DEBUG(fmt, ...)
13 #endif
14
15 struct thread {
16         void (*start_routine);
17         void *arg;
18         ucontext_t context;
19         void *stack;
20         int index;
21         int completed;
22 };
23
24 int thread_create(struct thread *t, void (*start_routine), void *arg);
25 void thread_start(struct thread *t);
26
27 #endif /* __LIBTHREADS_H__ */