fputws.c 945 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. extern int __fputws_unlocked(const wchar_t *__restrict ws,
  9. FILE *__restrict stream);
  10. #ifdef __DO_UNLOCKED
  11. weak_alias(__fputws_unlocked,fputws_unlocked);
  12. #ifndef __UCLIBC_HAS_THREADS__
  13. weak_alias(__fputws_unlocked,fputws);
  14. #endif
  15. int __fputws_unlocked(const wchar_t *__restrict ws,
  16. register FILE *__restrict stream)
  17. {
  18. size_t n = wcslen(ws);
  19. return (_wstdio_fwrite(ws, n, stream) == n) ? 0 : -1;
  20. }
  21. #elif defined __UCLIBC_HAS_THREADS__
  22. int fputws(const wchar_t *__restrict ws, register FILE *__restrict stream)
  23. {
  24. int retval;
  25. __STDIO_AUTO_THREADLOCK_VAR;
  26. __STDIO_AUTO_THREADLOCK(stream);
  27. retval = __fputws_unlocked(ws, stream);
  28. __STDIO_AUTO_THREADUNLOCK(stream);
  29. return retval;
  30. }
  31. #endif