fcloseall.c 859 B

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