vppinfra: refactor address sanitizer
Type: refactor
Change-Id: I5ca142ec1557d5b5c3806b43553ad9d3b5ea1112
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index 8d16749..2db611d 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -95,6 +95,15 @@
/* Make a string from the macro's argument */
#define CLIB_STRING_MACRO(x) #x
+/* sanitizers */
+#ifdef __has_feature
+#if __has_feature(address_sanitizer)
+#define CLIB_SANITIZE_ADDR 1
+#endif
+#elif defined(__SANITIZE_ADDRESS__)
+#define CLIB_SANITIZE_ADDR 1
+#endif
+
#define __clib_unused __attribute__ ((unused))
#define __clib_weak __attribute__ ((weak))
#define __clib_packed __attribute__ ((packed))
@@ -117,6 +126,12 @@
__attribute__ ((optimize ("no-optimize-sibling-calls")))
#endif
+#ifdef CLIB_SANITIZE_ADDR
+#define __clib_nosanitize_addr __attribute__ ((no_sanitize_address))
+#else
+#define __clib_nosanitize_addr
+#endif
+
#define never_inline __attribute__ ((__noinline__))
#if CLIB_DEBUG > 0