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