summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-03-31 07:38:43 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-03-31 07:38:43 +0300
commit2c8ba251866ed12fa17fb51abfca063e2f6f717d (patch)
treeca22160560e451e92891b05db94b4fccb2246c72
parent92435d45beeaab3ea269190c0f6c5d77e6f1d710 (diff)
downloadlibatomic_ops-2c8ba251866ed12fa17fb51abfca063e2f6f717d.tar.gz
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.
-rw-r--r--src/atomic_ops/sysdeps/gcc/generic.h6
1 files changed, 5 insertions, 1 deletions
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"