fseek() vs. fseeko()

Corinna Vinschen vinschen@redhat.com
Tue Jun 19 18:27:00 GMT 2012

On Jun 19 15:29, Sebastian Huber wrote:
> On 06/19/2012 03:11 PM, Corinna Vinschen wrote:
> >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.
> Ok, then this is a bug in the RTEMS targets using 64-bit off_t.
> Since the fseeko64() etc. are non-standard this should be invisible
> for the user.

In some way you can also declare this a bug in newlib.

But it would not be enough to redefine the _fseek_r API.  Since this is
an exported function, it's not such a good idea to change its arguments,
otherwise you break backward compatibility.

In theory, the right thing to do would be perhaps to change
fseeko/ftello so they call _fseek_r/_ftell_r on systems with 32 bit off_t
and _fseeko64_r/_ftello64_r on systems with 64 bit off_t.

Along these lines, fgetpos and fsetpos are a bit tricky since they
depend on the definition of fpos_t in include/stdio.h.  Right now,
only Cygwin defines fpos_t as 64 bit type in stdio.h, all other
targets define fpos_t as 32 bit and fpos64_t as 64 bit type to make
a clear distinction between the 32 bit and the 64 bit set of functions.
But just like on Cygwin, this isn't desirable on targets supporting 64
bit files.  But we can;t change that easily without breaking backward
compatibility.  Perhaps we should just define fgetpos and fsetpos as
macros which call fgetpos64 and fsetpos64 on __LARGE64_FILES targets
in stdio.h...


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

More information about the Newlib mailing list