🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #13039

Re: subroutine frequency

#13039
From: faustus
Date: Sun, 22 Feb 1987 03:03
28 lines
1263 bytes
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
Technical Details
Message-ID: <1284@ucbcad.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!ames!ucbcad!faustus
References: <1881@homxc.UUCP> <898@moscom.UUCP> <476@mntgfx.MENTOR.COM> <4160@utcsri.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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