Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Assume that we have functional, 64-bit fseeko()/ftello().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 17:49:42 +0000 (12:49 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Feb 2020 19:30:47 +0000 (14:30 -0500)
Windows has this, and so do all other live platforms according to the
buildfarm, so remove the configure probe and src/port/ substitution.

Keep the probe that detects whether _LARGEFILE_SOURCE has to be
defined to get that, though ... that seems to be still relevant in
some places.

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/bin/pg_dump/pg_backup_archiver.c
src/include/port.h
src/include/port/win32_port.h
src/port/fseeko.c [deleted file]
src/tools/msvc/Mkvcbuild.pm

index 569cd2fa916086a4f0bc1e4b3c0fba2432b46437..9625a82f0da01ababced6030ae5af38d8fd5de1c 100755 (executable)
--- a/configure
+++ b/configure
@@ -15169,30 +15169,9 @@ _ACEOF
 
 fi
 
-ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko"
-if test "x$ac_cv_func_fseeko" = xyes; then :
-  $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
-
-else
-  case " $LIBOBJS " in
-  *" fseeko.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS fseeko.$ac_objext"
- ;;
-esac
-
-fi
-
-
-case $host_os in
-   # NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos
-   # Mingw uses macros to access Win32 API calls
-   netbsd*|mingw*)
-
-$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
-
-       ac_cv_func_fseeko=yes;;
-   *)
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+# We require 64-bit fseeko() to be available, but run this check anyway
+# in case it finds that _LARGEFILE_SOURCE has to be #define'd for that.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
 $as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
 if ${ac_cv_sys_largefile_source+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -15259,8 +15238,7 @@ if test $ac_cv_sys_largefile_source != unknown; then
 $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
 
 fi
-;;
-esac
+
 
 # posix_fadvise() is a no-op on Solaris, so don't incur function overhead
 # by calling it, 2009-04-02
index 140909091a161c411a4b3313d617a09940ff7197..a70870184fdbbe9c9a0f69b749ecb6b7e460199e 100644 (file)
@@ -1660,16 +1660,9 @@ PGAC_CHECK_BUILTIN_FUNC([__builtin_clz], [unsigned int x])
 PGAC_CHECK_BUILTIN_FUNC([__builtin_ctz], [unsigned int x])
 PGAC_CHECK_BUILTIN_FUNC([__builtin_popcount], [unsigned int x])
 
-AC_REPLACE_FUNCS(fseeko)
-case $host_os in
-   # NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos
-   # Mingw uses macros to access Win32 API calls
-   netbsd*|mingw*)
-       AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.])
-       ac_cv_func_fseeko=yes;;
-   *)
-       AC_FUNC_FSEEKO;;
-esac
+# We require 64-bit fseeko() to be available, but run this check anyway
+# in case it finds that _LARGEFILE_SOURCE has to be #define'd for that.
+AC_FUNC_FSEEKO
 
 # posix_fadvise() is a no-op on Solaris, so don't incur function overhead
 # by calling it, 2009-04-02
