lib: private functions: do not repeat `private` word
[babeltrace.git] / lib / plugin / plugin-so.c
index 44aa967ed603b18820456e263468004178c319c1..c0fb97b599ca0c9842e5c2b3b37d2afca8edc7a2 100644 (file)
@@ -31,7 +31,7 @@
 #include <babeltrace/lib-logging-internal.h>
 
 #include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/plugin/plugin-so-internal.h>
 #include <babeltrace/plugin/plugin-dev.h>
@@ -39,6 +39,7 @@
 #include <babeltrace/graph/component-class-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/list-internal.h>
+#include <babeltrace/assert-internal.h>
 #include <string.h>
 #include <stdlib.h>
 #include <glib.h>
 #define PLUGIN_SUFFIX_LEN      max_t(size_t, sizeof(NATIVE_PLUGIN_SUFFIX), \
                                        sizeof(LIBTOOL_PLUGIN_SUFFIX))
 
-#define SECTION_BEGIN(_name)           (&(__start_##_name))
-#define SECTION_END(_name)             (&(__stop_##_name))
-#define SECTION_ELEMENT_COUNT(_name) (SECTION_END(_name) - SECTION_BEGIN(_name))
-
-#define DECLARE_SECTION(_type, _name)                          \
-       extern _type __start_##_name __attribute((weak));       \
-       extern _type __stop_##_name __attribute((weak))
-
-DECLARE_SECTION(struct __bt_plugin_descriptor const *, __bt_plugin_descriptors);
-DECLARE_SECTION(struct __bt_plugin_descriptor_attribute const *, __bt_plugin_descriptor_attributes);
-DECLARE_SECTION(struct __bt_plugin_component_class_descriptor const *, __bt_plugin_component_class_descriptors);
-DECLARE_SECTION(struct __bt_plugin_component_class_descriptor_attribute const *, __bt_plugin_component_class_descriptor_attributes);
+BT_PLUGIN_MODULE();
 
 /*
  * This list, global to the library, keeps all component classes that
@@ -106,7 +96,7 @@ void fini_comp_class_list(void)
 
        bt_list_for_each_entry_safe(comp_class, tmp, &component_class_list, node) {
                bt_list_del(&comp_class->node);
-               BT_PUT(comp_class->so_handle);
+               BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
        }
        BT_LOGD_STR("Released references from all component classes to shared library handles.");
 }
@@ -116,7 +106,7 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
 {
        struct bt_plugin_so_shared_lib_handle *shared_lib_handle;
 
-       assert(obj);
+       BT_ASSERT(obj);
        shared_lib_handle = container_of(obj,
                struct bt_plugin_so_shared_lib_handle, base);
        const char *path = shared_lib_handle->path ?
@@ -185,7 +175,8 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
                goto error;
        }
 
-       bt_object_init(shared_lib_handle, bt_plugin_so_shared_lib_handle_destroy);
+       bt_object_init_shared(&shared_lib_handle->base,
+               bt_plugin_so_shared_lib_handle_destroy);
 
        if (!path) {
                goto end;
@@ -197,7 +188,7 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
                goto error;
        }
 
-       shared_lib_handle->module = g_module_open(path, 0);
+       shared_lib_handle->module = g_module_open(path, G_MODULE_BIND_LOCAL);
        if (!shared_lib_handle->module) {
                /*
                 * DEBUG-level logging because we're only _trying_ to
@@ -214,7 +205,7 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
        goto end;
 
 error:
-       BT_PUT(shared_lib_handle);
+       BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
 
 end:
        if (shared_lib_handle) {
@@ -234,9 +225,9 @@ void bt_plugin_so_destroy_spec_data(struct bt_plugin *plugin)
                return;
        }
 
-       assert(plugin->type == BT_PLUGIN_TYPE_SO);
-       assert(spec);
-       BT_PUT(spec->shared_lib_handle);
+       BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
+       BT_ASSERT(spec);
+       BT_OBJECT_PUT_REF_AND_RESET(spec->shared_lib_handle);
        g_free(plugin->spec_data);
        plugin->spec_data = NULL;
 }
@@ -293,7 +284,7 @@ enum bt_plugin_status bt_plugin_so_init(
                bt_component_class_accept_port_connection_method accept_port_connection_method;
                bt_component_class_port_connected_method port_connected_method;
                bt_component_class_port_disconnected_method port_disconnected_method;
-               struct bt_component_class_iterator_methods iterator_methods;
+               struct bt_component_class_notification_iterator_methods iterator_methods;
        };
 
        enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
@@ -336,6 +327,10 @@ enum bt_plugin_status bt_plugin_so_init(
                const struct __bt_plugin_descriptor_attribute *cur_attr =
                        *cur_attr_ptr;
 
+               if (cur_attr == NULL) {
+                       continue;
+               }
+
                if (cur_attr->plugin_descriptor != descriptor) {
                        continue;
                }
@@ -393,6 +388,10 @@ enum bt_plugin_status bt_plugin_so_init(
                        *cur_cc_descr_ptr;
                struct comp_class_full_descriptor full_descriptor = {0};
 
+               if (cur_cc_descr == NULL) {
+                       continue;
+               }
+
                if (cur_cc_descr->plugin_descriptor != descriptor) {
                        continue;
                }
@@ -411,6 +410,10 @@ enum bt_plugin_status bt_plugin_so_init(
                const struct __bt_plugin_component_class_descriptor_attribute *cur_cc_descr_attr =
                        *cur_cc_descr_attr_ptr;
 
+               if (cur_cc_descr_attr == NULL) {
+                       continue;
+               }
+
                if (cur_cc_descr_attr->comp_class_descriptor->plugin_descriptor !=
                                descriptor) {
                        continue;
@@ -465,10 +468,6 @@ enum bt_plugin_status bt_plugin_so_init(
                                        cc_full_descr->iterator_methods.finalize =
                                                cur_cc_descr_attr->value.notif_iter_finalize_method;
                                        break;
-                               case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_SEEK_TIME_METHOD:
-                                       cc_full_descr->iterator_methods.seek_time =
-                                               cur_cc_descr_attr->value.notif_iter_seek_time_method;
-                                       break;
                                default:
                                        /*
                                         * WARN-level logging because
@@ -582,7 +581,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's description.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -593,7 +592,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's help string.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -604,7 +603,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's initialization method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -615,7 +614,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's finalization method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -626,7 +625,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's query method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -637,7 +636,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's \"accept port connection\" method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -648,7 +647,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's \"port connected\" method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -659,7 +658,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        if (ret) {
                                BT_LOGE_STR("Cannot set component class's \"port disconnected\" method.");
                                status = BT_PLUGIN_STATUS_ERROR;
-                               BT_PUT(comp_class);
+                               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
                }
@@ -673,7 +672,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                if (ret) {
                                        BT_LOGE_STR("Cannot set component class's notification iterator initialization method.");
                                        status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
+                                       BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                        goto end;
                                }
                        }
@@ -685,19 +684,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                if (ret) {
                                        BT_LOGE_STR("Cannot set source component class's notification iterator finalization method.");
                                        status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->iterator_methods.seek_time) {
-                               ret = bt_component_class_source_set_notification_iterator_seek_time_method(
-                                       comp_class,
-                                       cc_full_descr->iterator_methods.seek_time);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's notification iterator seek to time method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
+                                       BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                        goto end;
                                }
                        }
@@ -710,7 +697,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                if (ret) {
                                        BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method.");
                                        status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
+                                       BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                        goto end;
                                }
                        }
@@ -722,19 +709,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                if (ret) {
                                        BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method.");
                                        status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->iterator_methods.seek_time) {
-                               ret = bt_component_class_filter_set_notification_iterator_seek_time_method(
-                                       comp_class,
-                                       cc_full_descr->iterator_methods.seek_time);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's notification iterator seek to time method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_PUT(comp_class);
+                                       BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                        goto end;
                                }
                        }
@@ -755,7 +730,7 @@ enum bt_plugin_status bt_plugin_so_init(
                 */
                status = bt_plugin_add_component_class(plugin,
                        comp_class);
