Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!bu-cs!mirror!rayssd!srhqla!csun!polyslo!cquenel From: cquenel@polyslo.CalPoly.EDU (101 more school days) Newsgroups: comp.lang.c Subject: Re: Behaviour of setjmp/longjmp and registers Message-ID: <7249@polyslo.CalPoly.EDU> Date: 23 Jan 89 04:51:19 GMT References: <25@torsqnt.UUCP> <8867@bloom-beacon.MIT.EDU> <7222@polyslo.CalPoly.EDU> <8812@alice.UUCP> Reply-To: cquenel@polyslo.CalPoly.EDU (101 more school days) Organization: Blue Blaze Irregulars Lines: 51 I write: > Should it ever be necessary/desirable to restore any registers > on a long-jump BESIDES the frame-pointer and/or stack-pointer ? Andrew Koenig explains: [at one time VAX implementations would restore "register" variables] [this was arguably useful.] I see this as a BAD thing to try to guarantee. I agree with the way ANSI did it. To the best of my understanding the "register" storage class has always been a "hint" to the compiler. Since many modern compilers will fairly often out-right ignore these hints, it makes the use of this feature EXTREMELY unportable at best. Consider a very straight-forward example: I use this restoral feature to restore a register variable through a longjump. How many variables can I restore this way ? How many registers variables can I effectively use ? Depending on a "register" variable to actually BE in a register is (as far as I'm concerned) a BAD thing. I hope there weren't too many people who were in favor of this in the ANSI committees. Since setjmp/longjmp is such a work-around/violate-all-the-rules/ just-get-me-the-f*ck-back-to-where-I-started/ sorta feature, (That is to say, a LAST RESORT, to be used almost exclusively in system dependant routines.) I would say that it SHOULDN'T actually restore anything. If you need anything to be restored, then save it yourself when you do a setjump in a volatile variable. I think this newer definition of setjmp/longjmp is much cleaner and provides only what is necessary and most useful. As a compiler writer, it certainly makes sense to me to only implement what can be guaranteed. That is, to provide well-defined services that can be relied on, and don't provide anything that might/might-not work. Comments anyone ? --chris If you understand what you're doing, you're not learning anything. ------------------------------------------------------------------------------- | Nothing the God of Bio-Mechanics wouldn't let you in heaven for ? | ------------------------------------------------------------------------------- | Chris Quenelle | Smart Mailers -> cquenel@polyslo.CalPoly.EDU | | Computer Systems Lab | Dumb Mailers -> !ucbvax!voder!polyslo!cquenel | | Cal Poly State Univ. |-------------------------------------------------| | San Luis Obispo, CA 93407 | On a clear disk you can seek forever. | -------------------------------------------------------------------------------