index 77bf9edaba46dec6568f56ee57f8182272f5796b..15900ffc249b66a3afd93be5dbfa24b6bd10a486 100644 (file)
@@ -3872,15 +3872,6 @@ checkSeek(FILE *fp)
 {
    pgoff_t     tpos;
 
-   /*
-    * If pgoff_t is wider than long, we must have "real" fseeko and not an
-    * emulation using fseek.  Otherwise report no seek capability.
-    */
-#ifndef HAVE_FSEEKO
-   if (sizeof(pgoff_t) > sizeof(long))
-       return false;
-#endif
-
    /* Check that ftello works on this file */
    tpos = ftello(fp);
    if (tpos < 0)
index 2767cf0fc321cb1d52aed008f42e3cf57d6b994d..3f5f90fa0078e994ba9d4b068fd21a32acff4e2a 100644 (file)
@@ -331,13 +331,9 @@ extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
  * When necessary, these routines are provided by files in src/port/.
  */
 
-/* WIN32 handled in port/win32_port.h */
-#ifndef WIN32
+/* Type to use with fseeko/ftello */
+#ifndef WIN32                  /* WIN32 is handled in port/win32_port.h */
 #define pgoff_t off_t
-#ifdef __NetBSD__
-extern int fseeko(FILE *stream, off_t offset, int whence);
-extern off_t ftello(FILE *stream);
-#endif
 #endif
 
 extern double pg_erand48(unsigned short xseed[3]);
@@ -349,11 +345,6 @@ extern void pg_srand48(long seed);
 extern int fls(int mask);
 #endif
 
-#ifndef HAVE_FSEEKO
-#define fseeko(a, b, c) fseek(a, b, c)
-#define ftello(a)      ftell(a)
-#endif
-
 #ifndef HAVE_GETPEEREID
 /* On Windows, Perl might have incompatible definitions of uid_t and gid_t. */
 #ifndef PLPERL_HAVE_UID_GID
index ec0e3d5a3718448c4adf467a8fa84456f7587d22..91ec01468e84884ad54c4c975528b2ef18ceb393 100644 (file)
@@ -193,6 +193,7 @@ int         setitimer(int which, const struct itimerval *value, struct itimerval *oval
  * with 64-bit offsets.
  */
 #define pgoff_t __int64
+
 #ifdef _MSC_VER
 #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin)
 #define ftello(stream) _ftelli64(stream)
diff --git a/src/port/fseeko.c b/src/port/fseeko.c
deleted file mode 100644 (file)
index 02c1bcd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * fseeko.c
- *   64-bit versions of fseeko/ftello()
- *
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *   src/port/fseeko.c
- *
- *-------------------------------------------------------------------------
- */
-
-/*
- * We have to use the native defines here because configure hasn't
- * completed yet.
- */
-#ifdef __NetBSD__
-
-#include "c.h"
-
-#include <sys/stat.h>
-
-
-/*
- * On NetBSD, off_t and fpos_t are the same.  Standards
- * say off_t is an arithmetic type, but not necessarily integral,
- * while fpos_t might be neither.
- */
-
-int
-fseeko(FILE *stream, off_t offset, int whence)
-{
-   off_t       floc;
-   struct stat filestat;
-
-   switch (whence)
-   {
-       case SEEK_CUR:
-           if (fgetpos(stream, &floc) != 0)
-               goto failure;
-           floc += offset;
-           if (fsetpos(stream, &floc) != 0)
-               goto failure;
-           return 0;
-           break;
-       case SEEK_SET:
-           if (fsetpos(stream, &offset) != 0)
-               return -1;
-           return 0;
-           break;
-       case SEEK_END:
-           fflush(stream);     /* force writes to fd for stat() */
-           if (fstat(fileno(stream), &filestat) != 0)
-               goto failure;
-           floc = filestat.st_size;
-           floc += offset;
-           if (fsetpos(stream, &floc) != 0)
-               goto failure;
-           return 0;
-           break;
-       default:
-           errno = EINVAL;
-           return -1;
-   }
-
-failure:
-   return -1;
-}
-
-
-off_t
-ftello(FILE *stream)
-{
-   off_t       floc;
-
-   if (fgetpos(stream, &floc) != 0)
-       return -1;
-   return floc;
-}
-
-#endif
index a43e31c60eb819ed43fb5f823cb51b05045dd864..6a1435f4566dda4723ab35d91e46ea6489da3075 100644 (file)
@@ -94,7 +94,7 @@ sub mkvcbuild
    $solution = CreateSolution($vsVersion, $config);
 
    our @pgportfiles = qw(
-     chklocale.c explicit_bzero.c fls.c fseeko.c getpeereid.c getrusage.c inet_aton.c random.c
+     chklocale.c explicit_bzero.c fls.c getpeereid.c getrusage.c inet_aton.c random.c
      srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
      erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
      dirent.c dlopen.c getopt.c getopt_long.c