This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix the atomic_compare_and_exchange_*_rel definitions.
- From: Torvald Riegel <triegel at redhat dot com>
- To: Lei Xu <lei dot xu at nxp dot com>
- Cc: "carlos at systemhalted dot org" <carlos at systemhalted dot org>, "sjmunroe at us dot ibm dot com" <sjmunroe at us dot ibm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, Scott Wood <scott dot wood at nxp dot com>
- Date: Tue, 14 Jun 2016 12:16:30 +0200
- Subject: Re: [PATCH] Fix the atomic_compare_and_exchange_*_rel definitions.
- Authentication-results: sourceware.org; auth=none
- References: <1465723849-12811-1-git-send-email-lei dot xu at nxp dot com> <1465814229 dot 19633 dot 45 dot camel at localhost dot localdomain> <AM3PR04MB1297274106B14C1C0B23D16590540 at AM3PR04MB1297 dot eurprd04 dot prod dot outlook dot com>
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.