fputs.c 1.2 KB

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