The setjmp () function saves the contents of most general registers in the same way as they will be stored in any function entry. It also stores the stack pointer and return address. All of them are buffered. Then it arranges the function to return zero.
The longjmp () function restores the general registers and the stack pointer, and then jumps to the previously saved return address. In practice, this can be done explicitly, or by setting the stack and performing the normal return function. In this case, the function returns a nonzero value.
The principle is the same, but the details have slightly changed across the many different processors that I have encountered.
david.pfx
source share