_rfill.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 __UCLIBC_MJN3_ONLY__
  9. #warning CONSIDER: Do we really need a seperate rfill function?
  10. #endif
  11. #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.
  16. */
  17. size_t attribute_hidden __stdio_rfill(register FILE *__restrict stream)
  18. {
  19. size_t rv;
  20. __STDIO_STREAM_VALIDATE(stream);
  21. assert(stream->__filedes >= -2);
  22. assert(__STDIO_STREAM_IS_READING(stream));
  23. assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream)); /* Buffer must be empty. */
  24. assert(__STDIO_STREAM_BUFFER_SIZE(stream)); /* Must have a buffer. */
  25. assert(!(stream->__modeflags & __FLAG_UNGOT));
  26. #ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
  27. assert(stream->__bufgetc_u == stream->__bufstart);
  28. #endif
  29. rv = __stdio_READ(stream, stream->__bufstart,
  30. stream->__bufend - stream->__bufstart);
  31. stream->__bufpos = stream->__bufstart;
  32. stream->__bufread = stream->__bufstart + rv;
  33. __STDIO_STREAM_VALIDATE(stream);
  34. return rv;
  35. }
  36. #endif