fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / stdio64 / fsetpos64.c
blob046990d7aaa03f39d1a3f767d8421dbcba815f35
1 /*
2 FUNCTION
3 <<fsetpos64>>---restore position of a large stream or file
5 INDEX
6 fsetpos64
7 INDEX
8 _fsetpos64_r
10 ANSI_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 TRAD_SYNOPSIS
17 #include <stdio.h>
18 int fsetpos64(<[fp]>, <[pos]>)
19 FILE *<[fp]>;
20 _fpos64_t *<[pos]>;
22 int _fsetpos64_r(<[ptr]>, <[fp]>, <[pos]>)
23 struct _reent *<[ptr]>;
24 FILE *<[fp]>;
25 _fpos64_t *<[pos]>;
27 DESCRIPTION
28 Objects of type <<FILE>> can have a ``position'' that records how much
29 of the file your program has already read. Many of the <<stdio>> functions
30 depend on this position, and many change it as a side effect.
32 You can use <<fsetpos64>> to return the large file identified by <[fp]> to a
33 previous position <<*<[pos]>>> (after first recording it with <<fgetpos64>>).
35 See <<fseeko64>> for a similar facility.
37 RETURNS
38 <<fgetpos64>> returns <<0>> when successful. If <<fgetpos64>> fails, the
39 result is <<1>>. The reason for failure is indicated in <<errno>>:
40 either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
41 64-bit repositioning) or <<EINVAL>> (invalid file position).
43 PORTABILITY
44 <<fsetpos64>> is a glibc extension.
46 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
47 <<lseek64>>, <<read>>, <<sbrk>>, <<write>>.
50 #include <stdio.h>
52 #ifdef __LARGE64_FILES
54 int
55 _DEFUN (_fsetpos64_r, (ptr, iop, pos),
56 struct _reent *ptr _AND
57 FILE * iop _AND
58 _CONST _fpos64_t * pos)
60 int x = _fseeko64_r (ptr, iop, (_off64_t)(*pos), SEEK_SET);
62 if (x != 0)
63 return 1;
64 return 0;
67 #ifndef _REENT_ONLY
69 int
70 _DEFUN (fsetpos64, (iop, pos),
71 FILE * iop _AND
72 _CONST _fpos64_t * pos)
74 return _fsetpos64_r (_REENT, iop, pos);
77 #endif /* !_REENT_ONLY */
79 #endif /* __LARGE64_FILES */