diff options
author | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2009-01-08 03:14:24 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2009-01-08 03:14:24 +0000 |
commit | 9982752346aac68d257d258332591df1f7b7817d (patch) | |
tree | a6f1e0438084e4f64331de987399b0292a383367 /libstdc++-v3/config/cpu | |
parent | f5651df1abb64343a5e18ed6af8cde899d4b2198 (diff) | |
download | gcc-9982752346aac68d257d258332591df1f7b7817d.zip gcc-9982752346aac68d257d258332591df1f7b7817d.tar.gz gcc-9982752346aac68d257d258332591df1f7b7817d.tar.bz2 |
re PR libstdc++/36801 (config/cpu/generic/atomicity_mutex/atomicity.h incorrectly relies on global constructor ordering)
2009-01-07 Benjamin Kosnik <bkoz@redhat.com>
Jonathan Larmour <jifl@eCosCentric.com>
PR libstdc++/36801
* config/cpu/generic/atomicity_mutex/atomicity.h (get_atomic_mutex):
New.
(__gnu_cxx::__exchange_and_add): Use it.
* src/atomic.cc (get_atomic_mutex): New.
* src/debug.cc (get_safe_base_mutex): New.
* src/locale.cc (get_locale_cache_mutex): New.
* src/mt_allocator.cc (get_freelist): New.
(get_freelist_mutex): New.
* src/pool_allocator.cc (get_palloc_mutex): New.
* include/std/mutex (__once_functor_lock): To
(__get_once_functor_lock): ...this.
* src/mutex.cc (__once_mutex): Don't export, use
(get_once_mutex): ...this.
* config/abi/pre/gnu.ver: Adjust exports.
From-SVN: r143182
Diffstat (limited to 'libstdc++-v3/config/cpu')
-rw-r--r-- | libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h b/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h index e9ee10c..c2a9c3a 100644 --- a/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h +++ b/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h @@ -1,6 +1,6 @@ // Low-level functions for atomic operations: Generic version -*- C++ -*- -// Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006 +// Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2009 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -37,7 +37,12 @@ namespace { - __gnu_cxx::__mutex atomic_mutex; + __gnu_cxx::__mutex& + get_atomic_mutex() + { + static __gnu_cxx::__mutex atomic_mutex; + return atomic_mutex; + } } // anonymous namespace _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) @@ -46,7 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __attribute__ ((__unused__)) __exchange_and_add(volatile _Atomic_word* __mem, int __val) { - __gnu_cxx::__scoped_lock sentry(atomic_mutex); + __gnu_cxx::__scoped_lock sentry(get_atomic_mutex()); _Atomic_word __result; __result = *__mem; *__mem += __val; |