setjmp/longjmp

DAVID DYER-BENNET MRO1-2/L14 DTN 231-4076 ddb at mrvax.DEC
Thu Oct 25 01:33:23 AEST 1984


I will propose a semantics for setjmp/longjmp that is compiler-independent,
implementable in a not-too-bad worst-case way on all machines with which
I am familiar, and reasonably consistent with current implementations.

I see in previous articles enough information to convince me that we can't
ask that all local variables by restored in longjmp to their values at the
time of the setjmp, or to their last value in the routine containing the
setjmp.  If there is a way to achieve this that is affordable, I'd far
prefer it to my proposal.

So the problem comes down to characterizing which variables will be
restored, and which will have random values.  I propose that only
variables not altered since the setjmp call be guaranteed restored; other
variables will have random values (not necessarily their last set value,
the value they had at the time of the setjmp, or anything else).
This is obviously achievable by simply saving and restoring all registers
at setjmp/longjmp; on some hardware considerable improvements in this can
be made.  

So, is this enough to be useful?  And, is more achievable transportably?

I don't see how to achieve more transportably; if someone can, good.

I find this enough to be useful, but only marginally.  It is at least
fairly easy to know what I can count on.  I consider a little bit that
I can count on better than a lot that isn't there when I need it.

			-- David Dyer-Bennet
			-- ...decwrl!dec-rhea!dec-mrvax!ddb



More information about the Comp.lang.c mailing list