From 2c8ba251866ed12fa17fb51abfca063e2f6f717d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 31 Mar 2023 07:38:43 +0300 Subject: Eliminate 'atomic_thread_fence is unsupported with tsan' gcc-11 warning The workaround is to use __atomic_test_and_set instead of __atomic_thread_fence in case of option -fsanitize=thread is passed to gcc (or clang). The old behavior could be turned on by defining AO_USE_ATOMIC_THREAD_FENCE macro. * src/atomic_ops/sysdeps/gcc/generic.h [!AO_UNIPROCESSOR && AO_THREAD_SANITIZER && !AO_USE_ATOMIC_THREAD_FENCE] (AO_nop_read, AO_nop_write, AO_nop_full): Do not define (using __atomic_thread_fence); add comment. --- src/atomic_ops/sysdeps/gcc/generic.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/atomic_ops/sysdeps/gcc/generic.h b/src/atomic_ops/sysdeps/gcc/generic.h index 0a6d032..032990c 100644 --- a/src/atomic_ops/sysdeps/gcc/generic.h +++ b/src/atomic_ops/sysdeps/gcc/generic.h @@ -58,6 +58,10 @@ } # define AO_HAVE_nop_full +#elif defined(AO_THREAD_SANITIZER) && !defined(AO_USE_ATOMIC_THREAD_FENCE) + /* Workaround a compiler warning (reported by gcc-11, at least) */ + /* that atomic_thread_fence is unsupported with thread sanitizer. */ + #else AO_INLINE void AO_nop_read(void) @@ -82,7 +86,7 @@ __atomic_thread_fence(__ATOMIC_SEQ_CST); } # define AO_HAVE_nop_full -#endif /* !AO_UNIPROCESSOR */ +#endif /* !AO_UNIPROCESSOR && !AO_THREAD_SANITIZER */ #include "generic-small.h" -- cgit v1.2.1