… | |
… | |
210 | perror ("sigaction"); |
210 | perror ("sigaction"); |
211 | abort (); |
211 | abort (); |
212 | } |
212 | } |
213 | |
213 | |
214 | /* set the new stack */ |
214 | /* set the new stack */ |
215 | nstk.ss_sp = STACK_ADJUST_PTR (sptr,ssize); /* yes, some platforms (IRIX) get this wrong. */ |
215 | nstk.ss_sp = STACK_ADJUST_PTR (sptr, ssize); /* yes, some platforms (IRIX) get this wrong. */ |
216 | nstk.ss_size = STACK_ADJUST_SIZE (sptr,ssize); |
216 | nstk.ss_size = STACK_ADJUST_SIZE (sptr, ssize); |
217 | nstk.ss_flags = 0; |
217 | nstk.ss_flags = 0; |
218 | |
218 | |
219 | if (sigaltstack (&nstk, &ostk) < 0) |
219 | if (sigaltstack (&nstk, &ostk) < 0) |
220 | { |
220 | { |
221 | perror ("sigaltstack"); |
221 | perror ("sigaltstack"); |
… | |
… | |
305 | *--ctx->sp = (char *)sptr + ssize; /* StackBase */ |
305 | *--ctx->sp = (char *)sptr + ssize; /* StackBase */ |
306 | *--ctx->sp = sptr; /* StackLimit */ |
306 | *--ctx->sp = sptr; /* StackLimit */ |
307 | #endif |
307 | #endif |
308 | |
308 | |
309 | ctx->sp -= NUM_SAVED; |
309 | ctx->sp -= NUM_SAVED; |
|
|
310 | memset (ctx->sp, 0, sizeof (*ctx->sp) * NUM_SAVED); |
310 | |
311 | |
311 | # elif CORO_UCONTEXT |
312 | # elif CORO_UCONTEXT |
312 | |
313 | |
313 | getcontext (&(ctx->uc)); |
314 | getcontext (&(ctx->uc)); |
314 | |
315 | |
… | |
… | |
402 | args.arg = arg; |
403 | args.arg = arg; |
403 | args.self = ctx; |
404 | args.self = ctx; |
404 | args.main = &nctx; |
405 | args.main = &nctx; |
405 | |
406 | |
406 | pthread_attr_init (&attr); |
407 | pthread_attr_init (&attr); |
|
|
408 | #if __UCLIBC__ |
|
|
409 | /* exists, but is borked */ |
|
|
410 | /*pthread_attr_setstacksize (&attr, (size_t)ssize);*/ |
|
|
411 | #else |
407 | pthread_attr_setstack (&attr, sptr, (size_t)ssize); |
412 | pthread_attr_setstack (&attr, sptr, (size_t)ssize); |
|
|
413 | #endif |
408 | pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); |
414 | pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); |
409 | pthread_create (&ctx->id, &attr, coro_init, &args); |
415 | pthread_create (&ctx->id, &attr, coro_init, &args); |
410 | |
416 | |
411 | coro_transfer (args.main, args.self); |
417 | coro_transfer (args.main, args.self); |
412 | } |
418 | } |