aboutgitcodebugslistschat
path: root/iov.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-05-01 16:53:52 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-05-02 16:13:31 +0200
commit35598995869b0966eb97a16411d6ba5053005431 (patch)
tree6645dfd2dc3db6c8d311be30e60f68b01ed961fa /iov.h
parent40f8b2976ab09c77b14238d6eabaa7793d5365e4 (diff)
downloadpasst-35598995869b0966eb97a16411d6ba5053005431.tar
passt-35598995869b0966eb97a16411d6ba5053005431.tar.gz
passt-35598995869b0966eb97a16411d6ba5053005431.tar.bz2
passt-35598995869b0966eb97a16411d6ba5053005431.tar.lz
passt-35598995869b0966eb97a16411d6ba5053005431.tar.xz
passt-35598995869b0966eb97a16411d6ba5053005431.tar.zst
passt-35598995869b0966eb97a16411d6ba5053005431.zip
iov: Helper macro to construct iovs covering existing variables or fields
Laurent's recent changes mean we use IO vectors much more heavily in the TCP code. In many of those cases, and few others around the code base, individual iovs of these vectors are constructed to exactly cover existing variables or fields. We can make initializing such iovs shorter and clearer with a macro for the purpose. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'iov.h')
-rw-r--r--iov.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/iov.h b/iov.h
index 6058af7..5668ca5 100644
--- a/iov.h
+++ b/iov.h
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <string.h>
+#define IOV_OF_LVALUE(lval) \
+ (struct iovec){ .iov_base = &(lval), .iov_len = sizeof(lval) }
+
size_t iov_skip_bytes(const struct iovec *iov, size_t n,
size_t skip, size_t *offset);
size_t iov_from_buf(const struct iovec *iov, size_t iov_cnt,