On Sun, Sep 30, 2012 at 11:41 AM, Jonathan Wakely <jwakely....@gmail.com> wrote:
> There is no __gthread_recursive_mutex_destroy function in the gthreads API.
>
> Trying to use __gthread_mutex_destroy fails to compile on platforms
> where the mutex
> types are different. To avoid resource leaks libstdc++ needs to hack
> around the missing function with overloaded functions and SFINAE
> tricks to detect how a recursive mutex can be destroyed.
>
> This patch extends the gthreads API to include
> __gthread_recursive_mutex_destroy, defining it for each gthread model,
> and removing the hacks from libstdc++.

> +    return rtems_gxx_mutex_destroy( __mutex );

Space before '(', not space after.

Doing anything else here is going to be painful, but this assumes that
RTEMS uses the same representation for non-recursive and recursive
mutexes.  That is currently true, but it deserves a comment.


> --- a/libgcc/config/i386/gthr-win32.h
> +++ b/libgcc/config/i386/gthr-win32.h
> +static inline void
> +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex)
> +{
> +  __gthread_mutex_t __mutex2;
> +  __mutex2.sema = mutex->sema;
> +  __gthr_win32_mutex_destroy (&__mutex2);
> +}

I think it would be better to put this in
libgcc/config/i386/gthr-win32.c, like the other functions.  Then you
can just call CloseHandle.

> --- a/libgcc/config/mips/gthr-mipssde.h
> +++ b/libgcc/config/mips/gthr-mipssde.h
>
> +static inline int
> +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_mutex_destroy(__mutex);
> +}

Will this even compile?  It doesn't look like it.

Ian

Reply via email to