[glib/wip/smcv/address-sanitizer: 16/20] glib-private: Add infrastructure to detect AddressSanitizer




commit 4c5a6a129d9fdaec15f58c6fb66fecebfd9a919d
Author: Simon McVittie <smcv collabora com>
Date:   Thu Jan 28 21:01:51 2021 +0000

    glib-private: Add infrastructure to detect AddressSanitizer
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 glib/glib-private.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/glib/glib-private.h b/glib/glib-private.h
index 8b7ab132e..c2e7fd401 100644
--- a/glib/glib-private.h
+++ b/glib/glib-private.h
@@ -22,6 +22,19 @@
 #include "gwakeup.h"
 #include "gstdioprivate.h"
 
+/* gcc defines __SANITIZE_ADDRESS__, clang sets the address_sanitizer
+ * feature flag */
+#if defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer)
+
+/*
+ * %_GLIB_ADDRESS_SANITIZER:
+ *
+ * Private macro defined if the AddressSanitizer is in use.
+ */
+#define _GLIB_ADDRESS_SANITIZER
+
+#endif
+
 GMainContext *          g_get_worker_context            (void);
 gboolean                g_check_setuid                  (void);
 GMainContext *          g_main_context_new_with_next_id (guint next_id);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]