This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions



On 12/07/2018 15:24, Florian Weimer wrote:
> On 07/12/2018 07:52 PM, Adhemerval Zanella wrote:
>>
>>
>> On 12/07/2018 13:46, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>
>>>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>>>> index c569759..c2ab78a 100644
>>>> --- a/include/stdc-predef.h
>>>> +++ b/include/stdc-predef.h
>>>> @@ -57,7 +57,4 @@
>>>>       - 3 additional Zanabazar Square characters */
>>>>    #define __STDC_ISO_10646__        201706L
>>>>    -/* We do not support C11 <threads.h>.  */
>>>> -#define __STDC_NO_THREADS__        1
>>>
>>> Should we do this only if we know that the compiler has _Thread_local support (based on a GCC and __cplusplus version check)?
>>
>> It seems reasonable, since its a installed header.  Do we need to
>> check for __cplusplus too? Shouldn't __GNUC_PREREQ (4.9) be suffice?
> 
> I think we can use __thread instead of _Thread_local with even older compilers, and also factor in __cplusplus if it is recent enough (essentially 2011 and later) for the !__GNUC__ case.
> 
> Maybe it's sufficient to say
> 
> #if !defined (__GNUC__) && !defined (__cpluscplus) \
>   &&  __cplusplus < 201103L)
> # define __STDC_NO_THREADS__        1
> #endif
> 
> On the other hand, maybe your original change is right because in C11, _Thread_local support is not optional.  Implementations are required to recognize the keyword (and presumably ignore it) even if they define __STDC_NO_THREADS__.  And our <threads.h> will generally work fine even if the compiler does not actually support _Thread_local.  So I'd say go with your original change.
> 
> (But I do think you need to do something about thread_local in the C++ case, independently of this discussion.)

Also on GCC BZ#53769 [1] Joseph wrote that check for __STDC_VERSION__
and/or __STDC_NO_THREADS__ is not meaningful to documented incomplete
compiler support for language standard.  This is at least for GCC 
standpoint, not sure about other compilers.

We could add a check like:

#if (defined (__GNUC__) && !__GNUC_PREREQ (4.9))
    || (!defined (__cpluscplus) &&  __cplusplus < 201103L)
#  define __STDC_NO_THREADS__   1
#endif

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]