On Tue, Feb 19, 2008 at 10:05:07AM -0800, Bob La Quey wrote:
setjmp in C lets you get out of the stack, but not back to where you were.
The stack is saved in the environment. Doesn't that let you get back to
where you were?
Except that the "saved" stack is actively being overwritten by the code
that is now running. Longjmp doesn't create a new stack, just remembers
where in the stack you were. C only supports longjmp "outward" in the call
chain. You can't go back to where you were. Doing that requires trickery
with alternate stacks.
Have a look at <http://en.wikipedia.org/wiki/Coroutine> to see what's
necessary. There is a section on how to do coroutines in C.
David
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg