__fpending.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #include <stdio_ext.h>
  9. /* Solaris function --
  10. * Returns the number of bytes in the buffer for a writing stream.
  11. *
  12. * NOTE: GLIBC DIFFERENCE!!!
  13. *
  14. * glibc will return the number of wide chars pending for wide oriented
  15. * streams. We always return the number of bytes in the buffer, as we
  16. * convert wide chars to their multibyte encodings and buffer _those_.
  17. */
  18. #ifdef __UCLIBC_HAS_WCHAR__
  19. #warning Note: Unlike the glibc version, this __fpending returns bytes in buffer for wide streams too!
  20. link_warning(__fpending, "This version of __fpending returns bytes remaining in buffer for both narrow and wide streams. glibc's version returns wide chars in buffer for the wide stream case.")
  21. #endif
  22. size_t __fpending(register FILE * __restrict stream)
  23. {
  24. __STDIO_STREAM_VALIDATE(stream);
  25. return (__STDIO_STREAM_IS_WRITING(stream))
  26. ? __STDIO_STREAM_BUFFER_WUSED(stream)
  27. : 0;
  28. }