1 #include <lunaix/syscall.h>
5 __pthread_routine_wrapper(void *(*start_routine)(void*), void* arg)
7 void* ret = start_routine(arg);
9 do_lunaix_syscall(__SYSCALL_th_exit, ret);
11 return ret; // should not reach
15 pthread_create(pthread_t* thread,
16 const pthread_attr_t* attr,
17 void *(*start_routine)(void*), void* arg)
19 // FIXME attr currently not used
21 struct uthread_info th_info;
22 int ret = do_lunaix_syscall(__SYSCALL_th_create, thread, &th_info, __pthread_routine_wrapper, NULL);
28 // FIXME we should encapsulate these parameter into struct
29 // and pass it as a single thread param.
31 void** th_stack = (void**) th_info.th_stack_top;
32 th_stack[1] = (void*)start_routine;
39 pthread_detach(pthread_t thread)
41 return do_lunaix_syscall(__SYSCALL_th_detach, thread);
45 pthread_exit(void *value_ptr)
47 do_lunaix_syscall(__SYSCALL_th_exit, value_ptr);
51 pthread_join(pthread_t thread, void **value_ptr)
53 return do_lunaix_syscall(__SYSCALL_th_join, thread, value_ptr);
57 pthread_kill(pthread_t thread, int sig)
59 return do_lunaix_syscall(__SYSCALL_th_kill, thread, sig);
65 return do_lunaix_syscall(__SYSCALL_th_self);