1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
10 #ifdef __STDIO_BUFFERS
12 /* Read some data into the buffer.
13 * Returns number of bytes read into the buffer.
14 * If 0 is returned, then either EOF or ERROR.
15 * Side effects are those of _stdio_READ.
18 size_t attribute_hidden
__stdio_rfill(register FILE *__restrict stream
)
22 __STDIO_STREAM_VALIDATE(stream
);
23 assert(stream
->__filedes
>= -2);
24 assert(__STDIO_STREAM_IS_READING(stream
));
25 assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream
)); /* Buffer must be empty. */
26 assert(__STDIO_STREAM_BUFFER_SIZE(stream
)); /* Must have a buffer. */
27 assert(!(stream
->__modeflags
& __FLAG_UNGOT
));
28 #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
29 assert(stream
->__bufgetc_u
== stream
->__bufstart
);
32 rv
= __stdio_READ(stream
, stream
->__bufstart
,
33 stream
->__bufend
- stream
->__bufstart
);
34 stream
->__bufpos
= stream
->__bufstart
;
35 stream
->__bufread
= stream
->__bufstart
+ rv
;
37 __STDIO_STREAM_VALIDATE(stream
);