add function fc_iov_get_bytes
parent
21cd3a9798
commit
29cc5af134
3
HISTORY
3
HISTORY
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
Version 1.56 2022-01-31
|
Version 1.56 2022-02-02
|
||||||
* add function fc_gettid
|
* add function fc_gettid
|
||||||
* function normalize_path: NULL from parameter for getcwd
|
* function normalize_path: NULL from parameter for getcwd
|
||||||
* sockopt.[hc] support tcpwritev and tcpreadv
|
* sockopt.[hc] support tcpwritev and tcpreadv
|
||||||
|
* add function fc_iov_get_bytes
|
||||||
|
|
||||||
Version 1.55 2022-01-12
|
Version 1.55 2022-01-12
|
||||||
* fastcommon php extension adapt to php 8
|
* fastcommon php extension adapt to php 8
|
||||||
|
|
|
||||||
|
|
@ -1232,6 +1232,35 @@ static inline pid_t fc_gettid()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline size_t fc_iov_get_bytes(const
|
||||||
|
struct iovec *iov, const int iovcnt)
|
||||||
|
{
|
||||||
|
const struct iovec *iob;
|
||||||
|
const struct iovec *end;
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
|
switch (iovcnt) {
|
||||||
|
case 0:
|
||||||
|
return 0;
|
||||||
|
case 1:
|
||||||
|
return iov[0].iov_len;
|
||||||
|
case 2:
|
||||||
|
return iov[0].iov_len + iov[1].iov_len;
|
||||||
|
case 3:
|
||||||
|
return iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
|
||||||
|
case 4:
|
||||||
|
return iov[0].iov_len + iov[1].iov_len +
|
||||||
|
iov[2].iov_len + iov[3].iov_len;
|
||||||
|
default:
|
||||||
|
bytes = 0;
|
||||||
|
end = iov + iovcnt;
|
||||||
|
for (iob=iov; iob<end; iob++) {
|
||||||
|
bytes += iob->iov_len;
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue