diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-15 19:03:13 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-12-15 19:03:13 +0000 |
commit | a83ea497677e41dc76e17dd38ab08e4c8c8fb577 (patch) | |
tree | 7f2287749bdb532c7b8f07d4fdf2b69378b77add /libstdc++-v3/src/ios_init.cc | |
parent | 11037b2ef9622ddcbc736eba45f06e1275f2bf72 (diff) | |
download | gcc-a83ea497677e41dc76e17dd38ab08e4c8c8fb577.tar.gz |
2003-12-15 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/12855
* include/bits/ios_base.h (Init::_S_ios_base_init): Change to
_S_refcount, make atomic.
* src/ios.cc: Adjust definition.
* src/ios_init.cc (ios_base::Init::Init): Use __exchange_and_add,
and __atomic_add.
(ios_base::Init::~Init): Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust line numbers.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74642 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src/ios_init.cc')
-rw-r--r-- | libstdc++-v3/src/ios_init.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libstdc++-v3/src/ios_init.cc b/libstdc++-v3/src/ios_init.cc index 1645ea7b381..b40202553e5 100644 --- a/libstdc++-v3/src/ios_init.cc +++ b/libstdc++-v3/src/ios_init.cc @@ -80,7 +80,7 @@ namespace std ios_base::Init::Init() { - if (_S_ios_base_init == 0) + if (__exchange_and_add(&_S_refcount, 1) == 0) { // Standard streams default to synced with "C" operations. _S_synced_with_stdio = true; @@ -110,15 +110,18 @@ namespace std wcin.tie(&wcout); wcerr.flags(ios_base::unitbuf); #endif - - _S_ios_base_init = 1; + + // NB: Have to set refcount above one, so that standard + // streams are not re-initialized with uses of ios_base::Init + // besides <iostream> static object, ie just using <ios> with + // ios_base::Init objects. + __atomic_add(&_S_refcount, 1); } - ++_S_ios_base_init; } ios_base::Init::~Init() { - if (--_S_ios_base_init == 1) + if (__exchange_and_add(&_S_refcount, -1) == 2) { // Catch any exceptions thrown by basic_ostream::flush() try |