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

Emil Velikov emil.l.velikov at gmail.com
Tue Feb 3 06:12:23 PST 2015

On 3 February 2015 at 02:53, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> 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
>> ---
>> 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]
>    ...
>    #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
>    ...
>    ...
> 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 :-)
Upon closer look things could be fine, as

  linux/gnu: _GNU_SOURCE sets _POSIX_C_SOURCE 200809L.
With the latter of which guarding the __USE_XOPEN2K8  definition.

  cygwin: (hmm does it even set __linux*) we set _XOPEN_SOURCE=700.
Which is the guard for __USE_XOPEN2K8.

If one wants to be extra careful we can change
  #if defined(__linux__) || defined(__linux)
to check for the said old versions of glibc, but I believe we should be safe.

Would anyone else have comments on this patch ?


More information about the mesa-dev mailing list