diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-09-14 09:48:15 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-09-14 09:48:15 +0000 |
commit | 72de368c35b77c078b377d2496db3a4e417a32b2 (patch) | |
tree | eef2837703208f056261f360e2ea7f39d3036693 /libstdc++-v3/libsupc++ | |
parent | 0bb92388895783dad3b13b8deb9d182bbedc5408 (diff) | |
download | gcc-72de368c35b77c078b377d2496db3a4e417a32b2.tar.gz |
2006-09-13 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/atomicity.h: Move to...
* include/ext/atomicity.h: ...here.
* include/bits/concurrence.h: Move to...
* include/ext/concurrence.h: ...here.
* include/Makefile.am (ext_headers): Additions.
(bits_headers): Subtractions.
* include/Makefile.in: Regenerate.
* include/ext/bitmap_allocator.h (_Mutex), __threads_enabled,
_Lock, _Auto_Lock): Subsume into...
* include/bits/concurrence.h (__mutex): ..this. Error check
locking and unlocking.
(lock): Uglify to...
(__scoped_lock): Use __mutex.
(__glibcxx_mutex_define_initialized): Remove.
(__glibcxx_mutex_type): Remove.
* include/tr1/boost_shared_ptr.h: Formating tweaks, adjustments.
(_Lock_policy): Move from here...
* include/ext/concurrence.h: ... to here.
(__shared_ptr_default_lock_mode): To __default_lock_policy.
(_S_lockfree): To _S_atomic.
Document.
* libsupc++/guard.cc (static_mutex): Subsume into and fixup for...
* include/ext/concurrence.h (__recursive_mutex): ...this. Error
check locking and unlocking.
* libsupc++/eh_alloc.cc: Use __scoped_lock.
* config/os/aix/atomicity.h: Fixups for include paths, mutex to
__scoped_mutex change, removal of locking defines.
* config/os/irix/atomicity.h: Same.
* config/cpu/cris/atomicity.h: Same.
* config/cpu/m68k/atomicity.h: Same.
* config/cpu/hppa/atomicity.h: Same.
* config/cpu/mips/atomicity.h: Same.
* config/cpu/sparc/atomicity.h: Same.
* config/cpu/i386/atomicity.h: Same.
* config/cpu/i486/atomicity.h: Same.
* config/cpu/sh/atomicity.h: Same.
* config/cpu/generic/atomicity_mutex/atomicity.h: Same.
* include/ext/pool_allocator.h: Same.
* include/ext/bitmap_allocator.h: Same.
* include/ext/rc_string_base.h: Same.
* include/ext/mt_allocator.h: Same.
* include/bits/locale_classes.h: Same.
* include/bits/basic_string.h: Same.
* include/bits/ios_base.h: Same.
* include/tr1/memory: Same.
* src/pool_allocator.cc: Same.
* src/mt_allocator.cc: Same.
* src/locale_init.cc: Same.
* src/ios.cc: Same.
* src/locale.cc: Same.
* src/bitmap_allocator.cc: Same.
* src/ios_init.cc: Same.
* src/debug.cc: Same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r-- | libstdc++-v3/libsupc++/eh_alloc.cc | 41 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/guard.cc | 69 |
2 files changed, 22 insertions, 88 deletions
diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc index 97ecd6dadd5..217a8cd8043 100644 --- a/libstdc++-v3/libsupc++/eh_alloc.cc +++ b/libstdc++-v3/libsupc++/eh_alloc.cc @@ -39,7 +39,7 @@ #include <climits> #include <exception> #include "unwind-cxx.h" -#include "bits/gthr.h" +#include <ext/concurrence.h> #if _GLIBCXX_HOSTED using std::free; @@ -89,23 +89,11 @@ typedef char one_buffer[EMERGENCY_OBJ_SIZE] __attribute__((aligned)); static one_buffer emergency_buffer[EMERGENCY_OBJ_COUNT]; static bitmask_type emergency_used; - -#ifdef __GTHREADS -#ifdef __GTHREAD_MUTEX_INIT -static __gthread_mutex_t emergency_mutex =__GTHREAD_MUTEX_INIT; -#else -static __gthread_mutex_t emergency_mutex; -#endif - -#ifdef __GTHREAD_MUTEX_INIT_FUNCTION -static void -emergency_mutex_init () +namespace { - __GTHREAD_MUTEX_INIT_FUNCTION (&emergency_mutex); + // A single mutex controlling emergency allocations. + __gnu_cxx::__mutex emergency_mutex; } -#endif -#endif - extern "C" void * __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) throw() @@ -117,13 +105,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) throw() if (! ret) { -#ifdef __GTHREADS -#ifdef __GTHREAD_MUTEX_INIT_FUNCTION - static __gthread_once_t once = __GTHREAD_ONCE_INIT; - __gthread_once (&once, emergency_mutex_init); -#endif - __gthread_mutex_lock (&emergency_mutex); -#endif + __gnu_cxx::__scoped_lock sentry(emergency_mutex); bitmask_type used = emergency_used; unsigned int which = 0; @@ -141,9 +123,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) throw() ret = &emergency_buffer[which][0]; failed:; -#ifdef __GTHREADS - __gthread_mutex_unlock (&emergency_mutex); -#endif + if (!ret) std::terminate (); } @@ -167,16 +147,11 @@ __cxxabiv1::__cxa_free_exception(void *vptr) throw() if (ptr >= &emergency_buffer[0][0] && ptr < &emergency_buffer[0][0] + sizeof (emergency_buffer)) { - unsigned int which + const unsigned int which = (unsigned)(ptr - &emergency_buffer[0][0]) / EMERGENCY_OBJ_SIZE; -#ifdef __GTHREADS - __gthread_mutex_lock (&emergency_mutex); + __gnu_cxx::__scoped_lock sentry(emergency_mutex); emergency_used &= ~((bitmask_type)1 << which); - __gthread_mutex_unlock (&emergency_mutex); -#else - emergency_used &= ~((bitmask_type)1 << which); -#endif } else free (ptr - sizeof (__cxa_exception)); diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc index e7fe2b6e7b9..a56fe15e7ee 100644 --- a/libstdc++-v3/libsupc++/guard.cc +++ b/libstdc++-v3/libsupc++/guard.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2002 Free Software Foundation, Inc. +// Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -32,8 +32,8 @@ #include <bits/c++config.h> #include <cxxabi.h> #include <exception> -#include <bits/gthr.h> -#include <bits/atomicity.h> +#include <ext/atomicity.h> +#include <ext/concurrence.h> // The IA64/generic ABI uses the first byte of the guard variable. // The ARM EABI uses the least significant bit. @@ -42,49 +42,8 @@ #ifdef __GTHREADS namespace { - // static_mutex is a single mutex controlling all static initializations. - // This is a static class--the need for a static initialization function - // to pass to __gthread_once precludes creating multiple instances, though - // I suppose you could achieve the same effect with a template. - class static_mutex - { - static __gthread_recursive_mutex_t mutex; - -#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION - static void init(); -#endif - - public: - static void lock(); - static void unlock(); - }; - - __gthread_recursive_mutex_t static_mutex::mutex -#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT - = __GTHREAD_RECURSIVE_MUTEX_INIT -#endif - ; - -#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION - void static_mutex::init() - { - __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION (&mutex); - } -#endif - - void static_mutex::lock() - { -#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION - static __gthread_once_t once = __GTHREAD_ONCE_INIT; - __gthread_once (&once, init); -#endif - __gthread_recursive_mutex_lock (&mutex); - } - - void static_mutex::unlock () - { - __gthread_recursive_mutex_unlock (&mutex); - } + // A single mutex controlling all static initializations. + __gnu_cxx::__recursive_mutex static_mutex; } #ifndef _GLIBCXX_GUARD_TEST_AND_ACQUIRE @@ -125,14 +84,14 @@ namespace __gnu_cxx // as well check for this situation and throw an exception. // We use the second byte of the guard variable to remember that we're // in the middle of an initialization. - class recursive_init: public std::exception + class recursive_init_error: public std::exception { public: - recursive_init() throw() { } - virtual ~recursive_init() throw (); + recursive_init_error() throw() { } + virtual ~recursive_init_error() throw (); }; - recursive_init::~recursive_init() throw() { } + recursive_init_error::~recursive_init_error() throw() { } } namespace __cxxabiv1 @@ -158,7 +117,7 @@ namespace __cxxabiv1 if (recursion_push (g)) { #ifdef __EXCEPTIONS - throw __gnu_cxx::recursive_init(); + throw __gnu_cxx::recursive_init_error(); #else // Use __builtin_trap so we don't require abort(). __builtin_trap (); @@ -185,12 +144,12 @@ namespace __cxxabiv1 bool unlock; mutex_wrapper (): unlock(true) { - static_mutex::lock (); + static_mutex.lock(); } ~mutex_wrapper () { if (unlock) - static_mutex::unlock (); + static_mutex.unlock(); } } mw; @@ -213,7 +172,7 @@ namespace __cxxabiv1 recursion_pop (g); #ifdef __GTHREADS if (__gthread_active_p ()) - static_mutex::unlock (); + static_mutex.unlock(); #endif } @@ -224,7 +183,7 @@ namespace __cxxabiv1 _GLIBCXX_GUARD_SET_AND_RELEASE (g); #ifdef __GTHREADS if (__gthread_active_p ()) - static_mutex::unlock (); + static_mutex.unlock(); #endif } } |