aboutsummaryrefslogtreecommitdiff
path: root/c/common/platform.h
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas@google.com>2019-07-22 14:29:51 +0200
committerGitHub <noreply@github.com>2019-07-22 14:29:51 +0200
commitf1124c8524647932a72b17eedf03c6ed5676fc44 (patch)
tree3a9df04bebb0b2871cc1aa7247d8d97c2790ea7c /c/common/platform.h
parentc8b37e8fd1c6cc232d5f3b8fdcfb4ab98c5cf77a (diff)
downloadbrotli-f1124c8524647932a72b17eedf03c6ed5676fc44.tar.gz
More careful sanitizer detection (#764)
Diffstat (limited to 'c/common/platform.h')
-rwxr-xr-xc/common/platform.h7
1 files changed, 3 insertions, 4 deletions
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 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
}
#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 @@ extern "C" {
#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 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
}
#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