This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [ARM] bits/atomic.h and GCC atomic builtins
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ken Werner <ken at linux dot vnet dot ibm dot com>
- Cc: libc-ports at sources dot redhat dot com
- Date: Tue, 16 Nov 2010 15:55:36 +0000 (UTC)
- Subject: Re: [ARM] bits/atomic.h and GCC atomic builtins
- References: <201011121837.57149.ken@linux.vnet.ibm.com>
On Fri, 12 Nov 2010, Ken Werner wrote:
> Hi,
>
> This patch enhances the ARM version of bits/atomic.h to make use of the atomic
> builtins provided by GCC in case the backend provides a pattern to do this
> efficiently. Ok to apply?
How exactly did you test this patch?
> +#ifdef GNUC_PREREQ (4, 4)
This is not valid syntax. The compiler should have warned. It looks like
you mean #if not #ifdef and __GNUC_PREREQ not GNUC_PREREQ.
> +/* Use the atomic builtins provided by GCC version 4.4 and later. */
> +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
> + __sync_val_compare_and_swap ((mem), (oldval), (newval))
> +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
> + __sync_val_compare_and_swap ((mem), (oldval), (newval))
> +#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
> + __sync_val_compare_and_swap ((mem), (oldval), (newval))
> +#else
> #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
> ({ __arm_link_error (); oldval; })
> -
> #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
> ({ __arm_link_error (); oldval; })
> +#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
> + ({ __arm_link_error (); oldval; })
> +#endif
In any case, the fact that the code worked before shows that these macros
are not used and so this part of the change serves no purpose. If it were
useful, conditioning on __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* would probably
be better than a version conditional, although that would limit it to the
cases where these operations are inlined.
--
Joseph S. Myers
joseph@codesourcery.com