From 2bd8a567becb9934d52fe95aa8a722322ab660f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 21 May 2015 14:09:38 -0400 Subject: [PATCH] build fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- Makefile.am | 2 +- include/babeltrace/plugin/plugin-internal.h | 6 ++- include/babeltrace/plugin/plugin-system.h | 46 +++++++++++++++------ include/babeltrace/plugin/plugin.h | 4 +- include/babeltrace/plugin/source.h | 9 ---- plugins/Makefile.am | 4 +- plugins/plugin.c | 20 +++++---- 7 files changed, 57 insertions(+), 34 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1709f957..2cd22a5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include types compat lib formats converter bindings tests doc extras +SUBDIRS = include types compat lib formats converter bindings tests doc extras plugins dist_doc_DATA = ChangeLog LICENSE mit-license.txt gpl-2.0.txt \ std-ext-lib.txt README diff --git a/include/babeltrace/plugin/plugin-internal.h b/include/babeltrace/plugin/plugin-internal.h index 2214dc96..a0ed98d9 100644 --- a/include/babeltrace/plugin/plugin-internal.h +++ b/include/babeltrace/plugin/plugin-internal.h @@ -28,6 +28,8 @@ */ #include +#include +#include #include #include @@ -51,9 +53,9 @@ struct bt_plugin { BT_HIDDEN enum bt_plugin_status bt_plugin_init(struct bt_plugin *plugin, const char *name, - void *user_data,bt_plugin_destroy_func destroy_func, + void *user_data,bt_plugin_destroy_cb destroy_func, enum bt_plugin_type plugin_type, - bt_plugin_destroy_func plugin_destroy); + bt_plugin_destroy_cb plugin_destroy); #ifdef __cplusplus } diff --git a/include/babeltrace/plugin/plugin-system.h b/include/babeltrace/plugin/plugin-system.h index b8aa4a3b..fea024fd 100644 --- a/include/babeltrace/plugin/plugin-system.h +++ b/include/babeltrace/plugin/plugin-system.h @@ -31,11 +31,14 @@ */ #include +#include #ifdef __cplusplus extern "C" { #endif +struct bt_notification; + /** * Plug-in private data deallocation function type. * @@ -43,6 +46,33 @@ extern "C" { */ typedef void (*bt_plugin_destroy_cb)(struct bt_plugin *plugin); +/** + * Iterator creation function type. + * + * @param plugin Plug-in instance + */ +typedef struct bt_notification_iterator *( + *bt_plugin_source_iterator_create_cb)( + struct bt_plugin *plugin); + +/** + * Notification handling function type. + * + * @param plugin Plug-in instance + * @param notificattion Notification to handle + */ +typedef int (*bt_plugin_sink_handle_notification_cb)(struct bt_plugin *, + struct bt_notification *); + +typedef struct bt_notification *(bt_notification_iterator_get_notification_cb)( + struct bt_notification_iterator *); + +typedef struct bt_notification *(bt_notification_iterator_get_notification_cb)( + struct bt_notification_iterator *); + +typedef enum bt_notification_iterator_status (bt_notification_iterator_next_cb)( + struct bt_notification_iterator *); + /** * Get a plug-in's private (implementation) data. * @@ -51,7 +81,7 @@ typedef void (*bt_plugin_destroy_cb)(struct bt_plugin *plugin); */ extern void *bt_plugin_get_private_data(struct bt_plugin *plugin); - + /** Plug-in initialization functions */ /** * Allocate a source plug-in. @@ -63,7 +93,7 @@ extern void *bt_plugin_get_private_data(struct bt_plugin *plugin); * @returns A source plug-in instance */ extern struct bt_plugin *bt_plugin_source_create(const char *name, - void *private_data, bt_plugin_destroy_func destroy_func, + void *private_data, bt_plugin_destroy_cb destroy_func, bt_plugin_source_iterator_create_cb iterator_create_cb); /** @@ -76,7 +106,7 @@ extern struct bt_plugin *bt_plugin_source_create(const char *name, * @returns A sink plug-in instance */ extern struct bt_plugin *bt_plugin_sink_create(const char *name, - void *private_data, bt_plugin_destroy_func destroy_func, + void *private_data, bt_plugin_destroy_cb destroy_func, bt_plugin_sink_handle_notification_cb notification_cb); @@ -94,16 +124,6 @@ extern struct bt_notification_iterator *bt_notification_iterator_create( bt_notification_iterator_next_cb next_cb, bt_notification_iterator_get_notification_cb notification_cb); -/** - * Set an iterator's private data. - * - * @param plugin Plug-in instance on which to iterate - * @param data Iterator private data - * @returns One of #bt_notification_iterator_status values - */ -extern enum bt_notification_iterator_status *bt_notification_iterator_create( - struct bt_plugin *plugin, void *data); - #ifdef __cplusplus } #endif diff --git a/include/babeltrace/plugin/plugin.h b/include/babeltrace/plugin/plugin.h index bf9aaed1..77204d9d 100644 --- a/include/babeltrace/plugin/plugin.h +++ b/include/babeltrace/plugin/plugin.h @@ -69,7 +69,9 @@ enum bt_plugin_status { /** No error, okay. */ BT_PLUGIN_STATUS_OK = 0, -} +}; + +struct bt_plugin; /** * Get plug-in instance name. diff --git a/include/babeltrace/plugin/source.h b/include/babeltrace/plugin/source.h index 0e96529b..a333e392 100644 --- a/include/babeltrace/plugin/source.h +++ b/include/babeltrace/plugin/source.h @@ -36,15 +36,6 @@ extern "C" { struct bt_plugin; struct bt_notification_iterator; -/** - * Iterator creation function type. - * - * @param plugin Plug-in instance - */ -typedef struct bt_notification_iterator *( - *bt_plugin_source_iterator_create_func)( - struct bt_plugin *plugin); - /** * Create an iterator on a plug-in instance. * diff --git a/plugins/Makefile.am b/plugins/Makefile.am index d6523a74..55c866c8 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -4,13 +4,15 @@ SUBDIRS = . lib_LTLIBRARIES = libbabeltrace-plugin.la +# Plug-in system library libbabeltrace_plugin_la_SOURCES = \ plugin.c \ + filter.c \ source.c \ sink.c \ iterator.c -# Request that the linker keeps all static libraries objects. +# Request that the linker keeps all static librarie objects. libbabeltrace_plugin_la_LDFLAGS = \ -Wl,--no-as-needed -version-info $(BABELTRACE_LIBRARY_VERSION) diff --git a/plugins/plugin.c b/plugins/plugin.c index 8714d689..15f55a7f 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -26,6 +26,12 @@ * SOFTWARE. */ +#include +#include +#include + +static void bt_plugin_destroy(struct bt_ctf_ref *ref); + const char *bt_plugin_get_name(struct bt_plugin *plugin) { const char *ret = NULL; @@ -102,14 +108,14 @@ void bt_plugin_put(struct bt_plugin *plugin) BT_HIDDEN enum bt_plugin_status bt_plugin_init(struct bt_plugin *plugin, const char *name, - void *user_data, bt_plugin_destroy_func user_destroy_func, + void *user_data, bt_plugin_destroy_cb user_destroy_func, enum bt_plugin_type plugin_type, - bt_plugin_destroy_func plugin_destroy) + bt_plugin_destroy_cb plugin_destroy) { enum bt_plugin_status ret = BT_PLUGIN_STATUS_OK; if (!plugin || !name || name[0] == '\0' || - !destroy_func || !private_data) { + !user_destroy_func || !user_data || !plugin_destroy) { ret = BT_PLUGIN_STATUS_INVAL; goto end; } @@ -132,20 +138,20 @@ end: static void bt_plugin_destroy(struct bt_ctf_ref *ref) { - struct bt_ctf_plugin *plugin = NULL; + struct bt_plugin *plugin = NULL; if (!ref) { return; } - plugin = container_of(ref, struct bt_plugin, parent); + plugin = container_of(ref, struct bt_plugin, ref_count); /** * Destroy user data, base and source/filter/sink last since * it will deallocate the plugin. */ - assert(plugin->user_destroy_func); - plugin->user_destroy_func(plugin->user_data); + assert(plugin->user_data_destroy); + plugin->user_data_destroy(plugin->user_data); g_string_free(plugin->name, TRUE); -- 2.34.1