-               BT_PUT(comp_class);
+               BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                if (status < 0) {
                        BT_LOGE("Cannot add component class to plugin.");
                        goto end;
@@ -795,16 +770,33 @@ struct bt_plugin *bt_plugin_so_create_empty(
        }
 
        spec = plugin->spec_data;
-       spec->shared_lib_handle = bt_get(shared_lib_handle);
+       spec->shared_lib_handle = bt_object_get_ref(shared_lib_handle);
        goto end;
 
 error:
-       BT_PUT(plugin);
+       BT_OBJECT_PUT_REF_AND_RESET(plugin);
 
 end:
        return plugin;
 }
 
+static
+size_t count_non_null_items_in_section(const void *begin, const void *end)
+{
+       size_t count = 0;
+       const int * const *begin_int = (const int * const *) begin;
+       const int * const *end_int = (const int * const *) end;
+       const int * const *iter;
+
+       for (iter = begin_int; iter != end_int; iter++) {
+               if (*iter) {
+                       count++;
+               }
+       }
+
+       return count;
+}
+
 static
 struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
                struct bt_plugin_so_shared_lib_handle *shared_lib_handle,
@@ -824,10 +816,10 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
        size_t i;
        struct bt_plugin_set *plugin_set = NULL;
 
-       descriptor_count = descriptors_end - descriptors_begin;
-       attrs_count = attrs_end - attrs_begin;
-       cc_descriptors_count = cc_descriptors_end - cc_descriptors_begin;
-       cc_descr_attrs_count = cc_descr_attrs_end - cc_descr_attrs_begin;
+       descriptor_count = count_non_null_items_in_section(descriptors_begin, descriptors_end);
+       attrs_count = count_non_null_items_in_section(attrs_begin, attrs_end);
+       cc_descriptors_count = count_non_null_items_in_section(cc_descriptors_begin, cc_descriptors_end);
+       cc_descr_attrs_count =  count_non_null_items_in_section(cc_descr_attrs_begin, cc_descr_attrs_end);
 
        BT_LOGD("Creating all SO plugins from sections: "
                "plugin-path=\"%s\", "
@@ -850,12 +842,16 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
                goto error;
        }
 
