diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2004-07-01 14:49:29 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-07-01 14:49:29 +0000 |
commit | f65d32011500ab08d981d3927ca7d151b855861e (patch) | |
tree | 84fba1fc51e9a0c4e3e4895babf63448ac87b191 | |
parent | 60ba25bfc1c465184d34bae053b0d47161c20a76 (diff) | |
download | gcc-f65d32011500ab08d981d3927ca7d151b855861e.zip gcc-f65d32011500ab08d981d3927ca7d151b855861e.tar.gz gcc-f65d32011500ab08d981d3927ca7d151b855861e.tar.bz2 |
Per Bothner <per@bothner.com > Mohan Embar <gnustuff@thisiscool.com>
2004-07-01 Benjamin Kosnik <bkoz@redhat.com>
Per Bothner <per@bothner.com >
Mohan Embar <gnustuff@thisiscool.com>
PR libstdc++/16248
* include/bits/concurrence.h (__glibcxx_mutex_type): New.
(__glibcxx_mutex): Encapsulate mutex init function into type for
threaded configurations without __GTHREAD_MUTEX_INIT.
(lock::lock): Make device member a reference.
(lock::~lock): Same.
* include/ext/pool_allocator.h (__pool_base::_M_get_mutex): Change
to mutex_type.
* src/allocator.cc: Same.
Co-Authored-By: Mohan Embar <gnustuff@thisiscool.com>
Co-Authored-By: Per Bothner <per@bothner.com>
From-SVN: r83985
-rw-r--r-- | libstdc++-v3/ChangeLog | 14 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/concurrence.h | 23 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/pool_allocator.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/src/allocator.cc | 2 |
4 files changed, 31 insertions, 10 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4f19d10..b645080 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,17 @@ +2004-07-01 Benjamin Kosnik <bkoz@redhat.com> + Per Bothner <per@bothner.com > + Mohan Embar <gnustuff@thisiscool.com> + + PR libstdc++/16248 + * include/bits/concurrence.h (__glibcxx_mutex_type): New. + (__glibcxx_mutex): Encapsulate mutex init function into type for + threaded configurations without __GTHREAD_MUTEX_INIT. + (lock::lock): Make device member a reference. + (lock::~lock): Same. + * include/ext/pool_allocator.h (__pool_base::_M_get_mutex): Change + to mutex_type. + * src/allocator.cc: Same. + 2004-06-30 Brad Spencer <spencer@infointeractive.com> * include/ext/mt_allocator.h: Handle allocations at static diff --git a/libstdc++-v3/include/bits/concurrence.h b/libstdc++-v3/include/bits/concurrence.h index 03cd6eb..7b2fae9 100644 --- a/libstdc++-v3/include/bits/concurrence.h +++ b/libstdc++-v3/include/bits/concurrence.h @@ -37,18 +37,22 @@ #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) \ -__gthread_mutex_t NAME; \ -__gthread_once_t NAME ## _once = __GTHREAD_ONCE_INIT; \ -void NAME ## _init() { __GTHREAD_MUTEX_INIT_FUNCTION(&NAME); } +__glibcxx_mutex NAME # define __glibcxx_mutex_lock(NAME) \ -__gthread_once(&NAME ## _once, NAME ## _init); \ __gthread_mutex_lock(&NAME) # endif @@ -56,6 +60,7 @@ __gthread_mutex_lock(&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) @@ -64,19 +69,21 @@ __gthread_mutex_lock(&NAME) namespace __gnu_cxx { + typedef __glibcxx_mutex_type mutex_type; + class lock { // Externally defined and initialized. - __gthread_mutex_t* device; + mutex_type& device; public: // Acquire the mutex here with a constructor call. This ensures // that it is released in exit or during stack unwinding. - explicit lock(__gthread_mutex_t& name) : device(&name) - { __glibcxx_mutex_lock(*device); } + explicit lock(mutex_type& name) : device(name) + { __glibcxx_mutex_lock(device); } ~lock() throw() - { __glibcxx_mutex_unlock(*device); } + { __glibcxx_mutex_unlock(device); } private: lock(const lock&); diff --git a/libstdc++-v3/include/ext/pool_allocator.h b/libstdc++-v3/include/ext/pool_allocator.h index de6299b..eec79e7 100644 --- a/libstdc++-v3/include/ext/pool_allocator.h +++ b/libstdc++-v3/include/ext/pool_allocator.h @@ -100,7 +100,7 @@ namespace __gnu_cxx _Obj* volatile* _M_get_free_list(size_t __bytes); - __gthread_mutex_t& + mutex_type& _M_get_mutex(); // Returns an object of size __n, and optionally adds to size __n diff --git a/libstdc++-v3/src/allocator.cc b/libstdc++-v3/src/allocator.cc index af5de4d..e35aa3e 100644 --- a/libstdc++-v3/src/allocator.cc +++ b/libstdc++-v3/src/allocator.cc @@ -51,7 +51,7 @@ namespace __gnu_cxx return _S_free_list + __i; } - __gthread_mutex_t& + mutex_type& __pool_base::_M_get_mutex() { return __gnu_internal::palloc_init_mutex; } |