]> git.ipfire.org Git - thirdparty/glibc.git/blame - libio/ftello64.c
Use <> for include of kernel-features.h.
[thirdparty/glibc.git] / libio / ftello64.c
CommitLineData
3447be7b
RM
1/* Copyright (C) 1993, 1995-2001, 2002, 2003, 2004
2 Free Software Foundation, Inc.
41bdb6e2 3 This file is part of the GNU C Library.
dfd2257a 4
41bdb6e2
AJ
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
dfd2257a 9
41bdb6e2
AJ
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
dfd2257a 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
dfd2257a 14
41bdb6e2
AJ
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA.
dfd2257a 19
41bdb6e2
AJ
20 As a special exception, if you link the code in this file with
21 files compiled with a GNU compiler to produce an executable,
22 that does not cause the resulting executable to be covered by
23 the GNU Lesser General Public License. This exception does not
24 however invalidate any other reasons why the executable file
25 might be covered by the GNU Lesser General Public License.
26 This exception applies to code released by its copyright holders
27 in files containing the exception. */
dfd2257a
UD
28
29#include <stdio.h>
ef52edfc 30#include <stdlib.h>
dfd2257a
UD
31#include <libioP.h>
32#include <errno.h>
33
34
35off64_t
36ftello64 (fp)
37 _IO_FILE *fp;
38{
39#ifdef _G_LSEEK64
d64b6ad0 40 _IO_off64_t pos;
dfd2257a 41 CHECK_FILE (fp, -1L);
0261d33f 42 _IO_acquire_lock (fp);
52a16e58 43 pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
3447be7b 44 if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
d64b6ad0
UD
45 {
46 if (fp->_mode <= 0)
47 pos -= fp->_IO_save_end - fp->_IO_save_base;
d64b6ad0 48 }
0261d33f 49 _IO_release_lock (fp);
dfd2257a
UD
50 if (pos == _IO_pos_BAD)
51 {
52#ifdef EIO
53 if (errno == 0)
54 __set_errno (EIO);
55#endif
56 return -1L;
57 }
d64b6ad0 58 return pos;
dfd2257a
UD
59#else
60 __set_errno (ENOSYS);
61 return -1;
62#endif
63}