Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!ames!ucbcad!faustus From: faustus@ucbcad.UUCP Newsgroups: comp.arch Subject: Re: subroutine frequency Message-ID: <1284@ucbcad.berkeley.edu> Date: Sat, 21-Feb-87 22:03:16 EST Article-I.D.: ucbcad.1284 Posted: Sat Feb 21 22:03:16 1987 Date-Received: Sun, 22-Feb-87 07:48:04 EST References: <1881@homxc.UUCP> <898@moscom.UUCP> <476@mntgfx.MENTOR.COM> <4160@utcsri.UUCP> Organization: CAD Group, U.C. Berkeley Lines: 28 Keywords: register stack frame variable In article <4160@utcsri.UUCP>, greg@utcsri.UUCP (Gregory Smith) writes: > jmp_buf env; > > main(){ > register int i; > int j; > i = j = 1; > if(setjmp(env)){ > printf( "i==%d, j==%d\n", i, j ); > exit(0); > } > i = j = 2; > func(); > } > > func(){ > longjmp( env, 1 ); > } > > The above program should ideally report that i=2. Certainly it will say > that j is 2. If i is saved in the jmp_buf, and restored by longjmp, > then i will be reported as 1. Put a "register int k = 3" in func() -- the program had better not say that i is 3. It shouldn't be hard for setjmp() to restore the registers from the stack frame, as opposed to from the jmp_buf. Wayne