lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 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 __UCLIBC_MJN3_ONLY__ |
| 11 | #warning CONSIDER: Do we really need a seperate rfill function? |
| 12 | #endif |
| 13 | |
| 14 | #ifdef __STDIO_BUFFERS |
| 15 | |
| 16 | /* Read some data into the buffer. |
| 17 | * Returns number of bytes read into the buffer. |
| 18 | * If 0 is returned, then either EOF or ERROR. |
| 19 | * Side effects are those of _stdio_READ. |
| 20 | */ |
| 21 | |
| 22 | size_t attribute_hidden __stdio_rfill(register FILE *__restrict stream) |
| 23 | { |
| 24 | size_t rv; |
| 25 | |
| 26 | __STDIO_STREAM_VALIDATE(stream); |
| 27 | assert(stream->__filedes >= -1); |
| 28 | assert(__STDIO_STREAM_IS_READING(stream)); |
| 29 | assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream)); /* Buffer must be empty. */ |
| 30 | assert(__STDIO_STREAM_BUFFER_SIZE(stream)); /* Must have a buffer. */ |
| 31 | assert(!(stream->__modeflags & __FLAG_UNGOT)); |
| 32 | #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__ |
| 33 | assert(stream->__bufgetc_u == stream->__bufstart); |
| 34 | #endif |
| 35 | |
| 36 | rv = __stdio_READ(stream, stream->__bufstart, |
| 37 | stream->__bufend - stream->__bufstart); |
| 38 | stream->__bufpos = stream->__bufstart; |
| 39 | stream->__bufread = stream->__bufstart + rv; |
| 40 | |
| 41 | __STDIO_STREAM_VALIDATE(stream); |
| 42 | return rv; |
| 43 | } |
| 44 | |
| 45 | #endif |