X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=ea675da34abbfd4f34edcd042314b8fb93cf9426;hb=dec8f0a4fa7aa533c843e6eaec862be674ff3a1a;hp=c99ca9a913314bdb15c221943327a39e50dc2a75;hpb=3f25354e624361f40011b242c492c2118184cc44;p=musl diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index c99ca9a9..ea675da3 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,11 +1,5 @@ #include "stdio_impl.h" -#include - -static void cleanup(void *p) -{ - FILE *f = p; - if (!f->lockcount) __unlockfile(f); -} +#include size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) { @@ -15,17 +9,11 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) }; ssize_t cnt; - if (libc.main_thread) { - pthread_cleanup_push(cleanup, f); - cnt = syscall_cp(SYS_readv, f->fd, iov, 2); - pthread_cleanup_pop(0); - } else { - cnt = syscall(SYS_readv, f->fd, iov, 2); - } + cnt = iov[0].iov_len ? syscall(SYS_readv, f->fd, iov, 2) + : syscall(SYS_read, f->fd, iov[1].iov_base, iov[1].iov_len); if (cnt <= 0) { - f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt); - f->rpos = f->rend = 0; - return cnt; + f->flags |= cnt ? F_ERR : F_EOF; + return 0; } if (cnt <= iov[0].iov_len) return cnt; cnt -= iov[0].iov_len;