From mboxrd@z Thu Jan 1 00:00:00 1970 From: dmr@plan9.bell-labs.com (Dennis Ritchie) Date: Tue, 25 Mar 2003 00:14:53 -0500 Subject: [pups] V7 setjmp/longjmp Message-ID: <8b42de71c97729c28a22c46456004471@plan9.bell-labs.com> 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 volatile. We've been through this before. Dennis