[PATCH v2 3/5] include: Prefer GCC __atomic builtins if possible.

Zebediah Figura (she/her) zfigura at codeweavers.com
Mon Jan 18 10:45:30 CST 2021


On 1/18/21 5:52 AM, Alexandre Julliard wrote:
> "Zebediah Figura (she/her)" <zfigura at codeweavers.com> writes:
> 
>> On 1/15/21 10:34 AM, Alexandre Julliard wrote:
>>> Zebediah Figura <z.figura12 at gmail.com> writes:
>>>
>>>> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
>>>> ---
>>>> v2: avoid 16-bit __atomic_compare_exchange_n()
>>>>
>>>>  include/winnt.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
>>>>  1 file changed, 53 insertions(+)
>>>
>>> How are these better than the __sync ones in practice?
>>>
>>
>> I think the only real benefit is atomic exchange; it allows the compiler
>> to maybe yield better code for x86 than our inline assembly (although it
>> surely would never make a difference in practice), and presumably better
>> code for other platforms than a compare-and-swap loop.
> 
> For other platforms it would be OK to require the atomic builtin, we
> only care about old compilers on x86.
> 
> It would also be OK to use it as an alternative to inline assembly for
> InterlockedExchange, but I don't think it's necessary to duplicate all
> the other interlocked functions if there's no significant benefit.
> 

That makes sense, thanks. I'll resend without this patch, and just
change InterlockedExchange instead.



More information about the wine-devel mailing list