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-2021, 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 #include <limits.h>
17 
18 #ifdef HAVE_SYS_UIO_H
19 #include <sys/uio.h>
20 #endif
21 
22 /* If <sys/uio.h> is missing, define our own POSIX-compatible iovec struct. */
23 #ifndef HAVE_SYS_UIO_H
24 struct iovec
25 {
26  void *iov_base;
27  size_t iov_len;
28 };
29 #endif
30 
31 /*
32  * If <limits.h> didn't define IOV_MAX, define our own. POSIX requires at
33  * least 16.
34  */
35 #ifndef IOV_MAX
36 #define IOV_MAX 16
37 #endif
38 
39 /* Define a reasonable maximum that is safe to use on the stack. */
40 #define PG_IOV_MAX Min(IOV_MAX, 32)
41 
42 #if HAVE_DECL_PREADV
43 #define pg_preadv preadv
44 #else
45 extern ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
46 #endif
47 
48 #if HAVE_DECL_PWRITEV
49 #define pg_pwritev pwritev
50 #else
51 extern ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
52 #endif
53 
54 #endif /* PG_IOVEC_H */
size_t iov_len
Definition: pg_iovec.h:27
void * iov_base
Definition: pg_iovec.h:26
static int fd(const char *x, int i)
Definition: preproc-init.c:105
ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Definition: pwritev.c:29
ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
Definition: preadv.c:29
Definition: pg_iovec.h:24