X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=ea675da34abbfd4f34edcd042314b8fb93cf9426;hb=1d5750b95c06913a1f18a995481276d698d20fae;hp=ee17a576c5bb70c66c1def2d9d8f5537d7896059;hpb=58165923890865a6ac042fafce13f440ee986fd9;p=musl diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index ee17a576..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,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;