fix flaky ConnectTFOTimeout and ConnectTFOFallbackTimeout tests
[folly.git] / folly / CPortability.h
index 6f35319dfc4fc80ae8e0d2881da7783a89fd732c..37d97382e56b5d5d88e3759ce645a5d191c34e93 100644 (file)
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef CPORTABILITY_H
-#define CPORTABILITY_H
+#pragma once
 
 /* These definitions are in a separate file so that they
  * may be included from C- as well as C++-based projects. */
 # 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:
@@ -72,5 +80,3 @@
 #else
 # define UBSAN_DISABLE(x)
 #endif // UNDEFINED_SANITIZER
-
-#endif // CPORTABILITY_H