-       for (i = 0; i < descriptor_count; i++) {
+       for (i = 0; i < descriptors_end - descriptors_begin; i++) {
                enum bt_plugin_status status;
                const struct __bt_plugin_descriptor *descriptor =
                        descriptors_begin[i];
                struct bt_plugin *plugin;
 
+               if (descriptor == NULL) {
+                       continue;
+               }
+
                BT_LOGD("Creating plugin object for plugin: "
                        "name=\"%s\", abi-major=%d, abi-minor=%d",
                        descriptor->name, descriptor->major, descriptor->minor);
@@ -897,19 +893,19 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
                         * even a warning.
                         */
                        BT_LOGD_STR("Cannot initialize SO plugin object from sections.");
-                       BT_PUT(plugin);
+                       BT_OBJECT_PUT_REF_AND_RESET(plugin);
                        goto error;
                }
 
                /* Add to plugin set */
                bt_plugin_set_add_plugin(plugin_set, plugin);
-               bt_put(plugin);
+               bt_object_put_ref(plugin);
        }
 
        goto end;
 
 error:
-       BT_PUT(plugin_set);
+       BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
 
 end:
        return plugin_set;
@@ -928,17 +924,17 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_static(void)
 
        BT_LOGD_STR("Creating all SO plugins from built-in plugins.");
        plugin_set = bt_plugin_so_create_all_from_sections(shared_lib_handle,
-               SECTION_BEGIN(__bt_plugin_descriptors),
-               SECTION_END(__bt_plugin_descriptors),
-               SECTION_BEGIN(__bt_plugin_descriptor_attributes),
-               SECTION_END(__bt_plugin_descriptor_attributes),
-               SECTION_BEGIN(__bt_plugin_component_class_descriptors),
-               SECTION_END(__bt_plugin_component_class_descriptors),
-               SECTION_BEGIN(__bt_plugin_component_class_descriptor_attributes),
-               SECTION_END(__bt_plugin_component_class_descriptor_attributes));
+               __bt_get_begin_section_plugin_descriptors(),
+               __bt_get_end_section_plugin_descriptors(),
+               __bt_get_begin_section_plugin_descriptor_attributes(),
+               __bt_get_end_section_plugin_descriptor_attributes(),
+               __bt_get_begin_section_component_class_descriptors(),
+               __bt_get_end_section_component_class_descriptors(),
+               __bt_get_begin_section_component_class_descriptor_attributes(),
+               __bt_get_end_section_component_class_descriptor_attributes());
 
 end:
