aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2002-04-16 09:02:35 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2002-04-16 09:02:35 +0000
commit7211acadc0a5b3d1a341e91a6c1eff8f993b81a0 (patch)
treee008603b97b5bca7a55d3e4bd4ca03829e2d53f8 /winsup
parentc3b9aa576b88bec984dd3e7b7a20421d7ea4e173 (diff)
downloadnewlib-7211acadc0a5b3d1a341e91a6c1eff8f993b81a0.zip
newlib-7211acadc0a5b3d1a341e91a6c1eff8f993b81a0.tar.gz
newlib-7211acadc0a5b3d1a341e91a6c1eff8f993b81a0.tar.bz2
* CRT_fp8.c: New file.
* CRT_fp10.c: New file. * crt1.c (__CRT_PC) Declare. (__CRT_fesetenv): New static function, using _CRT_PC. (__mingw_CRTStartup):Use __CRT_fesetenv instead of _fpreset. (_gnu_exception_handler): Likewise. * Makefile.in (CRT0S): Add CRT_fp10.o. (MINGW_OBJS): Add CRT_fp8.o. (SRCDIST_FILES): Add CRT_fp8.c, CRT_fp10.c. Add CRT_fp8.o, CRT_fp10.o dependancies. * include/float.h (_fpreset): Expand comment. * include/fenv.h (FE_PC64_ENV): New define for Intel x87 (extended precison) environmemt. (FE_PC53_ENV): New define for MSVCRT default environmemt. (FE_DFL_ENV): Define as FE_PC53_ENV. * mingwex/fesetenv.c: Use FE_PC53_ENV, FE_PC64_ENV to determine precision control for default environment. * include/math.h: Fix long comment line. * profile/configure.in (CRT0S): Set to both gcrt1.o and gcrt2.o for mingw. * profile/configure: Regenerate.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/mingw/CRT_fp10.c12
-rw-r--r--winsup/mingw/CRT_fp8.c10
-rw-r--r--winsup/mingw/ChangeLog25
-rw-r--r--winsup/mingw/Makefile.in11
-rw-r--r--winsup/mingw/crt1.c20
-rw-r--r--winsup/mingw/include/fenv.h15
-rw-r--r--winsup/mingw/include/float.h9
-rw-r--r--winsup/mingw/include/math.h6
-rw-r--r--winsup/mingw/mingwex/fesetenv.c55
-rwxr-xr-xwinsup/mingw/profile/configure4
-rw-r--r--winsup/mingw/profile/configure.in4
11 files changed, 132 insertions, 39 deletions
diff --git a/winsup/mingw/CRT_fp10.c b/winsup/mingw/CRT_fp10.c
new file mode 100644
index 0000000..0527aeb
--- /dev/null
+++ b/winsup/mingw/CRT_fp10.c
@@ -0,0 +1,12 @@
+/*
+ * CRT_FP10.c
+ *
+ * This object file defines __CRT_PC to have a value of 10,
+ * which will set default floating point precesion to 64-bit mantissa
+ * at app startup.
+ *
+ * Linking in CRT_FP10.o before libmingw.a will override the value
+ * set by CRT_FP8.o.
+ */
+
+unsigned int __CRT_PC = 10;
diff --git a/winsup/mingw/CRT_fp8.c b/winsup/mingw/CRT_fp8.c
new file mode 100644
index 0000000..d375fef
--- /dev/null
+++ b/winsup/mingw/CRT_fp8.c
@@ -0,0 +1,10 @@
+/*
+ * CRT_FP8.c
+ *
+ * This object file defines __CRT_PC to have a value of 8, which
+ * set default floating point precesion to 53-bit mantissa at app startup.
+ *
+ * To change to 64-bit mantissa, link in CRT_FP10.o before libmningw.a.
+ */
+
+ unsigned int __CRT_PC = 8;
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index 9526dd2..cb9e1fa 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,28 @@
+2002-04-16 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * CRT_fp8.c: New file.
+ * CRT_fp10.c: New file.
+ * crt1.c (__CRT_PC) Declare.
+ (__CRT_fesetenv): New static function, using _CRT_PC.
+ (__mingw_CRTStartup):Use __CRT_fesetenv instead of _fpreset.
+ (_gnu_exception_handler): Likewise.
+ * Makefile.in (CRT0S): Add CRT_fp10.o.
+ (MINGW_OBJS): Add CRT_fp8.o.
+ (SRCDIST_FILES): Add CRT_fp8.c, CRT_fp10.c.
+ Add CRT_fp8.o, CRT_fp10.o dependancies.
+ * include/float.h (_fpreset): Expand comment.
+ * include/fenv.h (FE_PC64_ENV): New define for Intel x87
+ (extended precison) environmemt.
+ (FE_PC53_ENV): New define for MSVCRT default environmemt.
+ (FE_DFL_ENV): Define as FE_PC53_ENV.
+ * mingwex/fesetenv.c: Use FE_PC53_ENV, FE_PC64_ENV to determine
+ precision control for default environment.
+
+ * include/math.h: Fix long comment line.
+ * profile/configure.in (CRT0S): Set to both gcrt1.o and gcrt2.o
+ for mingw.
+ * profile/configure: Regenerate.
+
2002-04-12 Danny Smith <dannysmith@sourceforge.users.net>
* mingwex/Makefile.in (DISTFILES): Add suffix to wcstof.c.
diff --git a/winsup/mingw/Makefile.in b/winsup/mingw/Makefile.in
index 4ebce2b..1f92344 100644
--- a/winsup/mingw/Makefile.in
+++ b/winsup/mingw/Makefile.in
@@ -145,9 +145,10 @@ FLAGS_TO_PASS:=\
TARFLAGS="$(TARFLAGS)" \
TARFILEEXT="$(TARFILEEXT)"
-CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o
+CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
+ CRT_fp10.o
MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \
- main.o crtst.o mthr_stub.o
+ main.o crtst.o mthr_stub.o CRT_fp8.o
MOLD_OBJS = ctype_old.o string_old.o
LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \
@@ -160,7 +161,8 @@ Makefile.in README TODO config.guess config.sub configure configure.in \
crt1.c crtdll.def crtmt.c crtst.c ctype_old.c dllcrt1.c dllmain.c \
gccmain.c init.c install-sh jamfile main.c mkinstalldirs moldname-crtdll.def \
moldname-msvcrt.def moldname.def moldname.def.in msvcrt.def msvcrt20.def \
-msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c
+msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c \
+CRT_fp8.c CRT_fp10.c
all_dlls_host = @all_dlls_host@
install_dlls_host = @install_dlls_host@
@@ -383,6 +385,9 @@ dllmain.o: $(srcdir)/dllmain.c
main.o: $(srcdir)/main.c
oldnames.o: $(srcdir)/oldnames.c
string_old.o: $(srcdir)/string_old.c
+CRT_fp8.o: $(srcdir)/CRT_fp8.c
+CRT_fp10.o: $(srcdir)/CRT_fp10.c
+
Makefile: Makefile.in config.status configure
$(SHELL) config.status
diff --git a/winsup/mingw/crt1.c b/winsup/mingw/crt1.c
index f91f1da..b572c4f 100644
--- a/winsup/mingw/crt1.c
+++ b/winsup/mingw/crt1.c
@@ -61,6 +61,21 @@ __MINGW_IMPORT void __set_app_type(int);
*/
extern unsigned int _CRT_fmode;
+/*
+ * If the user links in CRT_fp10.o or a different object
+ * defining __CRT_PC this will override default FP precison set
+ * in CRT_fp8.o in libmingw.a.
+ */
+extern unsigned int __CRT_PC;
+static inline void
+__CRT_fesetenv (void)
+{
+ if (__CRT_PC == 8)
+ _fpreset();
+ else
+ __asm__ volatile ("fninit");
+}
+
static void
_mingw32_init_fmode ()
{
@@ -136,7 +151,7 @@ _gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
{
signal (SIGFPE, SIG_IGN);
if (reset_fpu)
- _fpreset ();
+ __CRT_fesetenv();
action = EXCEPTION_CONTINUE_EXECUTION;
}
else if (old_handler != SIG_DFL)
@@ -172,7 +187,7 @@ __mingw_CRTStartup ()
/*
* Initialize floating point unit.
*/
- _fpreset (); /* Supplied by the runtime library. */
+ __CRT_fesetenv();
/*
* Set up __argc, __argv and _environ.
@@ -231,4 +246,3 @@ WinMainCRTStartup ()
#endif
__mingw_CRTStartup ();
}
-
diff --git a/winsup/mingw/include/fenv.h b/winsup/mingw/include/fenv.h
index ddc43df..471bdcc 100644
--- a/winsup/mingw/include/fenv.h
+++ b/winsup/mingw/include/fenv.h
@@ -44,9 +44,18 @@ typedef struct
#define FE_TOWARDZERO 0x0c00
-/* The default floating point environment */
-#define FE_DFL_ENV ((const fenv_t *)-1)
-
+/*The C99 standard (7.6.9) allows us to define implementation-specific macros for
+ different fp environments */
+
+/* The default Intel x87 floating point environment (64-bit mantissa) */
+#define FE_PC64_ENV ((const fenv_t *)-1)
+
+/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
+#define FE_PC53_ENV ((const fenv_t *)-2)
+
+/* The FE_DFL_ENV macro is required by standard. *
+/* For now, define the MSVCRT version as default. */
+#define FE_DFL_ENV FE_PC53_ENV
#ifndef RC_INVOKED
#ifdef __cplusplus
diff --git a/winsup/mingw/include/float.h b/winsup/mingw/include/float.h
index 709f369..f24ecb4 100644
--- a/winsup/mingw/include/float.h
+++ b/winsup/mingw/include/float.h
@@ -191,7 +191,14 @@ unsigned int _statusfp (void); /* Report the FPU status word */
#define _clear87 _clearfp
#define _status87 _statusfp
-void _fpreset (void); /* Reset the FPU */
+
+/*
+ _fpreset initializes the control register to 0x27f,
+ the status register to zero and the tag word to 0FFFFh.
+ This differs from asm instruction fninit which sets control
+ word to 0x37f (64 bit mantissa precison rather than 53 bit)
+*/
+void _fpreset (void);
void fpreset (void);
/* Global 'variable' for the current floating point error code. */
diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h
index e8341c3..bc153cb 100644
--- a/winsup/mingw/include/math.h
+++ b/winsup/mingw/include/math.h
@@ -152,7 +152,6 @@ double frexp (double, int*);
double modf (double, double*);
double fmod (double, double);
-
#ifndef __STRICT_ANSI__
/* Complex number (for cabs) */
@@ -379,8 +378,9 @@ extern float truncf (float);
/* fmax and fmin.
- NaN arguments are treated as missing data: if one argument is a NaN and the other numeric, then the
- these functions choose the numeric value.
+ NaN arguments are treated as missing data: if one argument is a NaN
+ and the other numeric, then the these functions choose the numeric
+ value.
*/
extern double fmax (double, double);
diff --git a/winsup/mingw/mingwex/fesetenv.c b/winsup/mingw/mingwex/fesetenv.c
index 3fd7f32..c8f0761 100644
--- a/winsup/mingw/mingwex/fesetenv.c
+++ b/winsup/mingw/mingwex/fesetenv.c
@@ -1,22 +1,33 @@
-#include <fenv.h>
-
-/* 7.6.4.3
- The fesetenv function establishes the floating-point environment
- represented by the object pointed to by envp. The argument envp
- shall point to an object set by a call to fegetenv or feholdexcept,
- or equal the macro FE_DFL_ENV or an implementation-defined environment
- macro. Note that fesetenv merely installs the state of the exception
- flags represented through its argument, and does not raise these
- exceptions. */
-
-int fesetenv (const fenv_t * envp)
-{
- if (envp == FE_DFL_ENV)
-/* fninit initializes the control register to 0x37f,
- the status register to zero and the tag word to 0FFFFh.
- The other registers are unaffected */
- __asm__("fninit"); /* is _fpreset () safer? */
- else
- __asm__ ("fldenv %0;" : : "m" (*envp));
- return 0;
-}
+#include <fenv.h>
+
+/* 7.6.4.3
+ The fesetenv function establishes the floating-point environment
+ represented by the object pointed to by envp. The argument envp
+ points to an object set by a call to fegetenv or feholdexcept, or
+ equal the macro FE_DFL_ENV or an implementation-defined environment
+ macro. Note that fesetenv merely installs the state of the exception
+ flags represented through its argument, and does not raise these
+ exceptions.
+ */
+
+int fesetenv (const fenv_t * envp)
+{
+ if (envp == FE_PC64_ENV)
+/*
+ * fninit initializes the control register to 0x37f,
+ * the status register to zero and the tag word to 0FFFFh.
+ * The other registers are unaffected.
+ */
+ __asm__ ("fninit");
+
+ else if (envp == FE_PC53_ENV)
+/*
+ * MS _fpreset() does same *except* it sets control word
+ * to 0x27f (53-bit precison).
+ */
+ _fpreset();
+
+ else
+ __asm__ ("fldenv %0;" : : "m" (*envp));
+ return 0;
+}
diff --git a/winsup/mingw/profile/configure b/winsup/mingw/profile/configure
index 8f64910..f9c64e0 100755
--- a/winsup/mingw/profile/configure
+++ b/winsup/mingw/profile/configure
@@ -652,7 +652,7 @@ case "$target_os" in
CRT_ID=1
MNO_CYGWIN=
RUNTIME=crtdll
- CRT0S=gcrt1.o
+ CRT0S="gcrt1.o gcrt2.o"
;;
*cygwin*)
CRT_ID=2
@@ -667,7 +667,7 @@ case "$target_os" in
CRT_ID=2
MNO_CYGWIN=
RUNTIME=msvcrt
- CRT0S=gcrt2.o
+ CRT0S="gcrt1.o gcrt2.o"
;;
esac
diff --git a/winsup/mingw/profile/configure.in b/winsup/mingw/profile/configure.in
index b54eca3..e688a67 100644
--- a/winsup/mingw/profile/configure.in
+++ b/winsup/mingw/profile/configure.in
@@ -42,7 +42,7 @@ case "$target_os" in
CRT_ID=1
MNO_CYGWIN=
RUNTIME=crtdll
- CRT0S=gcrt1.o
+ CRT0S="gcrt1.o gcrt2.o"
;;
*cygwin*)
CRT_ID=2
@@ -57,7 +57,7 @@ case "$target_os" in
CRT_ID=2
MNO_CYGWIN=
RUNTIME=msvcrt
- CRT0S=gcrt2.o
+ CRT0S="gcrt1.o gcrt2.o"
;;
esac