OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / stdio / getchar.c
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 libc_hidden_proto(__fgetc_unlocked)
11
12 #undef getchar
13 #ifdef __DO_UNLOCKED
14
15 #undef getchar_unlocked
16 int getchar_unlocked(void)
17 {
18         register FILE *stream = stdin;
19
20         return __GETC_UNLOCKED_MACRO(stream);
21 }
22
23 #ifndef __UCLIBC_HAS_THREADS__
24 strong_alias(getchar_unlocked,getchar)
25 #endif
26
27 #elif defined __UCLIBC_HAS_THREADS__
28
29 int getchar(void)
30 {
31         register FILE *stream = stdin;
32
33         if (stream->__user_locking != 0) {
34                 return __GETC_UNLOCKED_MACRO(stream);
35         } else {
36                 int retval;
37                 __STDIO_ALWAYS_THREADLOCK(stream);
38                 retval = __GETC_UNLOCKED_MACRO(stream);
39                 __STDIO_ALWAYS_THREADUNLOCK(stream);
40                 return retval;
41         }
42 }
43
44 #endif