netinet/in.h: add IPPROTO_MH
[uclibc-ng.git] / libc / stdio / getchar.c
blobb6c650c9be990709e7dbead3c1aa309421b472f7
1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
6 */
8 #include "_stdio.h"
11 #undef getchar
12 #ifdef __DO_UNLOCKED
14 /* the only use of the hidden getchar_unlocked is in gets.c */
15 #undef getchar_unlocked
16 int getchar_unlocked(void)
18 register FILE *stream = stdin;
20 return __GETC_UNLOCKED_MACRO(stream);
22 libc_hidden_def(getchar_unlocked)
24 #ifndef __UCLIBC_HAS_THREADS__
25 strong_alias(getchar_unlocked,getchar)
26 #endif
28 #elif defined __UCLIBC_HAS_THREADS__
30 int getchar(void)
32 register FILE *stream = stdin;
34 if (stream->__user_locking != 0) {
35 return __GETC_UNLOCKED_MACRO(stream);
36 } else {
37 int retval;
38 __STDIO_ALWAYS_THREADLOCK(stream);
39 retval = __GETC_UNLOCKED_MACRO(stream);
40 __STDIO_ALWAYS_THREADUNLOCK(stream);
41 return retval;
45 #endif