putchar.c 824 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #undef putchar
  9. #ifdef __DO_UNLOCKED
  10. #undef putchar_unlocked
  11. int putchar_unlocked(int c)
  12. {
  13. register FILE *stream = stdout;
  14. return __PUTC_UNLOCKED_MACRO(c, stream);
  15. }
  16. #ifndef __UCLIBC_HAS_THREADS__
  17. strong_alias(putchar_unlocked,putchar)
  18. #endif
  19. #elif defined __UCLIBC_HAS_THREADS__
  20. int putchar(int c)
  21. {
  22. register FILE *stream = stdout;
  23. if (stream->__user_locking != 0) {
  24. return __PUTC_UNLOCKED_MACRO(c, stream);
  25. } else {
  26. int retval;
  27. __STDIO_ALWAYS_THREADLOCK(stream);
  28. retval = __PUTC_UNLOCKED_MACRO(c, stream);
  29. __STDIO_ALWAYS_THREADUNLOCK(stream);
  30. return retval;
  31. }
  32. }
  33. #endif