OSDN Git Service

Last portion of libc_hidden_proto removal.
[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 /* the only use of the hidden getchar_unlocked is in gets.c */
16 #undef getchar_unlocked
17 /* libc_hidden_proto(getchar_unlocked) */
18 int getchar_unlocked(void)
19 {
20         register FILE *stream = stdin;
21
22         return __GETC_UNLOCKED_MACRO(stream);
23 }
24 libc_hidden_def(getchar_unlocked)
25
26 #ifndef __UCLIBC_HAS_THREADS__
27 strong_alias(getchar_unlocked,getchar)
28 #endif
29
30 #elif defined __UCLIBC_HAS_THREADS__
31
32 int getchar(void)
33 {
34         register FILE *stream = stdin;
35
36         if (stream->__user_locking != 0) {
37                 return __GETC_UNLOCKED_MACRO(stream);
38         } else {
39                 int retval;
40                 __STDIO_ALWAYS_THREADLOCK(stream);
41                 retval = __GETC_UNLOCKED_MACRO(stream);
42                 __STDIO_ALWAYS_THREADUNLOCK(stream);
43                 return retval;
44         }
45 }
46
47 #endif