--- //depot/vendor/freebsd/src/lib/libthr/arch/i386/i386/_setcurthread.c 2003/03/31 20:07:00 +++ //depot/user/jake/thr/src/lib/libthr/arch/i386/i386/_setcurthread.c 2003/04/02 01:02:09 @@ -27,6 +27,7 @@ */ #include +#include #include @@ -66,7 +67,7 @@ } void * -_set_curthread(void *thr) +_set_curthread(ucontext_t *uc, void *thr) { union descriptor desc; void **ldt_entry; @@ -116,7 +117,10 @@ /* * Set up our gs with the index into the ldt for this entry. */ - _set_gs(LSEL(ldt_index, SEL_UPL)); + if (uc != NULL) + uc->uc_mcontext.mc_gs = LSEL(ldt_index, SEL_UPL); + else + _set_gs(LSEL(ldt_index, SEL_UPL)); return (ldt_entry); } --- //depot/vendor/freebsd/src/lib/libthr/arch/sparc64/sparc64/_setcurthread.c 2003/04/02 00:36:37 +++ //depot/user/jake/thr/src/lib/libthr/arch/sparc64/sparc64/_setcurthread.c 2003/04/02 01:02:09 @@ -48,9 +48,12 @@ } void * -_set_curthread(struct pthread *thread) +_set_curthread(ucontext_t *uc, struct pthread *thread) { - _curthread = thread; + if (uc != NULL) + uc->uc_mcontext.mc_global[6] = (uint64_t)thread; + else + _curthread = thread; return (NULL); } --- //depot/vendor/freebsd/src/lib/libthr/thread/thr_create.c 2003/04/01 19:35:55 +++ //depot/user/jake/thr/src/lib/libthr/thread/thr_create.c 2003/04/02 01:02:09 @@ -116,7 +116,8 @@ getcontext(&new_thread->ctx); new_thread->ctx.uc_stack.ss_sp = new_thread->stack; new_thread->ctx.uc_stack.ss_size = pattr->stacksize_attr; - makecontext(&new_thread->ctx, _thread_start, 1, new_thread); + makecontext(&new_thread->ctx, _thread_start, 0); + new_thread->arch_id = _set_curthread(&new_thread->ctx, new_thread); /* Copy the thread attributes: */ memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); @@ -208,12 +209,11 @@ } void -_thread_start(pthread_t thread) +_thread_start(void) { - thread->arch_id = _set_curthread(thread); /* Run the current thread's start routine with argument: */ - pthread_exit(thread->start_routine(thread->arg)); + pthread_exit(curthread->start_routine(curthread->arg)); /* This point should never be reached. */ PANIC("Thread has resumed after exit"); --- //depot/vendor/freebsd/src/lib/libthr/thread/thr_init.c 2003/04/01 19:35:55 +++ //depot/user/jake/thr/src/lib/libthr/thread/thr_init.c 2003/04/02 01:02:09 @@ -219,7 +219,7 @@ PANIC("Cannot allocate memory for initial thread"); } _thread_initial = pthread; - pthread->arch_id = _set_curthread(pthread); + pthread->arch_id = _set_curthread(NULL, pthread); /* Zero the initial thread structure: */ memset(pthread, 0, sizeof(struct pthread)); --- //depot/vendor/freebsd/src/lib/libthr/thread/thr_private.h 2003/04/01 19:35:55 +++ //depot/user/jake/thr/src/lib/libthr/thread/thr_private.h 2003/04/02 01:02:09 @@ -686,7 +686,7 @@ void _cond_wait_backout(pthread_t); int _find_thread(pthread_t); pthread_t _get_curthread(void); -void *_set_curthread(struct pthread *); +void *_set_curthread(ucontext_t *, struct pthread *); void _retire_thread(void *arch_id); void *_thread_stack_alloc(size_t, size_t); void _thread_stack_free(void *, size_t, size_t); @@ -720,7 +720,7 @@ void _thread_init(void); void _thread_sig_wrapper(int sig, siginfo_t *info, ucontext_t *context); void _thread_printf(int fd, const char *, ...); -void _thread_start(pthread_t); +void _thread_start(void); void _thread_seterrno(pthread_t, int); pthread_addr_t _thread_gc(pthread_addr_t); void _thread_enter_cancellation_point(void);