From 0a87ff8fbde10f75c8c09f0e209ea9d1da037d2d Mon Sep 17 00:00:00 2001 From: synqa Date: Sun, 8 Feb 2026 23:08:13 +0900 Subject: [PATCH] Add macro to disable thread sanitizer Define ATTRIBUTE_NO_TSAN as __attribute__((no_sanitize(\"thread\"))) when building with thread sanitizer enabled. Falls back to empty definition when thread sanitizer is not active or not supported compiler. --- src/Mayaqua/Mayaqua.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Mayaqua/Mayaqua.h b/src/Mayaqua/Mayaqua.h index 15a38af4..75a9df38 100644 --- a/src/Mayaqua/Mayaqua.h +++ b/src/Mayaqua/Mayaqua.h @@ -72,11 +72,26 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow) // Compiler dependent #ifndef OS_WIN32 -// Gcc compiler +// GCC or Clang compiler #define GCC_PACKED __attribute__ ((__packed__)) +// Clang compiler +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) +#define ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread"))) +#endif // __has_feature(thread_sanitizer) +#endif // __has_feature +// GCC compiler +#if defined(__SANITIZE_THREAD__) && !defined(ATTRIBUTE_NO_TSAN) +#define ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread"))) +#endif // __SANITIZE_THREAD__ +// Other or older Clang/GCC compiler +#ifndef ATTRIBUTE_NO_TSAN +#define ATTRIBUTE_NO_TSAN +#endif // ATTRIBUTE_NO_TSAN #else // OS_WIN32 // VC++ compiler #define GCC_PACKED +#define ATTRIBUTE_NO_TSAN #endif // OS_WIN32 // Macro that displays the current file name and line number