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_COMPARE_AND_SWAP_4 or
__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
or
grep -R HAVE_SYNC /usr/include/
on my x86 system, which does have a selection of atomic builtins.
Regards,
Phil.