This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] 12855
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Dec 2003 11:58:54 -0600
- Subject: [v3] 12855
tested x86/linux
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.
Index: include/bits/ios_base.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/ios_base.h,v
retrieving revision 1.34
diff -c -p -r1.34 ios_base.h
*** include/bits/ios_base.h 12 Oct 2003 10:12:08 -0000 1.34
--- include/bits/ios_base.h 15 Dec 2003 17:56:38 -0000
*************** namespace std
*** 493,506 ****
~Init();
// NB: Allows debugger applications use of the standard streams
! // from operator new. _S_ios_base_init must be incremented in
! // _S_ios_create _after_ initialization is completed.
static bool
! _S_initialized() { return _S_ios_base_init; }
private:
! static int _S_ios_base_init;
! static bool _S_synced_with_stdio;
};
// [27.4.2.2] fmtflags state functions
--- 493,505 ----
~Init();
// NB: Allows debugger applications use of the standard streams
! // from operator new.
static bool
! _S_initialized() { return _S_refcount > 0; }
private:
! static _Atomic_word _S_refcount;
! static bool _S_synced_with_stdio;
};
// [27.4.2.2] fmtflags state functions
Index: src/ios.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ios.cc,v
retrieving revision 1.51
diff -c -p -r1.51 ios.cc
*** src/ios.cc 17 Oct 2003 14:47:30 -0000 1.51
--- src/ios.cc 15 Dec 2003 17:56:38 -0000
*************** namespace std
*** 107,113 ****
const int ios_base::_S_local_word_size;
! int ios_base::Init::_S_ios_base_init = 0;
bool ios_base::Init::_S_synced_with_stdio = true;
--- 107,113 ----
const int ios_base::_S_local_word_size;
! _Atomic_word ios_base::Init::_S_refcount;
bool ios_base::Init::_S_synced_with_stdio = true;
Index: src/ios_init.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ios_init.cc,v
retrieving revision 1.1
diff -c -p -r1.1 ios_init.cc
*** src/ios_init.cc 17 Oct 2003 14:47:30 -0000 1.1
--- src/ios_init.cc 15 Dec 2003 17:56:38 -0000
*************** namespace std
*** 80,86 ****
ios_base::Init::Init()
{
! if (_S_ios_base_init == 0)
{
// Standard streams default to synced with "C" operations.
_S_synced_with_stdio = true;
--- 80,86 ----
ios_base::Init::Init()
{
! if (__exchange_and_add(&_S_refcount, 1) == 0)
{
// Standard streams default to synced with "C" operations.
_S_synced_with_stdio = true;
*************** namespace std
*** 110,124 ****
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
!
! _S_ios_base_init = 1;
}
- ++_S_ios_base_init;
}
ios_base::Init::~Init()
{
! if (--_S_ios_base_init == 1)
{
// Catch any exceptions thrown by basic_ostream::flush()
try
--- 110,127 ----
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
!
! // 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);
}
}
ios_base::Init::~Init()
{
! if (__exchange_and_add(&_S_refcount, -1) == 1)
{
// Catch any exceptions thrown by basic_ostream::flush()
try
Index: testsuite/27_io/ios_base/cons/assign_neg.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc,v
retrieving revision 1.6
diff -c -p -r1.6 assign_neg.cc
*** testsuite/27_io/ios_base/cons/assign_neg.cc 12 Oct 2003 10:12:09 -0000 1.6
--- testsuite/27_io/ios_base/cons/assign_neg.cc 15 Dec 2003 17:56:39 -0000
*************** void test01()
*** 41,45 ****
io1 = io2;
}
// { dg-error "within this context" "" { target *-*-* } 41 }
! // { dg-error "is private" "" { target *-*-* } 746 }
// { dg-error "operator=" "" { target *-*-* } 0 }
--- 41,45 ----
io1 = io2;
}
// { dg-error "within this context" "" { target *-*-* } 41 }
! // { dg-error "is private" "" { target *-*-* } 745 }
// { dg-error "operator=" "" { target *-*-* } 0 }
Index: testsuite/27_io/ios_base/cons/copy_neg.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc,v
retrieving revision 1.6
diff -c -p -r1.6 copy_neg.cc
*** testsuite/27_io/ios_base/cons/copy_neg.cc 12 Oct 2003 10:12:09 -0000 1.6
--- testsuite/27_io/ios_base/cons/copy_neg.cc 15 Dec 2003 17:56:39 -0000
*************** void test02()
*** 41,45 ****
test_base io2 = io1;
}
// { dg-error "within this context" "" { target *-*-* } 41 }
! // { dg-error "is private" "" { target *-*-* } 743 }
// { dg-error "copy constructor" "" { target *-*-* } 0 }
--- 41,45 ----
test_base io2 = io1;
}
// { dg-error "within this context" "" { target *-*-* } 41 }
! // { dg-error "is private" "" { target *-*-* } 742 }
// { dg-error "copy constructor" "" { target *-*-* } 0 }