PostgreSQL Source Code  git master
pg_iovec.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_iovec.h
4  * Header for vectored I/O functions, to use in place of <sys/uio.h>.
5  *
6  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/port/pg_iovec.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PG_IOVEC_H
14 #define PG_IOVEC_H
15 
16 #ifndef WIN32
17 
18 #include <limits.h>
19 #include <sys/uio.h>
20 
21 #else
22 
23 /* POSIX requires at least 16 as a maximum iovcnt. */
24 #define IOV_MAX 16
25 
26 /* Define our own POSIX-compatible iovec struct. */
27 struct iovec
28 {
29  void *iov_base;
30  size_t iov_len;
31 };
32 
33 #endif
34 
35 /* Define a reasonable maximum that is safe to use on the stack. */
36 #define PG_IOV_MAX Min(IOV_MAX, 32)
37 
38 /*
39  * Note that pg_preadv and pg_pwritev have a pg_ prefix as a warning that the
40  * Windows implementations have the side-effect of changing the file position.
41  */
42 
43 #if HAVE_DECL_PREADV
44 #define pg_preadv preadv
45 #else
46 extern ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
47 #endif
48 
49 #if HAVE_DECL_PWRITEV
50 #define pg_pwritev pwritev
51 #else
52 extern ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
53 #endif
54 
55 #endif /* PG_IOVEC_H */
ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Definition: pwritev.c:22
ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Definition: preadv.c:22
static int fd(const char *x, int i)
Definition: preproc-init.c:105