Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: fusl/src/stdio/__stdio_read.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/stdio/__stdio_exit.c ('k') | fusl/src/stdio/__stdio_seek.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/stdio/__stdio_read.c
diff --git a/fusl/src/stdio/__stdio_read.c b/fusl/src/stdio/__stdio_read.c
new file mode 100644
index 0000000000000000000000000000000000000000..f8fa6d3bf381bd5356e0f3c7bac33286f828ea25
--- /dev/null
+++ b/fusl/src/stdio/__stdio_read.c
@@ -0,0 +1,23 @@
+#include "stdio_impl.h"
+#include <sys/uio.h>
+
+size_t __stdio_read(FILE *f, unsigned char *buf, size_t len)
+{
+ struct iovec iov[2] = {
+ { .iov_base = buf, .iov_len = len - !!f->buf_size },
+ { .iov_base = f->buf, .iov_len = f->buf_size }
+ };
+ ssize_t cnt;
+
+ cnt = syscall(SYS_readv, f->fd, iov, 2);
+ if (cnt <= 0) {
+ f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt);
+ return cnt;
+ }
+ if (cnt <= iov[0].iov_len) return cnt;
+ cnt -= iov[0].iov_len;
+ f->rpos = f->buf;
+ f->rend = f->buf + cnt;
+ if (f->buf_size) buf[len-1] = *f->rpos++;
+ return len;
+}
« no previous file with comments | « fusl/src/stdio/__stdio_exit.c ('k') | fusl/src/stdio/__stdio_seek.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698