blob: 610737d3630ddf0f37f66f40fc1c8c233c81c767 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* 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#ifndef __DO_LARGEFILE
11#define FTELL ftell
12#endif
13
14libc_hidden_proto(FTELL)
15
16int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos)
17{
18#ifdef __STDIO_MBSTATE
19
20 int retval = -1;
21 __STDIO_AUTO_THREADLOCK_VAR;
22
23 __STDIO_AUTO_THREADLOCK(stream);
24
25 if ((pos->__pos = FTELL(stream)) >= 0) {
26 __COPY_MBSTATE(&(pos->__mbstate), &(stream->__state));
27 pos->__mblen_pending = stream->__ungot_width[0];
28 retval = 0;
29 }
30
31 __STDIO_AUTO_THREADUNLOCK(stream);
32
33 return retval;
34
35#else
36
37 return ((pos->__pos = FTELL(stream)) >= 0) ? 0 : -1;
38
39#endif
40}