index e98dfa29ce53c4b4366f4ee803e40294a58e8df2..87b3753846c0c61a77c8457b6770a2241a188c37 100755 (executable)
fi
-ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
-if test "x$ac_cv_func_pread" = xyes; then :
- $as_echo "#define HAVE_PREAD 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" pread.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS pread.$ac_objext"
- ;;
-esac
-
-fi
-
-ac_fn_c_check_func "$LINENO" "pwrite" "ac_cv_func_pwrite"
-if test "x$ac_cv_func_pwrite" = xyes; then :
- $as_echo "#define HAVE_PWRITE 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" pwrite.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS pwrite.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
;;
esac
+ case " $LIBOBJS " in
+ *" win32pread.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS win32pread.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
+ *" win32pwrite.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS win32pwrite.$ac_objext"
+ ;;
+esac
+
case " $LIBOBJS " in
*" win32security.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS win32security.$ac_objext"
index d551cb2acd10f40f07bbe534ec21e6711396b02a..cd29d533a5918e7a8a5e0f20b3bd6ce6edd83504 100644 (file)
getpeereid
inet_aton
mkdtemp
- pread
- pwrite
strlcat
strlcpy
strnlen
AC_LIBOBJ(win32error)
AC_LIBOBJ(win32link)
AC_LIBOBJ(win32ntdll)
+ AC_LIBOBJ(win32pread)
+ AC_LIBOBJ(win32pwrite)
AC_LIBOBJ(win32security)
AC_LIBOBJ(win32setlocale)
AC_LIBOBJ(win32stat)
index 73439c01991d56679d2f6c7e22e5348ebca32d03..ba868f0de9c025ab51be865cd36f257b0ba12984 100644 (file)
if (fd < 0)
goto error;
- if (pg_pwrite(fd, query, query_len, off) != query_len)
+ if (pwrite(fd, query, query_len, off) != query_len)
goto error;
- if (pg_pwrite(fd, "0円", 1, off + query_len) != 1)
+ if (pwrite(fd, "0円", 1, off + query_len) != 1)
goto error;
CloseTransientFile(fd);
index 197f06b5eca3fe9e5397b66d06f87a33fc864f16..9dd885d936f5d94f48f9c9ba7479f0e5aeeb2674 100644 (file)
/* write out tail end of mapping file (again) */
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
- if (pg_pwrite(fd, data, len, xlrec->offset) != len)
+ if (pwrite(fd, data, len, xlrec->offset) != len)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
index b65cb49d7ff235c02c3fa683fa22d6e545cf41b9..c9a7b979495d91df538040ad551ff00b290dadd2 100644 (file)
@@ -718,7 +718,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
- if (pg_pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
slru_errcause = SLRU_READ_FAILED;
@@ -873,7 +873,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
- if (pg_pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
index 26fbed00a4d63cb1f4e6b7211d914ecb1911215c..eb5115fd5a828ea892fc6f5a62832edfc6ce0bb9 100644 (file)
@@ -2189,7 +2189,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
INSTR_TIME_SET_CURRENT(start);
pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
- written = pg_pwrite(openLogFile, from, nleft, startoffset);
+ written = pwrite(openLogFile, from, nleft, startoffset);
pgstat_report_wait_end();
/*
@@ -3011,7 +3011,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
* enough.
*/
errno = 0;
- if (pg_pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
+ if (pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
{
/* if write didn't set errno, assume no disk space */
save_errno = errno ? errno : ENOSPC;
index f3dc4b7797a3486a145079ea68c2e1f26fce2baf..06e91547dd39d7e1650611fd2677219f5ddbc92a 100644 (file)
/* Reset errno first; eases reporting non-errno-affecting errors */
errno = 0;
- readbytes = pg_pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
+ readbytes = pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
#ifndef FRONTEND
pgstat_report_wait_end();
index 27e02fbfcda695c9b3c549eb7b95aa81abc9b882..21088e78f61bd36930deca1579077d8bea1f3fbe 100644 (file)
readOff = targetPageOff;
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
- r = pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
+ r = pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
if (r != XLOG_BLCKSZ)
{
char fname[MAXFNAMELEN];
index 09f071300d44a0722572851ca3fc4230654838d1..5e457f9be990f657c9532e8deee9f14a85141925 100644 (file)
@@ -1822,7 +1822,7 @@ basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
int rc;
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
- rc = pg_pread(fd, buf, nbytes, offset);
+ rc = pread(fd, buf, nbytes, offset);
pgstat_report_wait_end();
if (rc < 0)
index 3d37c1fe62e9fc4e41f59add19b912c4cdcad71c..8604fd4bc2e37543cdd94e04e3a897ebcfcafc2c 100644 (file)
@@ -915,7 +915,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
/* OK to write the logs */
errno = 0;
- byteswritten = pg_pwrite(recvFile, buf, segbytes, (off_t) startoff);
+ byteswritten = pwrite(recvFile, buf, segbytes, (off_t) startoff);
if (byteswritten <= 0)
{
char xlogfname[MAXFNAMELEN];
index 447d5a86c302dd36849b5644adaf2e15705eed4f..3d1a97335495aebc67cd47a2485fc945bd117004 100644 (file)
@@ -2063,7 +2063,7 @@ FileRead(File file, char *buffer, int amount, off_t offset,
retry:
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pread(vfdP->fd, buffer, amount, offset);
+ returnCode = pread(vfdP->fd, buffer, amount, offset);
pgstat_report_wait_end();
if (returnCode < 0)
@@ -2145,7 +2145,7 @@ FileWrite(File file, char *buffer, int amount, off_t offset,
retry:
errno = 0;
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pwrite(VfdCache[file].fd, buffer, amount, offset);
+ returnCode = pwrite(VfdCache[file].fd, buffer, amount, offset);
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
index eb43b2c5e576b5b58895f4db51b5ff28062fd5f4..bd973ba613aae0f030e7f34d4d868ad6e027793c 100644 (file)
@@ -1429,7 +1429,7 @@ AddToDataDirLockFile(int target_line, const char *str)
len = strlen(destbuffer);
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE);
- if (pg_pwrite(fd, destbuffer, len, 0) != len)
+ if (pwrite(fd, destbuffer, len, 0) != len)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
index 6739214eb83e9b8ecd635ea6a06cca998d92f4f1..8f0ef8e66b9e6cc64b5862456307f0d47a566f82 100644 (file)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
fdatasync(tmpfile);
}
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (pg_fsync_writethrough(tmpfile) != 0)
die("fsync failed");
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
/*
* This can generate write failures if the filesystem has
@@ -484,10 +484,10 @@ test_open_sync(const char *msg, int writes_size)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < 16 / writes_size; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- writes_size * 1024,
- writes * writes_size * 1024) !=
+ if (pwrite(tmpfile,
+ buf,
+ writes_size * 1024,
+ writes * writes_size * 1024) !=
writes_size * 1024)
die("write failed");
}
START_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
- if (pg_pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
index 5395f155aa1bbee208ebeab280f66f2043d8275a..87ff00feb729870b6c92d01c10309842da0ae7d0 100644 (file)
@@ -375,11 +375,11 @@ extern bool XLogReaderValidatePageHeader(XLogReaderState *state,
/*
* Error information from WALRead that both backend and frontend caller can
- * process. Currently only errors from pg_pread can be reported.
+ * process. Currently only errors from pread can be reported.
*/
typedef struct WALReadError
{
- int wre_errno; /* errno set by the last pg_pread() */
+ int wre_errno; /* errno set by the last pread() */
int wre_off; /* Offset we tried to read from. */
int wre_req; /* Bytes requested to be read. */
int wre_read; /* Bytes read by the last read(). */
index b6ee575681c91caf6427b0cd49b0ef185d6b36b0..4d61ecd91429332c0776fd7069479fb913762a15 100644 (file)
/* Define to 1 if you have the `ppoll' function. */
#undef HAVE_PPOLL
-/* Define to 1 if you have the `pread' function. */
-#undef HAVE_PREAD
-
/* Define to 1 if the PS_STRINGS thing exists. */
#undef HAVE_PS_STRINGS
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
-/* Define to 1 if you have the `pwrite' function. */
-#undef HAVE_PWRITE
-
/* Define to 1 if you have the <readline.h> header file. */
#undef HAVE_READLINE_H
index 85c9b38f4eeb11c368002eb67c82f7fd9300e42f..14b640fe33e3425d24cb8fb1ac8a194cb6d4caae 100644 (file)
extern int inet_aton(const char *cp, struct in_addr *addr);
#endif
-/*
- * Windows and older Unix don't have pread(2) and pwrite(2). We have
- * replacement functions, but they have slightly different semantics so we'll
- * use a name with a pg_ prefix to avoid confusion.
- */
-#ifdef HAVE_PREAD
-#define pg_pread pread
-#else
-extern ssize_t pg_pread(int fd, void *buf, size_t nbyte, off_t offset);
-#endif
-
-#ifdef HAVE_PWRITE
-#define pg_pwrite pwrite
-#else
-extern ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
-#endif
-
-/* For pg_pwritev() and pg_preadv(), see port/pg_iovec.h. */
-
#if !HAVE_DECL_STRLCAT
extern size_t strlcat(char *dst, const char *src, size_t siz);
#endif
index a48eed53eb705965fb5c179f1eb72ac6bdea5242..336e11b3ba4e5b36bf47e826d0ba676e20b33fd1 100644 (file)
#define HAVE_BUGGY_STRTOF 1
#endif
+/* in port/win32pread.c */
+extern ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset);
+
+/* in port/win32pwrite.c */
+extern ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
+
#endif /* PG_WIN32_PORT_H */
index d12e5a122bbd161c8d0d7866608fde70e0c8dbb7..aa7537503fb1bde3296e76ab2be997c35b220a49 100644 (file)
@@ -30,7 +30,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_READV
if (iovcnt == 1)
- return pg_pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return readv(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
index 0bdd69fffc48393859178f4e1dc2b4dbaac2bb98..cb7421381e4d7b67b6e3ac3003f2d8ba33062ad0 100644 (file)
@@ -30,7 +30,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_WRITEV
if (iovcnt == 1)
- return pg_pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return writev(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
/*-------------------------------------------------------------------------
*
- * pread.c
- * Implementation of pread(2) for platforms that lack one.
+ * win32pread.c
+ * Implementation of pread(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * src/port/pread.c
- *
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pread().
+ * src/port/win32pread.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pread(int fd, void *buf, size_t size, off_t offset)
+pread(int fd, void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -49,10 +41,4 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return read(fd, buf, size);
-#endif
}
/*-------------------------------------------------------------------------
*
- * pwrite.c
- * Implementation of pwrite(2) for platforms that lack one.
+ * win32pwrite.c
+ * Implementation of pwrite(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * src/port/pwrite.c
- *
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pwrite().
+ * src/port/win32pwrite.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
+pwrite(int fd, const void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -46,10 +38,4 @@ pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return write(fd, buf, size);
-#endif
}
index 1ffe6e66d5aa911f51517ab6a02ce3832708996b..a06dbcae4d292d484b06558a43ca8982381ca203 100644 (file)
getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
dirent.c getopt.c getopt_long.c
- pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c
+ preadv.c pwritev.c pg_bitutils.c
pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c
pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c
strerror.c tar.c
win32dlopen.c
win32env.c win32error.c
win32link.c
+ win32pread.c
+ win32pwrite.c
win32ntdll.c
win32security.c win32setlocale.c win32stat.c);
index 5301e01e833461f46f4573eeea23067d726192e1..5a461a5212c3b8dee131c03a31f6ad3fb1acb8ac 100644 (file)
HAVE_POSIX_FALLOCATE => undef,
HAVE_PPC_LWARX_MUTEX_HINT => undef,
HAVE_PPOLL => undef,
- HAVE_PREAD => undef,
HAVE_PS_STRINGS => undef,
HAVE_PTHREAD => undef,
HAVE_PTHREAD_BARRIER_WAIT => undef,
HAVE_PTHREAD_IS_THREADED_NP => undef,
HAVE_PTHREAD_PRIO_INHERIT => undef,
- HAVE_PWRITE => undef,
HAVE_READLINE_H => undef,
HAVE_READLINE_HISTORY_H => undef,
HAVE_READLINE_READLINE_H => undef,