diff options
Diffstat (limited to 'src/libthread/thread.c')
-rw-r--r-- | src/libthread/thread.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 550cc056..2b6d1e37 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -112,12 +112,19 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask); /* must initialize with current context */ - getcontext(&t->context.uc); + if(getcontext(&t->context.uc) < 0) + sysfatal("threadalloc getcontext: %r"); /* call makecontext to do the real work. */ /* leave a few words open on both ends */ t->context.uc.uc_stack.ss_sp = t->stk+8; t->context.uc.uc_stack.ss_size = t->stksize-64; +#ifdef __sun__ /* sigh */ + /* can avoid this with __MAKECONTEXT_V2_SOURCE but only on SunOS 5.9 */ + t->context.uc_stack.ss_sp = + (char*)t->context.uc_stack.ss_sp + +t->context.uc_stack.ss_size; +#endif makecontext(&t->context.uc, (void(*)())threadstart, 1, t); return t; |