Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site idis.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!idis!george From: george@idis.UUCP Newsgroups: net.lang.c Subject: Re: setjmp: read the manual(long article) Message-ID: <315@idis.UUCP> Date: Thu, 25-Oct-84 11:53:07 EST Article-I.D.: idis.315 Posted: Thu Oct 25 11:53:07 1984 Date-Received: Sun, 28-Oct-84 06:17:21 EST References: <363@tjalk.UUCP> Organization: University of Pittsburgh Lines: 41 I suggest that anyone seriously interested in setjmp/longjmp read the section titled "unwinding" from BTL CSTR #102, "The C Language Calling Sequence", by S. C. Johnson and D. M. Ritchie. Perhaps Dennis Ritchie could post that section. If anyone is going to implement a routine that has behavior different from "longjmp" (as described in the tech. report or UNIX V7 manuals) then it would be prudent to name it something other than "longjmp". Hans van Staveren wrote: > General solution, all machines, Amsterdam Compiler Kit: ... > Well here it is. Have the C-frontend recognize the word > setjmp. In a function containing a call to setjmp save all > registers, use none, and at the end restore them all. At > longjmp time just close your eyes and jump, no registers > need be restored except the frame pointer, stack pointer and > program counter. This means that functions not using > setjmp/longjmp are not bothered, in general the compiler can > continue its fancy register optimizations and all programs > will run correct. There is a minor problem with this. Since one can have an undefined extern pointer to a function, or a pointer to a function passed as an argument, one may need to pessimize all calls from some functions that do not explicitly call "setjmp". Thus contrary to what Hans claimed, some functions not using setjmp/longjmp are bothered. Presumably these do not occur too frequently in practice. Some programs not using setjmp/longjmp are also bothered. (I also believe I have heard that the Amsterdam compilers can cheat by looking at the source for undefined extern objects, although I do not know if it does so in the above instances.) George Rosenberg duke!mcnc!idis!george decvax!idis!george