plugin-dev: mark symbols meant to be public with __attribute__((visibility("default")))
[babeltrace.git] / include / babeltrace2 / plugin / plugin-dev.h
index 713725366f9ca9034a0dbb31f4118c84d463357f..3aeb1ebfdb76e730db167267a6f74d039014127a 100644 (file)
 #define _BT_HIDDEN __attribute__((visibility("hidden")))
 #endif
 
+/*
+ * _BT_EXPORT: set the visibility for exported functions.
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define _BT_EXPORT
+#else
+#define _BT_EXPORT __attribute__((visibility("default")))
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -352,35 +361,35 @@ other <code>BT_PLUGIN*()</code> macro.
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
        \
-       struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        }
@@ -1275,7 +1284,7 @@ method.
 @bt_pre_not_null{_method}
 */
 #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID(_plugin_id, _component_class_id, _method) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS, _plugin_id, _component_class_id, source, _method)
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD, _plugin_id, _component_class_id, source, _method)
 
 /*!
 @brief
@@ -1728,7 +1737,7 @@ method.
 @bt_pre_not_null{_method}
 */
 #define BT_PLUGIN_FILTER_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID(_plugin_id, _component_class_id, _method) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS, _plugin_id, _component_class_id, filter, _method)
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD, _plugin_id, _component_class_id, filter, _method)
 
 /*!
 @brief
@@ -2228,7 +2237,7 @@ method.
 @bt_pre_not_null{_method}
 */
 #define BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID(_plugin_id, _component_class_id, _method) \
-       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS, _plugin_id, _component_class_id, sink, _method)
+       __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD, _plugin_id, _component_class_id, sink, _method)
 
 /*!
 @brief
@@ -2660,13 +2669,31 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
        };                                                              \
        static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_component_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_component_class_id##_##_attr_name
 
+/*
+ * 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. This is fine because, as far as we have seen, gcc
+ * does not insert red zones around global variables.
+ */
+#if defined(__clang__)
+# if __has_feature(address_sanitizer)
+#  define __bt_plugin_variable_attribute_no_sanitize_address \
+       __attribute__((no_sanitize("address")))
+# else
+#  define __bt_plugin_variable_attribute_no_sanitize_address
+# endif
+#else
+#  define __bt_plugin_variable_attribute_no_sanitize_address
+#endif
+
 /*
  * Variable attributes for a plugin descriptor pointer to be added to
  * the plugin descriptor section (internal use).
  */
 #ifdef __APPLE__
 #define __BT_PLUGIN_DESCRIPTOR_ATTRS \
-       __attribute__((section("__DATA,btp_desc"), used))
+       __attribute__((section("__DATA,btp_desc"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
        __start___bt_plugin_descriptors
@@ -2683,7 +2710,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
 #else
 
 #define __BT_PLUGIN_DESCRIPTOR_ATTRS \
-       __attribute__((section("__bt_plugin_descriptors"), used))
+       __attribute__((section("__bt_plugin_descriptors"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
        __start___bt_plugin_descriptors
@@ -2702,7 +2730,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
  */
 #ifdef __APPLE__
 #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
-       __attribute__((section("__DATA,btp_desc_att"), used))
+       __attribute__((section("__DATA,btp_desc_att"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
        __start___bt_plugin_descriptor_attributes
@@ -2719,7 +2748,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
 #else
 
 #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
-       __attribute__((section("__bt_plugin_descriptor_attributes"), used))
+       __attribute__((section("__bt_plugin_descriptor_attributes"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
        __start___bt_plugin_descriptor_attributes
@@ -2738,7 +2768,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
  */
 #ifdef __APPLE__
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
-       __attribute__((section("__DATA,btp_cc_desc"), used))
+       __attribute__((section("__DATA,btp_cc_desc"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
        __start___bt_plugin_component_class_descriptors
@@ -2755,7 +2786,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
 #else
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
-       __attribute__((section("__bt_plugin_component_class_descriptors"), used))
+       __attribute__((section("__bt_plugin_component_class_descriptors"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
        __start___bt_plugin_component_class_descriptors
@@ -2775,7 +2807,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
  */
 #ifdef __APPLE__
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
-       __attribute__((section("__DATA,btp_cc_desc_att"), used))
+       __attribute__((section("__DATA,btp_cc_desc_att"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
        __start___bt_plugin_component_class_descriptor_attributes
@@ -2792,7 +2825,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
 #else
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
-       __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used))
+       __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used)) \
+       __bt_plugin_variable_attribute_no_sanitize_address
 
 #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
        __start___bt_plugin_component_class_descriptor_attributes
This page took 0.026761 seconds and 4 git commands to generate.