summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/bits/c++config
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-08-12 22:56:59 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-08-12 22:56:59 +0000
commitd8155f717c2ac0ba8a6251bdfa0e50fc90c9a181 (patch)
tree0e6c156d49fe7f64d815154ccc4cbd3c33f02455 /libstdc++-v3/include/bits/c++config
parent99b66d21e0d1073bc594d7bfaa0422c77db449cc (diff)
downloadppe42-gcc-d8155f717c2ac0ba8a6251bdfa0e50fc90c9a181.tar.gz
ppe42-gcc-d8155f717c2ac0ba8a6251bdfa0e50fc90c9a181.zip
2010-08-12 Kostya Serebryany <kcc@google.com>
Paolo Carlini <paolo.carlini@oracle.com> * include/bits/c++config (_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE, _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER): Add. * src/ios_init.cc (ios_base::Init::~Init): Decorate with the latter. * include/tr1_impl/boost_sp_counted_base.h: Likewise. * include/ext/rc_string_base.h: Likewise. * include/bits/locale_classes.h: Likewise. * include/bits/basic_string.h: Likewise. * include/bits/ios_base.h: Likewise. * testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust dg-error line number. * testsuite/27_io/ios_base/cons/copy_neg.cc: Likewise. * testsuite/ext/profile/mutex_extensions.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163210 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/c++config')
-rw-r--r--libstdc++-v3/include/bits/c++config29
1 files changed, 29 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 9dc9ac24cd8..fef6933a3b5 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -60,6 +60,35 @@
# define _GLIBCXX_DEPRECATED_ATTR
#endif
+// Macros for race detectors.
+// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and
+// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain
+// atomic (lock-free) synchronization to race detectors:
+// the race detector will infer a happens-before arc from the former to the
+// latter when they share the same argument pointer.
+//
+// The most frequent use case for these macros (and the only case in the
+// current implementation of the library) is atomic reference counting:
+// void _M_remove_reference()
+// {
+// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount)
+// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0)
+// {
+// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount)
+// _M_destroy(__a);
+// }
+// }
+// The annotations in this example tell the race detector that all memory
+// accesses occurred when the refcount was positive do not race with
+// memory accesses which occurred after the refcount became zero.
+
+#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
+# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A)
+#endif
+#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
+# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A)
+#endif
+
// Macros for activating various namespace association modes.
// _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG
// _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL
OpenPOWER on IntegriCloud