Gcc 1.26 available for anonymous Internet FTP

Alex S. Crain alex at umbc3.UMD.EDU
Tue Dec 6 10:40:18 AEST 1988


In article <10628 at stb.UUCP> michael at stb.UUCP (Michael) writes:

>W h a t ? Setjmp/longjmp take a jmpbuf as an argument; in every 68000 system
>I've seen, this is an array big enough to store a movem d0-d7/a0-a6 (13
>longs). So a setjmp/longjmp can (and do elsewhere) save registers and
>register variables.
>
>Or am I missing what you mean by saving register variables?

	Sorry, I wasn't very clear.
	From the GCC internals document....

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

When you use setjmp and longjmp, the only automatic
variables guaranteed to remain valid are those declared
volatile.  This is a consequence of automatic register
allocation.  Consider this function:

jmp_buf j;

foo ()
{
  int a, b;

  a = fun1 ();
  if (setjmp (j))
    return a;

  a = fun2 ();
  /* longjmp (j) may be occur in fun3.} */
  return a + fun3 ();
}


Here a may or may not be restored to its first value when the
longjmp occurs.  If a is allocated in a register, then
its first value is restored; otherwise, it keeps the last value stored
in it.

If you use the -W option with the -O option, you will
get a warning when GNU CC thinks such a problem might be possible.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-- 
					:alex.
					Systems Programmer
nerwin!alex at umbc3.umd.edu		UMBC
alex at umbc3.umd.edu



More information about the Unix-pc.general mailing list