[Patch] Fix libstdc++/11378 (take2) + xsputn optmizations

Nathan Myers ncm-nospam@cantrip.org
Tue Jul 8 17:02:00 GMT 2003


On Tue, Jul 08, 2003 at 11:23:42AM -0500, Benjamin Kosnik wrote:
> 
> >I think that means 64-bit streampos and streamoff types, mainly.  
> 
> If -D_FILE_OFFSET_BITS=64 is added, as below, then streampos will be ok.
> Streamoff can be fixed in config/io/c_io_stdio.h, by using long long
> instead of long for non-64 bit targets.
> 
> If fseek/fgetpos/fsetpos were being used, then this would be all that
> was necessary, as _FILE_OFFSET_BITS would switch fseek->fseek64,
> fgetpos->fgetpos64, fsetpos->fsetpos64. With lseek, I don't think there
> are as many options.

I think it would be a grave error to introduce compile-time
dependencies into the interface.  Glibc had no choice, as they
were constrained by backward compatibility.  

Instead, our streamoff and streampos types should always be 64-bit
types on all platforms.  (That is, "int64_t", not "long long".) 
Furthermore, we should use the 64-bit versions of system calls 
automatically wherever they exist.  Where they don't, we should check 
for range errors where we convert a 64-bit offset to a 32-bit offset.

As a matter of staging, we might introduce the 64-bit types and the 
range checks first, and then work on enabling use of the 64-bit system 
calls after.  That would probably flush out helpers quicker.

Nathan Myers
ncm-nospam@cantrip.org



More information about the Libstdc++ mailing list