+#if 3 <= __GNUC__
+# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define ATTRIBUTE_MALLOC
+#endif
+
+#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+#else
+# define ATTRIBUTE_ALLOC_SIZE(args)
+#endif
+
+#define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
+
+/* Work around GCC bug 59600: when a function is inlined, the inlined
+ code may have its addresses sanitized even if the function has the
+ no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
+ clang 3.4. */
+#if (! ADDRESS_SANITIZER \
+ || ((4 < __GNUC__ + (9 <= __GNUC_MINOR__)) \
+ || 3 < __clang_major__ + (4 <= __clang_minor__)))
+# define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
+#else
+# define ADDRESS_SANITIZER_WORKAROUND NO_INLINE
+#endif
+
+/* Attribute of functions whose code should not have addresses
+ sanitized. */
+
+#if (__has_attribute (no_sanitize_address) \
+ || 4 < __GNUC__ + (8 <= __GNUC_MINOR__))
+# define ATTRIBUTE_NO_SANITIZE_ADDRESS \
+ __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND
+#elif __has_attribute (no_address_safety_analysis)
+# define ATTRIBUTE_NO_SANITIZE_ADDRESS \
+ __attribute__ ((no_address_safety_analysis)) ADDRESS_SANITIZER_WORKAROUND
+#else
+# define ATTRIBUTE_NO_SANITIZE_ADDRESS
+#endif
+