[PATCH] Fix the atomic_compare_and_exchange_*_rel definitions.

Torvald Riegel triegel@redhat.com
Tue Jun 14 10:16:00 GMT 2016


On Tue, 2016-06-14 at 04:27 +0000, Lei Xu wrote:
> [XuLei] Yes, I agree with you. At first I plan to fix this to add atomic_compare_and_exchange_bool_rel in powerpc definitions.
> Next I considered whether the default definitions in include/atomic.h should be changed:
> The atomic_compare_and_exchange_val_acq was defined according to __arch_c_compare_and_exchange_val_32_acq,
> Why not atomic_compare_and_exchange_val_rel? If there is no __arch_compare_and_exchange_val_32_rel, it can also use atomic_compare_and_exchange_val_acq.
> 
> Meantime we can define atomic_compare_and_exchange_bool_rel to use __arch_compare_and_exchange_bool_32_rel firstly, then atomic_compare_and_exchange_val_rel;
> This is similarly with atomic_compare_and_exchange_bool_acq definitions.
> 
> These can be applied to generic but not powerpc specific and follows the same rules:
> For acq, Firstly try to use __arch_*acq, then use atomic_*val_*acq;
> For rel, firstly to use __arch_*rel, then use atomic_*val_*rel, then atomic_*val*acq;
> 
> But I did not test this on all of the archs, and just compile it successfully on x86 platform.
> 
> So the key point may be that whether it need to change the default generic files, if NOT, I will modify the files in powerpc definitions.
> Thanks.
> -------------------------[xulei]
> 
> A third option to improve this would be to remove atomic_compare_and_exchange_bool_rel and replace it with atomic_compare_exchange_weak_release (ie, the matching C11 atomic operation).  There are just three callsites that would have to change.

Thinking more about this, I think the easiest way is actually to remove
atomic_compare_and_exchange_bool_rel completely and replace the current
3 calls to it with C11 atomics.  I'll send a patch that does this
shortly.





More information about the Libc-alpha mailing list