1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Assume that we have functional, 64-bit fseeko()/ftello().

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
This commit is contained in:
Tom Lane
2020-02-21 12:49:42 -05:00
parent 3f9c1697dc
commit 799d22461a
7 changed files with 11 additions and 141 deletions

View 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)

View 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

View 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)

View File

@ -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

View 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