1 #include <errno.h> 2 #include "stdarg.h" 3 #include "stdbool.h" 4 #include "pthread_impl.h" 5 6 struct user_param { 7 unsigned long user_area; 8 unsigned long user_sp; 9 unsigned long map_base; 10 unsigned int map_size; 11 }; 12 __thread_clone(int (* func)(void *),int flags,struct pthread * thread,unsigned char * sp)13int __thread_clone(int (*func)(void *), int flags, struct pthread *thread, unsigned char *sp) 14 { 15 int ret; 16 bool join_flag = false; 17 struct user_param param; 18 19 if (thread->detach_state == DT_JOINABLE) { 20 join_flag = true; 21 } 22 23 param.user_area = TP_ADJ(thread); 24 param.user_sp = sp; 25 param.map_base = thread->map_base; 26 param.map_size = thread->map_size; 27 ret = __syscall(SYS_create_user_thread , func, ¶m, join_flag); 28 if (ret < 0) { 29 return ret; 30 } 31 32 thread->tid = (unsigned long)ret; 33 return 0; 34 } 35