PostgreSQL Source Code git master
Macros | Functions
pg_iovec.h File Reference
#include <limits.h>
#include <sys/uio.h>
#include <unistd.h>
Include dependency graph for pg_iovec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define  IOV_MAX   16
 
#define  PG_IOV_MAX   Min(IOV_MAX, 128)
 

Functions

static ssize_t  pg_preadv (int fd, const struct iovec *iov, int iovcnt, off_t offset)
 
static ssize_t  pg_pwritev (int fd, const struct iovec *iov, int iovcnt, off_t offset)
 

Macro Definition Documentation

IOV_MAX

#define IOV_MAX   16

Definition at line 39 of file pg_iovec.h.

PG_IOV_MAX

#define PG_IOV_MAX   Min(IOV_MAX, 128)

Definition at line 47 of file pg_iovec.h.

Function Documentation

pg_preadv()

static ssize_t pg_preadv ( int  fd,
const struct iovec *  iov,
int  iovcnt,
off_t  offset 
)
inlinestatic

Definition at line 54 of file pg_iovec.h.

55{
56#if HAVE_DECL_PREADV
57 /*
58 * Avoid a small amount of argument copying overhead in the kernel if
59 * there is only one iovec.
60 */
61 if (iovcnt == 1)
62 return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
63 else
64 return preadv(fd, iov, iovcnt, offset);
65#else
66 ssize_t sum = 0;
67 ssize_t part;
68
69 for (int i = 0; i < iovcnt; ++i)
70 {
71 part = pg_pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
72 if (part < 0)
73 {
74 if (i == 0)
75 return -1;
76 else
77 return sum;
78 }
79 sum += part;
80 offset += part;
81 if ((size_t) part < iov[i].iov_len)
82 return sum;
83 }
84 return sum;
85#endif
86}
i
int i
Definition: isn.c:77
#define pg_pread
Definition: port.h:226
static int fd(const char *x, int i)
Definition: preproc-init.c:105

References fd(), i, and pg_pread.

Referenced by FileReadV(), and pgaio_io_perform_synchronously().

pg_pwritev()

static ssize_t pg_pwritev ( int  fd,
const struct iovec *  iov,
int  iovcnt,
off_t  offset 
)
inlinestatic

Definition at line 93 of file pg_iovec.h.

94{
95#if HAVE_DECL_PWRITEV
96 /*
97 * Avoid a small amount of argument copying overhead in the kernel if
98 * there is only one iovec.
99 */
100 if (iovcnt == 1)
101 return pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
102 else
103 return pwritev(fd, iov, iovcnt, offset);
104#else
105 ssize_t sum = 0;
106 ssize_t part;
107
108 for (int i = 0; i < iovcnt; ++i)
109 {
110 part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
111 if (part < 0)
112 {
113 if (i == 0)
114 return -1;
115 else
116 return sum;
117 }
118 sum += part;
119 offset += part;
120 if ((size_t) part < iov[i].iov_len)
121 return sum;
122 }
123 return sum;
124#endif
125}
#define pg_pwrite
Definition: port.h:227

References fd(), i, and pg_pwrite.

Referenced by FileWriteV(), pg_pwritev_with_retry(), and pgaio_io_perform_synchronously().

AltStyle によって変換されたページ (->オリジナル) /