aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/ios.cc
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>2003-05-11 04:20:57 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2003-05-11 04:20:57 +0000
commit51ff814940515c59592755b2381c40abcbdb8481 (patch)
treed71fba2b50f60c163b3ae4a43531c159bc10ec81 /libstdc++-v3/src/ios.cc
parent6e5d72baacbe5026ce1eb854d4e2f314d0f852fd (diff)
downloadgcc-51ff814940515c59592755b2381c40abcbdb8481.zip
gcc-51ff814940515c59592755b2381c40abcbdb8481.tar.gz
gcc-51ff814940515c59592755b2381c40abcbdb8481.tar.bz2
[multiple changes]
2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9027 PR libstdc++/9520 PR libstdc++/10096 * include/bits/fstream.tcc (basic_file::_M_underflow): Add generic implementation, based on old wchar_t specialization, add support for codecvt::in() return value of codecvt_base::noconv, remove _M_file.sys_ungetc() call. * include/std/std_fstream.h (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specialization declarations, call _M_underflow from generic versions of underflow and uflow. * src/fstream.cc (basic_file::underflow, basic_file::uflow, basic_file::_M_underflow): Remove specializations. * src/Makefile.am (sources): Remove fstream.cc. * src/Makefile.in: Regenerated. * testsuite/27_io/basic_filebuf/underflow/10096.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/1.cc: New test. * testsuite/27_io/basic_filebuf/underflow/char/9027.cc: New test. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc: New test. 2003-05-10 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h (__stdio_filebuf): Remove stack buffer. * config/io/basic_file_stdio.h (__basic_file::xsgetn): Remove unbuffered bits. (__basic_file::xsputn): Same. (__basic_file::seekoff): Same. (__basic_file::seekpos): Same. (__basic_file::showmanyc): Same. * config/io/basic_file_stdio.cc: Same. * include/std/std_fstream.h: Same. * include/bits/fstream.tcc: Same. * src/fstream.cc: Same. * testsuite/27_io/basic_filebuf/sgetn/char/1.cc (test05): Tidy. 2003-05-10 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9520 PR libstdc++/9661 PR libstdc++/9662 * include/ext/stdio_sync_filebuf.h: New file. (basic_stdiobuf): New. * include/Makefile.am (ext_headers): Add ext/stdio_sync_filebuf.h * include/Makefile.in: Regenerate. * include/bits/ios_base.h (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove declarations. * src/globals.cc (buf_cout_sync, buf_cin_sync, buf_cerr_sync, buf_wcout_sync, buf_wcin_sync, buf_wcerr_sync): Define. * src/ios.cc (Init::_S_create_buffers, Init::_S_destroy_buffers): Remove. (Init::Init): Create and use syncronized buffers. (ios_base::sync_with_stdio): Destroy syncronized buffers, create and install unsyncronized buffers. * testsuite/27_io/objects/char/10.cc: New test. * testsuite/27_io/objects/char/9.cc: New test. * testsuite/27_io/objects/char/9661-1.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.cc: New test. * testsuite/27_io/objects/char/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/1.cc: New test. * testsuite/27_io/objects/wchar_t/10.cc: New test. * testsuite/27_io/objects/wchar_t/2.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-1_xin.in: New. * testsuite/27_io/objects/wchar_t/2523-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/2523-2_xin.in: New. * testsuite/27_io/objects/wchar_t/3045.cc: New test. * testsuite/27_io/objects/wchar_t/3647.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.cc: New test. * testsuite/27_io/objects/wchar_t/3_xin.in: New. * testsuite/27_io/objects/wchar_t/4_xin.cc: New test. * testsuite/27_io/objects/wchar_t/4_xin.in: New. * testsuite/27_io/objects/wchar_t/5.cc: New test. * testsuite/27_io/objects/wchar_t/5268.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.cc: New test. * testsuite/27_io/objects/wchar_t/5280_xin.in: New. * testsuite/27_io/objects/wchar_t/6.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6548_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-1_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-1_xin.in: New. * testsuite/27_io/objects/wchar_t/6648-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/6648-2_xin.in: New. * testsuite/27_io/objects/wchar_t/7.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.cc: New test. * testsuite/27_io/objects/wchar_t/7744_xin.in: New. * testsuite/27_io/objects/wchar_t/8.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9_xin.in: New. * testsuite/27_io/objects/wchar_t/9520.cc: New test. * testsuite/27_io/objects/wchar_t/9661-1.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.cc: New test. * testsuite/27_io/objects/wchar_t/9661-2_xin.in: New. * testsuite/27_io/objects/wchar_t/9662.cc: New test. * testsuite/ext/stdiobuf_char.cc: New test. * testsuite/ext/stdiobuf_wchar_t.cc: New test. From-SVN: r66678
Diffstat (limited to 'libstdc++-v3/src/ios.cc')
-rw-r--r--libstdc++-v3/src/ios.cc118
1 files changed, 61 insertions, 57 deletions
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index b3acc49..ee4fd24 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -38,15 +38,24 @@
#include <fstream>
#include <bits/atomicity.h>
#include <ext/stdio_filebuf.h>
+#include <ext/stdio_sync_filebuf.h>
namespace __gnu_cxx
{
// Extern declarations for global objects in src/globals.cc.
+ extern stdio_sync_filebuf<char> buf_cout_sync;
+ extern stdio_sync_filebuf<char> buf_cin_sync;
+ extern stdio_sync_filebuf<char> buf_cerr_sync;
+
extern stdio_filebuf<char> buf_cout;
extern stdio_filebuf<char> buf_cin;
extern stdio_filebuf<char> buf_cerr;
#ifdef _GLIBCPP_USE_WCHAR_T
+ extern stdio_sync_filebuf<wchar_t> buf_wcout_sync;
+ extern stdio_sync_filebuf<wchar_t> buf_wcin_sync;
+ extern stdio_sync_filebuf<wchar_t> buf_wcerr_sync;
+
extern stdio_filebuf<wchar_t> buf_wcout;
extern stdio_filebuf<wchar_t> buf_wcin;
extern stdio_filebuf<wchar_t> buf_wcerr;
@@ -153,50 +162,6 @@ namespace std
ios_base::failure::what() const throw()
{ return _M_name; }
- void
- ios_base::Init::_S_create_buffers(bool __sync)
- {
- size_t __out_size = __sync ? 0 : static_cast<size_t>(BUFSIZ);
- size_t __in_size = __sync ? 1 : static_cast<size_t>(BUFSIZ);
-
- // Create stream buffers for the standard streams and use those
- // buffers without destroying and recreating the streams.
- new (&buf_cout) stdio_filebuf<char>(stdout, ios_base::out, __out_size);
- new (&buf_cin) stdio_filebuf<char>(stdin, ios_base::in, __in_size);
- new (&buf_cerr) stdio_filebuf<char>(stderr, ios_base::out, __out_size);
- cout.rdbuf(&buf_cout);
- cin.rdbuf(&buf_cin);
- cerr.rdbuf(&buf_cerr);
- clog.rdbuf(&buf_cerr);
-
-#ifdef _GLIBCPP_USE_WCHAR_T
- new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out, __out_size);
- new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in, __in_size);
- new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out, __out_size);
- wcout.rdbuf(&buf_wcout);
- wcin.rdbuf(&buf_wcin);
- wcerr.rdbuf(&buf_wcerr);
- wclog.rdbuf(&buf_wcerr);
-#endif
- }
-
- void
- ios_base::Init::_S_destroy_buffers()
- {
- // Explicitly call dtors to free any memory that is dynamically
- // allocated by filebuf ctor or member functions, but don't
- // deallocate all memory by calling operator delete.
- buf_cout.~stdio_filebuf();
- buf_cin.~stdio_filebuf();
- buf_cerr.~stdio_filebuf();
-
-#ifdef _GLIBCPP_USE_WCHAR_T
- buf_wcout.~stdio_filebuf();
- buf_wcin.~stdio_filebuf();
- buf_wcerr.~stdio_filebuf();
-#endif
- }
-
ios_base::Init::Init()
{
if (_S_ios_base_init == 0)
@@ -204,25 +169,32 @@ namespace std
// Standard streams default to synced with "C" operations.
ios_base::Init::_S_synced_with_stdio = true;
- // The standard streams are constructed once only and never destroyed.
- // The stream buffers are set in _S_create_buffers below.
- new (&cout) ostream(NULL);
- new (&cin) istream(NULL);
- new (&cerr) ostream(NULL);
- new (&clog) ostream(NULL);
+ new (&buf_cout_sync) stdio_sync_filebuf<char>(stdout);
+ new (&buf_cin_sync) stdio_sync_filebuf<char>(stdin);
+ new (&buf_cerr_sync) stdio_sync_filebuf<char>(stderr);
+
+ // The standard streams are constructed once only and never
+ // destroyed.
+ new (&cout) ostream(&buf_cout_sync);
+ new (&cin) istream(&buf_cin_sync);
+ new (&cerr) ostream(&buf_cerr_sync);
+ new (&clog) ostream(&buf_cerr_sync);
cin.tie(&cout);
cerr.flags(ios_base::unitbuf);
#ifdef _GLIBCPP_USE_WCHAR_T
- new (&wcout) wostream(NULL);
- new (&wcin) wistream(NULL);
- new (&wcerr) wostream(NULL);
- new (&wclog) wostream(NULL);
+ new (&buf_wcout_sync) stdio_sync_filebuf<wchar_t>(stdout);
+ new (&buf_wcin_sync) stdio_sync_filebuf<wchar_t>(stdin);
+ new (&buf_wcerr_sync) stdio_sync_filebuf<wchar_t>(stderr);
+
+ new (&wcout) wostream(&buf_wcout_sync);
+ new (&wcin) wistream(&buf_wcin_sync);
+ new (&wcerr) wostream(&buf_wcerr_sync);
+ new (&wclog) wostream(&buf_wcerr_sync);
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
- _S_create_buffers(ios_base::Init::_S_synced_with_stdio);
_S_ios_base_init = 1;
}
++_S_ios_base_init;
@@ -389,8 +361,40 @@ namespace std
if (!__sync && __ret)
{
ios_base::Init::_S_synced_with_stdio = __sync;
- ios_base::Init::_S_destroy_buffers();
- ios_base::Init::_S_create_buffers(__sync);
+
+ // Explicitly call dtors to free any memory that is
+ // dynamically allocated by filebuf ctor or member functions,
+ // but don't deallocate all memory by calling operator delete.
+ buf_cout_sync.~stdio_sync_filebuf<char>();
+ buf_cin_sync.~stdio_sync_filebuf<char>();
+ buf_cerr_sync.~stdio_sync_filebuf<char>();
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+ buf_wcout_sync.~stdio_sync_filebuf<wchar_t>();
+ buf_wcin_sync.~stdio_sync_filebuf<wchar_t>();
+ buf_wcerr_sync.~stdio_sync_filebuf<wchar_t>();
+#endif
+
+ // Create stream buffers for the standard streams and use
+ // those buffers without destroying and recreating the
+ // streams.
+ new (&buf_cout) stdio_filebuf<char>(stdout, ios_base::out);
+ new (&buf_cin) stdio_filebuf<char>(stdin, ios_base::in);
+ new (&buf_cerr) stdio_filebuf<char>(stderr, ios_base::out);
+ cout.rdbuf(&buf_cout);
+ cin.rdbuf(&buf_cin);
+ cerr.rdbuf(&buf_cerr);
+ clog.rdbuf(&buf_cerr);
+
+#ifdef _GLIBCPP_USE_WCHAR_T
+ new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out);
+ new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in);
+ new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out);
+ wcout.rdbuf(&buf_wcout);
+ wcin.rdbuf(&buf_wcin);
+ wcerr.rdbuf(&buf_wcerr);
+ wclog.rdbuf(&buf_wcerr);
+#endif
}
return __ret;
}