From owner-freebsd-arch Mon Jan 7 15:32: 2 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id BFCBD37B400 for ; Mon, 7 Jan 2002 15:31:53 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id KAA06184; Tue, 8 Jan 2002 10:31:30 +1100 Date: Tue, 8 Jan 2002 10:32:11 +1100 (EST) From: Bruce Evans X-X-Sender: To: Daniel Eischen Cc: Nate Williams , Dan Eischen , Peter Wemm , Archie Cobbs , Alfred Perlstein , Subject: Re: Request for review: getcontext, setcontext, etc In-Reply-To: Message-ID: <20020108100855.D2662-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 7 Jan 2002, Daniel Eischen wrote: > If you have a call to a function in the middle of doing > some FP stuff, that function itself could do a slew of > other FP calculations: > > /* FP munch */ > foo_fp_munch_lots_more(); > /* FP munch some more */ > > What guarantees do you have that the FP state is restored > to where it was prior to calling foo_fp_munch_lots_more()? The compiler must arrange to preserve sufficient FP state across normal function calls, just like it must do for non-FP state. This may be a very machine-dependent subset of the full FP state. On i386's, only the control word and the tag word are normally preserved across (application) functions. In C99, the control word may be changed by functions in the feset*() family. The scope of these changes is not completely clear, but since the functions are functions, it is clear that not all functions preserve the control word. The tag word conventionally must say that all FP registers are free on entry to a function call and keep saying this if function doesn't return an FP result; OTOH, if the function returns an FP result, then that result will be in a register and the tag for that register will change). The i386 setjmp()/longjmp() takes advantage of this to only preserve the control word explicitly. It doesn't completelty understand the feset*() family yet. Neither do I :-). My current understanding is that longjmp() must _not_ undo the effects of feset*(). This is not easy to implement, since longjmp() must restore any FP state that set temporarily (e.g., changes of the rounding mode for conversion from FP to integer). The tag word is preserved automatically since neither setjmp() nor longjmp returns an FP result. OTOH, asynchronous function calls (signal handlers) need to preserve the full state. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message