_rfill.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include "_stdio.h"
  8. #ifdef __STDIO_BUFFERS
  9. /* Read some data into the buffer.
  10. * Returns number of bytes read into the buffer.
  11. * If 0 is returned, then either EOF or ERROR.
  12. * Side effects are those of _stdio_READ.
  13. */
  14. size_t attribute_hidden __stdio_rfill(register FILE *__restrict stream)
  15. {
  16. size_t rv;
  17. __STDIO_STREAM_VALIDATE(stream);
  18. assert(stream->__filedes >= -2);
  19. assert(__STDIO_STREAM_IS_READING(stream));
  20. assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream)); /* Buffer must be empty. */
  21. assert(__STDIO_STREAM_BUFFER_SIZE(stream)); /* Must have a buffer. */
  22. assert(!(stream->__modeflags & __FLAG_UNGOT));
  23. #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
  24. assert(stream->__bufgetc_u == stream->__bufstart);
  25. #endif
  26. rv = __stdio_READ(stream, stream->__bufstart,
  27. stream->__bufend - stream->__bufstart);
  28. stream->__bufpos = stream->__bufstart;
  29. stream->__bufread = stream->__bufstart + rv;
  30. __STDIO_STREAM_VALIDATE(stream);
  31. return rv;
  32. }
  33. #endif