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