1 /* Copyright (C) 2004       Manuel Novoa III    <mjn3@codepoet.org>
2  *
3  * GNU Library General Public License (LGPL) version 2 or later.
4  *
5  * Dedicated to Toni.  See uClibc/DEDICATION.mjn3 for details.
6  */
7 
8 #include "_stdio.h"
9 
10 #ifdef __STDIO_BUFFERS
11 
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.
16  */
17 
__stdio_rfill(register FILE * __restrict stream)18 size_t attribute_hidden __stdio_rfill(register FILE *__restrict stream)
19 {
20 	size_t rv;
21 
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);
30 #endif
31 
32 	rv = __stdio_READ(stream, stream->__bufstart,
33 					  stream->__bufend - stream->__bufstart);
34 	stream->__bufpos = stream->__bufstart;
35 	stream->__bufread = stream->__bufstart + rv;
36 
37 	__STDIO_STREAM_VALIDATE(stream);
38 	return rv;
39 }
40 
41 #endif
42