fcloseall.c 832 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. /* NOTE: GLIBC difference!!! -- fcloseall
  9. * According to the info pages, glibc actually fclose()s all open files.
  10. * Apparently, glibc's new version only fflush()s and unbuffers all
  11. * writing streams to cope with unordered destruction of c++ static
  12. * objects.
  13. */
  14. int fcloseall (void)
  15. {
  16. #ifdef __STDIO_HAS_OPENLIST
  17. int retval = 0;
  18. __STDIO_THREADLOCK_OPENLIST;
  19. while (_stdio_openlist) {
  20. if (fclose(_stdio_openlist)) {
  21. retval = EOF;
  22. }
  23. }
  24. __STDIO_THREADUNLOCK_OPENLIST;
  25. return retval;
  26. #else
  27. #warning Always fails in this configuration because no open file list.
  28. return EOF;
  29. #endif
  30. }