]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Detect Whether We're Being Compiled with ASAN
authorW. Felix Handte <w@felixhandte.com>
Thu, 12 Sep 2019 22:32:22 +0000 (18:32 -0400)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Oct 2019 17:40:16 +0000 (13:40 -0400)
lib/common/mem.h

index acc7231e968175bafdb090752dbecb451df4baec..983b55edc990cee4091dbc90b4880d6be7ce0f4c 100644 (file)
@@ -74,6 +74,19 @@ void __msan_poison(const volatile void *a, size_t size);
 intptr_t __msan_test_shadow(const volatile void *x, size_t size);
 #endif
 
+/* detects whether we are being compiled under asan */
+#if defined (__has_feature)
+#  if __has_feature(address_sanitizer)
+#    define ADDRESS_SANITIZER 1
+#  endif
+#elif defined(__SANITIZE_ADDRESS__)
+#  define ADDRESS_SANITIZER 1
+#endif
+
+#if defined (ADDRESS_SANITIZER)
+#  include <sanitizer/asan_interface.h>
+#endif
+
 
 /*-**************************************************************
 *  Basic Types