2024-02-28 02:52:00 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* iov.c - helpers for using (partial) iovecs.
|
|
|
|
*
|
|
|
|
* Copyrigh Red Hat
|
|
|
|
* Author: Laurent Vivier <lvivier@redhat.com>
|
|
|
|
*
|
|
|
|
* This file also contains code originally from QEMU include/qemu/iov.h:
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Amit Shah <amit.shah@redhat.com>
|
|
|
|
* Michael Tokarev <mjt@tls.msk.ru>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IOVEC_H
|
|
|
|
#define IOVEC_H
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-05-01 08:53:52 +02:00
|
|
|
#define IOV_OF_LVALUE(lval) \
|
|
|
|
(struct iovec){ .iov_base = &(lval), .iov_len = sizeof(lval) }
|
|
|
|
|
2024-02-28 02:52:01 +01:00
|
|
|
size_t iov_skip_bytes(const struct iovec *iov, size_t n,
|
2024-03-01 05:06:44 +01:00
|
|
|
size_t skip, size_t *offset);
|
2024-02-28 02:52:00 +01:00
|
|
|
size_t iov_from_buf(const struct iovec *iov, size_t iov_cnt,
|
|
|
|
size_t offset, const void *buf, size_t bytes);
|
|
|
|
size_t iov_to_buf(const struct iovec *iov, size_t iov_cnt,
|
|
|
|
size_t offset, void *buf, size_t bytes);
|
|
|
|
size_t iov_size(const struct iovec *iov, size_t iov_cnt);
|
|
|
|
#endif /* IOVEC_H */
|