X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=ea675da34abbfd4f34edcd042314b8fb93cf9426;hb=21a172dd36cae7a08492fd3a7500d7bf0daee13e;hp=6cd7b0733a85a3e83deb5c14ed1f6616888d3480;hpb=dab441aea240f3b7c18a26d2ef51979ea36c301c;p=musl diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index 6cd7b073..ea675da3 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,12 +1,5 @@ #include "stdio_impl.h" #include -#include - -static void cleanup(void *p) -{ - FILE *f = p; - if (!f->lockcount) __unlockfile(f); -} size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) { @@ -16,13 +9,11 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) }; ssize_t cnt; - pthread_cleanup_push(cleanup, f); - cnt = syscall_cp(SYS_readv, f->fd, iov, 2); - pthread_cleanup_pop(0); + 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;