[Mesa-dev] [PATCH v2] c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default

Emil Velikov emil.l.velikov at gmail.com
Mon Feb 2 18:53:23 PST 2015


Hi Felix,

On 2 February 2015 at 19:04, Felix Janda <felix.janda at posteo.de> wrote:
> Previously PTHREAD_MUTEX_RECURSIVE_NP had been used on linux for
> compatibility with old glibc. Since mesa defines __GNU_SOURCE__
> on linux PTHREAD_MUTEX_RECURSIVE is also available since at least
> 1998. So we can unconditionally use the portable version
> PTHREAD_MUTEX_RECURSIVE.
> ---
> Previous patch didn't work as intended since on glibc these are
> part of an enum and not defines.
>
>From a quick look at {e,}glibc sources [1]

   PTHREAD_MUTEX_RECURSIVE_NP,
   ...
   #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
   ...
   PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
   ...

Which does not seem to have relation with _GNU_SOURCE_ as the commit
mentions. Note I don't even pretend to know the convoluted web of
macros, so I could be a bit off :-)

Also if there is a bug report associated with this please mention it
in the commit message, like
Bugzilla: $(full_url)

Thanks
Emil

[1] http://osxr.org/glibc/source/nptl/sysdeps/pthread/pthread.h#0048

Thanks
Emil

> ---
>  include/c11/threads_posix.h | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h
> index f9c165d..2182c28 100644
> --- a/include/c11/threads_posix.h
> +++ b/include/c11/threads_posix.h
> @@ -177,13 +177,8 @@ mtx_init(mtx_t *mtx, int type)
>        && type != (mtx_try|mtx_recursive))
>          return thrd_error;
>      pthread_mutexattr_init(&attr);
> -    if ((type & mtx_recursive) != 0) {
> -#if defined(__linux__) || defined(__linux)
> -        pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
> -#else
> +    if ((type & mtx_recursive) != 0)
>          pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
> -#endif
> -    }
>      pthread_mutex_init(mtx, &attr);
>      pthread_mutexattr_destroy(&attr);
>      return thrd_success;
> --
> 2.0.5
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list