mailing list of musl libc
 help / color / mirror / code / Atom feed
eedce03a2190774ec91aa18e5ac44a2a4eada45c blob 876 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
 
#include "stdio_impl.h"
#include <sys/uio.h>

size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
{
	struct iovec iovs[2] = {
		{ .iov_base = f->wbase, .iov_len = f->wpos-f->wbase },
		{ .iov_base = (void *)buf, .iov_len = len }
	};
	struct iovec *iov = iovs;
	size_t rem = iov[0].iov_len + iov[1].iov_len;
	int iovcnt = 2;
	ssize_t cnt;
	if (iov[0].iov_len == 0) {
		iov++;
		iovcnt--;
	}
	for (;;) {
		cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
		if (cnt == rem) {
			f->wend = f->buf + f->buf_size;
			f->wpos = f->wbase = f->buf;
			return len;
		}
		if (cnt < 0) {
			f->wpos = f->wbase = f->wend = 0;
			f->flags |= F_ERR;
			return iovcnt == 2 ? 0 : len-iov[0].iov_len;
		}
		rem -= cnt;
		if (cnt > iov[0].iov_len) {
			cnt -= iov[0].iov_len;
			iov++; iovcnt--;
		}
		iov[0].iov_base = (char *)iov[0].iov_base + cnt;
		iov[0].iov_len -= cnt;
	}
}
debug log:

solving eedce03a ...
found eedce03a in https://inbox.vuxu.org/musl/20201012164342.2987876-1-jouni.roivas@tuxera.com/ ||
	https://inbox.vuxu.org/musl/20201012125901.2629590-1-jouni.roivas@tuxera.com/
found d2d89475 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 d2d89475b0f9429dca8b538b689f97c27bbe5fee	src/stdio/__stdio_write.c

applying [1/2] https://inbox.vuxu.org/musl/20201012164342.2987876-1-jouni.roivas@tuxera.com/
diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
index d2d89475..eedce03a 100644

Checking patch src/stdio/__stdio_write.c...
Applied patch src/stdio/__stdio_write.c cleanly.

skipping https://inbox.vuxu.org/musl/20201012125901.2629590-1-jouni.roivas@tuxera.com/ for eedce03a
index at:
100644 eedce03a2190774ec91aa18e5ac44a2a4eada45c	src/stdio/__stdio_write.c

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

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).