X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b60166b327a9108b07e3069fa6568a451529ffd9..7909fc6dec8d1499c5b9fa331a810a77b08c84a2:/lunaix-os/usr/libc/src/pthread.c?ds=sidebyside diff --git a/lunaix-os/usr/libc/src/pthread.c b/lunaix-os/usr/libc/src/pthread.c index 08c82e0..26d6abf 100644 --- a/lunaix-os/usr/libc/src/pthread.c +++ b/lunaix-os/usr/libc/src/pthread.c @@ -1,37 +1,21 @@ #include #include -static void* -__pthread_routine_wrapper(void *(*start_routine)(void*), void* arg) -{ - void* ret = start_routine(arg); - - do_lunaix_syscall(__SYSCALL_th_exit, ret); - - return ret; // should not reach -} - int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void *(*start_routine)(void*), void* arg) { // FIXME attr currently not used + int ret; + struct uthread_param th_param; - struct uthread_info th_info; - int ret = do_lunaix_syscall(__SYSCALL_th_create, thread, &th_info, __pthread_routine_wrapper, NULL); - - if (ret) { - return ret; - } - - // FIXME we should encapsulate these parameter into struct - // and pass it as a single thread param. - - void** th_stack = (void**) th_info.th_stack_top; - th_stack[1] = (void*)start_routine; - th_stack[2] = arg; + th_param.th_handler = start_routine; + th_param.arg1 = arg; + extern void th_trampoline(); + ret = do_lunaix_syscall(__SYSCALL_th_create, thread, + &th_param, th_trampoline); return ret; }