Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2004-07-02 14:01:51 +0400
committerDanny Smith <dannysmith@users.sourceforge.net>2004-07-02 14:01:51 +0400
commit64b9893f0d1e9c25d75bda78a49dc6e189d35e06 (patch)
tree0f0aa6f732725b88219628a08a3fe2f0363ad74a /winsup
parent2cb47d686eff408aab237c0a54f9094a7fc1bd76 (diff)
2 * mingwex/Makefile.in (MATH_DISTFILES): Remove pow.c,
(MATH_OBJS): Remove pow,o. * include/math.h (pow): Declare with _CRTIMP. Add comment on how to avoid excess precision problems.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/mingw/ChangeLog7
-rw-r--r--winsup/mingw/include/math.h44
-rw-r--r--winsup/mingw/mingwex/Makefile.in4
3 files changed, 48 insertions, 7 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index 64cad4ee4..28a97d214 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,10 @@
+2004-07-02 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * mingwex/Makefile.in (MATH_DISTFILES): Remove pow.c,
+ (MATH_OBJS): Remove pow,o.
+ * include/math.h (pow): Declare with _CRTIMP.
+ Add comment on how to avoid excess precision problems.
+
2004-06-30 Danny Smith <dannysmith@users.sourceforge.net>
* include/stdio.h (__mingw_fseeko64): Add prototype.
diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h
index fd6ce95d3..68ba5c752 100644
--- a/winsup/mingw/include/math.h
+++ b/winsup/mingw/include/math.h
@@ -129,7 +129,6 @@ struct _exception
double retval;
};
-
_CRTIMP double __cdecl sin (double);
_CRTIMP double __cdecl cos (double);
_CRTIMP double __cdecl tan (double);
@@ -143,10 +142,7 @@ _CRTIMP double __cdecl atan2 (double, double);
_CRTIMP double __cdecl exp (double);
_CRTIMP double __cdecl log (double);
_CRTIMP double __cdecl log10 (double);
-#ifdef __NO_ISOCEXT
-_CRTIMP
-#endif
- double __cdecl pow (double, double);
+_CRTIMP double __cdecl pow (double, double);
_CRTIMP double __cdecl sqrt (double);
_CRTIMP double __cdecl ceil (double);
_CRTIMP double __cdecl floor (double);
@@ -156,6 +152,44 @@ _CRTIMP double __cdecl frexp (double, int*);
_CRTIMP double __cdecl modf (double, double*);
_CRTIMP double __cdecl fmod (double, double);
+/* Excess precision when using a 64-bit mantissa for FPU math ops can
+ cause unexpected results with some of the MSVCRT math functions. For
+ example, unless the function return value is stored (truncating to
+ 53-bit mantissa), calls to pow with both x and y as integral values
+ sometimes produce a non-integral result.
+ One workaround is to reset the FPU env to 53-bit mantissa
+ by a call to fesetenv (FE_PC53_ENV). Amother is to force storage
+ of the return value of individual math functions using wrappers.
+ NB, using these wrappers will disable builtin math functions and
+ hence disable the folding of function results at compile time when
+ arguments are constant. */
+
+#if 0
+#define __DEFINE_FLOAT_STORE_MATHFN_D1(fn1) \
+static __inline__ double \
+__float_store_ ## fn1 (double x) \
+{ \
+ __volatile__ double res = (fn1) (x); \
+ return res; \
+}
+
+#define __DEFINE_FLOAT_STORE_MATHFN_D2(fn2) \
+static __inline__ double \
+__float_store_ ## fn2 (double x, double y) \
+{ \
+ __volatile__ double res = (fn2) (x, y); \
+ return res; \
+}
+#endif
+
+/* For example, here is how to force the result of the pow function
+ to be stored: */
+#if 0
+#undef pow
+/* Define the ___float_store_pow function and use it instead of pow(). */
+__DEFINE_FLOAT_STORE_MATHFN_D2 (pow)
+#define pow __float_store_pow
+#endif
#ifndef __STRICT_ANSI__
diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in
index db26626c2..6853ca32d 100644
--- a/winsup/mingw/mingwex/Makefile.in
+++ b/winsup/mingw/mingwex/Makefile.in
@@ -53,7 +53,7 @@ MATH_DISTFILES = \
log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \
lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \
nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c \
- pow.c powf.c powi.c powif.c powil.c powl.c \
+ powf.c powi.c powif.c powil.c powl.c \
remainder.S remainderf.S remainderl.S remquo.S \
remquof.S remquol.S rint.c rintf.c rintl.c round.c roundf.c \
roundl.c scalbn.S scalbnf.S scalbnl.S s_erf.c sf_erf.c \
@@ -135,7 +135,7 @@ MATH_OBJS = \
log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \
lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \
nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o \
- pow.o powf.o powi.o powif.o powil.o powl.o \
+ powf.o powi.o powif.o powil.o powl.o \
remainder.o remainderf.o remainderl.o remquo.o \
remquof.o remquol.o rint.o rintf.o rintl.o round.o roundf.o \
roundl.o scalbn.o scalbnf.o scalbnl.o s_erf.o sf_erf.o \