strtof() is in C99 and all targeted systems have it. We can remove the
configure probe and some dead code, but we still need replacement code
for a couple of systems that have known buggy implementations selected
via platform template.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/152683.
1659830125%40sss.pgh.pa.us
fi
-ac_fn_c_check_func "$LINENO" "strtof" "ac_cv_func_strtof"
-if test "x$ac_cv_func_strtof" = xyes; then :
- $as_echo "#define HAVE_STRTOF 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" strtof.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS strtof.$ac_objext"
- ;;
-esac
-
-fi
-
if test "$enable_thread_safety" = yes; then
# Cygwin and (apparently, based on test results) Mingw both
# have a broken strtof(), so substitute its implementation.
# That's not a perfect fix, since 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.
+ # but we have no better options.
case " $LIBOBJS " in
*" strtof.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS strtof.$ac_objext"
strlcat
strlcpy
strnlen
- strtof
]))
if test "$enable_thread_safety" = yes; then
# Cygwin and (apparently, based on test results) Mingw both
# have a broken strtof(), so substitute its implementation.
# That's not a perfect fix, since 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.
+ # but we have no better options.
AC_LIBOBJ([strtof])
AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
fi
/* Define to 1 if you have the `strsignal' function. */
#undef HAVE_STRSIGNAL
-/* Define to 1 if you have the `strtof' function. */
-#undef HAVE_STRTOF
-
/* Define to 1 if the system has the type `struct addrinfo'. */
#undef HAVE_STRUCT_ADDRINFO
extern void explicit_bzero(void *buf, size_t len);
#endif
-#ifndef HAVE_STRTOF
-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)))
#include <float.h>
#include <math.h>
-#ifndef HAVE_STRTOF
-/*
- * strtof() is part of C99; this version is only for the benefit of obsolete
- * platforms. As such, it is known to return incorrect values for edge cases,
- * which have to be allowed for in variant files for regression test results
- * for any such platform.
- */
-
-float
-strtof(const char *nptr, char **endptr)
-{
- int caller_errno = errno;
- double dresult;
- float fresult;
-
- errno = 0;
- dresult = strtod(nptr, endptr);
- fresult = (float) dresult;
- if (errno == 0)
- {
- /*
- * Value might be in-range for double but not float.
- */
- if (dresult != 0 && fresult == 0)
- caller_errno = ERANGE; /* underflow */
- if (!isinf(dresult) && isinf(fresult))
- caller_errno = ERANGE; /* overflow */
- }
- else
- caller_errno = errno;
-
- errno = caller_errno;
- return fresult;
-}
-
-#elif HAVE_BUGGY_STRTOF
/*
* 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
}
}
}
-
-#endif
HAVE_STRLCPY => undef,
HAVE_STRNLEN => 1,
HAVE_STRSIGNAL => undef,
- HAVE_STRTOF => 1,
HAVE_STRUCT_ADDRINFO => 1,
HAVE_STRUCT_CMSGCRED => undef,
HAVE_STRUCT_OPTION => undef,