1*43511Sbostic /* reset.c 4.2 90/06/23 */ 213496Ssam 313496Ssam /* 4*43511Sbostic * This can't be written in C. You have to longjmp from a context 5*43511Sbostic * below (stackwise) the call to setjmp: 6*43511Sbostic * 7*43511Sbostic * /* test reset/setexit *(/ 8*43511Sbostic * main() 9*43511Sbostic * { 10*43511Sbostic * int i = setexit(); 11*43511Sbostic * printf("i=%d\n", i); 12*43511Sbostic * if (i == 0) 13*43511Sbostic * reset(1); 14*43511Sbostic * } 15*43511Sbostic * 16*43511Sbostic * The above prints `longjmp botch' and dumps core. 17*43511Sbostic */ 18*43511Sbostic 19*43511Sbostic /* 2013496Ssam * Backwards compatible setexit/reset. 2113496Ssam */ 2213496Ssam #include <setjmp.h> 2313496Ssam 2413496Ssam static jmp_buf save; 2513496Ssam setexit()2613496Ssamsetexit() 2713496Ssam { 2813496Ssam 2913496Ssam return (setjmp(save)); 3013496Ssam } 3113496Ssam reset(x)3213496Ssamreset(x) 3313496Ssam { 3413496Ssam 3513496Ssam longjmp(save, x); 3613496Ssam } 37