fputs.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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: The standard says fputs returns a nonnegative number on
  9. * success. In this implementation, we return the length of the
  10. * string written on success.
  11. */
  12. #ifdef __DO_UNLOCKED
  13. int fputs_unlocked(register const char * __restrict s,
  14. FILE * __restrict stream)
  15. {
  16. size_t n = strlen(s);
  17. return ((fwrite_unlocked(s, 1, n, stream) == n) ? n : EOF);
  18. }
  19. libc_hidden_def(fputs_unlocked)
  20. #ifndef __UCLIBC_HAS_THREADS__
  21. strong_alias(fputs_unlocked,fputs)
  22. libc_hidden_def(fputs)
  23. #endif
  24. #elif defined __UCLIBC_HAS_THREADS__
  25. int fputs(const char * __restrict s, register FILE * __restrict stream)
  26. {
  27. int retval;
  28. __STDIO_AUTO_THREADLOCK_VAR;
  29. __STDIO_AUTO_THREADLOCK(stream);
  30. retval = fputs_unlocked(s, stream);
  31. __STDIO_AUTO_THREADUNLOCK(stream);
  32. return retval;
  33. }
  34. libc_hidden_def(fputs)
  35. #endif