Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Ambiguity in definition of setjmp/longjmp makes them much less useful Message-ID: <1990Oct16.163648.559@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1597@redsox.bsw.com> <1990Oct09.143521.24019@unx.sas.com> <1990Oct10.152659.6334@zoo.toronto.edu> <1990Oct15.174203.21441@bbt.se> Date: Tue, 16 Oct 90 16:36:48 GMT In article <1990Oct15.174203.21441@bbt.se> pgd@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@zoo.toronto.edu utzoo!henry