mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-15 04:00:26 +08:00
atomicity.h: Move to...
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. From-SVN: r116942
This commit is contained in:
parent
06fcf75439
commit
2e362c7474
@ -1,3 +1,63 @@
|
||||
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.
|
||||
|
||||
2006-09-12 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* libsupc++/eh_globals.cc: Remove __gnu_internal.
|
||||
|
@ -27,7 +27,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -28,12 +28,12 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
__glibcxx_mutex_define_initialized(atomic_mutex);
|
||||
__gnu_cxx::__mutex atomic_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
@ -42,11 +42,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
|
||||
{
|
||||
__glibcxx_mutex_lock(atomic_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(atomic_mutex);
|
||||
_Atomic_word __result;
|
||||
__result = *__mem;
|
||||
*__mem += __val;
|
||||
__glibcxx_mutex_unlock(atomic_mutex);
|
||||
return __result;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -74,12 +74,12 @@ __atomic_add (volatile _Atomic_word* __mem, int __val)
|
||||
|
||||
/* This is generic/atomicity.h */
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
__glibcxx_mutex_define_initialized(atomic_mutex);
|
||||
__gnu_cxx::__mutex atomic_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
@ -88,11 +88,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
|
||||
{
|
||||
__glibcxx_mutex_lock(atomic_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(atomic_mutex);
|
||||
_Atomic_word __result;
|
||||
__result = *__mem;
|
||||
*__mem += __val;
|
||||
__glibcxx_mutex_unlock(atomic_mutex);
|
||||
return __result;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
/* We cannot use the cpu/powerpc/bits/atomicity.h inline assembly
|
||||
definitions for these operations since they depend on operations
|
||||
@ -48,15 +48,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_Atomic_word
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add (volatile _Atomic_word* __mem, int __val)
|
||||
{
|
||||
return ::fetch_and_add (const_cast<atomic_p>(__mem), __val);
|
||||
}
|
||||
{ return ::fetch_and_add(const_cast<atomic_p>(__mem), __val); }
|
||||
|
||||
void
|
||||
__attribute__ ((__unused__))
|
||||
__atomic_add (volatile _Atomic_word* __mem, int __val)
|
||||
{
|
||||
(void) ::fetch_and_add (const_cast<atomic_p>(__mem), __val);
|
||||
}
|
||||
{ (void) ::fetch_and_add(const_cast<atomic_p>(__mem), __val); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
@ -28,7 +28,7 @@
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <mutex.h>
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -93,7 +93,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
|
||||
bits_builddir = ./bits
|
||||
bits_headers = \
|
||||
${bits_srcdir}/allocator.h \
|
||||
${bits_srcdir}/atomicity.h \
|
||||
${bits_srcdir}/basic_ios.h \
|
||||
${bits_srcdir}/basic_ios.tcc \
|
||||
${bits_srcdir}/basic_string.h \
|
||||
@ -102,7 +101,6 @@ bits_headers = \
|
||||
${bits_srcdir}/char_traits.h \
|
||||
${bits_srcdir}/codecvt.h \
|
||||
${bits_srcdir}/concept_check.h \
|
||||
${bits_srcdir}/concurrence.h \
|
||||
${bits_srcdir}/cpp_type_traits.h \
|
||||
${bits_srcdir}/deque.tcc \
|
||||
${bits_srcdir}/fstream.tcc \
|
||||
@ -529,9 +527,11 @@ ext_srcdir = ${glibcxx_srcdir}/include/ext
|
||||
ext_builddir = ./ext
|
||||
ext_headers = \
|
||||
${ext_srcdir}/algorithm \
|
||||
${ext_srcdir}/atomicity.h \
|
||||
${ext_srcdir}/array_allocator.h \
|
||||
${ext_srcdir}/bitmap_allocator.h \
|
||||
${ext_srcdir}/codecvt_specializations.h \
|
||||
${ext_srcdir}/concurrence.h \
|
||||
${ext_srcdir}/debug_allocator.h \
|
||||
${ext_srcdir}/stdio_filebuf.h \
|
||||
${ext_srcdir}/stdio_sync_filebuf.h \
|
||||
|
@ -318,7 +318,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
|
||||
bits_builddir = ./bits
|
||||
bits_headers = \
|
||||
${bits_srcdir}/allocator.h \
|
||||
${bits_srcdir}/atomicity.h \
|
||||
${bits_srcdir}/basic_ios.h \
|
||||
${bits_srcdir}/basic_ios.tcc \
|
||||
${bits_srcdir}/basic_string.h \
|
||||
@ -327,7 +326,6 @@ bits_headers = \
|
||||
${bits_srcdir}/char_traits.h \
|
||||
${bits_srcdir}/codecvt.h \
|
||||
${bits_srcdir}/concept_check.h \
|
||||
${bits_srcdir}/concurrence.h \
|
||||
${bits_srcdir}/cpp_type_traits.h \
|
||||
${bits_srcdir}/deque.tcc \
|
||||
${bits_srcdir}/fstream.tcc \
|
||||
@ -750,9 +748,11 @@ ext_srcdir = ${glibcxx_srcdir}/include/ext
|
||||
ext_builddir = ./ext
|
||||
ext_headers = \
|
||||
${ext_srcdir}/algorithm \
|
||||
${ext_srcdir}/atomicity.h \
|
||||
${ext_srcdir}/array_allocator.h \
|
||||
${ext_srcdir}/bitmap_allocator.h \
|
||||
${ext_srcdir}/codecvt_specializations.h \
|
||||
${ext_srcdir}/concurrence.h \
|
||||
${ext_srcdir}/debug_allocator.h \
|
||||
${ext_srcdir}/stdio_filebuf.h \
|
||||
${ext_srcdir}/stdio_sync_filebuf.h \
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
@ -1,101 +0,0 @@
|
||||
// Support for concurrent programing -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2003, 2004, 2005
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
/** @file concurrence.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _CONCURRENCE_H
|
||||
#define _CONCURRENCE_H 1
|
||||
|
||||
// GCC's thread abstraction layer
|
||||
#include "bits/gthr.h"
|
||||
|
||||
#if __GTHREADS
|
||||
|
||||
# ifdef __GTHREAD_MUTEX_INIT
|
||||
# define __glibcxx_mutex_type __gthread_mutex_t
|
||||
# define __glibcxx_mutex_define_initialized(NAME) \
|
||||
__gthread_mutex_t NAME = __GTHREAD_MUTEX_INIT
|
||||
# define __glibcxx_mutex_lock(NAME) \
|
||||
__gthread_mutex_lock(&NAME)
|
||||
# else
|
||||
// Implies __GTHREAD_MUTEX_INIT_FUNCTION
|
||||
struct __glibcxx_mutex : public __gthread_mutex_t
|
||||
{
|
||||
__glibcxx_mutex() { __GTHREAD_MUTEX_INIT_FUNCTION(this); }
|
||||
};
|
||||
|
||||
# define __glibcxx_mutex_type __glibcxx_mutex
|
||||
# define __glibcxx_mutex_define_initialized(NAME) \
|
||||
__glibcxx_mutex NAME
|
||||
# define __glibcxx_mutex_lock(NAME) \
|
||||
__gthread_mutex_lock(&NAME)
|
||||
# endif
|
||||
|
||||
# define __glibcxx_mutex_unlock(NAME) __gthread_mutex_unlock(&NAME)
|
||||
|
||||
#else
|
||||
|
||||
# define __glibcxx_mutex_type __gthread_mutex_t
|
||||
# define __glibcxx_mutex_define_initialized(NAME) __gthread_mutex_t NAME
|
||||
# define __glibcxx_mutex_lock(NAME)
|
||||
# define __glibcxx_mutex_unlock(NAME)
|
||||
|
||||
#endif
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
typedef __glibcxx_mutex_type mutex_type;
|
||||
|
||||
/// @brief Scoped lock idiom.
|
||||
// Acquire the mutex here with a constructor call, then release with
|
||||
// the destructor call in accordance with RAII style.
|
||||
class lock
|
||||
{
|
||||
// Externally defined and initialized.
|
||||
mutex_type& device;
|
||||
|
||||
public:
|
||||
explicit lock(mutex_type& name) : device(name)
|
||||
{ __glibcxx_mutex_lock(device); }
|
||||
|
||||
~lock() throw()
|
||||
{ __glibcxx_mutex_unlock(device); }
|
||||
|
||||
private:
|
||||
lock(const lock&);
|
||||
lock& operator=(const lock&);
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
||||
#endif
|
@ -42,7 +42,7 @@
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <bits/localefwd.h>
|
||||
#include <bits/locale_classes.h>
|
||||
|
||||
|
@ -45,8 +45,7 @@
|
||||
#include <bits/localefwd.h>
|
||||
#include <cstring> // For strcmp.
|
||||
#include <string>
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/gthr.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Low-level functions for atomic operations -*- C++ -*-
|
||||
// Support for atomic operations -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
@ -41,6 +41,10 @@
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
// Functions for portable atomic access.
|
||||
// To abstract locking primatives across all thread policies, use:
|
||||
// __exchange_and_add_dispatch
|
||||
// __atomic_add_dispatch
|
||||
#ifdef _GLIBCXX_ATOMIC_BUILTINS
|
||||
static inline _Atomic_word
|
||||
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
|
||||
@ -52,11 +56,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
#else
|
||||
_Atomic_word
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add(volatile _Atomic_word* __mem, int __val);
|
||||
__exchange_and_add(volatile _Atomic_word*, int);
|
||||
|
||||
void
|
||||
__attribute__ ((__unused__))
|
||||
__atomic_add(volatile _Atomic_word* __mem, int __val);
|
||||
__atomic_add(volatile _Atomic_word*, int);
|
||||
#endif
|
||||
|
||||
static inline _Atomic_word
|
@ -34,25 +34,13 @@
|
||||
#ifndef _BITMAP_ALLOCATOR_H
|
||||
#define _BITMAP_ALLOCATOR_H 1
|
||||
|
||||
// For std::size_t, and ptrdiff_t.
|
||||
#include <cstddef>
|
||||
|
||||
// For __throw_bad_alloc().
|
||||
#include <bits/functexcept.h>
|
||||
|
||||
// For std::pair.
|
||||
#include <utility>
|
||||
|
||||
// For greater_equal, and less_equal.
|
||||
#include <functional>
|
||||
|
||||
// For operator new.
|
||||
#include <new>
|
||||
|
||||
// For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock.
|
||||
#include <bits/gthr.h>
|
||||
|
||||
#include <cstddef> // For std::size_t, and ptrdiff_t.
|
||||
#include <bits/functexcept.h> // For __throw_bad_alloc().
|
||||
#include <utility> // For std::pair.
|
||||
#include <functional> // For greater_equal, and less_equal.
|
||||
#include <new> // For operator new.
|
||||
#include <debug/debug.h> // _GLIBCXX_DEBUG_ASSERT
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
|
||||
/** @brief The constant in the expression below is the alignment
|
||||
@ -65,144 +53,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
using std::size_t;
|
||||
using std::ptrdiff_t;
|
||||
|
||||
#if defined __GTHREADS
|
||||
namespace
|
||||
{
|
||||
/** @brief If true, then the application being compiled will be
|
||||
* using threads, so use mutexes as a synchronization primitive,
|
||||
* else do no use any synchronization primitives.
|
||||
*/
|
||||
bool const __threads_enabled = __gthread_active_p();
|
||||
} // anonymous namespace
|
||||
#endif
|
||||
|
||||
#if defined __GTHREADS
|
||||
/** @class _Mutex bitmap_allocator.h bitmap_allocator.h
|
||||
*
|
||||
* @brief _Mutex is an OO-Wrapper for __gthread_mutex_t.
|
||||
*
|
||||
* It does not allow you to copy or assign an already initialized
|
||||
* mutex. This is used merely as a convenience for the locking
|
||||
* classes.
|
||||
*/
|
||||
class _Mutex
|
||||
{
|
||||
__gthread_mutex_t _M_mut;
|
||||
|
||||
// Prevent Copying and assignment.
|
||||
_Mutex(_Mutex const&);
|
||||
_Mutex& operator=(_Mutex const&);
|
||||
|
||||
public:
|
||||
_Mutex()
|
||||
{
|
||||
if (__threads_enabled)
|
||||
{
|
||||
#if !defined __GTHREAD_MUTEX_INIT
|
||||
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mut);
|
||||
#else
|
||||
__gthread_mutex_t __mtemp = __GTHREAD_MUTEX_INIT;
|
||||
_M_mut = __mtemp;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
~_Mutex()
|
||||
{
|
||||
// Gthreads does not define a Mutex Destruction Function.
|
||||
}
|
||||
|
||||
__gthread_mutex_t*
|
||||
_M_get() { return &_M_mut; }
|
||||
};
|
||||
|
||||
/** @class _Lock bitmap_allocator.h bitmap_allocator.h
|
||||
*
|
||||
* @brief _Lock is a simple manual locking class which allows you to
|
||||
* manually lock and unlock a mutex associated with the lock.
|
||||
*
|
||||
* There is no automatic locking or unlocking happening without the
|
||||
* programmer's explicit instructions. This class unlocks the mutex
|
||||
* ONLY if it has not been locked. However, this check does not
|
||||
* apply for locking, and wayward use may cause dead-locks.
|
||||
*/
|
||||
class _Lock
|
||||
{
|
||||
_Mutex* _M_pmt;
|
||||
bool _M_locked;
|
||||
|
||||
// Prevent Copying and assignment.
|
||||
_Lock(_Lock const&);
|
||||
_Lock& operator=(_Lock const&);
|
||||
|
||||
public:
|
||||
_Lock(_Mutex* __mptr)
|
||||
: _M_pmt(__mptr), _M_locked(false)
|
||||
{ }
|
||||
|
||||
void
|
||||
_M_lock()
|
||||
{
|
||||
if (__threads_enabled)
|
||||
{
|
||||
_M_locked = true;
|
||||
__gthread_mutex_lock(_M_pmt->_M_get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_M_unlock()
|
||||
{
|
||||
if (__threads_enabled)
|
||||
{
|
||||
if (__builtin_expect(_M_locked, true))
|
||||
{
|
||||
__gthread_mutex_unlock(_M_pmt->_M_get());
|
||||
_M_locked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~_Lock() { }
|
||||
};
|
||||
|
||||
/** @class _Auto_Lock bitmap_allocator.h bitmap_allocator.h
|
||||
*
|
||||
* @brief _Auto_Lock locks the associated mutex on construction, and
|
||||
* unlocks on destruction.
|
||||
*
|
||||
* There are no checks performed, and this class follows the RAII
|
||||
* principle.
|
||||
*/
|
||||
class _Auto_Lock
|
||||
{
|
||||
_Mutex* _M_pmt;
|
||||
// Prevent Copying and assignment.
|
||||
_Auto_Lock(_Auto_Lock const&);
|
||||
_Auto_Lock& operator=(_Auto_Lock const&);
|
||||
|
||||
void
|
||||
_M_lock()
|
||||
{
|
||||
if (__threads_enabled)
|
||||
__gthread_mutex_lock(_M_pmt->_M_get());
|
||||
}
|
||||
|
||||
void
|
||||
_M_unlock()
|
||||
{
|
||||
if (__threads_enabled)
|
||||
__gthread_mutex_unlock(_M_pmt->_M_get());
|
||||
}
|
||||
|
||||
public:
|
||||
_Auto_Lock(_Mutex* __mptr) : _M_pmt(__mptr)
|
||||
{ this->_M_lock(); }
|
||||
|
||||
~_Auto_Lock() { this->_M_unlock(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace balloc
|
||||
{
|
||||
/** @class __mini_vector bitmap_allocator.h bitmap_allocator.h
|
||||
@ -699,9 +549,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
*/
|
||||
class free_list
|
||||
{
|
||||
typedef size_t* value_type;
|
||||
typedef balloc::__mini_vector<value_type> vector_type;
|
||||
typedef vector_type::iterator iterator;
|
||||
typedef size_t* value_type;
|
||||
typedef balloc::__mini_vector<value_type> vector_type;
|
||||
typedef vector_type::iterator iterator;
|
||||
typedef __mutex mutex_type;
|
||||
|
||||
struct _LT_pointer_compare
|
||||
{
|
||||
@ -712,11 +563,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
};
|
||||
|
||||
#if defined __GTHREADS
|
||||
_Mutex*
|
||||
mutex_type&
|
||||
_M_get_mutex()
|
||||
{
|
||||
static _Mutex _S_mutex;
|
||||
return &_S_mutex;
|
||||
static mutex_type _S_mutex;
|
||||
return _S_mutex;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -807,7 +658,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_M_insert(size_t* __addr) throw()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bfl_lock(_M_get_mutex());
|
||||
__gnu_cxx::__scoped_lock __bfl_lock(_M_get_mutex());
|
||||
#endif
|
||||
// Call _M_validate to decide what should be done with
|
||||
// this particular free list.
|
||||
@ -859,13 +710,15 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
class bitmap_allocator : private free_list
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
typedef free_list::mutex_type mutex_type;
|
||||
|
||||
template<typename _Tp1>
|
||||
struct rebind
|
||||
{
|
||||
@ -971,7 +824,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_Bitmap_counter<_Alloc_block*> _S_last_request;
|
||||
static typename _BPVector::size_type _S_last_dealloc_index;
|
||||
#if defined __GTHREADS
|
||||
static _Mutex _S_mut;
|
||||
static mutex_type _S_mut;
|
||||
#endif
|
||||
|
||||
public:
|
||||
@ -993,7 +846,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_M_allocate_single_object() throw(std::bad_alloc)
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bit_lock(&_S_mut);
|
||||
__gnu_cxx::__scoped_lock __bit_lock(_S_mut);
|
||||
#endif
|
||||
|
||||
// The algorithm is something like this: The last_request
|
||||
@ -1091,7 +944,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_M_deallocate_single_object(pointer __p) throw()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bit_lock(&_S_mut);
|
||||
__gnu_cxx::__scoped_lock __bit_lock(_S_mut);
|
||||
#endif
|
||||
_Alloc_block* __real_p = reinterpret_cast<_Alloc_block*>(__p);
|
||||
|
||||
@ -1105,8 +958,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
||||
if (__gnu_cxx::balloc::_Inclusive_between<_Alloc_block*>
|
||||
(__real_p)
|
||||
(_S_mem_blocks[_S_last_dealloc_index]))
|
||||
(__real_p) (_S_mem_blocks[_S_last_dealloc_index]))
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1);
|
||||
|
||||
@ -1116,8 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
}
|
||||
else
|
||||
{
|
||||
_Iterator _iter =
|
||||
__gnu_cxx::balloc::
|
||||
_Iterator _iter = __gnu_cxx::balloc::
|
||||
__find_if(_S_mem_blocks.begin(),
|
||||
_S_mem_blocks.end(),
|
||||
__gnu_cxx::balloc::
|
||||
@ -1276,7 +1127,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
#if defined __GTHREADS
|
||||
template<typename _Tp>
|
||||
__gnu_cxx::_Mutex
|
||||
typename bitmap_allocator<_Tp>::mutex_type
|
||||
bitmap_allocator<_Tp>::_S_mut;
|
||||
#endif
|
||||
|
||||
@ -1284,4 +1135,3 @@ _GLIBCXX_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
// LocalWords: namespace GTHREADS bool const gthread endif Mutex mutex
|
||||
|
184
libstdc++-v3/include/ext/concurrence.h
Normal file
184
libstdc++-v3/include/ext/concurrence.h
Normal file
@ -0,0 +1,184 @@
|
||||
// Support for concurrent programing -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2003, 2004, 2005, 2006
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
/** @file concurrence.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _CONCURRENCE_H
|
||||
#define _CONCURRENCE_H 1
|
||||
|
||||
#include <bits/gthr.h>
|
||||
#include <bits/functexcept.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
// Available locking policies:
|
||||
// _S_single single-threaded code that doesn't need to be locked.
|
||||
// _S_mutex multi-threaded code that requires additional support
|
||||
// from gthr.h or abstraction layers in concurrance.h.
|
||||
// _S_atomic multi-threaded code using atomic operations.
|
||||
enum _Lock_policy { _S_single, _S_mutex, _S_atomic };
|
||||
|
||||
// Compile time constant that indicates prefered locking policy in
|
||||
// the current configuration.
|
||||
static const _Lock_policy __default_lock_policy =
|
||||
#ifdef __GTHREADS
|
||||
// NB: This macro doesn't actually exist yet in the compiler, but is
|
||||
// set somewhat haphazardly at configure time.
|
||||
#ifdef _GLIBCXX_ATOMIC_BUILTINS
|
||||
_S_atomic;
|
||||
#else
|
||||
_S_mutex;
|
||||
#endif
|
||||
#else
|
||||
_S_single;
|
||||
#endif
|
||||
|
||||
class __mutex
|
||||
{
|
||||
private:
|
||||
__gthread_mutex_t _M_mutex;
|
||||
|
||||
__mutex(const __mutex&);
|
||||
__mutex& operator=(const __mutex&);
|
||||
|
||||
public:
|
||||
__mutex()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
#if defined __GTHREAD_MUTEX_INIT
|
||||
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
|
||||
_M_mutex = __tmp;
|
||||
#else
|
||||
__GTHREAD_MUTEX_INIT_FUNCTION(_M_mutex);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_mutex_lock(&_M_mutex) != 0)
|
||||
std::__throw_runtime_error("__mutex::lock");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_mutex_unlock(&_M_mutex) != 0)
|
||||
std::__throw_runtime_error("__mutex::unlock");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
class __recursive_mutex
|
||||
{
|
||||
private:
|
||||
__gthread_recursive_mutex_t _M_mutex;
|
||||
|
||||
__recursive_mutex(const __recursive_mutex&);
|
||||
__recursive_mutex& operator=(const __recursive_mutex&);
|
||||
|
||||
public:
|
||||
__recursive_mutex()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
#if defined __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||
__gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
|
||||
_M_mutex = __tmp;
|
||||
#else
|
||||
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(_M_mutex);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_recursive_mutex_lock(&_M_mutex) != 0)
|
||||
std::__throw_runtime_error("__recursive_mutex::lock");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0)
|
||||
std::__throw_runtime_error("__recursive_mutex::unlock");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief Scoped lock idiom.
|
||||
// Acquire the mutex here with a constructor call, then release with
|
||||
// the destructor call in accordance with RAII style.
|
||||
class __scoped_lock
|
||||
{
|
||||
public:
|
||||
typedef __mutex mutex_type;
|
||||
|
||||
private:
|
||||
mutex_type& _M_device;
|
||||
|
||||
__scoped_lock(const __scoped_lock&);
|
||||
__scoped_lock& operator=(const __scoped_lock&);
|
||||
|
||||
public:
|
||||
explicit __scoped_lock(mutex_type& __name) : _M_device(__name)
|
||||
{ _M_device.lock(); }
|
||||
|
||||
~__scoped_lock() throw()
|
||||
{ _M_device.unlock(); }
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE
|
||||
|
||||
#endif
|
@ -37,8 +37,7 @@
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/gthr.h>
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
@ -52,8 +52,8 @@
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_Obj* volatile*
|
||||
_M_get_free_list(size_t __bytes);
|
||||
|
||||
mutex_type&
|
||||
__mutex&
|
||||
_M_get_mutex();
|
||||
|
||||
// Returns an object of size __n, and optionally adds to size __n
|
||||
@ -218,7 +218,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
{
|
||||
_Obj* volatile* __free_list = _M_get_free_list(__bytes);
|
||||
|
||||
lock sentry(_M_get_mutex());
|
||||
__scoped_lock sentry(_M_get_mutex());
|
||||
_Obj* __restrict__ __result = *__free_list;
|
||||
if (__builtin_expect(__result == 0, 0))
|
||||
__ret = static_cast<_Tp*>(_M_refill(_M_round_up(__bytes)));
|
||||
@ -248,7 +248,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_Obj* volatile* __free_list = _M_get_free_list(__bytes);
|
||||
_Obj* __q = reinterpret_cast<_Obj*>(__p);
|
||||
|
||||
lock sentry(_M_get_mutex());
|
||||
__scoped_lock sentry(_M_get_mutex());
|
||||
__q ->_M_free_list_link = *__free_list;
|
||||
*__free_list = __q;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
#ifndef _RC_STRING_BASE_H
|
||||
#define _RC_STRING_BASE_H 1
|
||||
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// <tr1/memory> -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -40,10 +40,9 @@
|
||||
#include <iosfwd> // std::basic_ostream
|
||||
#include <cstdlib> // std::abort
|
||||
|
||||
#include <bits/gthr.h>
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <ext/concurrence.h>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
#include <tr1/boost_shared_ptr.h>
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -33,19 +33,12 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
namespace balloc
|
||||
{
|
||||
template class __mini_vector<std::pair
|
||||
<bitmap_allocator<char>::_Alloc_block*,
|
||||
bitmap_allocator<char>::_Alloc_block*> >;
|
||||
|
||||
template class __mini_vector<std::pair
|
||||
<bitmap_allocator<wchar_t>::_Alloc_block*,
|
||||
bitmap_allocator<wchar_t>::_Alloc_block*> >;
|
||||
|
||||
template class __mini_vector<std::pair<bitmap_allocator<char>::_Alloc_block*, bitmap_allocator<char>::_Alloc_block*> >;
|
||||
template class __mini_vector<std::pair<bitmap_allocator<wchar_t>::_Alloc_block*, bitmap_allocator<wchar_t>::_Alloc_block*> >;
|
||||
template class __mini_vector<size_t*>;
|
||||
|
||||
template size_t** __lower_bound
|
||||
(size_t**, size_t**,
|
||||
size_t const&, free_list::_LT_pointer_compare);
|
||||
template size_t** __lower_bound(size_t**, size_t**, size_t const&,
|
||||
free_list::_LT_pointer_compare);
|
||||
}
|
||||
|
||||
size_t*
|
||||
@ -53,25 +46,24 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_M_get(size_t __sz) throw(std::bad_alloc)
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Lock __bfl_lock(_M_get_mutex());
|
||||
__bfl_lock._M_lock();
|
||||
mutex_type& __bfl_mutex = _M_get_mutex();
|
||||
#endif
|
||||
iterator __temp =
|
||||
__gnu_cxx::balloc::__lower_bound
|
||||
(_M_get_free_list().begin(), _M_get_free_list().end(),
|
||||
__sz, _LT_pointer_compare());
|
||||
const vector_type& __free_list = _M_get_free_list();
|
||||
using __gnu_cxx::balloc::__lower_bound;
|
||||
iterator __tmp = __lower_bound(__free_list.begin(), __free_list.end(),
|
||||
__sz, _LT_pointer_compare());
|
||||
|
||||
if (__temp == _M_get_free_list().end() || !_M_should_i_give(**__temp, __sz))
|
||||
if (__tmp == __free_list.end() || !_M_should_i_give(**__tmp, __sz))
|
||||
{
|
||||
// We release the lock here, because operator new is
|
||||
// guaranteed to be thread-safe by the underlying
|
||||
// implementation.
|
||||
#if defined __GTHREADS
|
||||
__bfl_lock._M_unlock();
|
||||
__bfl_mutex.unlock();
|
||||
#endif
|
||||
// Try twice to get the memory: once directly, and the 2nd
|
||||
// time after clearing the free list. If both fail, then
|
||||
// throw std::bad_alloc().
|
||||
// time after clearing the free list. If both fail, then throw
|
||||
// std::bad_alloc().
|
||||
int __ctr = 2;
|
||||
while (__ctr)
|
||||
{
|
||||
@ -79,8 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
--__ctr;
|
||||
try
|
||||
{
|
||||
__ret = reinterpret_cast<size_t*>
|
||||
(::operator new(__sz + sizeof(size_t)));
|
||||
__ret = reinterpret_cast<size_t*>(::operator new(__sz + sizeof(size_t)));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -95,10 +86,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t* __ret = *__temp;
|
||||
_M_get_free_list().erase(__temp);
|
||||
size_t* __ret = *__tmp;
|
||||
_M_get_free_list().erase(__tmp);
|
||||
#if defined __GTHREADS
|
||||
__bfl_lock._M_unlock();
|
||||
__bfl_mutex.unlock();
|
||||
#endif
|
||||
return __ret + 1;
|
||||
}
|
||||
@ -109,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
_M_clear()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bfl_lock(_M_get_mutex());
|
||||
__gnu_cxx::__scoped_lock __bfl_lock(_M_get_mutex());
|
||||
#endif
|
||||
vector_type& __free_list = _M_get_free_list();
|
||||
iterator __iter = __free_list.begin();
|
||||
|
@ -35,14 +35,14 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
static __glibcxx_mutex_define_initialized(iterator_base_mutex);
|
||||
}
|
||||
__gnu_cxx::__mutex iterator_base_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
namespace __gnu_debug
|
||||
{
|
||||
@ -192,7 +192,7 @@ namespace __gnu_debug
|
||||
// Attach to the new sequence (if there is one)
|
||||
if (__seq)
|
||||
{
|
||||
__gnu_cxx::lock sentry(iterator_base_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(iterator_base_mutex);
|
||||
_M_sequence = __seq;
|
||||
_M_version = _M_sequence->_M_version;
|
||||
_M_prior = 0;
|
||||
@ -217,7 +217,7 @@ namespace __gnu_debug
|
||||
_Safe_iterator_base::
|
||||
_M_detach()
|
||||
{
|
||||
__gnu_cxx::lock sentry(iterator_base_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(iterator_base_mutex);
|
||||
if (_M_sequence)
|
||||
{
|
||||
// Remove us from this sequence's list
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <bits/atomicity.h>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <fstream>
|
||||
#include <bits/atomicity.h>
|
||||
#include <ext/stdio_filebuf.h>
|
||||
#include <ext/stdio_sync_filebuf.h>
|
||||
|
||||
|
@ -32,14 +32,12 @@
|
||||
#include <cctype>
|
||||
#include <cwctype> // For towupper, etc.
|
||||
#include <locale>
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
// Mutex object for cache access.
|
||||
static __glibcxx_mutex_define_initialized(locale_cache_mutex);
|
||||
}
|
||||
__gnu_cxx::__mutex locale_cache_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
// XXX GLIBCXX_ABI Deprecated
|
||||
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
|
||||
@ -391,7 +389,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
locale::_Impl::
|
||||
_M_install_cache(const facet* __cache, size_t __index)
|
||||
{
|
||||
__gnu_cxx::lock sentry(locale_cache_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(locale_cache_mutex);
|
||||
if (_M_caches[__index] != 0)
|
||||
{
|
||||
// Some other thread got in first.
|
||||
|
@ -32,8 +32,7 @@
|
||||
#include <cctype>
|
||||
#include <cwctype> // For towupper, etc.
|
||||
#include <locale>
|
||||
#include <bits/atomicity.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/concurrence.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -200,8 +199,7 @@ namespace
|
||||
fake_time_cache_w timepunct_cache_w;
|
||||
#endif
|
||||
|
||||
// Mutex object for locale initialization.
|
||||
static __glibcxx_mutex_define_initialized(locale_mutex);
|
||||
__gnu_cxx::__mutex locale_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
@ -209,7 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
locale::locale() throw() : _M_impl(0)
|
||||
{
|
||||
_S_initialize();
|
||||
__gnu_cxx::lock sentry(locale_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(locale_mutex);
|
||||
_S_global->_M_add_reference();
|
||||
_M_impl = _S_global;
|
||||
}
|
||||
@ -220,7 +218,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
_S_initialize();
|
||||
_Impl* __old;
|
||||
{
|
||||
__gnu_cxx::lock sentry(locale_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(locale_mutex);
|
||||
__old = _S_global;
|
||||
__other._M_impl->_M_add_reference();
|
||||
_S_global = __other._M_impl;
|
||||
|
@ -32,7 +32,7 @@
|
||||
//
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <bits/concurrence.h>
|
||||
#include <ext/concurrence.h>
|
||||
#include <ext/mt_allocator.h>
|
||||
#include <cstring>
|
||||
|
||||
@ -59,13 +59,13 @@ namespace
|
||||
|
||||
// Ensure freelist is constructed first.
|
||||
static __freelist freelist;
|
||||
static __glibcxx_mutex_define_initialized(freelist_mutex);
|
||||
__gnu_cxx::__mutex freelist_mutex;
|
||||
|
||||
static void
|
||||
_M_destroy_thread_key(void* __id)
|
||||
{
|
||||
// Return this thread id record to the front of thread_freelist.
|
||||
__gnu_cxx::lock sentry(freelist_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(freelist_mutex);
|
||||
size_t _M_id = reinterpret_cast<size_t>(__id);
|
||||
|
||||
typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record;
|
||||
@ -497,11 +497,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
{
|
||||
__gnu_cxx::lock sentry(freelist_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(freelist_mutex);
|
||||
|
||||
if (!freelist._M_thread_freelist_array
|
||||
|| freelist._M_max_threads
|
||||
< _M_options._M_max_threads)
|
||||
|| freelist._M_max_threads < _M_options._M_max_threads)
|
||||
{
|
||||
const size_t __k = sizeof(_Thread_record)
|
||||
* _M_options._M_max_threads;
|
||||
@ -622,7 +621,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
if (_M_id == 0)
|
||||
{
|
||||
{
|
||||
__gnu_cxx::lock sentry(freelist_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(freelist_mutex);
|
||||
if (freelist._M_thread_freelist)
|
||||
{
|
||||
_M_id = freelist._M_thread_freelist->_M_id;
|
||||
@ -695,7 +694,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
{
|
||||
__gnu_cxx::lock sentry(freelist_mutex);
|
||||
__gnu_cxx::__scoped_lock sentry(freelist_mutex);
|
||||
|
||||
if (!freelist._M_thread_freelist_array
|
||||
|| freelist._M_max_threads
|
||||
|
@ -37,8 +37,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
static __glibcxx_mutex_define_initialized(palloc_init_mutex);
|
||||
}
|
||||
__gnu_cxx::__mutex palloc_init_mutex;
|
||||
} // anonymous namespace
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
|
||||
@ -50,7 +50,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||
return _S_free_list + __i;
|
||||
}
|
||||
|
||||
mutex_type&
|
||||
__mutex&
|
||||
__pool_alloc_base::_M_get_mutex()
|
||||
{ return palloc_init_mutex; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user