From: Kenny Yu Date: Mon, 6 Jun 2016 23:20:39 +0000 (-0700) Subject: folly: define FOLLY_SANITIZE_THREAD convenience macro for TSAN X-Git-Tag: 2016.07.26~163 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0c620c8f910f407314ff19f4b44c770fe938fe36;p=folly.git folly: define FOLLY_SANITIZE_THREAD convenience macro for TSAN Summary: This defines the macro `FOLLY_SANITIZE_THREAD`, similar to `FOLLY_SANITIZE_ADDRESS`. Note that gcc *just* landed support for the `__SANITIZE_THREAD__` macro two weeks ago: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64354 Reviewed By: igorsugak Differential Revision: D3389021 fbshipit-source-id: df6497a7741657c297ee812ed07cbae102b6810d --- diff --git a/folly/CPortability.h b/folly/CPortability.h index febf2a14..37d97382 100644 --- a/folly/CPortability.h +++ b/folly/CPortability.h @@ -55,6 +55,15 @@ # define FOLLY_DISABLE_ADDRESS_SANITIZER #endif +/* Define a convenience macro to test when thread sanitizer is being used + * across the different compilers (e.g. clang, gcc) */ +#if defined(__clang__) +# if __has_feature(thread_sanitizer) +# define FOLLY_SANITIZE_THREAD 1 +# endif +#elif defined(__GNUC__) && __SANITIZE_THREAD__ +# define FOLLY_SANITIZE_THREAD 1 +#endif /** * ASAN/MSAN/TSAN define pre-processor symbols: