Re:Coroutines in C with Arbitrary Arguments
by rumcajz on Sunday April 19, 2015 @06:16AM
(#9402632)
It uses dynamically allocated array (char filler_[...]) to shift stack pointer to arbitrary memory address. If it doesn't work with your compiler you may try to use alloca() instead.
[ Parent
| on HN ]
Here's my implementation in c++, using alloca(): https://github.com/jaroslov/coro. Without debugger support, coroutines are pretty difficult to work with.
Oh I see, it moves the stack pointer so it coincides with the heap allocated memory?
I like articles that combine hacking and C, but this one really needs more explanation.
This article is really about the arguments to the coroutine. The original idea for shifting the stack pointer comes from here: http://fanf.livejournal.com/105413.html