On Wed, Dec 05, 2012 at 03:13:20PM +0400, Dmitry Vyukov wrote: > I hope I addressed all your comments in this revision. > I've fixed nand atomic operation, made atomic operations atomic again > and added visibility attribute to interface functions.
Mostly, still, __sync_lock_test_and_set isn't full barrier unlike most other __sync_* builtins, so either you'd need to use __atomic_exchange_n if available (you can e.g. guard it with #ifdef __ATOMIC_SEQ_CST), or if not available also use __sync_synchronize (). Also, for the atomic load and store, it would be nice to use __atomic_load_n and __atomic_store_n if available (as fallback __sync_synchronize (), which I believe needs to be before resp. after the memory operation depending on whether it is load or store). And we'll need to tweak libsanitizer makefiles, so it uses -mcx16 on x86_64 64-bit when compiling that tsan_atomic*.cc, either we just ignore for libsanitizer the pre-CX16 AMD CPUs, those were just a few initial models I think, or we'd need to do IFUNC dispatcher, or perhaps just one time cpuid check that would see if it can do 16-byte atomics or not. Jakub