- * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Paul Woegerer <paul_woegerer@mentor.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Clang supports the no_sanitize variable attribute on global variables.
+ * GCC only supports the no_sanitize_address function attribute, which is
+ * not what we need.
+ */
+#if defined(__clang__)
+# if __has_feature(address_sanitizer)
+# define __lttng_ust_variable_attribute_no_sanitize_address \
+ __attribute__((no_sanitize("address")))
+# else
+# define __lttng_ust_variable_attribute_no_sanitize_address
+# endif
+#else
+# define __lttng_ust_variable_attribute_no_sanitize_address
+#endif
+
+/*
+ * g++ 4.8 and prior do not support C99 compound literals. Therefore,
+ * force allocating those on the heap with these C++ compilers.
+ */
+#if defined (__cplusplus) && defined (__GNUC__) && \
+ (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 8))
+# ifndef LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP
+# define LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP
+# endif
+#endif
+
+/*
+ * Compound literals with static storage are needed by LTTng.
+ * Compound literals are part of the C99 and C11 standards, but not
+ * part of the C++ standards. However, those are supported by both g++ and
+ * clang. In order to be strictly C++11 compliant, defining
+ * LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP before including this header
+ * allocates those on the heap in C++.