From 2054a0d13fbfba65d23d17a1e35c9dd62f28c2ab Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 25 Jul 2019 12:42:00 -0400 Subject: [PATCH] lib: standardize listener ID types with new `bt_listener_id` type Signed-off-by: Philippe Proulx Change-Id: Ief13a1409b8f0038c0f035878fb49cfe6cf10207 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1782 Tested-by: jenkins Reviewed-by: Simon Marchi --- include/babeltrace2/graph/graph.h | 16 +++++----- .../babeltrace2/trace-ir/trace-class-const.h | 4 +-- include/babeltrace2/trace-ir/trace-const.h | 4 +-- include/babeltrace2/types.h | 2 ++ src/bindings/python/bt2/bt2/native_bt.i | 3 +- src/bindings/python/bt2/bt2/native_bt_graph.i | 20 ++++++------ src/bindings/python/bt2/bt2/native_bt_trace.i | 4 +-- .../python/bt2/bt2/native_bt_trace_class.i | 4 +-- src/lib/graph/graph.c | 32 +++++++++---------- src/lib/trace-ir/trace-class.c | 4 +-- src/lib/trace-ir/trace.c | 4 +-- src/plugins/ctf/fs-sink/fs-sink-trace.h | 2 +- .../lttng-utils/debug-info/debug-info.c | 2 +- .../lttng-utils/debug-info/trace-ir-mapping.h | 4 +-- src/plugins/text/details/details.h | 4 +-- 15 files changed, 55 insertions(+), 54 deletions(-) diff --git a/include/babeltrace2/graph/graph.h b/include/babeltrace2/graph/graph.h index 46aebf98..80059295 100644 --- a/include/babeltrace2/graph/graph.h +++ b/include/babeltrace2/graph/graph.h @@ -183,56 +183,56 @@ bt_graph_add_filter_component_input_port_added_listener( bt_graph *graph, bt_graph_filter_component_input_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_sink_component_input_port_added_listener( bt_graph *graph, bt_graph_sink_component_input_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_source_component_output_port_added_listener( bt_graph *graph, bt_graph_source_component_output_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_filter_component_output_port_added_listener( bt_graph *graph, bt_graph_filter_component_output_port_added_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_source_filter_component_ports_connected_listener( bt_graph *graph, bt_graph_source_filter_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_filter_filter_component_ports_connected_listener( bt_graph *graph, bt_graph_filter_filter_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_source_sink_component_ports_connected_listener( bt_graph *graph, bt_graph_source_sink_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); extern bt_graph_add_listener_status bt_graph_add_filter_sink_component_ports_connected_listener( bt_graph *graph, bt_graph_filter_sink_component_ports_connected_listener_func listener, bt_graph_listener_removed_func listener_removed, void *data, - int *listener_id); + bt_listener_id *listener_id); typedef enum bt_graph_add_interrupter_status { BT_GRAPH_ADD_INTERRUPTER_STATUS_OK = __BT_FUNC_STATUS_OK, diff --git a/include/babeltrace2/trace-ir/trace-class-const.h b/include/babeltrace2/trace-ir/trace-class-const.h index b3b97b1f..023ce650 100644 --- a/include/babeltrace2/trace-ir/trace-class-const.h +++ b/include/babeltrace2/trace-ir/trace-class-const.h @@ -60,7 +60,7 @@ extern bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener( const bt_trace_class *trace_class, bt_trace_class_destruction_listener_func listener, - void *data, uint64_t *listener_id); + void *data, bt_listener_id *listener_id); typedef enum bt_trace_class_remove_listener_status { BT_TRACE_CLASS_REMOVE_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, @@ -69,7 +69,7 @@ typedef enum bt_trace_class_remove_listener_status { extern bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_listener( - const bt_trace_class *trace_class, uint64_t listener_id); + const bt_trace_class *trace_class, bt_listener_id listener_id); extern void bt_trace_class_get_ref(const bt_trace_class *trace_class); diff --git a/include/babeltrace2/trace-ir/trace-const.h b/include/babeltrace2/trace-ir/trace-const.h index b55a5395..f437aec0 100644 --- a/include/babeltrace2/trace-ir/trace-const.h +++ b/include/babeltrace2/trace-ir/trace-const.h @@ -70,7 +70,7 @@ typedef enum bt_trace_add_listener_status { extern bt_trace_add_listener_status bt_trace_add_destruction_listener( const bt_trace *trace, bt_trace_destruction_listener_func listener, - void *data, uint64_t *listener_id); + void *data, bt_listener_id *listener_id); typedef enum bt_trace_remove_listener_status { BT_TRACE_REMOVE_LISTENER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, @@ -78,7 +78,7 @@ typedef enum bt_trace_remove_listener_status { } bt_trace_remove_listener_status; extern bt_trace_remove_listener_status bt_trace_remove_destruction_listener( - const bt_trace *trace, uint64_t listener_id); + const bt_trace *trace, bt_listener_id listener_id); extern void bt_trace_get_ref(const bt_trace *trace); diff --git a/include/babeltrace2/types.h b/include/babeltrace2/types.h index 5b49f50c..7f40fd8c 100644 --- a/include/babeltrace2/types.h +++ b/include/babeltrace2/types.h @@ -78,6 +78,8 @@ if (ret) { */ typedef int bt_bool; +typedef uint64_t bt_listener_id; + typedef const uint8_t *bt_uuid; typedef struct bt_clock_class bt_clock_class; diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i index 7b032b17..4f349f5c 100644 --- a/src/bindings/python/bt2/bt2/native_bt.i +++ b/src/bindings/python/bt2/bt2/native_bt.i @@ -48,11 +48,10 @@ #include "common/assert.h" #include "py-common/py-common.h" - -typedef const uint8_t *bt_uuid; %} typedef int bt_bool; +typedef uint64_t bt_listener_id; /* For uint*_t/int*_t */ %include "stdint.i" diff --git a/src/bindings/python/bt2/bt2/native_bt_graph.i b/src/bindings/python/bt2/bt2/native_bt_graph.i index c592452d..b2e37ff2 100644 --- a/src/bindings/python/bt2/bt2/native_bt_graph.i +++ b/src/bindings/python/bt2/bt2/native_bt_graph.i @@ -207,7 +207,7 @@ PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, { PyObject *py_listener_ids = NULL; PyObject *py_listener_id = NULL; - int listener_id; + bt_listener_id listener_id; bt_graph_add_listener_status status; const char * const module_name = "graph_add_port_added_listener() (Python)"; @@ -238,7 +238,7 @@ PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -260,7 +260,7 @@ PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -282,7 +282,7 @@ PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -304,7 +304,7 @@ PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -474,7 +474,7 @@ PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, { PyObject *py_listener_ids = NULL; PyObject *py_listener_id = NULL; - int listener_id; + bt_listener_id listener_id; bt_graph_add_listener_status status; const char * const module_name = "graph_add_ports_connected_listener() (Python)"; @@ -503,7 +503,7 @@ PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -525,7 +525,7 @@ PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -547,7 +547,7 @@ PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); @@ -569,7 +569,7 @@ PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, goto error; } - py_listener_id = PyLong_FromLong(listener_id); + py_listener_id = PyLong_FromUnsignedLongLong(listener_id); if (!py_listener_id) { BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(module_name, "Failed to allocate one PyLong."); diff --git a/src/bindings/python/bt2/bt2/native_bt_trace.i b/src/bindings/python/bt2/bt2/native_bt_trace.i index 34530299..e220dfa7 100644 --- a/src/bindings/python/bt2/bt2/native_bt_trace.i +++ b/src/bindings/python/bt2/bt2/native_bt_trace.i @@ -51,7 +51,7 @@ trace_destroyed_listener(const bt_trace *trace, void *py_callable) } int bt_bt2_trace_add_destruction_listener(bt_trace *trace, - PyObject *py_callable, uint64_t *id) + PyObject *py_callable, bt_listener_id *id) { bt_trace_add_listener_status status; @@ -68,4 +68,4 @@ int bt_bt2_trace_add_destruction_listener(bt_trace *trace, %} int bt_bt2_trace_add_destruction_listener(bt_trace *trace, - PyObject *py_callable, uint64_t *id); + PyObject *py_callable, bt_listener_id *id); diff --git a/src/bindings/python/bt2/bt2/native_bt_trace_class.i b/src/bindings/python/bt2/bt2/native_bt_trace_class.i index fe17de7b..540497e7 100644 --- a/src/bindings/python/bt2/bt2/native_bt_trace_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_trace_class.i @@ -53,7 +53,7 @@ trace_class_destroyed_listener(const bt_trace_class *trace_class, void *py_calla int bt_bt2_trace_class_add_destruction_listener( bt_trace_class *trace_class, PyObject *py_callable, - uint64_t *id) + bt_listener_id *id) { bt_trace_class_add_listener_status status; @@ -71,4 +71,4 @@ int bt_bt2_trace_class_add_destruction_listener( int bt_bt2_trace_class_add_destruction_listener( bt_trace_class *trace_class, PyObject *py_callable, - uint64_t *id); + bt_listener_id *id); diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 192ec9e5..e4aed1f2 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -791,7 +791,7 @@ bt_graph_add_source_component_output_port_added_listener( struct bt_graph *graph, bt_graph_source_component_output_port_added_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_port_added listener = { .base = { @@ -800,7 +800,7 @@ bt_graph_add_source_component_output_port_added_listener( }, .func = (port_added_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -826,7 +826,7 @@ bt_graph_add_filter_component_output_port_added_listener( struct bt_graph *graph, bt_graph_filter_component_output_port_added_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_port_added listener = { .base = { @@ -835,7 +835,7 @@ bt_graph_add_filter_component_output_port_added_listener( }, .func = (port_added_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -861,7 +861,7 @@ bt_graph_add_filter_component_input_port_added_listener( struct bt_graph *graph, bt_graph_filter_component_input_port_added_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_port_added listener = { .base = { @@ -870,7 +870,7 @@ bt_graph_add_filter_component_input_port_added_listener( }, .func = (port_added_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -896,7 +896,7 @@ bt_graph_add_sink_component_input_port_added_listener( struct bt_graph *graph, bt_graph_sink_component_input_port_added_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_port_added listener = { .base = { @@ -905,7 +905,7 @@ bt_graph_add_sink_component_input_port_added_listener( }, .func = (port_added_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -931,7 +931,7 @@ bt_graph_add_source_filter_component_ports_connected_listener( struct bt_graph *graph, bt_graph_source_filter_component_ports_connected_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_ports_connected listener = { .base = { @@ -940,7 +940,7 @@ bt_graph_add_source_filter_component_ports_connected_listener( }, .func = (ports_connected_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -967,7 +967,7 @@ bt_graph_add_source_sink_component_ports_connected_listener( struct bt_graph *graph, bt_graph_source_sink_component_ports_connected_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_ports_connected listener = { .base = { @@ -976,7 +976,7 @@ bt_graph_add_source_sink_component_ports_connected_listener( }, .func = (ports_connected_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -1003,7 +1003,7 @@ bt_graph_add_filter_filter_component_ports_connected_listener( struct bt_graph *graph, bt_graph_filter_filter_component_ports_connected_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_ports_connected listener = { .base = { @@ -1012,7 +1012,7 @@ bt_graph_add_filter_filter_component_ports_connected_listener( }, .func = (ports_connected_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); @@ -1039,7 +1039,7 @@ bt_graph_add_filter_sink_component_ports_connected_listener( struct bt_graph *graph, bt_graph_filter_sink_component_ports_connected_listener_func func, bt_graph_listener_removed_func listener_removed, void *data, - int *out_listener_id) + bt_listener_id *out_listener_id) { struct bt_graph_listener_ports_connected listener = { .base = { @@ -1048,7 +1048,7 @@ bt_graph_add_filter_sink_component_ports_connected_listener( }, .func = (ports_connected_func_t) func, }; - int listener_id; + bt_listener_id listener_id; BT_ASSERT_PRE_NON_NULL(graph, "Graph"); BT_ASSERT_PRE_NON_NULL(func, "Listener"); diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index d968ddfe..24740a5c 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -160,7 +160,7 @@ end: enum bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener( const struct bt_trace_class *_tc, bt_trace_class_destruction_listener_func listener, - void *data, uint64_t *listener_id) + void *data, bt_listener_id *listener_id) { struct bt_trace_class *tc = (void *) _tc; uint64_t i; @@ -208,7 +208,7 @@ bool has_listener_id(const struct bt_trace_class *tc, uint64_t listener_id) } enum bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_listener( - const struct bt_trace_class *_tc, uint64_t listener_id) + const struct bt_trace_class *_tc, bt_listener_id listener_id) { struct bt_trace_class *tc = (void *) _tc; struct bt_trace_class_destruction_listener_elem *elem; diff --git a/src/lib/trace-ir/trace.c b/src/lib/trace-ir/trace.c index 0f683fb4..7b1749eb 100644 --- a/src/lib/trace-ir/trace.c +++ b/src/lib/trace-ir/trace.c @@ -406,7 +406,7 @@ const struct bt_stream *bt_trace_borrow_stream_by_id_const( enum bt_trace_add_listener_status bt_trace_add_destruction_listener( const struct bt_trace *c_trace, bt_trace_destruction_listener_func listener, - void *data, uint64_t *listener_id) + void *data, bt_listener_id *listener_id) { struct bt_trace *trace = (void *) c_trace; uint64_t i; @@ -454,7 +454,7 @@ bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id) } enum bt_trace_remove_listener_status bt_trace_remove_destruction_listener( - const struct bt_trace *c_trace, uint64_t listener_id) + const struct bt_trace *c_trace, bt_listener_id listener_id) { struct bt_trace *trace = (void *) c_trace; struct bt_trace_destruction_listener_elem *elem; diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.h b/src/plugins/ctf/fs-sink/fs-sink-trace.h index 6b982fa3..3d8ddb4b 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.h +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.h @@ -55,7 +55,7 @@ struct fs_sink_trace { */ const bt_trace *ir_trace; - uint64_t ir_trace_destruction_listener_id; + bt_listener_id ir_trace_destruction_listener_id; /* Trace's directory */ GString *path; diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.c index fd8e1d26..f3ba254f 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.c @@ -119,7 +119,7 @@ struct debug_info { bt_self_component *self_comp; struct debug_info_component *comp; const bt_trace *input_trace; - uint64_t destruction_listener_id; + bt_listener_id destruction_listener_id; /* * Hash table of VPIDs (pointer to int64_t) to diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h index e09cf763..26d9c96e 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h @@ -83,7 +83,7 @@ struct trace_ir_metadata_maps { struct field_class_resolving_context *fc_resolving_ctx; - uint64_t destruction_listener_id; + bt_listener_id destruction_listener_id; }; struct trace_ir_data_maps { @@ -106,7 +106,7 @@ struct trace_ir_data_maps { */ GHashTable *packet_map; - uint64_t destruction_listener_id; + bt_listener_id destruction_listener_id; }; struct trace_ir_maps { diff --git a/src/plugins/text/details/details.h b/src/plugins/text/details/details.h index 71f8882d..f3bd0828 100644 --- a/src/plugins/text/details/details.h +++ b/src/plugins/text/details/details.h @@ -54,7 +54,7 @@ struct details_trace_class_meta { * Trace class destruction listener ID (`UINT64_C(-1)` if * there's no listener ID. */ - uint64_t tc_destruction_listener_id; + bt_listener_id tc_destruction_listener_id; }; /* @@ -69,7 +69,7 @@ struct details_trace { * Trace destruction listener ID (`UINT64_C(-1)` if there's no * listener ID. */ - uint64_t trace_destruction_listener_id; + bt_listener_id trace_destruction_listener_id; }; /* A `sink.text.details` component */ -- 2.34.1