aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2022-08-05 09:42:31 +1200
committerThomas Munro <tmunro@postgresql.org>2022-08-05 09:49:21 +1200
commitcf112c122060568aa06efe4e6e6fb9b2dd4f1090 (patch)
tree099d16d2064108f43c06d70ab5178a38d8554106 /src/include
parent71f5dc6dfb3de50de28ddde53793540c2fa98b1f (diff)
downloadpostgresql-cf112c122060568aa06efe4e6e6fb9b2dd4f1090.tar.gz
postgresql-cf112c122060568aa06efe4e6e6fb9b2dd4f1090.zip
Remove dead pread and pwrite replacement code.
pread() and pwrite() are in SUSv2, and all targeted Unix systems have them. Previously, we defined pg_pread and pg_pwrite to emulate these function with lseek() on old Unixen. The names with a pg_ prefix were a reminder of a portability hazard: they might change the current file position. That hazard is gone, so we can drop the prefixes. Since the remaining replacement code is Windows-only, move it into src/port/win32p{read,write}.c, and move the declarations into src/include/port/win32_port.h. No need for vestigial HAVE_PREAD, HAVE_PWRITE macros as they were only used for declarations in port.h which have now moved into win32_port.h. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Greg Stark <stark@mit.edu> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/xlogreader.h4
-rw-r--r--src/include/pg_config.h.in6
-rw-r--r--src/include/port.h19
-rw-r--r--src/include/port/win32_port.h6
4 files changed, 8 insertions, 27 deletions
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index 5395f155aa1..87ff00feb72 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -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(). */
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index b6ee575681c..4d61ecd9142 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -388,9 +388,6 @@
/* 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
@@ -406,9 +403,6 @@
/* 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
diff --git a/src/include/port.h b/src/include/port.h
index 85c9b38f4ee..14b640fe33e 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -417,25 +417,6 @@ extern char *mkdtemp(char *path);
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
diff --git a/src/include/port/win32_port.h b/src/include/port/win32_port.h
index a48eed53eb7..336e11b3ba4 100644
--- a/src/include/port/win32_port.h
+++ b/src/include/port/win32_port.h
@@ -562,4 +562,10 @@ typedef unsigned short mode_t;
#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 */