OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / stdio / ftello.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 #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE)
11 libc_hidden_proto(ftello64)
12 #endif
13
14 #ifndef __DO_LARGEFILE
15 # define FTELL         ftell
16 # define OFFSET_TYPE   long int
17 #endif
18
19 OFFSET_TYPE FTELL(register FILE *stream)
20 {
21 #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE)
22
23         __offmax_t pos = ftello64(stream);
24
25         if ((sizeof(long) >= sizeof(__offmax_t)) || (((long) pos) == pos)) {
26                 return ((long) pos);
27         } else {
28                 __set_errno(EOVERFLOW);
29                 return -1;
30         }
31
32 #else
33
34         __offmax_t pos = 0;
35         __STDIO_AUTO_THREADLOCK_VAR;
36
37         __STDIO_AUTO_THREADLOCK(stream);
38
39         __STDIO_STREAM_VALIDATE(stream);
40
41         if ((__SEEK(stream, &pos, SEEK_CUR) < 0)
42                 || (__stdio_adjust_position(stream, &pos) < 0)) {
43                 pos = -1;
44         }
45
46         __STDIO_AUTO_THREADUNLOCK(stream);
47
48         return pos;
49
50 #endif
51 }
52
53 #ifdef __DO_LARGEFILE
54 libc_hidden_proto(ftello64)
55 libc_hidden_def(ftello64)
56 #else
57 libc_hidden_proto(ftell)
58 libc_hidden_def(ftell)
59 strong_alias(ftell,ftello)
60 #endif