fseek() vs. fseeko()

Corinna Vinschen vinschen@redhat.com
Tue Jun 19 17:11:00 GMT 2012


On Jun 19 14:54, Sebastian Huber wrote:
> It seems that fsetpos() is also limited to long:
> 
> int
> _DEFUN(_fsetpos_r, (ptr, iop, pos),
>        struct _reent * ptr _AND
>        FILE * iop          _AND
>        _CONST _fpos_t * pos)
> {
>   int x = _fseek_r (ptr, iop, *pos, SEEK_SET);
> 
>   if (x != 0)
>     return 1;
>   return 0;
> }
> 
> I think _fseek_r() should be changed to:
> 
> int
> _DEFUN(_fseek_r, (ptr, fp, offset, whence),
>        struct _reent *ptr _AND
>        register FILE *fp  _AND
>        off_t offset       _AND
>        int whence)

There are 64 bit capable functions available, see newlib/libc/stdio64.
I didn't implement that stuff, but I think the idea was that targets
using 64 bit off_t would use the fseeko64/ftello64/fsetpos64 functions.

In Cygwin, for instance, off_t is 64 bit.  An application calling
fseeko will actually call fseeko64 by redirecting the fseeko entry
point to fseeko64.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat



More information about the Newlib mailing list