+case $host_os in
+ # Cygwin and (apparently, based on test results) Mingw both
+ # have a broken strtof(), so substitute the same replacement
+ # code we use with VS2013. That's not a perfect fix, since
+ # (unlike with VS2013) it doesn't avoid double-rounding, but
+ # we have no better options. To get that, though, we have to
+ # force the file to be compiled despite HAVE_STRTOF.
+ mingw*|cygwin*)
+ case " $LIBOBJS " in
+ *" strtof.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strtof.$ac_objext"
+ ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: On $host_os we will use our strtof wrapper." >&5
+$as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
+ ;;
+esac
+
case $host_os in
# Windows uses a specialised env handler
strtof
]))
+case $host_os in
+ # Cygwin and (apparently, based on test results) Mingw both
+ # have a broken strtof(), so substitute the same replacement
+ # code we use with VS2013. That's not a perfect fix, since
+ # (unlike with VS2013) it doesn't avoid double-rounding, but
+ # we have no better options. To get that, though, we have to
+ # force the file to be compiled despite HAVE_STRTOF.
+ mingw*|cygwin*)
+ AC_LIBOBJ([strtof])
+ AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
+ ;;
+esac
+
case $host_os in
# Windows uses a specialised env handler
extern float strtof(const char *nptr, char **endptr);
#endif
+#ifdef HAVE_BUGGY_STRTOF
+extern float pg_strtof(const char *nptr, char **endptr);
+#define strtof(a,b) (pg_strtof((a),(b)))
+#endif
+
#ifndef HAVE_MKDTEMP
extern char *mkdtemp(char *path);
#endif
#endif
#define PGDLLEXPORT
+
+/*
+ * Cygwin has a strtof() which is literally just (float)strtod(), which means
+ * we get misrounding _and_ silent over/underflow. Using our wrapper doesn't
+ * fix the misrounding but does fix the error checks, which cuts down on the
+ * number of test variant files needed.
+ */
+#define HAVE_BUGGY_STRTOF 1
#define isnan(x) _isnan(x)
#endif
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || \
+ defined(__MINGW32__) || defined(__MINGW64__)
/*
* VS2013 has a strtof() that seems to give correct answers for valid input,
* even on the rounding edge cases, but which doesn't handle out-of-range
* input correctly. Work around that.
+ *
+ * Mingw claims to have a strtof, and my reading of its source code suggests
+ * that it ought to work (and not need this hack), but the regression test
+ * results disagree with me; whether this is a version issue or not is not
+ * clear. However, using our wrapper (and the misrounded-input variant file,
+ * already required for supporting ancient systems) can't make things any
+ * worse, except for a tiny performance loss when reading zeros.
+ *
+ * See also cygwin.h for another instance of this.
*/
-#define HAVE_BUGGY_WINDOWS_STRTOF 1
-extern float pg_strtof(const char *nptr, char **endptr);
-#define strtof(a,b) (pg_strtof((a),(b)))
-
+#define HAVE_BUGGY_STRTOF 1
#endif
/* Pulled from Makefile.port in MinGW */
return fresult;
}
-#elif HAVE_BUGGY_WINDOWS_STRTOF
+#elif HAVE_BUGGY_STRTOF
/*
* On Windows, there's a slightly different problem: VS2013 has a strtof()
* that returns the correct results for valid input, but may fail to report an
* well, so prefer to round the strtod() result in such cases. (Normally we'd
* just say "too bad" if strtof() doesn't support subnormals, but since we're
* already in here fixing stuff, we might as well do the best fix we can.)
+ *
+ * Cygwin has a strtof() which is literally just (float)strtod(), which means
+ * we can't avoid the double-rounding problem; but using this wrapper does get
+ * us proper over/underflow checks. (Also, if they fix their strtof(), the
+ * wrapper doesn't break anything.)
+ *
+ * Test results on Mingw suggest that it has the same problem, though looking
+ * at the code I can't figure out why.
*/
float
pg_strtof(const char *nptr, char **endptr)
-float8:out:i.86-.*-freebsd=float8-small-is-zero.out
-float8:out:i.86-.*-openbsd=float8-small-is-zero.out
-float8:out:i.86-.*-netbsd=float8-small-is-zero.out
-float8:out:m68k-.*-netbsd=float8-small-is-zero.out
-float8:out:i.86-pc-cygwin=float8-small-is-zero.out
+float4:out:.*-.*-cygwin.*=float4-misrounded-input.out
+float4:out:.*-.*-mingw.*=float4-misrounded-input.out
float4:out:hppa.*-hp-hpux10.*=float4-misrounded-input.out