Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!decvax!cca!ima!ism780b!jim
From: jim@ism780b.UUCP
Newsgroups: net.lang.c
Subject: Re: Re: What is the setjump call - (nf)
Message-ID: <52@ism780b.UUCP>
Date: Wed, 10-Oct-84 00:22:20 EDT
Article-I.D.: ism780b.52
Posted: Wed Oct 10 00:22:20 1984
Date-Received: Fri, 12-Oct-84 03:47:13 EDT
Lines: 34

#R:apollo:-22099700:ism780b:25500028:000:815
ism780b!jim    Oct  7 16:58:00 1984

#include 

jmp_buf jmpbuf;

main()
{
	/* register */ int i;

	i = 0;
	setjmp(jmpbuf);
	for( ;; i++ )
	    foo(i);

	printf("%d\n", i);
}
foo(i)
{
	if( i == 5 ) longjmp(jmpbuf, 1);
}

If you get 5 from the above, but 0 if you remove the /* */,
your setjmp/longjmp is BROKEN!!  It should always give 5.
Note that the manual says that all data have values as of the time
*longjmp* was called, not as of the time the setjmp was called
(which is unimplementable; why do you get 5 instead of 0 in the above?).
To do this, longjmp must unwind the stack, restoring registers
as it goes.  Note that this only requires jmp_buf to have 3 words, instead
of the brain-damaged 10 in the 4.1 implementation, where the registers
are saved at setjmp time, which is all wrong.

-- Jim Balter, INTERACTIVE Systems (ima!jim)