This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ARM] bits/atomic.h and GCC atomic builtins


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]