This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/53889] New: Gthreads doesn't support destroying recursive mutexes
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 07 Jul 2012 18:48:53 +0000
- Subject: [Bug other/53889] New: Gthreads doesn't support destroying recursive mutexes
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53889
Bug #: 53889
Summary: Gthreads doesn't support destroying recursive mutexes
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
There is no __gthread_recursive_mutex_destroy function in the gthreads API.
Using __gthread_mutex_destroy fails to compile on platforms where the mutex
types are different. This means to avoid resource leaks libstdc++ needs to hack
around it with:
// FIXME: gthreads doesn't define __gthread_recursive_mutex_destroy
// so we need to obtain a __gthread_mutex_t to destroy
private:
template<typename _Mx, typename _Rm>
static void
_S_destroy_win32(_Mx* __mx, _Rm const* __rmx)
{
__mx->counter = __rmx->counter;
__mx->sema = __rmx->sema;
__gthread_mutex_destroy(__mx);
}
// matches a gthr-win32.h recursive mutex
template<typename _Rm>
static typename __enable_if<(bool)sizeof(&_Rm::sema), void>::__type
_S_destroy(_Rm* __mx)
{
__gthread_mutex_t __tmp;
_S_destroy_win32(&__tmp, __mx);
}
// matches a recursive mutex with a member 'actual'
template<typename _Rm>
static typename __enable_if<(bool)sizeof(&_Rm::actual), void>::__type
_S_destroy(_Rm* __mx)
{ __gthread_mutex_destroy(&__mx->actual); }
// matches when there's only one mutex type
template<typename _Rm>
static typename
__enable_if<std::__are_same<_Rm, __gthread_mutex_t>::__value,
void>::__type
_S_destroy(_Rm* __mx)
{ __gthread_mutex_destroy(__mx); }
Gthreads should define __gthread_recursive_mutex_destroy