Skip to content

Commit

Permalink
Use __tsan_atomic_thread_fence in lib/portaudio/pa_memorybarrier.h
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Nov 15, 2024
1 parent eb54636 commit 91213b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,7 @@ target_link_libraries(mixxx-lib PUBLIC PortAudio::PortAudio)
add_library(PortAudioRingBuffer STATIC EXCLUDE_FROM_ALL
lib/portaudio/pa_ringbuffer.c
)
target_compile_options(PortAudioRingBuffer PUBLIC -fsanitize=thread)
target_include_directories(mixxx-lib SYSTEM PUBLIC lib/portaudio)
target_link_libraries(mixxx-lib PRIVATE PortAudioRingBuffer)

Expand Down
15 changes: 14 additions & 1 deletion lib/portaudio/pa_memorybarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,20 @@
*
****************/

#if defined(__APPLE__)
// clang can use __has_feature(thread_sanitizer) gcc sets __SANITIZE_THREAD__
#ifdef __has_feature
#if __has_feature(thread_sanitizer)
# define __SANITIZE_THREAD__ 1
#endif
#endif

#if defined(__SANITIZE_THREAD__) && __has_include(<sanitizer/tsan_interface_atomic.h>)
# include <sanitizer/tsan_interface_atomic.h>
# warning Building under Thread Sanitizer!

Check warning on line 72 in lib/portaudio/pa_memorybarrier.h

View workflow job for this annotation

GitHub Actions / clazy

Building under Thread Sanitizer! [-W#warnings]

Check warning on line 72 in lib/portaudio/pa_memorybarrier.h

View workflow job for this annotation

GitHub Actions / clang-tidy

Building under Thread Sanitizer! [-W#warnings]

Check warning on line 72 in lib/portaudio/pa_memorybarrier.h

View workflow job for this annotation

GitHub Actions / macOS 12 x64

Building under Thread Sanitizer! [-W#warnings]

Check warning on line 72 in lib/portaudio/pa_memorybarrier.h

View workflow job for this annotation

GitHub Actions / macOS 12 arm64

Building under Thread Sanitizer! [-W#warnings]
# 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__)
Expand Down

0 comments on commit 91213b4

Please sign in to comment.