1 #include "stdio_impl.h"
4 size_t __stdio_write(FILE *f
, const unsigned char *buf
, size_t len
)
6 struct iovec iovs
[2] = {
7 { .iov_base
= f
->wbase
, .iov_len
= f
->wpos
-f
->wbase
},
8 { .iov_base
= (void *)buf
, .iov_len
= len
}
10 struct iovec
*iov
= iovs
;
11 size_t rem
= iov
[0].iov_len
+ iov
[1].iov_len
;
15 cnt
= syscall(SYS_writev
, f
->fd
, iov
, iovcnt
);
17 f
->wend
= f
->buf
+ f
->buf_size
;
18 f
->wpos
= f
->wbase
= f
->buf
;
22 f
->wpos
= f
->wbase
= f
->wend
= 0;
24 return iovcnt
== 2 ? 0 : len
-iov
[0].iov_len
;
27 if (cnt
> iov
[0].iov_len
) {
28 cnt
-= iov
[0].iov_len
;
31 iov
[0].iov_base
= (char *)iov
[0].iov_base
+ cnt
;
32 iov
[0].iov_len
-= cnt
;