-       BT_PUT(shared_lib_handle);
+       BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
 
        return plugin_set;
 }
@@ -956,6 +952,14 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end = NULL;
+       struct __bt_plugin_descriptor const * const *(*get_begin_section_plugin_descriptors)(void);
+       struct __bt_plugin_descriptor const * const *(*get_end_section_plugin_descriptors)(void);
+       struct __bt_plugin_descriptor_attribute const * const *(*get_begin_section_plugin_descriptor_attributes)(void);
+       struct __bt_plugin_descriptor_attribute const * const *(*get_end_section_plugin_descriptor_attributes)(void);
+       struct __bt_plugin_component_class_descriptor const * const *(*get_begin_section_component_class_descriptors)(void);
+       struct __bt_plugin_component_class_descriptor const * const *(*get_end_section_component_class_descriptors)(void);
+       struct __bt_plugin_component_class_descriptor_attribute const * const *(*get_begin_section_component_class_descriptor_attributes)(void);
+       struct __bt_plugin_component_class_descriptor_attribute const * const *(*get_end_section_component_class_descriptor_attributes)(void);
        bt_bool is_libtool_wrapper = BT_FALSE, is_shared_object = BT_FALSE;
        struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
 
@@ -995,34 +999,42 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                goto end;
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__start___bt_plugin_descriptors",
-                       (gpointer *) &descriptors_begin)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_plugin_descriptors",
+                       (gpointer *) &get_begin_section_plugin_descriptors)) {
+               descriptors_begin = get_begin_section_plugin_descriptors();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__start___bt_plugin_descriptors");
+                       "__bt_get_begin_section_plugin_descriptors");
                goto end;
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__stop___bt_plugin_descriptors",
-                       (gpointer *) &descriptors_end)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_plugin_descriptors",
+                       (gpointer *) &get_end_section_plugin_descriptors)) {
+               descriptors_end = get_end_section_plugin_descriptors();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__stop___bt_plugin_descriptors");
+                       "__bt_get_end_section_plugin_descriptors");
                goto end;
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__start___bt_plugin_descriptor_attributes",
-                       (gpointer *) &attrs_begin)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_plugin_descriptor_attributes",
+                       (gpointer *) &get_begin_section_plugin_descriptor_attributes)) {
+                attrs_begin = get_begin_section_plugin_descriptor_attributes();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__start___bt_plugin_descriptor_attributes");
+                       "__bt_get_begin_section_plugin_descriptor_attributes");
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__stop___bt_plugin_descriptor_attributes",
-                       (gpointer *) &attrs_end)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_plugin_descriptor_attributes",
+                       (gpointer *) &get_end_section_plugin_descriptor_attributes)) {
+               attrs_end = get_end_section_plugin_descriptor_attributes();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__stop___bt_plugin_descriptor_attributes");
+                       "__bt_get_end_section_plugin_descriptor_attributes");
        }
 
        if ((!!attrs_begin - !!attrs_end) != 0) {
@@ -1030,24 +1042,28 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                        "path=\"%s\", symbol-start=\"%s\", "
                        "symbol-end=\"%s\", symbol-start-addr=%p, "
                        "symbol-end-addr=%p",
-                       path, "__start___bt_plugin_descriptor_attributes",
-                       "__stop___bt_plugin_descriptor_attributes",
+                       path, "__bt_get_begin_section_plugin_descriptor_attributes",
+                       "__bt_get_end_section_plugin_descriptor_attributes",
                        attrs_begin, attrs_end);
                goto end;
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__start___bt_plugin_component_class_descriptors",
-                       (gpointer *) &cc_descriptors_begin)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_component_class_descriptors",
+                       (gpointer *) &get_begin_section_component_class_descriptors)) {
+               cc_descriptors_begin = get_begin_section_component_class_descriptors();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__start___bt_plugin_component_class_descriptors");
+                       "__bt_get_begin_section_component_class_descriptors");
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__stop___bt_plugin_component_class_descriptors",
-                       (gpointer *) &cc_descriptors_end)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_component_class_descriptors",
+                       (gpointer *) &get_end_section_component_class_descriptors)) {
+               cc_descriptors_end = get_end_section_component_class_descriptors();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__stop___bt_plugin_component_class_descriptors");
+                       "__bt_get_end_section_component_class_descriptors");
        }
 
        if ((!!cc_descriptors_begin - !!cc_descriptors_end) != 0) {
@@ -1055,24 +1071,28 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                        "path=\"%s\", symbol-start=\"%s\", "
                        "symbol-end=\"%s\", symbol-start-addr=%p, "
                        "symbol-end-addr=%p",
-                       path, "__start___bt_plugin_component_class_descriptors",
-                       "__stop___bt_plugin_component_class_descriptors",
+                       path, "__bt_get_begin_section_component_class_descriptors",
+                       "__bt_get_end_section_component_class_descriptors",
                        cc_descriptors_begin, cc_descriptors_end);
                goto end;
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__start___bt_plugin_component_class_descriptor_attributes",
-                       (gpointer *) &cc_descr_attrs_begin)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_component_class_descriptor_attributes",
+                       (gpointer *) &get_begin_section_component_class_descriptor_attributes)) {
+               cc_descr_attrs_begin = get_begin_section_component_class_descriptor_attributes();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__start___bt_plugin_component_class_descriptor_attributes");
+                       "__bt_get_begin_section_component_class_descriptor_attributes");
        }
 
