#include <limits.h>
#include <sys/uio.h>
#include <unistd.h>
Go to the source code of this file.
|
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) |
|
◆ PG_IOV_MAX
#define PG_IOV_MAX Min(IOV_MAX, 32) |
◆ pg_preadv()
static ssize_t pg_preadv |
( |
int |
fd, |
|
|
const struct iovec * |
iov, |
|
|
int |
iovcnt, |
|
|
off_t |
offset |
|
) |
| |
|
inlinestatic |
Definition at line 44 of file pg_iovec.h.
45{
46#if HAVE_DECL_PREADV
47
48
49
50
51 if (iovcnt == 1)
52 return pread(
fd, iov[0].iov_base, iov[0].iov_len, offset);
53 else
54 return preadv(
fd, iov, iovcnt, offset);
55#else
56 ssize_t sum = 0;
57 ssize_t part;
58
59 for (
int i = 0;
i < iovcnt; ++
i)
60 {
61 part =
pg_pread(
fd, iov[
i].iov_base, iov[
i].iov_len, offset);
62 if (part < 0)
63 {
65 return -1;
66 else
67 return sum;
68 }
69 sum += part;
70 offset += part;
71 if ((
size_t) part < iov[
i].iov_len)
72 return sum;
73 }
74 return sum;
75#endif
76}
static int fd(const char *x, int i)
References fd(), i, and pg_pread.
Referenced by FileReadV().
◆ pg_pwritev()
static ssize_t pg_pwritev |
( |
int |
fd, |
|
|
const struct iovec * |
iov, |
|
|
int |
iovcnt, |
|
|
off_t |
offset |
|
) |
| |
|
inlinestatic |
Definition at line 83 of file pg_iovec.h.
84{
85#if HAVE_DECL_PWRITEV
86
87
88
89
90 if (iovcnt == 1)
91 return pwrite(
fd, iov[0].iov_base, iov[0].iov_len, offset);
92 else
93 return pwritev(
fd, iov, iovcnt, offset);
94#else
95 ssize_t sum = 0;
96 ssize_t part;
97
98 for (
int i = 0;
i < iovcnt; ++
i)
99 {
100 part =
pg_pwrite(
fd, iov[
i].iov_base, iov[
i].iov_len, offset);
101 if (part < 0)
102 {
104 return -1;
105 else
106 return sum;
107 }
108 sum += part;
109 offset += part;
110 if ((
size_t) part < iov[
i].iov_len)
111 return sum;
112 }
113 return sum;
114#endif
115}
References fd(), i, and pg_pwrite.
Referenced by FileWriteV(), and pg_pwritev_with_retry().