[PATCH] nptl: Extract <bits/atomic_wide_counter.h> from pthread_cond_common.c

Andreas Schwab schwab@linux-m68k.org
Wed Nov 3 19:47:11 GMT 2021


On Nov 03 2021, Florian Weimer wrote:

> * Andreas Schwab:
>
>> On Nov 03 2021, Florian Weimer wrote:
>>
>>> * Andreas Schwab:
>>>
>>>> On Nov 02 2021, Florian Weimer via Libc-alpha wrote:
>>>>
>>>>> +/* Counter that is monotonically increasing (by less than 2**31 per
>>>>> +   increment), with a single writer, and an arbitrary number of
>>>>> +   readers.  */
>>>>> +typedef union
>>>>> +{
>>>>> +  __extension__ unsigned long long int __value64;
>>>>> +  struct
>>>>> +  {
>>>>> +    unsigned int __low;
>>>>> +    unsigned int __high;
>>>>> +  } __value32;
>>>>> +} __atomic_wide_counter;
>>>>
>>>> Why doesn't this need to account for endianess?
>>>
>>> The ABI is not compatible between 64-bit and 32-bit for other reasons
>>> (the counters count differently, the 32-bit variant is just 62 bits).
>>> You cannot have a shared mapping with different word sizes.  I don't
>>> think this matters.
>>
>> Why do you need a union then?
>
> __HAVE_64B_ATOMICS is not available in the installed headers.  It's what
> governs the choice between the two layouts, and not __WORDSIZE.

Why is it an installed header?  If it cannot be used without this
internal define, how is that useful outside glibc?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Libc-alpha mailing list