Path: utzoo!attcan!uunet!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: Ambiguity in definition of setjmp/longjmp makes them much less useful Message-ID: Date: 11 Oct 90 18:37:19 GMT References: <1597@redsox.bsw.com> <1990Oct09.143521.24019@unx.sas.com> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 33 In-reply-to: sasrer@unx.sas.com's message of 9 Oct 90 14:35:21 GMT In article <1990Oct09.143521.24019@unx.sas.com> sasrer@unx.sas.com (Rodney Radford) writes: | In article <1597@redsox.bsw.com> campbell@redsox.bsw.com (Larry Campbell) writes: | >My real question is this: Why not define the behavior of setjmp/longjmp so | >that the values of ALL local variables are defined, whether or not they've | >been allocated to registers? Otherwise, setjmp/longjmp are significantly | >less useful. | | The reason for the ambiguity is because ANSI chose not to make setjmp/longjmp | functions known by the C compiler so that it just treats them just like any | other functions (ie: does not force local automatics values from registers | to storage). ANSI chose not to make any of the functions special case so | that an application may redefine the functions (although this is frowned upon | in some cases). The setjmp/longjmp functions themselves do not have the | required information to force the values from the registers, so we are stuck | with this oddity. In some implementations, setjmp could easily get the information if it so desired. For example on systems that use MIPS chips (MIPS, SGI, DECstation, etc.), there is a side table that contains the information for each function on what registers in the preserved register set are saved and where they are saved, how to calculate the virtual frame pointer, etc. The table can be made to appear in memory by emitting a specific external. The 88k computers have a similar facility, though the table is always in memory. Longjmp could unwind each stack frame, and reset the registers until it got back to where it should be, but that is usually too hard to justify doing to management! -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Do apple growers tell their kids money doesn't grow on bushes?