News for hackers. Stuff that matters.
Re:Coroutines in C with Arbitrary Arguments by userbinator on Sunday April 19, 2015 @07:52AM (#9402820)
It should be possible to do this without malloc(), by allocating the co-stack as an array within the current stack. Something like this...

    char stack[STACK_SIZE];
    int anchor_[unoptimisable_];
    char filler_[(char*)&anchor_ - (char*)(stack + STACK_SIZE)];
    ...
(Haven't tested it, but it's basically the same principle. The same caveats about stack layout and VLAs apply.)
Re:Coroutines in C with Arbitrary Arguments by rumcajz on Sunday April 19, 2015 @09:10AM (#9402992)
Except that if the parent function terminated before the coroutine it have launched, you would get memory overwrites.
Re:Coroutines in C with Arbitrary Arguments by mtanski on Sunday April 19, 2015 @09:46AM (#9403104)
You would also need to align the stack per. target requirements (gcc keyword, or offset the address). The aliment guarantees for char[] placed on stack are probably insufficient for many machines.
Re:Coroutines in C with Arbitrary Arguments by userbinator on Sunday April 19, 2015 @10:08AM (#9403174)
If none of the variables on the stack are smaller than your desired alignment size, and the stack starts out aligned (which it should), then it will remain aligned.