[pups] V7 setjmp/longjmp

Michael Davidson michael_davidson at pacbell.net
Wed Jan 1 02:02:37 AEST 2003


Wolfgang Helbig wrote:

>Michael Davidson distrusted:
>
>>Note that this means that r4, r3 and r2 get restored to the values
>>that they had at the time that the next stack frame was established
>>(ie when the "next" function down was called from the original context)
>>and that these are not necessarily the values that they had at the
>>moment when the original call to setjnp returned. Hence the various
>>caveats about not relying on the value of any register variables
>>after returning via longjmp.
>>
>
>You can trust register variables when setjmp() returns the second time. Then
>the registers are restored to the values they had when the "next" function was 
>called, that is the "values as of the time longjmp() was called" (quoted from
>longjmp(3)'s man page. Thus any variable behaves the same, regardless of its
>storage class.
>
Yes, you are right - V7 restores the register variables to a state which
is consistent with the other auto variables in the function - ie the value
which they had when longjmp was called.

The caveats about not relying on register variables applied to V6.





More information about the TUHS mailing list