OSDN Git Service

Last portion of libc_hidden_proto removal.
[uclinux-h8/uClibc.git] / libc / stdio / fileno.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(fileno_unlocked) */
11
12 #ifdef __DO_UNLOCKED
13
14 int fileno_unlocked(register FILE *stream)
15 {
16         __STDIO_STREAM_VALIDATE(stream);
17
18         if ((!__STDIO_STREAM_IS_CUSTOM(stream)) && (stream->__filedes >= 0)) {
19                 return stream->__filedes;
20         }
21
22         __set_errno(EBADF);
23         return -1;
24 }
25 libc_hidden_def(fileno_unlocked)
26
27 #ifndef __UCLIBC_HAS_THREADS__
28 /* libc_hidden_proto(fileno) */
29 strong_alias(fileno_unlocked,fileno)
30 libc_hidden_def(fileno)
31 #endif
32
33 #elif defined __UCLIBC_HAS_THREADS__
34
35 /* libc_hidden_proto(fileno) */
36 int fileno(register FILE *stream)
37 {
38         int retval;
39         __STDIO_AUTO_THREADLOCK_VAR;
40
41         __STDIO_AUTO_THREADLOCK(stream);
42
43         retval = fileno_unlocked(stream);
44
45         __STDIO_AUTO_THREADUNLOCK(stream);
46
47         return retval;
48 }
49 libc_hidden_def(fileno)
50
51 #endif