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 #ifdef __UCLIBC_HAS_LFS__
20 libc_hidden_proto(fseeko64)
22 libc_hidden_proto(fseek)
24 int FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence)
26 #if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE)
28 return fseeko64(stream, offset, whence);
32 __offmax_t pos = offset;
34 __STDIO_AUTO_THREADLOCK_VAR;
36 if (((unsigned int) whence) > 2) {
39 __STDIO_AUTO_THREADLOCK(stream);
41 __STDIO_STREAM_VALIDATE(stream);
43 if ((!__STDIO_STREAM_IS_WRITING(stream)
44 || !__STDIO_COMMIT_WRITE_BUFFER(stream))
45 && ((whence != SEEK_CUR)
46 || (__stdio_adjust_position(stream, &pos) >= 0))
47 && (__SEEK(stream, &pos, whence) >= 0)
50 /* Clear reading/writing modes, EOF, and ungots. */
51 stream->__modeflags &=
52 ~(__MASK_READING|__FLAG_WRITING|__FLAG_EOF);
54 /* Make sure all pointers are reset. */
55 __STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream);
56 __STDIO_STREAM_DISABLE_GETC(stream);
57 __STDIO_STREAM_DISABLE_PUTC(stream);
59 /* We reinitialize the mbstate object. Doing so is
60 * implementation defined behavior. */
61 #ifdef __STDIO_MBSTATE
62 __INIT_MBSTATE(&(stream->__state));
64 #ifdef __UCLIBC_HAS_WCHAR__
65 stream->__ungot_width[0] = 0;
71 __STDIO_STREAM_VALIDATE(stream);
73 __STDIO_AUTO_THREADUNLOCK(stream);
82 libc_hidden_def(fseeko64)
84 libc_hidden_def(fseek)
85 strong_alias(fseek,fseeko)