1 /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
3 * GNU Library General Public License (LGPL) version 2 or later.
5 * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
10 #if SEEK_SET != 0 || SEEK_CUR != 1 || SEEK_END != 2
11 # error Assumption violated -- values of SEEK_SET, SEEK_CUR, SEEK_END
14 #ifndef __DO_LARGEFILE
16 # define OFFSET_TYPE long int
19 int FSEEK(register FILE *stream
, OFFSET_TYPE offset
, int whence
)
21 #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE)
23 return fseeko64(stream
, offset
, whence
);
27 __offmax_t pos
= offset
;
29 __STDIO_AUTO_THREADLOCK_VAR
;
31 if (((unsigned int) whence
) > 2) {
34 __STDIO_AUTO_THREADLOCK(stream
);
36 __STDIO_STREAM_VALIDATE(stream
);
38 if ((!__STDIO_STREAM_IS_WRITING(stream
)
39 || !__STDIO_COMMIT_WRITE_BUFFER(stream
))
40 && ((whence
!= SEEK_CUR
)
41 || (__stdio_adjust_position(stream
, &pos
) >= 0))
42 && (__SEEK(stream
, &pos
, whence
) >= 0)
45 /* Clear reading/writing modes, EOF, and ungots. */
46 stream
->__modeflags
&=
47 ~(__MASK_READING
|__FLAG_WRITING
|__FLAG_EOF
);
49 /* Make sure all pointers are reset. */
50 __STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream
);
51 __STDIO_STREAM_DISABLE_GETC(stream
);
52 __STDIO_STREAM_DISABLE_PUTC(stream
);
54 /* We reinitialize the mbstate object. Doing so is
55 * implementation defined behavior. */
56 #ifdef __STDIO_MBSTATE
57 __INIT_MBSTATE(&(stream
->__state
));
59 #ifdef __UCLIBC_HAS_WCHAR__
60 stream
->__ungot_width
[0] = 0;
66 __STDIO_STREAM_VALIDATE(stream
);
68 __STDIO_AUTO_THREADUNLOCK(stream
);
77 libc_hidden_def(fseeko64
)
79 libc_hidden_def(fseek
)
80 strong_alias_untyped(fseek
,fseeko
)