Ambiguity in definition of setjmp/longjmp makes them much less useful
Henry Spencer
henry at zoo.toronto.edu
Wed Oct 17 02:36:48 AEST 1990
In article <1990Oct15.174203.21441 at bbt.se> pgd at bbt.se writes:
>>... The original pdp11 C compiler had a predictable stack-frame format
>>and could do stack unravelling right.
>
>I am not 100% sure of this, but I think that the original C library
>just restored some registers without any fancy unravelling. (r5,sp,pc).
It restored r2-r4 as well, necessarily, since they were the programmer's
register variables. This was done by unravelling the stack, looking
for a frame whose address was equal to the saved frame pointer (r5),
and then, more or less, restoring the three registers you mention *and*
doing a return, which unstacked r2-r4. The stack unravelling was pretty
simple, because the format was fixed and every call saved r2-r4. So
it really was quite straightforward to get it right.
>It also kept all variables, except for register variables, in memory.
That's what the "register" keyword was for, after all.
>The original c-library also had nargs()...
Well, it depends on how "original" we are talking about. Nargs() had
vanished by the time setjmp()/longjmp() appeared in their definitive form,
in V7. It was always of somewhat doubtful usefulness, given the presence
of datatypes of different sizes.
--
"...the i860 is a wonderful source | Henry Spencer at U of Toronto Zoology
of thesis topics." --Preston Briggs | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list