dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
eb8b6e
From c132731b260174f5939099ceb4fccde84710c502 Mon Sep 17 00:00:00 2001
eb8b6e
From: Lennart Poettering <lennart@poettering.net>
eb8b6e
Date: Mon, 3 Dec 2018 17:30:19 +0100
eb8b6e
Subject: [PATCH] macro: define HAS_FEATURE_ADDRESS_SANITIZER also on gcc
eb8b6e
eb8b6e
Let's make differences between compilers more minimal.
eb8b6e
eb8b6e
Related: #2039327
eb8b6e
eb8b6e
(cherry picked from commit 01da36fadd365329cfd9e2c97eb419c63404b25f)
eb8b6e
---
eb8b6e
 src/basic/macro.h | 13 +++++++++++++
eb8b6e
 1 file changed, 13 insertions(+)
eb8b6e
eb8b6e
diff --git a/src/basic/macro.h b/src/basic/macro.h
eb8b6e
index 0fe6a62aa8..e87026882f 100644
eb8b6e
--- a/src/basic/macro.h
eb8b6e
+++ b/src/basic/macro.h
eb8b6e
@@ -55,6 +55,19 @@
eb8b6e
 #  endif
eb8b6e
 #endif
eb8b6e
 
eb8b6e
+#if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
eb8b6e
+#  ifdef __SANITIZE_ADDRESS__
eb8b6e
+#      define HAS_FEATURE_ADDRESS_SANITIZER 1
eb8b6e
+#  elif defined(__has_feature)
eb8b6e
+#    if __has_feature(address_sanitizer)
eb8b6e
+#      define HAS_FEATURE_ADDRESS_SANITIZER 1
eb8b6e
+#    endif
eb8b6e
+#  endif
eb8b6e
+#  if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
eb8b6e
+#    define HAS_FEATURE_ADDRESS_SANITIZER 0
eb8b6e
+#  endif
eb8b6e
+#endif
eb8b6e
+
eb8b6e
 /* Temporarily disable some warnings */
eb8b6e
 #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT                     \
eb8b6e
         _Pragma("GCC diagnostic push");                                 \