Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio64 / fsetpos64.c
blob254eb53d7578baac70760169c2aab452b402e708
1 /*
2 FUNCTION
3 <<fsetpos64>>---restore position of a large stream or file
5 INDEX
6 fsetpos64
7 INDEX
8 _fsetpos64_r
10 SYNOPSIS
11 #include <stdio.h>
12 int fsetpos64(FILE *<[fp]>, const _fpos64_t *<[pos]>);
13 int _fsetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>,
14 const _fpos64_t *<[pos]>);
16 DESCRIPTION
17 Objects of type <<FILE>> can have a ``position'' that records how much
18 of the file your program has already read. Many of the <<stdio>> functions
19 depend on this position, and many change it as a side effect.
21 You can use <<fsetpos64>> to return the large file identified by <[fp]> to a
22 previous position <<*<[pos]>>> (after first recording it with <<fgetpos64>>).
24 See <<fseeko64>> for a similar facility.
26 RETURNS
27 <<fgetpos64>> returns <<0>> when successful. If <<fgetpos64>> fails, the
28 result is <<1>>. The reason for failure is indicated in <<errno>>:
29 either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
30 64-bit repositioning) or <<EINVAL>> (invalid file position).
32 PORTABILITY
33 <<fsetpos64>> is a glibc extension.
35 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
36 <<lseek64>>, <<read>>, <<sbrk>>, <<write>>.
39 #include <stdio.h>
41 #ifdef __LARGE64_FILES
43 int
44 _fsetpos64_r (struct _reent *ptr,
45 FILE * iop,
46 const _fpos64_t * pos)
48 int x = _fseeko64_r (ptr, iop, (_off64_t)(*pos), SEEK_SET);
50 if (x != 0)
51 return 1;
52 return 0;
55 #ifndef _REENT_ONLY
57 int
58 fsetpos64 (FILE * iop,
59 const _fpos64_t * pos)
61 return _fsetpos64_r (_REENT, iop, pos);
64 #endif /* !_REENT_ONLY */
66 #endif /* __LARGE64_FILES */