This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: I want my FPE!
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 17 Sep 2009 21:36:47 +0100
- Subject: Re: I want my FPE!
- References: <loom.20090917T213422-417@post.gmane.org>
Mark Geisert wrote:
> Is there something I need to do to "condition" the Cygwin environment to
> generate FP exceptions? I saw the code in winsup/something/or/other to map x86
> FP exceptions to SIGFPE but it seems somehow the exceptions aren't being
> generated in the first place.
Very possibly not. There's probably a bit in the FPUCW you need to set or
something. Ah, yes: see winsup/cygwin/crt0.c:
> /* In the following ifdef'd i386 code, the FPU precision is set to 80 bits
> and all FPU exceptions are masked. The former is needed to make long
> doubles work correctly. The latter causes the FPU to generate NaNs and
> Infinities instead of signals for certain operations.
> */
> #define FPU_RESERVED 0xF0C0
> #define FPU_DEFAULT 0x033f
> {
> volatile unsigned short cw;
>
> /* Get Control Word */
> __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
>
> /* mask in */
> cw &= FPU_RESERVED;
> cw |= FPU_DEFAULT;
>
> /* set cw */
> __asm__ volatile ("fldcw %0" :: "m" (cw));
> }
You can copy and paste that hunk into your own main() and change the
constants to anything you like.
cheers,
DaveK
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple