Subject: RE: Current news on b17 release
From: [email-masked] (Sean McNeil)

6 Jan 1997 19:54:11 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "[email-masked]" <[email-masked]>,
        "'Geoffrey Noer'"
	 <[email-masked]>
Original-Sender: [email-masked]

The FPU for the x86 is not getting initialized properly for IEEE floating point use.
This causes innaccuracy in some FP code I have been investigating.  The following
crt0.c provides the necessary work:

#ifdef __PPC__
/* For the PowerPC, we want to make this function have its structured
   exception table exception function point to something we control.  */

extern void __cygwin_exception_handler();
extern void mainCRTStartup(void) __attribute__((__exception__(__cygwin_exception_handler)));
#endif

#ifdef __i386__
#define FPU_RESERVED 0xF0C0
#define FPU_DEFAULT  0x033f

/* For debugging on *#!$@ windbg.  bp for breakpoint.  */
int __cygwin_crt0_bp = 0;
#endif

void
mainCRTStartup ()
{
#ifdef __i386__
  if (__cygwin_crt0_bp)
    asm volatile ("int3");

  {
    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));
  }
#endif

  cygwin_crt0 ();
}

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".