aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2002-04-30 19:04:43 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2002-04-30 19:04:43 +0000
commit5cdd50a59159258c25a53b0a2bcee9c8d6081812 (patch)
tree675e7bd479fa5aadbb72f715cd7b93fb419ebd2a /libstdc++-v3/src
parent2b46bc671e8df2b62b5e27c4deab768c641cdc79 (diff)
downloadgcc-5cdd50a59159258c25a53b0a2bcee9c8d6081812.tar.gz
gcc-5cdd50a59159258c25a53b0a2bcee9c8d6081812.tar.bz2
gcc-5cdd50a59159258c25a53b0a2bcee9c8d6081812.zip
stdio_filebuf.h: New file.
2002-04-30 Benjamin Kosnik <bkoz@redhat.com> * include/ext/stdio_filebuf.h: New file. * include/ext/enc_filebuf.h: New file. * config/io/basic_file_stdio.h (__basic_file::sys_open): Add fd ctor. * config/io/basic_file_stdio.cc: Same. * include/bits/fstream.tcc (filebuf::_M_allocate_internal_buffer): Remove _M_unbuf hacks. (filebuf::_M_destroy_internal_buffer): Same. (filebuf::filebuf(cfile, openmode, int_type): Remove definition. (filebuf::fd): Remove. * include/std/std_fstream.h (filebuf::_M_unbuf): Remove. (filebuf::filebuf(__c_file*, openmode, int_type)): Remove. (filebuf::fd): Remove. * src/ios.cc (ios_base::_S_ios_create): Change to use specialized filebufs. (ios_base::_S_ios_destroy): Same. * src/misc-inst.cc (file_filebuf<char>): Add instantiation. * include/Makefile.am (ext_headers): Add ext_filebuf.h, stdio_filebuf.h. * include/Makefile.in: Regenerate. From-SVN: r52961
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/globals.cc9
-rw-r--r--libstdc++-v3/src/ios.cc46
-rw-r--r--libstdc++-v3/src/misc-inst.cc7
3 files changed, 37 insertions, 25 deletions
diff --git a/libstdc++-v3/src/globals.cc b/libstdc++-v3/src/globals.cc
index cf9087f9e08..36d193fb406 100644
--- a/libstdc++-v3/src/globals.cc
+++ b/libstdc++-v3/src/globals.cc
@@ -31,6 +31,7 @@
#include <istream>
#include <ostream>
#include <locale>
+#include <ext/stdio_filebuf.h>
// On AIX, and perhaps other systems, library initialization order is
// not guaranteed. For example, the static initializers for the main
@@ -176,8 +177,8 @@ namespace std
fake_ostream cerr;
fake_ostream clog;
- typedef char fake_filebuf[sizeof(filebuf)]
- __attribute__ ((aligned(__alignof__(filebuf))));
+ typedef char fake_filebuf[sizeof(__gnu_cxx::stdio_filebuf<char>)]
+ __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<char>))));
fake_filebuf buf_cout;
fake_filebuf buf_cin;
fake_filebuf buf_cerr;
@@ -192,8 +193,8 @@ namespace std
fake_wostream wcerr;
fake_wostream wclog;
- typedef char fake_wfilebuf[sizeof(wfilebuf)]
- __attribute__ ((aligned(__alignof__(wfilebuf))));
+ typedef char fake_wfilebuf[sizeof(__gnu_cxx::stdio_filebuf<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<wchar_t>))));
fake_wfilebuf buf_wcout;
fake_wfilebuf buf_wcin;
fake_wfilebuf buf_wcerr;
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index 8e834fd65b0..c1167f8c15c 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -36,8 +36,8 @@
#include <ostream>
#include <istream>
#include <fstream>
-
#include <bits/atomicity.h>
+#include <ext/stdio_filebuf.h>
namespace std
{
@@ -46,18 +46,21 @@ namespace std
extern ostream cout;
extern ostream cerr;
extern ostream clog;
- extern filebuf buf_cout;
- extern filebuf buf_cin;
- extern filebuf buf_cerr;
+
+ using __gnu_cxx::stdio_filebuf;
+ extern stdio_filebuf<char> buf_cout;
+ extern stdio_filebuf<char> buf_cin;
+ extern stdio_filebuf<char> buf_cerr;
#ifdef _GLIBCPP_USE_WCHAR_T
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
- extern wfilebuf buf_wcout;
- extern wfilebuf buf_wcin;
- extern wfilebuf buf_wcerr;
+
+ extern stdio_filebuf<wchar_t> buf_wcout;
+ extern stdio_filebuf<wchar_t> buf_wcin;
+ extern stdio_filebuf<wchar_t> buf_wcerr;
#endif
// Definitions for static const data members of __ios_flags.
@@ -147,15 +150,15 @@ namespace std
void
ios_base::Init::_S_ios_create(bool __sync)
{
- int __out_bufsize = __sync ? 0 : static_cast<int>(BUFSIZ);
- int __in_bufsize = __sync ? 1 : static_cast<int>(BUFSIZ);
+ int __out_size = __sync ? 0 : static_cast<int>(BUFSIZ);
+ int __in_size = __sync ? 1 : static_cast<int>(BUFSIZ);
// NB: The file globals.cc creates the four standard files
// with NULL buffers. At this point, we swap out the dummy NULL
// [io]stream objects and buffers with the real deal.
- new (&buf_cout) filebuf(stdout, ios_base::out, __out_bufsize);
- new (&buf_cin) filebuf(stdin, ios_base::in, __in_bufsize);
- new (&buf_cerr) filebuf(stderr, ios_base::out, __out_bufsize);
+ 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);
new (&cout) ostream(&buf_cout);
new (&cin) istream(&buf_cin);
new (&cerr) ostream(&buf_cerr);
@@ -164,9 +167,9 @@ namespace std
cerr.flags(ios_base::unitbuf);
#ifdef _GLIBCPP_USE_WCHAR_T
- new (&buf_wcout) wfilebuf(stdout, ios_base::out, __out_bufsize);
- new (&buf_wcin) wfilebuf(stdin, ios_base::in, __in_bufsize);
- new (&buf_wcerr) wfilebuf(stderr, ios_base::out, __out_bufsize);
+ 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);
new (&wcout) wostream(&buf_wcout);
new (&wcin) wistream(&buf_wcin);
new (&wcerr) wostream(&buf_wcerr);
@@ -182,13 +185,14 @@ namespace std
// 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.~filebuf();
- buf_cin.~filebuf();
- buf_cerr.~filebuf();
+ buf_cout.~stdio_filebuf();
+ buf_cin.~stdio_filebuf();
+ buf_cerr.~stdio_filebuf();
+
#ifdef _GLIBCPP_USE_WCHAR_T
- buf_wcout.~wfilebuf();
- buf_wcin.~wfilebuf();
- buf_wcerr.~wfilebuf();
+ buf_wcout.~stdio_filebuf();
+ buf_wcin.~stdio_filebuf();
+ buf_wcerr.~stdio_filebuf();
#endif
}
diff --git a/libstdc++-v3/src/misc-inst.cc b/libstdc++-v3/src/misc-inst.cc
index a276a732ed3..07a4b1a1aa2 100644
--- a/libstdc++-v3/src/misc-inst.cc
+++ b/libstdc++-v3/src/misc-inst.cc
@@ -44,6 +44,7 @@
#include <istream>
#include <ostream>
#include <iomanip>
+#include <ext/stdio_filebuf.h>
// NB: Unnecessary if the .h headers already include these.
#ifndef _GLIBCPP_FULLY_COMPLIANT_HEADERS
@@ -264,4 +265,10 @@ namespace std
__copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*,
basic_streambuf<wchar_t>*);
#endif
+
+ using __gnu_cxx::stdio_filebuf;
+ template class stdio_filebuf<char>;
+#ifdef _GLIBCPP_USE_WCHAR_T
+ template class stdio_filebuf<wchar_t>;
+#endif
} //std