4 ms·
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
by rumcajz 12y ago
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.
- ehmmm 12y agoOh 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.
- rumcajz 12y agoThis 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 http://fanf.livejournal.com/105413.html
- thechao 12y agoHere's my implementation in c++, using alloca(): https://github.com/jaroslov/coro https://github.com/jaroslov/coro. Without debugger support, coroutines are pretty difficult to work with.