This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: I want my FPE!


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]