Re: libstdc++/8610: std::streamoff type is 32-bit in GCC 3.2 whereas it was 64-bit in GCC 2.96
Jason Elbaum <[email protected]> Thu, 27 Feb 2003 11:47:54 +0200
| Newsgroups | gmane.comp.gcc.bugs,gmane.comp.gcc.prs |
|---|---|
| Organization | Motorola Semiconductor Israel |
| Message-ID | <[email protected]> |
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8610
Regarding PR 8610: I've recently built gcc-3.2.1 in large file mode
under Solaris 7. To do so, I made the following changes. Since I'm not
familiar with the internals of libstdc++ or g++, I don't know whether
this is the ideal way to implement this change, but it does work for
this particular configuration.
In particular, I'm assuming this library code can be compiled *either*
for standard file access *or* for large file I/O, but that the choice
must be built-in at compile time of the compiler library. In other
words, this becomes a large-file-I/O compiler installation which will
not work correctly if large file I/O is not enabled (since basic_file.o
will incorporate a particular setting for _FILE_OFFSET_BITS which may be
different from the compile-time setting, causing incompatible types for
streamoff). To fix this, I assume seekoff()/seekpos() must be inlined
and implemented in the header file. I have not done this.
My changes:
1. In libstdc++-v3/config/io/c_io_stdio.h:
Old code:
typedef long streamoff;
New code:
typedef off_t streamoff;
2. In sparc-sun-solaris2.7/libstdc++-v3/src/basic_file.cc:
In __basic_file<char>::seekoff():
#if _FILE_OFFSET_BITS == 64
fseeko(_M_cfile, __off, __way);
return ftello(_M_cfile);
#else
fseek(_M_cfile, __off, __way);
return ftell(_M_cfile);
#endif
In __basic_file<char>::seekpos():
#if _FILE_OFFSET_BITS == 64
fseeko(_M_cfile, __pos, ios_base::beg);
return ftello(_M_cfile);
#else
fseek(_M_cfile, __pos, ios_base::beg);
return ftell(_M_cfile);
#endif
Regards,
Jason Elbaum
[email protected]