[RFC] Large file iostreams
Pétur Runólfsson
peturr02@ru.is
Thu Oct 16 16:50:00 GMT 2003
Benjamin Kosnik wrote:
> >The standard requires in several places that streamoff must be a
> >typedef, so it is defined as
> > typedef class __streamoff streamoff;
>
> Bummer, this.
Yes, it doesn't seem to serve any real purpose.
> >streamoff and fpos are in a new header bits/postypes.h; it seems
> >more descriptive than fpos.h since streamoff is also a class type.
>
> Yeah. Here are the mods to make it build cleanly and pass the
> testsuite....
>
> I'm a bit worried about
>
> off_type = pos_type
>
> no longer working.
It may be OK to allow this, the important thing is to prevent
long = pos_type
This will fail at runtime, but only when the size of files exceeds
2 GB. Such bugs are very hard to debug, so making this not compile
is the correct way to go.
However, there are very few valid reasons for extracting the
streamoff from a fpos (except when overriding
basic_streambuf::seekpos), so I think the constructor should remain
explicit until somebody complains. Also, the extracted value is
meaningless in general for wfilebuf, and useless without the state
when using stateful encodings.
> However,
>
> off_type = off_type(pos_type)
>
> seems conformant, as well as
>
> off_type(pos_type)
Yes, the expression O(p) appears in 27.4.3.
The attached patch passes the testsuite. It differs from the last
version in that operators ++ and -- have been added to streamoff,
to make testsuite/27_io/objects/char/10.cc pass. Also implementation
defined behaviour in streamoff and fpos is documented (that is all
behaviour in streamoff and fpos, except for fpos::state()).
Note: Due to lack of current autotools, makefile bits are both
incomplete and untested.
Petur
2003-10-15 Petur Runolfsson <peturr02@ru.is>
PR libstdc++/8610
PR libstdc++/11450
PR libstdc++/11543
PR libstdc++/12065
* config/linker-map.gnu: Add __streamoff.
* config/io/basic_file_stdio.cc (__basic_file::seekoff):
Change return value from streampos to streamoff.
(__basic_file::seekpos): Delete.
* config/io/basic_file_stdio.h: Same.
* config/io/c_io_stdio.h: Add __streamoff_base_type typedef,
remove streamoff and wstreamsize typedefs.
* config/os/generic/fpos.h: Remove.
* config/os/gnu-linux/fpos.h: Remove.
* include/Makefile.am (bits_headers): Add bits/postypes.h.
* include/bits/char_traits.h: Include bits/postypes.h instead of
bits/fpos.h.
* include/bits/fstream.tcc (basic_filebuf::open,
basic_filebuf::pbackfail): Don't use < or >= to compare pos_type
values, use == and != instead.
(basic_filebuf::_M_seek): Use explicit conversion from streamoff
to pos_type.
(basic_filebuf::imbue): Don't use ! on pos_type values, use
== instead. Don't use __check_facet(_M_codecvt) unless is_open().
* include/bits/postypes.h: New file.
(streamoff, streampos, wstreampos): Define typedefs, with
streamoff defined as...
(__streamoff): New class. Document implementation defined
aspects.
(fpos): New implementation. Document implementation defined
aspects.
* include/bits/sstream.tcc (basic_stringbuf::seekpos): Use
explicit conversion from pos_type to off_type.
* include/std/std_iosfwd.h: Include bits/postypes.h instead
of bits/fpos.h.
* testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc: Use
explicit conversion from pos_type to off_type.
* testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/char/11543.cc: New test.
* testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc: Use
explicit conversion from pos_type to off_type.
* testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/wchar_t/11543.cc: New test.
* testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc: Use
explicit conversion from pos_type to off_type.
* testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc: Same.
* testsuite/27_io/basic_istream/seekg/char/2.cc: Same.
* testsuite/27_io/basic_stringbuf/seekoff/char/1.cc: Same.
* testsuite/27_io/basic_stringbuf/seekpos/char/1.cc: Same.
* testsuite/27_io/fpos/11450.cc: New test.
* testsuite/27_io/fpos/mbstate_t/12065.cc: New test.
* testsuite/27_io/fpos/mbstate_t/3.cc: Use explicit conversion
from streampos to streamoff.
* testsuite/27_io/fpos/mbstate_t/4_neg.cc: New test.
* testsuite/27_io/types/3.cc: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: streamoff.diff.gz
Type: application/x-gzip
Size: 9699 bytes
Desc: streamoff.diff.gz
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031016/55386422/attachment.bin>
More information about the Libstdc++
mailing list