Framework for exporting system header to user space (#59)
[lunaix-os.git] / lunaix-os / usr / libc / src / pthread.c
1 #include <syscall.h>
2 #include <pthread.h>
3
4 int 
5 pthread_create(pthread_t* thread,
6                 const pthread_attr_t* attr,
7                 void *(*start_routine)(void*), void* arg)
8 {
9     // FIXME attr currently not used
10     int ret;
11     struct uthread_param th_param;
12
13     th_param.th_handler = start_routine;
14     th_param.arg1 = arg;
15
16     extern void th_trampoline();
17     ret = do_lunaix_syscall(__NR__lxsys_th_create, thread, 
18                             &th_param, th_trampoline);
19     return ret;
20 }
21
22 int 
23 pthread_detach(pthread_t thread)
24 {
25     return do_lunaix_syscall(__NR__lxsys_th_detach, thread);
26 }
27
28 void 
29 pthread_exit(void *value_ptr)
30 {
31     do_lunaix_syscall(__NR__lxsys_th_exit, value_ptr);
32 }
33
34 int 
35 pthread_join(pthread_t thread, void **value_ptr)
36 {
37     return do_lunaix_syscall(__NR__lxsys_th_join, thread, value_ptr);
38 }
39
40 int 
41 pthread_kill(pthread_t thread, int sig)
42 {
43     return do_lunaix_syscall(__NR__lxsys_th_kill, thread, sig);
44 }
45
46 pthread_t 
47 pthread_self(void)
48 {
49     return do_lunaix_syscall(__NR__lxsys_th_self);
50 }