X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=ea675da34abbfd4f34edcd042314b8fb93cf9426;hb=2fab90a71acd3698954c08b9062db67188443dd7;hp=5947344438b30559206d0966210455c28a9c6615;hpb=2b4fcfdacf93c3dfd6ac15e31790a9e154374679;p=musl diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index 59473444..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,12 +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); - return cnt; + f->flags |= cnt ? F_ERR : F_EOF; + return 0; } if (cnt <= iov[0].iov_len) return cnt; cnt -= iov[0].iov_len;