[pups] V7 setjmp/longjmp

Dennis Ritchie dmr at plan9.bell-labs.com
Tue Mar 25 15:14:53 AEST 2003

Helbig remarked (quoting Davidson):

 > >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.

 > Nope, even in V6, register variables are restored to the values they had
 > when reset(III) was called! (reset() is the name of longjmp() in V6).
 > By the way, reset() is much smaller than longjmp() but provides the same
 > functionality.

 > I wonder why longjmp() was rewritten.

Setjmp/longjmp do more (setjmp returns different values
for the initial call and the longjmp-invoked one).
But the thing that would become more important
is that the PDP-11 compiler's calling sequence was
especially friendly toward restoring register values--
it just worked automatically.

Other machines and compilers were not so friendly.
This is why ANSI and ISO had to put in special rules
about promising to preserve only things marked

We've been through this before.


More information about the TUHS mailing list