More careful sanitizer detection (#764)

diff --git a/c/common/platform.h b/c/common/platform.h
index bf5f97b..b6d634e 100755
--- a/c/common/platform.h
+++ b/c/common/platform.h
@@ -308,8 +308,7 @@
 }
 #else  /* BROTLI_ALIGNED_READ */
 /* Unaligned memory access is allowed: just cast pointer to requested type. */
-#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \
-    defined(MEMORY_SANITIZER)
+#if BROTLI_SANITIZED
 /* Consider we have an unaligned load/store of 4 bytes from address 0x...05.
    AddressSanitizer will treat it as a 3-byte access to the range 05:07 and
    will miss a bug if 08 is the first unaddressable byte.
@@ -334,7 +333,7 @@
 #define BrotliUnalignedRead32 __sanitizer_unaligned_load32
 #define BrotliUnalignedRead64 __sanitizer_unaligned_load64
 #define BrotliUnalignedWrite64 __sanitizer_unaligned_store64
-#else
+#else  /* BROTLI_SANITIZED */
 static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
   return *(const uint16_t*)p;
 }
@@ -374,7 +373,7 @@
 }
 #endif  /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
 #endif  /* BROTLI_64_BITS */
-#endif  /* ASAN / TSAN / MSAN */
+#endif  /* BROTLI_SANITIZED */
 #endif  /* BROTLI_ALIGNED_READ */
 
 #if BROTLI_LITTLE_ENDIAN
diff --git a/c/include/brotli/port.h b/c/include/brotli/port.h
index 20dc231..825237a 100644
--- a/c/include/brotli/port.h
+++ b/c/include/brotli/port.h
@@ -218,6 +218,20 @@
   BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
 #endif
 
+#if defined(__has_feature)
+#define BROTLI_HAS_FEATURE(feature) __has_feature(feature)
+#else
+#define BROTLI_HAS_FEATURE(feature) (0)
+#endif
+
+#if defined(ADDRESS_SANITIZER) || BROTLI_HAS_FEATURE(address_sanitizer) || \
+    defined(THREAD_SANITIZER) || BROTLI_HAS_FEATURE(thread_sanitizer) ||   \
+    defined(MEMORY_SANITIZER) || BROTLI_HAS_FEATURE(memory_sanitizer)
+#define BROTLI_SANITIZED 1
+#else
+#define BROTLI_SANITIZED 0
+#endif
+
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define BROTLI_PUBLIC
 #elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \