Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Assume that we have rint().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 18:47:40 +0000 (13:47 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 19:30:47 +0000 (14:30 -0500)
Windows has this since _MSC_VER >= 1200, and so do all other live
platforms according to the buildfarm, so remove the configure probe
and src/port/ substitution.

This is part of a series of commits to get rid of no-longer-relevant
configure checks and dead src/port/ code.  I'm committing them separately
to make it easier to back out individual changes if they prove less
portable than I expect.

Discussion: https://postgr.es/m/15379.1582221614@sss.pgh.pa.us

configure
configure.in
src/include/pg_config.h.in
src/include/port.h
src/port/rint.c [deleted file]
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Solution.pm

index 8d38e792aade8b86a1a4dc06d3da44050ab3d5e8..d746255f25de00f5fe70e3c80c16f7088d985644 100755 (executable)
--- a/configure
+++ b/configure
@@ -15628,19 +15628,6 @@ esac
 
 fi
 
-ac_fn_c_check_func "$LINENO" "rint" "ac_cv_func_rint"
-if test "x$ac_cv_func_rint" = xyes; then :
-  $as_echo "#define HAVE_RINT 1" >>confdefs.h
-
-else
-  case " $LIBOBJS " in
-  *" rint.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS rint.$ac_objext"
- ;;
-esac
-
-fi
-
 ac_fn_c_check_func "$LINENO" "srandom" "ac_cv_func_srandom"
 if test "x$ac_cv_func_srandom" = xyes; then :
   $as_echo "#define HAVE_SRANDOM 1" >>confdefs.h
index 86b1d298c601f1dd1aaca6f6a36cc1bebb5a6238..a9c91dadbc1b384789e45fa78362cc5ab7d885a6 100644 (file)
@@ -1707,7 +1707,6 @@ AC_REPLACE_FUNCS(m4_normalize([
    pread
    pwrite
    random
-   rint
    srandom
    strlcat
    strlcpy
index ef4c175c9847e632c87f3d2ddf5aca3e3d77f222..e3e74728204d954d181fe7b61a0aa3b31ce67803 100644 (file)
 /* Define to 1 if you have the `readlink' function. */
 #undef HAVE_READLINK
 
-/* Define to 1 if you have the `rint' function. */
-#undef HAVE_RINT
-
 /* Define to 1 if you have the global variable
    'rl_completion_append_character'. */
 #undef HAVE_RL_COMPLETION_APPEND_CHARACTER
index e40452c1ed0c89de7b0a7c09a6b4e67b266f12e7..3be994b43c738ca71391735ac7ba25ff5f7c728d 100644 (file)
@@ -385,10 +385,6 @@ extern float pg_strtof(const char *nptr, char **endptr);
 extern char *mkdtemp(char *path);
 #endif
 
-#ifndef HAVE_RINT
-extern double rint(double x);
-#endif
-
 #ifndef HAVE_INET_ATON
 #include <netinet/in.h>
 #include <arpa/inet.h>
diff --git a/src/port/rint.c b/src/port/rint.c
deleted file mode 100644 (file)
index d59d9ab..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * rint.c
- *   rint() implementation
- *
- * By Pedro Gimeno Fortea, donated to the public domain
- *
- * IDENTIFICATION
- *   src/port/rint.c
- *
- *-------------------------------------------------------------------------
- */
-#include "c.h"
-
-#include <math.h>
-
-/*
- * Round to nearest integer, with halfway cases going to the nearest even.
- */
-double
-rint(double x)
-{
-   double      x_orig;
-   double      r;
-
-   /* Per POSIX, NaNs must be returned unchanged. */
-   if (isnan(x))
-       return x;
-
-   if (x <= 0.0)
-   {
-       /* Both positive and negative zero should be returned unchanged. */
-       if (x == 0.0)
-           return x;
-
-       /*
-        * Subtracting 0.5 from a number very close to -0.5 can round to
-        * exactly -1.0, producing incorrect results, so we take the opposite
-        * approach: add 0.5 to the negative number, so that it goes closer to
-        * zero (or at most to +0.5, which is dealt with next), avoiding the
-        * precision issue.
-        */
-       x_orig = x;
-       x += 0.5;
-
-       /*
-        * Be careful to return minus zero when input+0.5 >= 0, as that's what
-        * rint() should return with negative input.
-        */
-       if (x >= 0.0)
-           return -0.0;
-
-       /*
-        * For very big numbers the input may have no decimals.  That case is
-        * detected by testing x+0.5 == x+1.0; if that happens, the input is
-        * returned unchanged.  This also covers the case of minus infinity.
-        */
-       if (x == x_orig + 1.0)
-           return x_orig;
-
-       /* Otherwise produce a rounded estimate. */
-       r = floor(x);
-
-       /*
-        * If the rounding did not produce exactly input+0.5 then we're done.
-        */
-       if (r != x)
-           return r;
-
-       /*
-        * The original fractional part was exactly 0.5 (since
-        * floor(input+0.5) == input+0.5).  We need to round to nearest even.
-        * Dividing input+0.5 by 2, taking the floor and multiplying by 2
-        * yields the closest even number.  This part assumes that division by
-        * 2 is exact, which should be OK because underflow is impossible
-        * here: x is an integer.
-        */
-       return floor(x * 0.5) * 2.0;
-   }
-   else
-   {
-       /*
-        * The positive case is similar but with signs inverted and using
-        * ceil() instead of floor().
-        */
-       x_orig = x;
-       x -= 0.5;
-       if (x <= 0.0)
-           return 0.0;
-       if (x == x_orig - 1.0)
-           return x_orig;
-       r = ceil(x);
-       if (r != x)
-           return r;
-       return ceil(x * 0.5) * 2.0;
-   }
-}
index 6a1435f4566dda4723ab35d91e46ea6489da3075..2e87d81172d0142c25170c2ce121167cb5852949 100644 (file)
@@ -104,8 +104,6 @@ sub mkvcbuild
      sprompt.c strerror.c tar.c thread.c
      win32env.c win32error.c win32security.c win32setlocale.c);
 
-   push(@pgportfiles, 'rint.c') if ($vsVersion < '12.00');
-
    push(@pgportfiles, 'strtof.c') if ($vsVersion < '14.00');
 
    if ($vsVersion >= '9.00')
index 56d52fc331057b1a65b23239d6f07427cea06222..cb03d03a971a770fb3b7c8e1d8cefaf7e657d322 100644 (file)
@@ -321,7 +321,6 @@ sub GenerateFiles
        HAVE_READLINE_HISTORY_H     => undef,
        HAVE_READLINE_READLINE_H    => undef,
        HAVE_READLINK               => undef,
-       HAVE_RINT                   => 1,
        HAVE_RL_COMPLETION_APPEND_CHARACTER      => undef,
        HAVE_RL_COMPLETION_MATCHES               => undef,
        HAVE_RL_COMPLETION_SUPPRESS_QUOTE        => undef,