source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/stdio/__stdio_read.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 544 bytes
Line 
1#include "stdio_impl.h"
2#include <sys/uio.h>
3
4size_t __stdio_read(FILE *f, unsigned char *buf, size_t len)
5{
6 struct iovec iov[2] = {
7 { .iov_base = buf, .iov_len = len - !!f->buf_size },
8 { .iov_base = f->buf, .iov_len = f->buf_size }
9 };
10 ssize_t cnt;
11
12 cnt = syscall(SYS_readv, f->fd, iov, 2);
13 if (cnt <= 0) {
14 f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt);
15 return cnt;
16 }
17 if (cnt <= iov[0].iov_len) return cnt;
18 cnt -= iov[0].iov_len;
19 f->rpos = f->buf;
20 f->rend = f->buf + cnt;
21 if (f->buf_size) buf[len-1] = *f->rpos++;
22 return len;
23}
Note: See TracBrowser for help on using the repository browser.