1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-07 21:18:41 +03:00

io-util.h: move iovec stuff from macro.h to io-util.h

This commit is contained in:
Lennart Poettering 2015-10-27 01:02:30 +01:00
parent ceee6d3a44
commit afc5dbf37f
14 changed files with 53 additions and 41 deletions

View File

@ -21,8 +21,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <sys/types.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "time-util.h"
@ -37,3 +38,39 @@ int pipe_eof(int fd);
int fd_wait_for_event(int fd, int event, usec_t timeout);
ssize_t sparse_write(int fd, const void *p, size_t sz, size_t run_length);
#define IOVEC_SET_STRING(i, s) \
do { \
struct iovec *_i = &(i); \
char *_s = (char *)(s); \
_i->iov_base = _s; \
_i->iov_len = strlen(_s); \
} while(false)
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n) {
unsigned j;
size_t r = 0;
for (j = 0; j < n; j++)
r += i[j].iov_len;
return r;
}
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
unsigned j;
for (j = 0; j < n; j++) {
size_t sub;
if (_unlikely_(k <= 0))
break;
sub = MIN(i[j].iov_len, k);
i[j].iov_len -= sub;
i[j].iov_base = (uint8_t*) i[j].iov_base + sub;
k -= sub;
}
return k;
}

View File

@ -33,6 +33,7 @@
#include "fd-util.h"
#include "formats-util.h"
#include "io-util.h"
#include "log.h"
#include "macro.h"
#include "missing.h"

View File

@ -22,11 +22,10 @@
***/
#include <assert.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <inttypes.h>
#include <stdbool.h>
#include <sys/param.h>
#include <sys/types.h>
#define _printf_(a,b) __attribute__ ((format (printf, a, b)))
#define _alloc_(...) __attribute__ ((alloc_size(__VA_ARGS__)))
@ -302,42 +301,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
#define char_array_0(x) x[sizeof(x)-1] = 0;
#define IOVEC_SET_STRING(i, s) \
do { \
struct iovec *_i = &(i); \
char *_s = (char *)(s); \
_i->iov_base = _s; \
_i->iov_len = strlen(_s); \
} while(false)
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n) {
unsigned j;
size_t r = 0;
for (j = 0; j < n; j++)
r += i[j].iov_len;
return r;
}
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
unsigned j;
for (j = 0; j < n; j++) {
size_t sub;
if (_unlikely_(k <= 0))
break;
sub = MIN(i[j].iov_len, k);
i[j].iov_len -= sub;
i[j].iov_base = (uint8_t*) i[j].iov_base + sub;
k -= sub;
}
return k;
}
#define VA_FORMAT_ADVANCE(format, ap) \
do { \
int _argtypes[128]; \

View File

@ -20,6 +20,7 @@
***/
#include "fd-util.h"
#include "io-util.h"
#include "parse-util.h"
#include "show-status.h"
#include "string-util.h"

View File

@ -45,6 +45,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "io-util.h"
#include "journald-native.h"
#include "log.h"
#include "macro.h"

View File

@ -21,9 +21,10 @@
#include "audit-type.h"
#include "fd-util.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "journald-audit.h"
#include "missing.h"
#include "hexdecoct.h"
#include "string-util.h"
typedef struct MapField {

View File

@ -26,6 +26,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "io-util.h"
#include "journald-console.h"
#include "journald-server.h"
#include "parse-util.h"

View File

@ -31,6 +31,7 @@
#include "escape.h"
#include "fd-util.h"
#include "formats-util.h"
#include "io-util.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-syslog.h"

View File

@ -26,6 +26,7 @@
#include "fd-util.h"
#include "fs-util.h"
#include "io-util.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-native.h"

View File

@ -44,6 +44,7 @@
#include "fs-util.h"
#include "hashmap.h"
#include "hostname-util.h"
#include "io-util.h"
#include "journal-authenticate.h"
#include "journal-file.h"
#include "journal-internal.h"

View File

@ -33,6 +33,7 @@
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "io-util.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-server.h"

View File

@ -27,6 +27,7 @@
#include "fd-util.h"
#include "formats-util.h"
#include "io-util.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-server.h"

View File

@ -32,6 +32,7 @@
#include "bus-type.h"
#include "bus-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "memfd-util.h"
#include "string-util.h"
#include "strv.h"

View File

@ -22,6 +22,7 @@
#include <netinet/tcp.h>
#include "fd-util.h"
#include "io-util.h"
#include "missing.h"
#include "resolved-dns-stream.h"