__sync_lock_test_and_set on ARM

Phil Endecott spam_from_gcc_help_2@chezphil.org
Wed Sep 12 17:32:00 GMT 2007

Hi David,

David Daney wrote:
> Phil Endecott wrote:
>> This raises another issue, which is whether there is any way for code to 
>> determine which of the atomic builtins are provided, i.e. I'd like to 
>> write:
>> #if HAS__sync_lock_test_and_set
>> .. locking code using __sync_lock_test_and_set
>> #elseif HAS__sync_something_else
>> .. locking code using builtins that expand to LDREX and STREX
>> #else
>> #warn "no atomic ops, falling back to pthread mutex"
>> ...
>> #endif
> The proper symbol to test would be something like: 
> __GCC_HAVE_SYNC_LOCK_TEST_AND_SET_4  they are automatically set by GCC 
> when the builtin functions are available.

Really?  I don't see anything like that in the output of

gcc -dM -E - < /dev/null|grep -i sync
grep -R HAVE_SYNC /usr/include/

on my x86 system, which does have a selection of atomic builtins.



More information about the Gcc-help mailing list