diff --git a/lib/portaudio/pa_memorybarrier.h b/lib/portaudio/pa_memorybarrier.h index 6f07b603e97..c37298af394 100644 --- a/lib/portaudio/pa_memorybarrier.h +++ b/lib/portaudio/pa_memorybarrier.h @@ -60,7 +60,13 @@ * ****************/ -#if defined(__APPLE__) +#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include() +# include +# warning Building under Thread Sanitizer! +# define PaUtil_FullMemoryBarrier() __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst) +# define PaUtil_ReadMemoryBarrier() __tsan_atomic_thread_fence(__tsan_memory_order_acquire) +# define PaUtil_WriteMemoryBarrier() __tsan_atomic_thread_fence(__tsan_memory_order_release) +#elif defined(__APPLE__) /* Support for the atomic library was added in C11. */ # if (__STDC_VERSION__ < 201112L) || defined(__STDC_NO_ATOMICS__)