aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>2001-01-10 17:24:11 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2001-01-10 17:24:11 +0000
commit469550eb04a94073a477be716178a36e9cfa4bb9 (patch)
tree107deb0232beda084443cf0e1e84b32fabb0d4e7
parent761491c8dc565cd85bfe7b59c41706b61faffd63 (diff)
downloadgcc-469550eb04a94073a477be716178a36e9cfa4bb9.zip
gcc-469550eb04a94073a477be716178a36e9cfa4bb9.tar.gz
gcc-469550eb04a94073a477be716178a36e9cfa4bb9.tar.bz2
Fixes for libstdc++/1576
2001-01-09 Benjamin Kosnik <bkoz@redhat.com> <kainz@ilm.com> Fixes for libstdc++/1576 * src/stdstreams.cc: Initialize with NULL filebuf. Delete file, move contents into.... * src/ios.cc: ...Here. Put defines for iostreams objects and initialization routines into one file to simplify DSO interaction. * include/bits/std_iostream.h: Touch. * include/bits/ios_base.h (_S_synched_with_stdio): Make static. * src/Makefile.am (sources): Remove stdstreams.cc. * src/Makefile.in: Regenerate. From-SVN: r38871
-rw-r--r--libstdc++-v3/ChangeLog16
-rw-r--r--libstdc++-v3/include/bits/ios_base.h2
-rw-r--r--libstdc++-v3/include/bits/std_iostream.h10
-rw-r--r--libstdc++-v3/src/Makefile.am6
-rw-r--r--libstdc++-v3/src/Makefile.in8
-rw-r--r--libstdc++-v3/src/ios.cc73
-rw-r--r--libstdc++-v3/src/stdstreams.cc48
7 files changed, 61 insertions, 102 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 87cfab9..1b41104 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,11 +1,25 @@
+2001-01-09 Benjamin Kosnik <bkoz@redhat.com>
+ <kainz@ilm.com>
+
+ Fixes for libstdc++/1576
+ * src/stdstreams.cc: Initialize with NULL filebuf. Delete
+ file, move contents into....
+ * src/ios.cc: ...Here. Put defines for iostreams objects and
+ initialization routines into one file to simplify DSO interaction.
+ * include/bits/std_iostream.h: Touch.
+ * include/bits/ios_base.h (_S_synched_with_stdio): Make static.
+ * src/Makefile.am (sources): Remove stdstreams.cc.
+ * src/Makefile.in: Regenerate.
+
2001-01-10 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
* tests_flags.in (check_directory): Fix typo.
2001-01-09 Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
+
* include/bits/std_complex.h: Fix a typo.
-2001-01-10 Loren J. Rittle <ljrittle@acm.org>
+2001-01-09 Loren J. Rittle <ljrittle@acm.org>
* config/os/bsd/freebsd/bits/ctype_inline.h (is): (Make right
code path:) Remove magic constants and restructure to handle
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index c5de5b8..6aea042 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -294,7 +294,7 @@ namespace std {
~Init();
private:
static int _S_ios_base_init;
- bool _M_synced_with_stdio;
+ static bool _S_synced_with_stdio;
filebuf* _M_cout;
filebuf* _M_cin;
filebuf* _M_cerr;
diff --git a/libstdc++-v3/include/bits/std_iostream.h b/libstdc++-v3/include/bits/std_iostream.h
index b08d038..191e09d 100644
--- a/libstdc++-v3/include/bits/std_iostream.h
+++ b/libstdc++-v3/include/bits/std_iostream.h
@@ -1,6 +1,6 @@
// Standard iostream objects -*- C++ -*-
-// Copyright (C) 1997-1999 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -38,8 +38,8 @@
#include <bits/std_ostream.h>
#include <bits/std_istream.h>
-namespace std {
-
+namespace std
+{
extern istream cin;
extern ostream cout;
extern ostream cerr;
@@ -55,4 +55,6 @@ namespace std {
static ios_base::Init __ioinit;
} // namespace std
-#endif /* _CPP_IOSTREAM */
+#endif
+
+
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 18acebe..a6e15d1 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -1,6 +1,6 @@
## Makefile for the src subdirectory of the GNU C++ Standard library.
##
-## Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+## Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
@@ -21,7 +21,7 @@
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
## USA.
-## $Id: Makefile.am,v 1.61 2000/12/23 07:13:57 bkoz Exp $
+## $Id: Makefile.am,v 1.62 2001/01/04 04:21:42 bkoz Exp $
AUTOMAKE_OPTIONS = 1.3 gnits
MAINT_CHARSET = latin1
@@ -176,7 +176,7 @@ sources = \
limitsMEMBERS.cc \
complex_io.cc \
stdexcept.cc bitset.cc \
- c++io.cc ios.cc stdstreams.cc strstream.cc \
+ c++io.cc ios.cc strstream.cc \
locale.cc localename.cc codecvt.cc \
locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index cdb547ce..df23ffb 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -170,7 +170,7 @@ std_headers = algorithm bitset complex deque fstream functional iomanip ios i
build_headers = bits/std_limits.h bits/c++config.h bits/c++io.h bits/c++threads.h bits/atomicity.h bits/os_defines.h bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
-sources = limitsMEMBERS.cc complex_io.cc stdexcept.cc bitset.cc c++io.cc ios.cc stdstreams.cc strstream.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
+sources = limitsMEMBERS.cc complex_io.cc stdexcept.cc bitset.cc c++io.cc ios.cc strstream.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc
wstring_sources = wstring-inst.cc
@@ -258,9 +258,9 @@ libinst_wstring_la_LDFLAGS =
libinst_wstring_la_LIBADD =
libinst_wstring_la_OBJECTS = wstring-inst.lo
libstdc___la_OBJECTS = limitsMEMBERS.lo complex_io.lo stdexcept.lo \
-bitset.lo c++io.lo ios.lo stdstreams.lo strstream.lo locale.lo \
-localename.lo codecvt.lo locale-inst.lo stl-inst.lo misc-inst.lo \
-valarray-inst.lo string-inst.lo
+bitset.lo c++io.lo ios.lo strstream.lo locale.lo localename.lo \
+codecvt.lo locale-inst.lo stl-inst.lo misc-inst.lo valarray-inst.lo \
+string-inst.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index bac371a..83ff7ca 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -32,7 +32,8 @@
//
#include <bits/std_ios.h>
-#include <bits/std_iostream.h>
+#include <bits/std_ostream.h>
+#include <bits/std_istream.h>
#include <bits/std_fstream.h>
namespace std
@@ -104,9 +105,20 @@ namespace std
const ios_base::seekdir ios_base::cur;
const ios_base::seekdir ios_base::end;
+ const int ios_base::_S_local_words;
int ios_base::Init::_S_ios_base_init = 0;
+ bool ios_base::Init::_S_synced_with_stdio = true;
- const int ios_base::_S_local_words;
+ istream cin(NULL);
+ ostream cout(NULL);
+ ostream cerr(NULL);
+ ostream clog(NULL);
+#ifdef _GLIBCPP_USE_WCHAR_T
+ wistream wcin(NULL);
+ wostream wcout(NULL);
+ wostream wcerr(NULL);
+ wostream wclog(NULL);
+#endif
ios_base::failure::failure(const string& __str)
{
@@ -126,40 +138,30 @@ namespace std
if (++_S_ios_base_init == 1)
{
// NB: std_iostream.h creates the four standard files with
- // default buffers. At this point, we swap out the default
- // buffers for the properly-constructed ones, and dispose of
- // the default buffers.
- streambuf* __old;
+ // NULL buffers. At this point, we swap out these placeholder
+ // objects for the properly-constructed ones
_M_cout = new filebuf(1, "stdout", ios_base::out);
_M_cin = new filebuf(0, "stdin", ios_base::in);
_M_cerr = new filebuf(2, "stderr", ios_base::out);
- __old = cout.rdbuf(_M_cout);
- __old->~streambuf();
- __old = cin.rdbuf(_M_cin);
- __old->~streambuf();
+ new (&cout) ostream(_M_cout);
+ new (&cin) istream(_M_cin);
+ new (&cerr) ostream(_M_cerr);
+ new (&clog) ostream(_M_cerr);
cin.tie(&cout);
- __old = cerr.rdbuf(_M_cerr);
- __old->~streambuf();
cerr.flags(ios_base::unitbuf);
- __old = clog.rdbuf(_M_cerr);
- __old->~streambuf();
+
#ifdef _GLIBCPP_USE_WCHAR_T
- wstreambuf* __wold;
_M_wcout = new wfilebuf(1, "stdout", ios_base::out);
_M_wcin = new wfilebuf(0, "stdin", ios_base::in);
_M_wcerr = new wfilebuf(2, "stderr", ios_base::out);
- __wold = wcout.rdbuf(_M_wcout);
- __wold->~wstreambuf();
- __wold = wcin.rdbuf(_M_wcin);
- __wold->~wstreambuf();
- wcin.tie(&wcout);
- __wold = wcerr.rdbuf(_M_wcerr);
- __wold->~wstreambuf();
+ new (&wcout) wostream(_M_wcout);
+ new (&wcin) wistream(_M_wcin);
+ new (&wcerr) wostream(_M_wcerr);
+ new (&wclog) wostream(_M_wcerr);
+ wcin.tie(&cout);
wcerr.flags(ios_base::unitbuf);
- __wold = wclog.rdbuf(_M_wcerr);
- __wold->~wstreambuf();
#endif
- _M_synced_with_stdio = true;
+ ios_base::Init::_S_synced_with_stdio = true;
}
}
@@ -314,13 +316,15 @@ namespace std
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 49. Underspecification of ios_base::sync_with_stdio
- bool __ret = __ioinit._M_synced_with_stdio;
+ bool __ret = ios_base::Init::_S_synced_with_stdio;
#endif
// Turn off sync with C FILE* for cin, cout, cerr, clog iff
// currently synchronized.
if (!__sync && __ret)
{
+#if 0
+ // no longer need to do this
// Need to dispose of the buffers created at initialization.
__ioinit._M_cout->~filebuf();
__ioinit._M_cin->~filebuf();
@@ -336,23 +340,10 @@ namespace std
cerr.rdbuf(__ioinit._M_cerr);
cerr.flags(ios_base::unitbuf);
clog.rdbuf(__ioinit._M_cerr);
+#endif
#ifdef _GLIBCPP_USE_WCHAR_T
- __ioinit._M_wcout->~wfilebuf();
- __ioinit._M_wcin->~wfilebuf();
- __ioinit._M_wcerr->~wfilebuf();
- __ioinit._M_wcout = new wfilebuf();
- __ioinit._M_wcin = new wfilebuf();
- __ioinit._M_wcerr = new wfilebuf();
- __ioinit._M_wcout->open("wstdout", ios_base::out);
- __ioinit._M_wcin->open("wstdin", ios_base::in);
- __ioinit._M_wcerr->open("wstderr", ios_base::out);
- wcout.rdbuf(__ioinit._M_wcout);
- wcin.rdbuf(__ioinit._M_wcin);
- wcerr.rdbuf(__ioinit._M_wcerr);
- wcerr.flags(ios_base::unitbuf);
- wclog.rdbuf(__ioinit._M_wcerr);
#endif
- __ioinit._M_synced_with_stdio = false;
+ ios_base::Init::_S_synced_with_stdio = false;
}
return __ret;
diff --git a/libstdc++-v3/src/stdstreams.cc b/libstdc++-v3/src/stdstreams.cc
deleted file mode 100644
index cb69541..0000000
--- a/libstdc++-v3/src/stdstreams.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-
-// Copyright (C) 1997-1999 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <bits/std_istream.h>
-#include <bits/std_ostream.h>
-#include <bits/std_fstream.h>
-
-namespace std {
-
- filebuf __cfileinit;
- istream cin(&__cfileinit);
- ostream cout(&__cfileinit);
- ostream cerr(&__cfileinit);
- ostream clog(&__cfileinit);
-#ifdef _GLIBCPP_USE_WCHAR_T
- wfilebuf __wfileinit;
- wistream wcin(&__wfileinit);
- wostream wcout(&__wfileinit);
- wostream wcerr(&__wfileinit);
- wostream wclog(&__wfileinit);
-#endif
-
-} // std