Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cbf4403

Browse files
committed
Simplify replacement code for strtof.
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 <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/152683.1659830125%40sss.pgh.pa.us
1 parent 24c3ce8 commit cbf4403

File tree

6 files changed

+2
-64
lines changed

6 files changed

+2
-64
lines changed

configure

+1-15
Original file line numberDiff line numberDiff line change
@@ -16734,19 +16734,6 @@ esac
1673416734

1673516735
fi
1673616736

16737-
ac_fn_c_check_func "$LINENO" "strtof" "ac_cv_func_strtof"
16738-
if test "x$ac_cv_func_strtof" = xyes; then :
16739-
$as_echo "#define HAVE_STRTOF 1" >>confdefs.h
16740-
16741-
else
16742-
case " $LIBOBJS " in
16743-
*" strtof.$ac_objext "* ) ;;
16744-
*) LIBOBJS="$LIBOBJS strtof.$ac_objext"
16745-
;;
16746-
esac
16747-
16748-
fi
16749-
1675016737

1675116738

1675216739
if test "$enable_thread_safety" = yes; then
@@ -16770,8 +16757,7 @@ if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
1677016757
# Cygwin and (apparently, based on test results) Mingw both
1677116758
# have a broken strtof(), so substitute its implementation.
1677216759
# That's not a perfect fix, since it doesn't avoid double-rounding,
16773-
# but we have no better options. To get that, though, we have to
16774-
# force the file to be compiled despite HAVE_STRTOF.
16760+
# but we have no better options.
1677516761
case " $LIBOBJS " in
1677616762
*" strtof.$ac_objext "* ) ;;
1677716763
*) LIBOBJS="$LIBOBJS strtof.$ac_objext"

configure.ac

+1-3
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,6 @@ AC_REPLACE_FUNCS(m4_normalize([
18741874
strlcat
18751875
strlcpy
18761876
strnlen
1877-
strtof
18781877
]))
18791878

18801879
if test "$enable_thread_safety" = yes; then
@@ -1885,8 +1884,7 @@ if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
18851884
# Cygwin and (apparently, based on test results) Mingw both
18861885
# have a broken strtof(), so substitute its implementation.
18871886
# That's not a perfect fix, since it doesn't avoid double-rounding,
1888-
# but we have no better options. To get that, though, we have to
1889-
# force the file to be compiled despite HAVE_STRTOF.
1887+
# but we have no better options.
18901888
AC_LIBOBJ([strtof])
18911889
AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
18921890
fi

src/include/pg_config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@
460460
/* Define to 1 if you have the `strsignal' function. */
461461
#undef HAVE_STRSIGNAL
462462

463-
/* Define to 1 if you have the `strtof' function. */
464-
#undef HAVE_STRTOF
465-
466463
/* Define to 1 if the system has the type `struct addrinfo'. */
467464
#undef HAVE_STRUCT_ADDRINFO
468465

src/include/port.h

-4
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,6 @@ extern int getpeereid(int sock, uid_t *uid, gid_t *gid);
387387
extern void explicit_bzero(void *buf, size_t len);
388388
#endif
389389

390-
#ifndef HAVE_STRTOF
391-
extern float strtof(const char *nptr, char **endptr);
392-
#endif
393-
394390
#ifdef HAVE_BUGGY_STRTOF
395391
extern float pg_strtof(const char *nptr, char **endptr);
396392
#define strtof(a,b) (pg_strtof((a),(b)))

src/port/strtof.c

-38
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,7 @@
1616
#include <float.h>
1717
#include <math.h>
1818

19-
#ifndef HAVE_STRTOF
20-
/*
21-
* strtof() is part of C99; this version is only for the benefit of obsolete
22-
* platforms. As such, it is known to return incorrect values for edge cases,
23-
* which have to be allowed for in variant files for regression test results
24-
* for any such platform.
25-
*/
26-
27-
float
28-
strtof(const char *nptr, char **endptr)
29-
{
30-
int caller_errno = errno;
31-
double dresult;
32-
float fresult;
33-
34-
errno = 0;
35-
dresult = strtod(nptr, endptr);
36-
fresult = (float) dresult;
3719

38-
if (errno == 0)
39-
{
40-
/*
41-
* Value might be in-range for double but not float.
42-
*/
43-
if (dresult != 0 && fresult == 0)
44-
caller_errno = ERANGE; /* underflow */
45-
if (!isinf(dresult) && isinf(fresult))
46-
caller_errno = ERANGE; /* overflow */
47-
}
48-
else
49-
caller_errno = errno;
50-
51-
errno = caller_errno;
52-
return fresult;
53-
}
54-
55-
#elif HAVE_BUGGY_STRTOF
5620
/*
5721
* Cygwin has a strtof() which is literally just (float)strtod(), which means
5822
* we can't avoid the double-rounding problem; but using this wrapper does get
@@ -119,5 +83,3 @@ pg_strtof(const char *nptr, char **endptr)
11983
}
12084
}
12185
}
122-
123-
#endif

src/tools/msvc/Solution.pm

-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ sub GenerateFiles
349349
HAVE_STRLCPY => undef,
350350
HAVE_STRNLEN => 1,
351351
HAVE_STRSIGNAL => undef,
352-
HAVE_STRTOF => 1,
353352
HAVE_STRUCT_ADDRINFO => 1,
354353
HAVE_STRUCT_CMSGCRED => undef,
355354
HAVE_STRUCT_OPTION => undef,

0 commit comments

Comments
 (0)