setjmp/longjmp

Fletcher Kittredge fkittred at bbn.com
Fri Apr 28 04:04:03 AEST 1989


In article <12491 at ut-emx.UUCP> clyde at ut-emx.UUCP (Clyde W. Hoover) writes:
>
>	Well, we ran headlong into that very problem ourselves.  What is
> going on is that the Encore C compiler puts variables into registers
> (making the 'register' declaration somewhat superflous).

This is common behavior for any optimizing compiler.  For instance,
the compilers for the RISC chips for Sun, HP and MIPS do this.  Compilers
can do a better job than humans in figuring out which variables should
be in registers.

>  Upon longjmp,
> the contents of the registers are restored to what they were at the time
> of the call to setjmp and since your flag has been stuffed into a register,
> it is being reset.

Again, this is standard behavior umong modern CPUs and Unix implementations.
I have found this behavior in DEC, HP and Sun systems.  Both document this
behavior, and it appears to me that ANSI C and Posix both require this
behavior.

regards,
fletcher


Fletcher E. Kittredge  fkittred at bbn.com



More information about the Comp.std.c mailing list