public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 31fbf6d0e1cf6ef60b30a53c47649ce5753e9596 1453 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
// SPDX-License-Identifier: GPL-2.0-or-later

/* some parts copied from QEMU include/qemu/iov.h */

#ifndef IOVEC_H
#define IOVEC_H

#include <unistd.h>
#include <string.h>

size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,
			 size_t offset, const void *buf, size_t bytes);
size_t iov_to_buf_full(const struct iovec *iov, const unsigned int iov_cnt,
		       size_t offset, void *buf, size_t bytes);

static inline size_t iov_from_buf(const struct iovec *iov,
				  unsigned int iov_cnt, size_t offset,
				  const void *buf, size_t bytes)
{
	if (__builtin_constant_p(bytes) && iov_cnt &&
		offset <= iov[0].iov_len && bytes <= iov[0].iov_len - offset) {
		memcpy((char *)iov[0].iov_base + offset, buf, bytes);
		return bytes;
	} else {
		return iov_from_buf_full(iov, iov_cnt, offset, buf, bytes);
	}
}

static inline size_t iov_to_buf(const struct iovec *iov,
				const unsigned int iov_cnt, size_t offset,
				void *buf, size_t bytes)
{
	if (__builtin_constant_p(bytes) && iov_cnt &&
		offset <= iov[0].iov_len && bytes <= iov[0].iov_len - offset) {
		memcpy(buf, (char *)iov[0].iov_base + offset, bytes);
		return bytes;
	} else {
		return iov_to_buf_full(iov, iov_cnt, offset, buf, bytes);
	}
}

size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt);
unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt,
		  const struct iovec *iov, unsigned int iov_cnt,
		  size_t offset, size_t bytes);
#endif

debug log:

solving 31fbf6d0e1cf ...
found 31fbf6d0e1cf in https://archives.passt.top/passt-dev/20240202141151.3762941-2-lvivier@redhat.com/

applying [1/1] https://archives.passt.top/passt-dev/20240202141151.3762941-2-lvivier@redhat.com/
diff --git a/iov.h b/iov.h
new file mode 100644
index 000000000000..31fbf6d0e1cf

Checking patch iov.h...
Applied patch iov.h cleanly.

index at:
100644 31fbf6d0e1cf6ef60b30a53c47649ce5753e9596	iov.h

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).