delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/06/19:54:11

From: sean AT mcneil DOT com (Sean McNeil)
Subject: RE: Current news on b17 release
6 Jan 1997 19:54:11 -0800 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <01BBFC03.19813460.cygnus.gnu-win32@mcneil.mcneil.com>
Mime-Version: 1.0
Original-To: "gnu-win32 AT cygnus DOT com" <gnu-win32 AT cygnus DOT com>,
"'Geoffrey Noer'"
<noer AT cygnus DOT com>
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019