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
Created attachment 27760 [details] Add __gthread_recursive_mutex_destroy. Untested.
Author: redi Date: Tue Oct 2 20:22:32 2012 New Revision: 192002 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192002 Log: libgcc: PR other/53889 * gthr.h (__gthread_recursive_mutex_destroy): Document new required function. * gthr-posix.h (__gthread_recursive_mutex_destroy): Define. * gthr-single.h (__gthread_recursive_mutex_destroy): Likewise. * config/gthr-rtems.h (__gthread_recursive_mutex_destroy): Likewise. * config/gthr-vxworks.h (__gthread_recursive_mutex_destroy): Likewise. * config/i386/gthr-win32.h (__gthread_recursive_mutex_destroy): Likewise. * config/mips/gthr-mipssde.h (__gthread_recursive_mutex_destroy): Likewise. * config/pa/gthr-dce.h (__gthread_recursive_mutex_destroy): Likewise. * config/s390/gthr-tpf.h (__gthread_recursive_mutex_destroy): Likewise. libstdc++-v3: PR other/53889 * include/std/mutex (__recursive_mutex_base::~__recursive_mutex_base): Use __gthread_recursive_mutex_destroy. (__recursive_mutex_base::_S_destroy): Remove. (__recursive_mutex_base::_S_destroy_win32): Likewise. * include/ext/concurrence.h (__recursive_mutex::~__recursive_mutex): Use __gthread_recursive_mutex_destroy. (__recursive_mutex::_S_destroy): Remove. (__recursive_mutex::_S_destroy_win32): Likewise. Modified: trunk/libgcc/ChangeLog trunk/libgcc/config/gthr-rtems.h trunk/libgcc/config/gthr-vxworks.h trunk/libgcc/config/i386/gthr-win32.c trunk/libgcc/config/i386/gthr-win32.h trunk/libgcc/config/mips/gthr-mipssde.h trunk/libgcc/config/pa/gthr-dce.h trunk/libgcc/config/s390/gthr-tpf.h trunk/libgcc/gthr-posix.h trunk/libgcc/gthr-single.h trunk/libgcc/gthr.h trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/ext/concurrence.h trunk/libstdc++-v3/include/std/mutex
libgcc changes approved by Ian: http://gcc.gnu.org/ml/gcc-patches/2012-10/msg00123.html This is fixed for 4.8
Author: redi Date: Fri Oct 5 07:35:12 2012 New Revision: 192114 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192114 Log: PR other/53889 * config/i386/gthr-win32.h (__gthread_recursive_mutex_destroy): Fix parameter names. Modified: trunk/libgcc/ChangeLog trunk/libgcc/config/i386/gthr-win32.h