-       if (!g_module_symbol(shared_lib_handle->module, "__stop___bt_plugin_component_class_descriptor_attributes",
-                       (gpointer *) &cc_descr_attrs_end)) {
+       if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_component_class_descriptor_attributes",
+                       (gpointer *) &get_end_section_component_class_descriptor_attributes)) {
+               cc_descr_attrs_end = get_end_section_component_class_descriptor_attributes();
+       } else {
                BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
-                       "__stop___bt_plugin_component_class_descriptor_attributes");
+                       "__bt_get_end_section_component_class_descriptor_attributes");
        }
 
        if ((!!cc_descr_attrs_begin - !!cc_descr_attrs_end) != 0) {
@@ -1080,8 +1100,8 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                        "path=\"%s\", symbol-start=\"%s\", "
                        "symbol-end=\"%s\", symbol-start-addr=%p, "
                        "symbol-end-addr=%p",
-                       path, "__start___bt_plugin_component_class_descriptor_attributes",
-                       "__stop___bt_plugin_component_class_descriptor_attributes",
+                       path, "__bt_get_begin_section_component_class_descriptor_attributes",
+                       "__bt_get_end_section_component_class_descriptor_attributes",
                        cc_descr_attrs_begin, cc_descr_attrs_end);
                goto end;
        }
@@ -1094,7 +1114,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                cc_descr_attrs_begin, cc_descr_attrs_end);
 
 end:
-       BT_PUT(shared_lib_handle);
+       BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
        return plugin_set;
 }
 
@@ -1103,7 +1123,7 @@ void plugin_comp_class_destroy_listener(struct bt_component_class *comp_class,
                void *data)
 {
        bt_list_del(&comp_class->node);
-       BT_PUT(comp_class->so_handle);
+       BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
        BT_LOGV("Component class destroyed: removed entry from list: "
                "comp-cls-addr=%p", comp_class);
 }
@@ -1114,11 +1134,11 @@ void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
 {
        struct bt_plugin_so_spec_data *spec = plugin->spec_data;
 
-       assert(plugin->spec_data);
-       assert(plugin->type == BT_PLUGIN_TYPE_SO);
+       BT_ASSERT(plugin->spec_data);
+       BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
 
        bt_list_add(&comp_class->node, &component_class_list);
-       comp_class->so_handle = bt_get(spec->shared_lib_handle);
+       comp_class->so_handle = bt_object_get_ref(spec->shared_lib_handle);
 
        /* Add our custom destroy listener */
        bt_component_class_add_destroy_listener(comp_class,
This page took 0.033485 seconds and 4 git commands to generate.