From d6e69534ef08a2dd8bff9eb5af1eab63736b3d31 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 8 Dec 2018 13:07:25 -0500 Subject: [PATCH] lib: rename "notification" -> "message" The term "notification" is usually used, in APIs, for asynchronous alerts of some sort. You get notified for something that you were not actively waiting for, like an interrupt. From Merriam-Webster, a _message_ is: > a communication in writing, in speech, or by signals and a _communication_ is: > information communicated : information transmitted or conveyed Therefore, "message" seems more adapted than "notification" for Babeltrace's API, where you actively iterate messages which are communications from an upstream component to a downstream component. Signed-off-by: Philippe Proulx --- .gitignore | 3 +- cli/babeltrace.c | 2 +- configure.ac | 4 +- include/Makefile.am | 38 +- include/babeltrace/babeltrace.h | 26 +- .../babeltrace/graph/component-class-filter.h | 34 +- .../graph/component-class-internal.h | 12 +- .../component-class-sink-colander-internal.h | 4 +- .../babeltrace/graph/component-class-source.h | 34 +- .../babeltrace/graph/connection-internal.h | 20 +- include/babeltrace/graph/graph-internal.h | 32 +- .../{notification-const.h => message-const.h} | 46 +- ...on-event-const.h => message-event-const.h} | 12 +- ...nt-internal.h => message-event-internal.h} | 18 +- .../{notification-event.h => message-event.h} | 18 +- ...ity-const.h => message-inactivity-const.h} | 12 +- ...ternal.h => message-inactivity-internal.h} | 12 +- ...tion-inactivity.h => message-inactivity.h} | 16 +- include/babeltrace/graph/message-internal.h | 134 +++ .../graph/message-iterator-internal.h | 170 ++++ ...fication-iterator.h => message-iterator.h} | 22 +- ...-packet-const.h => message-packet-const.h} | 16 +- ...t-internal.h => message-packet-internal.h} | 28 +- ...notification-packet.h => message-packet.h} | 24 +- ...-stream-const.h => message-stream-const.h} | 24 +- ...m-internal.h => message-stream-internal.h} | 16 +- include/babeltrace/graph/message-stream.h | 60 ++ .../babeltrace/graph/notification-internal.h | 134 --- .../graph/notification-iterator-internal.h | 170 ---- .../babeltrace/graph/notification-stream.h | 60 -- ...rator.h => port-output-message-iterator.h} | 50 +- ...lf-component-port-input-message-iterator.h | 86 ++ ...mponent-port-input-notification-iterator.h | 86 -- ...ion-iterator.h => self-message-iterator.h} | 40 +- include/babeltrace/lib-logging-internal.h | 6 +- include/babeltrace/plugin/plugin-dev.h | 100 +- include/babeltrace/types.h | 14 +- lib/graph/Makefile.am | 4 +- lib/graph/component-class-sink-colander.c | 50 +- lib/graph/component-class.c | 48 +- lib/graph/component-source.c | 4 +- lib/graph/component.c | 4 +- lib/graph/connection.c | 46 +- lib/graph/graph.c | 86 +- lib/graph/iterator.c | 534 +++++------ lib/graph/message/Makefile.am | 8 + .../discarded-events.c | 38 +- .../discarded-packets.c | 38 +- lib/graph/message/event.c | 201 ++++ lib/graph/message/inactivity.c | 111 +++ .../notification.c => message/message.c} | 50 +- lib/graph/message/packet.c | 271 ++++++ lib/graph/message/stream.c | 240 +++++ lib/graph/notification/Makefile.am | 8 - lib/graph/notification/event.c | 201 ---- lib/graph/notification/inactivity.c | 111 --- lib/graph/notification/packet.c | 271 ------ lib/graph/notification/stream.c | 240 ----- lib/lib-logging.c | 102 +- lib/plugin/plugin-so.c | 64 +- plugins/ctf/common/Makefile.am | 4 +- plugins/ctf/common/bfcr/bfcr.h | 2 +- .../ctf/common/metadata/visitor-generate-ir.c | 2 +- plugins/ctf/common/msg-iter/Makefile.am | 7 + .../common/{notif-iter => msg-iter}/logging.c | 6 +- .../common/{notif-iter => msg-iter}/logging.h | 10 +- .../notif-iter.c => msg-iter/msg-iter.c} | 628 ++++++------ .../notif-iter.h => msg-iter/msg-iter.h} | 240 ++--- plugins/ctf/common/notif-iter/Makefile.am | 7 - plugins/ctf/fs-sink/writer.c | 52 +- plugins/ctf/fs-sink/writer.h | 4 +- plugins/ctf/fs-src/data-stream-file.c | 138 +-- plugins/ctf/fs-src/data-stream-file.h | 16 +- plugins/ctf/fs-src/fs.c | 256 ++--- plugins/ctf/fs-src/fs.h | 22 +- plugins/ctf/lttng-live/data-stream.c | 34 +- plugins/ctf/lttng-live/data-stream.h | 4 +- plugins/ctf/lttng-live/lttng-live-internal.h | 22 +- plugins/ctf/lttng-live/lttng-live.c | 152 +-- plugins/ctf/lttng-live/lttng-viewer-abi.h | 2 +- plugins/ctf/lttng-live/viewer-connection.c | 16 +- plugins/ctf/plugin.c | 8 +- plugins/lttng-utils/copy.c | 2 +- plugins/lttng-utils/debug-info.h | 6 +- plugins/lttng-utils/plugin.c | 128 +-- plugins/text/dmesg/dmesg.c | 240 ++--- plugins/text/dmesg/dmesg.h | 14 +- plugins/text/plugin.c | 12 +- plugins/text/pretty/pretty.c | 50 +- plugins/text/pretty/pretty.h | 6 +- plugins/text/pretty/print.c | 10 +- plugins/utils/counter/counter.c | 68 +- plugins/utils/counter/counter.h | 2 +- plugins/utils/dummy/dummy.c | 34 +- plugins/utils/dummy/dummy.h | 2 +- plugins/utils/muxer/muxer.c | 898 +++++++++--------- plugins/utils/muxer/muxer.h | 14 +- plugins/utils/plugin.c | 22 +- plugins/utils/trimmer/copy.c | 2 +- plugins/utils/trimmer/iterator.c | 180 ++-- plugins/utils/trimmer/iterator.h | 14 +- tests/lib/Makefile.am | 6 +- tests/lib/test-plugin-plugins/sfs.c | 30 +- ..._iterator.c => test_bt_message_iterator.c} | 320 +++---- tests/lib/test_graph_topo.c | 8 +- 105 files changed, 4006 insertions(+), 4007 deletions(-) rename include/babeltrace/graph/{notification-const.h => message-const.h} (58%) rename include/babeltrace/graph/{notification-event-const.h => message-event-const.h} (81%) rename include/babeltrace/graph/{notification-event-internal.h => message-event-internal.h} (75%) rename include/babeltrace/graph/{notification-event.h => message-event.h} (76%) rename include/babeltrace/graph/{notification-inactivity-const.h => message-inactivity-const.h} (80%) rename include/babeltrace/graph/{notification-inactivity-internal.h => message-inactivity-internal.h} (80%) rename include/babeltrace/graph/{notification-inactivity.h => message-inactivity.h} (74%) create mode 100644 include/babeltrace/graph/message-internal.h create mode 100644 include/babeltrace/graph/message-iterator-internal.h rename include/babeltrace/graph/{notification-iterator.h => message-iterator.h} (72%) rename include/babeltrace/graph/{notification-packet-const.h => message-packet-const.h} (75%) rename include/babeltrace/graph/{notification-packet-internal.h => message-packet-internal.h} (64%) rename include/babeltrace/graph/{notification-packet.h => message-packet.h} (68%) rename include/babeltrace/graph/{notification-stream-const.h => message-stream-const.h} (68%) rename include/babeltrace/graph/{notification-stream-internal.h => message-stream-internal.h} (80%) create mode 100644 include/babeltrace/graph/message-stream.h delete mode 100644 include/babeltrace/graph/notification-internal.h delete mode 100644 include/babeltrace/graph/notification-iterator-internal.h delete mode 100644 include/babeltrace/graph/notification-stream.h rename include/babeltrace/graph/{port-output-notification-iterator.h => port-output-message-iterator.h} (51%) create mode 100644 include/babeltrace/graph/self-component-port-input-message-iterator.h delete mode 100644 include/babeltrace/graph/self-component-port-input-notification-iterator.h rename include/babeltrace/graph/{self-notification-iterator.h => self-message-iterator.h} (51%) create mode 100644 lib/graph/message/Makefile.am rename lib/graph/{notification => message}/discarded-events.c (54%) rename lib/graph/{notification => message}/discarded-packets.c (54%) create mode 100644 lib/graph/message/event.c create mode 100644 lib/graph/message/inactivity.c rename lib/graph/{notification/notification.c => message/message.c} (59%) create mode 100644 lib/graph/message/packet.c create mode 100644 lib/graph/message/stream.c delete mode 100644 lib/graph/notification/Makefile.am delete mode 100644 lib/graph/notification/event.c delete mode 100644 lib/graph/notification/inactivity.c delete mode 100644 lib/graph/notification/packet.c delete mode 100644 lib/graph/notification/stream.c create mode 100644 plugins/ctf/common/msg-iter/Makefile.am rename plugins/ctf/common/{notif-iter => msg-iter}/logging.c (88%) rename plugins/ctf/common/{notif-iter => msg-iter}/logging.h (84%) rename plugins/ctf/common/{notif-iter/notif-iter.c => msg-iter/msg-iter.c} (81%) rename plugins/ctf/common/{notif-iter/notif-iter.h => msg-iter/msg-iter.h} (56%) delete mode 100644 plugins/ctf/common/notif-iter/Makefile.am rename tests/lib/{test_bt_notification_iterator.c => test_bt_message_iterator.c} (63%) diff --git a/.gitignore b/.gitignore index 0ef95c97..71a74bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ /tests/lib/test_bin_info_complete /tests/lib/test_bitfield /tests/lib/test_bt_ctf_field_type_validation -/tests/lib/test_bt_notification_heap /tests/lib/test_bt_objects /tests/lib/test_bt_values /tests/lib/test_trace_ir_ref @@ -30,7 +29,7 @@ /tests/lib/writer/bt_python_helper.py /tests/lib/writer/test_ctf_writer_empty_packet.py /tests/lib/writer/test_ctf_writer_no_packet_context.py -/tests/lib/test_bt_notification_iterator +/tests/lib/test_bt_message_iterator /tests/lib/test_cc_prio_map /tests/lib/test_graph_topo /tests/lib/trace-ir/test_trace_ir diff --git a/cli/babeltrace.c b/cli/babeltrace.c index ae1a9263..101fb5f5 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -56,7 +56,7 @@ static const char* log_level_env_var_names[] = { "BABELTRACE_SRC_CTF_FS_LOG_LEVEL", "BABELTRACE_SRC_CTF_LTTNG_LIVE_LOG_LEVEL", "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL", - "BABELTRACE_PLUGIN_CTF_NOTIF_ITER_LOG_LEVEL", + "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL", "BABELTRACE_PLUGIN_CTFCOPYTRACE_LIB_LOG_LEVEL", "BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL", "BABELTRACE_SRC_TEXT_DMESG_LOG_LEVEL", diff --git a/configure.ac b/configure.ac index d03990f0..ce51dbed 100644 --- a/configure.ac +++ b/configure.ac @@ -743,7 +743,7 @@ AC_CONFIG_FILES([ lib/prio_heap/Makefile lib/plugin/Makefile lib/graph/Makefile - lib/graph/notification/Makefile + lib/graph/message/Makefile lib/trace-ir/Makefile lib/ctf-writer/Makefile include/Makefile @@ -772,7 +772,7 @@ AC_CONFIG_FILES([ plugins/ctf/common/Makefile plugins/ctf/common/bfcr/Makefile plugins/ctf/common/metadata/Makefile - plugins/ctf/common/notif-iter/Makefile + plugins/ctf/common/msg-iter/Makefile plugins/ctf/common/utils/Makefile plugins/ctf/fs-src/Makefile plugins/ctf/fs-sink/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 09bfcf75..0edf60da 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -150,7 +150,7 @@ babeltraceplugininclude_HEADERS = \ babeltrace/plugin/plugin-const.h \ babeltrace/plugin/plugin-set-const.h -# Graph, component, and notification API +# Graph, component, and message API babeltracegraphincludedir = "$(includedir)/babeltrace/graph" babeltracegraphinclude_HEADERS = \ babeltrace/graph/component-class-const.h \ @@ -168,33 +168,33 @@ babeltracegraphinclude_HEADERS = \ babeltrace/graph/connection-const.h \ babeltrace/graph/graph-const.h \ babeltrace/graph/graph.h \ - babeltrace/graph/notification-const.h \ - babeltrace/graph/notification-event-const.h \ - babeltrace/graph/notification-event.h \ - babeltrace/graph/notification-inactivity-const.h \ - babeltrace/graph/notification-inactivity.h \ - babeltrace/graph/notification-packet-const.h \ - babeltrace/graph/notification-packet.h \ - babeltrace/graph/notification-stream-const.h \ - babeltrace/graph/notification-stream.h \ + babeltrace/graph/message-const.h \ + babeltrace/graph/message-event-const.h \ + babeltrace/graph/message-event.h \ + babeltrace/graph/message-inactivity-const.h \ + babeltrace/graph/message-inactivity.h \ + babeltrace/graph/message-packet-const.h \ + babeltrace/graph/message-packet.h \ + babeltrace/graph/message-stream-const.h \ + babeltrace/graph/message-stream.h \ babeltrace/graph/port-const.h \ babeltrace/graph/port-input-const.h \ babeltrace/graph/port-output-const.h \ - babeltrace/graph/port-output-notification-iterator.h \ + babeltrace/graph/port-output-message-iterator.h \ babeltrace/graph/query-executor-const.h \ babeltrace/graph/query-executor.h \ babeltrace/graph/self-component-class-filter.h \ babeltrace/graph/self-component-class-sink.h \ babeltrace/graph/self-component-class-source.h \ babeltrace/graph/self-component-filter.h \ - babeltrace/graph/self-component-port-input-notification-iterator.h \ + babeltrace/graph/self-component-port-input-message-iterator.h \ babeltrace/graph/self-component-port-input.h \ babeltrace/graph/self-component-port-output.h \ babeltrace/graph/self-component-port.h \ babeltrace/graph/self-component-sink.h \ babeltrace/graph/self-component-source.h \ babeltrace/graph/self-component.h \ - babeltrace/graph/self-notification-iterator.h + babeltrace/graph/self-message-iterator.h noinst_HEADERS = \ babeltrace/compat/stdlib-internal.h \ @@ -271,12 +271,12 @@ noinst_HEADERS = \ babeltrace/graph/component-source-internal.h \ babeltrace/graph/connection-internal.h \ babeltrace/graph/graph-internal.h \ - babeltrace/graph/notification-event-internal.h \ - babeltrace/graph/notification-inactivity-internal.h \ - babeltrace/graph/notification-internal.h \ - babeltrace/graph/notification-iterator-internal.h \ - babeltrace/graph/notification-packet-internal.h \ - babeltrace/graph/notification-stream-internal.h \ + babeltrace/graph/message-event-internal.h \ + babeltrace/graph/message-inactivity-internal.h \ + babeltrace/graph/message-internal.h \ + babeltrace/graph/message-iterator-internal.h \ + babeltrace/graph/message-packet-internal.h \ + babeltrace/graph/message-stream-internal.h \ babeltrace/graph/port-internal.h \ babeltrace/graph/query-executor-internal.h \ babeltrace/list-internal.h \ diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index 0d349995..01b220d1 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -94,7 +94,7 @@ #include #include -/* Graph, component, and notification API */ +/* Graph, component, and message API */ #include #include #include @@ -110,32 +110,32 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include #include #include #include #include -#include +#include #endif /* BABELTRACE_BABELTRACE_H */ diff --git a/include/babeltrace/graph/component-class-filter.h b/include/babeltrace/graph/component-class-filter.h index d7832cff..80aeeb74 100644 --- a/include/babeltrace/graph/component-class-filter.h +++ b/include/babeltrace/graph/component-class-filter.h @@ -29,8 +29,8 @@ /* For enum bt_self_component_status */ #include -/* For enum bt_self_notification_iterator_status */ -#include +/* For enum bt_self_message_iterator_status */ +#include /* For enum bt_query_status */ #include @@ -39,7 +39,7 @@ * For bt_component_class, bt_component_class_filter, bt_port_input, * bt_port_output, bt_query_executor, bt_self_component_class_filter, * bt_self_component_filter, bt_self_component_port_input, - * bt_self_component_port_output, bt_value, bt_notification_array_const + * bt_self_component_port_output, bt_value, bt_message_array_const */ #include @@ -55,20 +55,20 @@ typedef enum bt_self_component_status typedef void (*bt_component_class_filter_finalize_method)( bt_self_component_filter *self_component); -typedef enum bt_self_notification_iterator_status -(*bt_component_class_filter_notification_iterator_init_method)( - bt_self_notification_iterator *notification_iterator, +typedef enum bt_self_message_iterator_status +(*bt_component_class_filter_message_iterator_init_method)( + bt_self_message_iterator *message_iterator, bt_self_component_filter *self_component, bt_self_component_port_output *port); typedef void -(*bt_component_class_filter_notification_iterator_finalize_method)( - bt_self_notification_iterator *notification_iterator); +(*bt_component_class_filter_message_iterator_finalize_method)( + bt_self_message_iterator *message_iterator); -typedef enum bt_self_notification_iterator_status -(*bt_component_class_filter_notification_iterator_next_method)( - bt_self_notification_iterator *notification_iterator, - bt_notification_array_const notifs, uint64_t capacity, +typedef enum bt_self_message_iterator_status +(*bt_component_class_filter_message_iterator_next_method)( + bt_self_message_iterator *message_iterator, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count); typedef enum bt_query_status @@ -122,7 +122,7 @@ bt_component_class *bt_component_class_filter_as_component_class( extern bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_component_class_filter_notification_iterator_next_method method); + bt_component_class_filter_message_iterator_next_method method); extern int bt_component_class_filter_set_init_method( bt_component_class_filter *comp_class, @@ -160,13 +160,13 @@ extern int bt_component_class_filter_set_query_method( bt_component_class_filter *comp_class, bt_component_class_filter_query_method method); -extern int bt_component_class_filter_set_notification_iterator_init_method( +extern int bt_component_class_filter_set_message_iterator_init_method( bt_component_class_filter *comp_class, - bt_component_class_filter_notification_iterator_init_method method); + bt_component_class_filter_message_iterator_init_method method); -extern int bt_component_class_filter_set_notification_iterator_finalize_method( +extern int bt_component_class_filter_set_message_iterator_finalize_method( bt_component_class_filter *comp_class, - bt_component_class_filter_notification_iterator_finalize_method method); + bt_component_class_filter_message_iterator_finalize_method method); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/component-class-internal.h b/include/babeltrace/graph/component-class-internal.h index 909d450e..741129ee 100644 --- a/include/babeltrace/graph/component-class-internal.h +++ b/include/babeltrace/graph/component-class-internal.h @@ -67,9 +67,9 @@ struct bt_component_class_source { struct { bt_component_class_source_init_method init; bt_component_class_source_finalize_method finalize; - bt_component_class_source_notification_iterator_init_method notif_iter_init; - bt_component_class_source_notification_iterator_finalize_method notif_iter_finalize; - bt_component_class_source_notification_iterator_next_method notif_iter_next; + bt_component_class_source_message_iterator_init_method msg_iter_init; + bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; + bt_component_class_source_message_iterator_next_method msg_iter_next; bt_component_class_source_query_method query; bt_component_class_source_accept_output_port_connection_method accept_output_port_connection; bt_component_class_source_output_port_connected_method output_port_connected; @@ -95,9 +95,9 @@ struct bt_component_class_filter { struct { bt_component_class_filter_init_method init; bt_component_class_filter_finalize_method finalize; - bt_component_class_filter_notification_iterator_init_method notif_iter_init; - bt_component_class_filter_notification_iterator_finalize_method notif_iter_finalize; - bt_component_class_filter_notification_iterator_next_method notif_iter_next; + bt_component_class_filter_message_iterator_init_method msg_iter_init; + bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; + bt_component_class_filter_message_iterator_next_method msg_iter_next; bt_component_class_filter_query_method query; bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection; bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection; diff --git a/include/babeltrace/graph/component-class-sink-colander-internal.h b/include/babeltrace/graph/component-class-sink-colander-internal.h index 037c64b1..a56f0b4e 100644 --- a/include/babeltrace/graph/component-class-sink-colander-internal.h +++ b/include/babeltrace/graph/component-class-sink-colander-internal.h @@ -25,14 +25,14 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { #endif struct bt_component_class_sink_colander_data { - bt_notification_array_const notifs; + bt_message_array_const msgs; uint64_t *count_addr; }; diff --git a/include/babeltrace/graph/component-class-source.h b/include/babeltrace/graph/component-class-source.h index 77444ec2..d0fed047 100644 --- a/include/babeltrace/graph/component-class-source.h +++ b/include/babeltrace/graph/component-class-source.h @@ -29,8 +29,8 @@ /* For enum bt_self_component_status */ #include -/* For enum bt_self_notification_iterator_status */ -#include +/* For enum bt_self_message_iterator_status */ +#include /* For enum bt_query_status */ #include @@ -39,7 +39,7 @@ * For bt_component_class, bt_component_class_source, bt_port_input, * bt_query_executor, bt_self_component_class_source, * bt_self_component_source, bt_self_component_port_output, bt_value, - * bt_notification_array_const + * bt_message_array_const */ #include @@ -55,20 +55,20 @@ typedef enum bt_self_component_status typedef void (*bt_component_class_source_finalize_method)( bt_self_component_source *self_component); -typedef enum bt_self_notification_iterator_status -(*bt_component_class_source_notification_iterator_init_method)( - bt_self_notification_iterator *notification_iterator, +typedef enum bt_self_message_iterator_status +(*bt_component_class_source_message_iterator_init_method)( + bt_self_message_iterator *message_iterator, bt_self_component_source *self_component, bt_self_component_port_output *port); typedef void -(*bt_component_class_source_notification_iterator_finalize_method)( - bt_self_notification_iterator *notification_iterator); +(*bt_component_class_source_message_iterator_finalize_method)( + bt_self_message_iterator *message_iterator); -typedef enum bt_self_notification_iterator_status -(*bt_component_class_source_notification_iterator_next_method)( - bt_self_notification_iterator *notification_iterator, - bt_notification_array_const notifs, uint64_t capacity, +typedef enum bt_self_message_iterator_status +(*bt_component_class_source_message_iterator_next_method)( + bt_self_message_iterator *message_iterator, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count); typedef enum bt_query_status @@ -105,7 +105,7 @@ bt_component_class *bt_component_class_source_as_component_class( extern bt_component_class_source *bt_component_class_source_create( const char *name, - bt_component_class_source_notification_iterator_next_method method); + bt_component_class_source_message_iterator_next_method method); extern int bt_component_class_source_set_init_method( bt_component_class_source *comp_class, @@ -131,13 +131,13 @@ extern int bt_component_class_source_set_query_method( bt_component_class_source *comp_class, bt_component_class_source_query_method method); -extern int bt_component_class_source_set_notification_iterator_init_method( +extern int bt_component_class_source_set_message_iterator_init_method( bt_component_class_source *comp_class, - bt_component_class_source_notification_iterator_init_method method); + bt_component_class_source_message_iterator_init_method method); -extern int bt_component_class_source_set_notification_iterator_finalize_method( +extern int bt_component_class_source_set_message_iterator_finalize_method( bt_component_class_source *comp_class, - bt_component_class_source_notification_iterator_finalize_method method); + bt_component_class_source_message_iterator_finalize_method method); #ifdef __cplusplus } diff --git a/include/babeltrace/graph/connection-internal.h b/include/babeltrace/graph/connection-internal.h index 2395fcd3..c86bc82d 100644 --- a/include/babeltrace/graph/connection-internal.h +++ b/include/babeltrace/graph/connection-internal.h @@ -25,8 +25,8 @@ */ #include -#include -#include +#include +#include #include #include #include @@ -50,17 +50,17 @@ struct bt_connection { struct bt_port *upstream_port; /* - * Weak references to all the notification iterators that were + * Weak references to all the message iterators that were * created on this connection. */ GPtrArray *iterators; - bool notified_upstream_port_connected; - bool notified_upstream_port_disconnected; - bool notified_downstream_port_connected; - bool notified_downstream_port_disconnected; - bool notified_graph_ports_connected; - bool notified_graph_ports_disconnected; + bool msgied_upstream_port_connected; + bool msgied_upstream_port_disconnected; + bool msgied_downstream_port_connected; + bool msgied_downstream_port_disconnected; + bool msgied_graph_ports_connected; + bool msgied_graph_ports_disconnected; }; BT_HIDDEN @@ -73,7 +73,7 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph); BT_HIDDEN void bt_connection_remove_iterator(struct bt_connection *conn, - struct bt_self_component_port_input_notification_iterator *iterator); + struct bt_self_component_port_input_message_iterator *iterator); static inline struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn) diff --git a/include/babeltrace/graph/graph-internal.h b/include/babeltrace/graph/graph-internal.h index 2ff92d35..09927fcf 100644 --- a/include/babeltrace/graph/graph-internal.h +++ b/include/babeltrace/graph/graph-internal.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ struct bt_graph { * BT_GRAPH_STATUS_CANNOT_CONSUME. The internal "no check" * functions always work. * - * In bt_port_output_notification_iterator_create(), on success, + * In bt_port_output_message_iterator_create(), on success, * this flag is cleared so that the iterator remains the only * consumer for the graph's lifetime. */ @@ -90,30 +90,30 @@ struct bt_graph { GArray *filter_sink_ports_disconnected; } listeners; - /* Pool of `struct bt_notification_event *` */ - struct bt_object_pool event_notif_pool; + /* Pool of `struct bt_message_event *` */ + struct bt_object_pool event_msg_pool; - /* Pool of `struct bt_notification_packet_beginning *` */ - struct bt_object_pool packet_begin_notif_pool; + /* Pool of `struct bt_message_packet_beginning *` */ + struct bt_object_pool packet_begin_msg_pool; - /* Pool of `struct bt_notification_packet_end *` */ - struct bt_object_pool packet_end_notif_pool; + /* Pool of `struct bt_message_packet_end *` */ + struct bt_object_pool packet_end_msg_pool; /* - * Array of `struct bt_notification *` (weak). + * Array of `struct bt_message *` (weak). * - * This is an array of all the notifications ever created from + * This is an array of all the messages ever created from * this graph. Some of them can be in one of the pools above, - * some of them can be at large. Because each notification has a + * some of them can be at large. Because each message has a * weak pointer to the graph containing its pool, we need to - * notify each notification that the graph is gone on graph + * notify each message that the graph is gone on graph * destruction. * * TODO: When we support a maximum size for object pools, - * add a way for a notification to remove itself from this + * add a way for a message to remove itself from this * array (on destruction). */ - GPtrArray *notifications; + GPtrArray *messages; }; static inline @@ -168,8 +168,8 @@ int bt_graph_remove_unconnected_component(struct bt_graph *graph, struct bt_component *component); BT_HIDDEN -void bt_graph_add_notification(struct bt_graph *graph, - struct bt_notification *notif); +void bt_graph_add_message(struct bt_graph *graph, + struct bt_message *msg); static inline const char *bt_graph_status_string(enum bt_graph_status status) diff --git a/include/babeltrace/graph/notification-const.h b/include/babeltrace/graph/message-const.h similarity index 58% rename from include/babeltrace/graph/notification-const.h rename to include/babeltrace/graph/message-const.h index 87540889..e345ca4d 100644 --- a/include/babeltrace/graph/notification-const.h +++ b/include/babeltrace/graph/message-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,7 +24,7 @@ * SOFTWARE. */ -/* For bt_notification */ +/* For bt_message */ #include #ifdef __cplusplus @@ -32,39 +32,39 @@ extern "C" { #endif /** - * Notification types. Unhandled notification types should be ignored. + * Message types. Unhandled message types should be ignored. */ -enum bt_notification_type { - BT_NOTIFICATION_TYPE_EVENT = 0, - BT_NOTIFICATION_TYPE_INACTIVITY = 1, - BT_NOTIFICATION_TYPE_STREAM_BEGINNING = 2, - BT_NOTIFICATION_TYPE_STREAM_END = 3, - BT_NOTIFICATION_TYPE_PACKET_BEGINNING = 4, - BT_NOTIFICATION_TYPE_PACKET_END = 5, +enum bt_message_type { + BT_MESSAGE_TYPE_EVENT = 0, + BT_MESSAGE_TYPE_INACTIVITY = 1, + BT_MESSAGE_TYPE_STREAM_BEGINNING = 2, + BT_MESSAGE_TYPE_STREAM_END = 3, + BT_MESSAGE_TYPE_PACKET_BEGINNING = 4, + BT_MESSAGE_TYPE_PACKET_END = 5, }; /** - * Get a notification's type. + * Get a message's type. * - * @param notification Notification instance - * @returns One of #bt_notification_type + * @param message Message instance + * @returns One of #bt_message_type */ -extern enum bt_notification_type bt_notification_get_type( - const bt_notification *notification); +extern enum bt_message_type bt_message_get_type( + const bt_message *message); -extern void bt_notification_get_ref(const bt_notification *notification); +extern void bt_message_get_ref(const bt_message *message); -extern void bt_notification_put_ref(const bt_notification *notification); +extern void bt_message_put_ref(const bt_message *message); -#define BT_NOTIFICATION_PUT_REF_AND_RESET(_var) \ +#define BT_MESSAGE_PUT_REF_AND_RESET(_var) \ do { \ - bt_notification_put_ref(_var); \ + bt_message_put_ref(_var); \ (_var) = NULL; \ } while (0) -#define BT_NOTIFICATION_MOVE_REF(_var_dst, _var_src) \ +#define BT_MESSAGE_MOVE_REF(_var_dst, _var_src) \ do { \ - bt_notification_put_ref(_var_dst); \ + bt_message_put_ref(_var_dst); \ (_var_dst) = (_var_src); \ (_var_src) = NULL; \ } while (0) @@ -73,4 +73,4 @@ extern void bt_notification_put_ref(const bt_notification *notification); } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_CONST_H */ diff --git a/include/babeltrace/graph/notification-event-const.h b/include/babeltrace/graph/message-event-const.h similarity index 81% rename from include/babeltrace/graph/notification-event-const.h rename to include/babeltrace/graph/message-event-const.h index a9e47dcb..8d0d6fc1 100644 --- a/include/babeltrace/graph/notification-event-const.h +++ b/include/babeltrace/graph/message-event-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,18 +24,18 @@ * SOFTWARE. */ -/* For bt_notification, bt_event */ +/* For bt_message, bt_event */ #include #ifdef __cplusplus extern "C" { #endif -extern const bt_event *bt_notification_event_borrow_event_const( - const bt_notification *notification); +extern const bt_event *bt_message_event_borrow_event_const( + const bt_message *message); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_EVENT_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H */ diff --git a/include/babeltrace/graph/notification-event-internal.h b/include/babeltrace/graph/message-event-internal.h similarity index 75% rename from include/babeltrace/graph/notification-event-internal.h rename to include/babeltrace/graph/message-event-internal.h index ff165e34..5727df29 100644 --- a/include/babeltrace/graph/notification-event-internal.h +++ b/include/babeltrace/graph/message-event-internal.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_EVENT_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_EVENT_INTERNAL_H +#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H /* * Copyright 2017-2018 Philippe Proulx @@ -27,29 +27,29 @@ #include #include #include -#include +#include #include #ifdef __cplusplus extern "C" { #endif -struct bt_notification_event { - struct bt_notification parent; +struct bt_message_event { + struct bt_message parent; struct bt_event *event; }; BT_HIDDEN -struct bt_notification *bt_notification_event_new(struct bt_graph *graph); +struct bt_message *bt_message_event_new(struct bt_graph *graph); BT_HIDDEN -void bt_notification_event_recycle(struct bt_notification *notif); +void bt_message_event_recycle(struct bt_message *msg); BT_HIDDEN -void bt_notification_event_destroy(struct bt_notification *notif); +void bt_message_event_destroy(struct bt_message *msg); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_EVENT_INTERNAL_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-event.h b/include/babeltrace/graph/message-event.h similarity index 76% rename from include/babeltrace/graph/notification-event.h rename to include/babeltrace/graph/message-event.h index be5b94ea..9a727475 100644 --- a/include/babeltrace/graph/notification-event.h +++ b/include/babeltrace/graph/message-event.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_EVENT_H -#define BABELTRACE_GRAPH_NOTIFICATION_EVENT_H +#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_H +#define BABELTRACE_GRAPH_MESSAGE_EVENT_H /* * Copyright 2017-2018 Philippe Proulx @@ -25,8 +25,8 @@ */ /* - * For bt_self_notification_iterator, bt_event, bt_packet, - * bt_event_class, bt_notification + * For bt_self_message_iterator, bt_event, bt_packet, + * bt_event_class, bt_message */ #include @@ -35,16 +35,16 @@ extern "C" { #endif extern -bt_notification *bt_notification_event_create( - bt_self_notification_iterator *notification_iterator, +bt_message *bt_message_event_create( + bt_self_message_iterator *message_iterator, bt_event_class *event_class, bt_packet *packet); -extern bt_event *bt_notification_event_borrow_event( - bt_notification *notification); +extern bt_event *bt_message_event_borrow_event( + bt_message *message); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_EVENT_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_H */ diff --git a/include/babeltrace/graph/notification-inactivity-const.h b/include/babeltrace/graph/message-inactivity-const.h similarity index 80% rename from include/babeltrace/graph/notification-inactivity-const.h rename to include/babeltrace/graph/message-inactivity-const.h index 9f5bf001..7aab72ba 100644 --- a/include/babeltrace/graph/notification-inactivity-const.h +++ b/include/babeltrace/graph/message-inactivity-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_INACTIVITY_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_INACTIVITY_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -23,7 +23,7 @@ * SOFTWARE. */ -/* For bt_notification, bt_clock_value */ +/* For bt_message, bt_clock_value */ #include #ifdef __cplusplus @@ -31,11 +31,11 @@ extern "C" { #endif extern const bt_clock_value * -bt_notification_inactivity_borrow_default_clock_value_const( - const bt_notification *notif); +bt_message_inactivity_borrow_default_clock_value_const( + const bt_message *msg); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_INACTIVITY_CONST_H */ diff --git a/include/babeltrace/graph/notification-inactivity-internal.h b/include/babeltrace/graph/message-inactivity-internal.h similarity index 80% rename from include/babeltrace/graph/notification-inactivity-internal.h rename to include/babeltrace/graph/message-inactivity-internal.h index 662c995a..b0523cad 100644 --- a/include/babeltrace/graph/notification-inactivity-internal.h +++ b/include/babeltrace/graph/message-inactivity-internal.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_INTERNAL_H +#ifndef BABELTRACE_GRAPH_MESSAGE_INACTIVITY_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_INACTIVITY_INTERNAL_H /* * Copyright 2017-2018 Philippe Proulx @@ -25,11 +25,11 @@ #include #include -#include +#include -struct bt_notification_inactivity { - struct bt_notification parent; +struct bt_message_inactivity { + struct bt_message parent; struct bt_clock_value *default_cv; }; -#endif /* BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_INTERNAL_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_INACTIVITY_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-inactivity.h b/include/babeltrace/graph/message-inactivity.h similarity index 74% rename from include/babeltrace/graph/notification-inactivity.h rename to include/babeltrace/graph/message-inactivity.h index ee9937ab..8425d57b 100644 --- a/include/babeltrace/graph/notification-inactivity.h +++ b/include/babeltrace/graph/message-inactivity.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_H -#define BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_H +#ifndef BABELTRACE_GRAPH_MESSAGE_INACTIVITY_H +#define BABELTRACE_GRAPH_MESSAGE_INACTIVITY_H /* * Copyright 2017-2018 Philippe Proulx @@ -23,7 +23,7 @@ * SOFTWARE. */ -/* For bt_self_notification_iterator, bt_notification, bt_clock_class */ +/* For bt_self_message_iterator, bt_message, bt_clock_class */ #include #include @@ -33,15 +33,15 @@ extern "C" { #endif extern -bt_notification *bt_notification_inactivity_create( - bt_self_notification_iterator *notification_iterator, +bt_message *bt_message_inactivity_create( + bt_self_message_iterator *message_iterator, bt_clock_class *default_clock_class); -extern void bt_notification_inactivity_set_default_clock_value( - bt_notification *notif, uint64_t raw_value); +extern void bt_message_inactivity_set_default_clock_value( + bt_message *msg, uint64_t raw_value); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_INACTIVITY_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_INACTIVITY_H */ diff --git a/include/babeltrace/graph/message-internal.h b/include/babeltrace/graph/message-internal.h new file mode 100644 index 00000000..8f6158ea --- /dev/null +++ b/include/babeltrace/graph/message-internal.h @@ -0,0 +1,134 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2015 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct bt_stream *(*get_stream_func)( + struct bt_message *message); + +struct bt_message { + struct bt_object base; + enum bt_message_type type; + uint64_t seq_num; + bt_bool frozen; + + /* Owned by this; keeps the graph alive while the msg. is alive */ + struct bt_graph *graph; +}; + +#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type) \ + BT_ASSERT_PRE(((struct bt_message *) (_msg))->type == (_type), \ + "Message has the wrong type: expected-type=%s, " \ + "%![msg-]+n", bt_message_type_string(_type), \ + (_msg)) + +BT_HIDDEN +void bt_message_init(struct bt_message *message, + enum bt_message_type type, + bt_object_release_func release, + struct bt_graph *graph); + +static inline +void bt_message_reset(struct bt_message *message) +{ + BT_ASSERT(message); + +#ifdef BT_DEV_MODE + message->frozen = BT_FALSE; + message->seq_num = UINT64_C(-1); +#endif +} + +static inline +struct bt_message *bt_message_create_from_pool( + struct bt_object_pool *pool, struct bt_graph *graph) +{ + struct bt_message *msg = bt_object_pool_create_object(pool); + + if (unlikely(!msg)) { +#ifdef BT_LIB_LOGE + BT_LIB_LOGE("Cannot allocate one message from message pool: " + "%![pool-]+o, %![graph-]+g", pool, graph); +#endif + goto error; + } + + if (likely(!msg->graph)) { + msg->graph = graph; + } + + goto end; + +error: + BT_ASSERT(!msg); + +end: + return msg; +} + +static inline void _bt_message_freeze(struct bt_message *message) +{ + message->frozen = BT_TRUE; +} + +BT_HIDDEN +void bt_message_unlink_graph(struct bt_message *msg); + +#ifdef BT_DEV_MODE +# define bt_message_freeze _bt_message_freeze +#else +# define bt_message_freeze(_x) +#endif /* BT_DEV_MODE */ + +static inline +const char *bt_message_type_string(enum bt_message_type type) +{ + switch (type) { + case BT_MESSAGE_TYPE_EVENT: + return "BT_MESSAGE_TYPE_EVENT"; + case BT_MESSAGE_TYPE_INACTIVITY: + return "BT_MESSAGE_TYPE_INACTIVITY"; + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + return "BT_MESSAGE_TYPE_STREAM_BEGINNING"; + case BT_MESSAGE_TYPE_STREAM_END: + return "BT_MESSAGE_TYPE_STREAM_END"; + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + return "BT_MESSAGE_TYPE_PACKET_BEGINNING"; + case BT_MESSAGE_TYPE_PACKET_END: + return "BT_MESSAGE_TYPE_PACKET_END"; + default: + return "(unknown)"; + } +} + +#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-iterator-internal.h b/include/babeltrace/graph/message-iterator-internal.h new file mode 100644 index 00000000..bc604249 --- /dev/null +++ b/include/babeltrace/graph/message-iterator-internal.h @@ -0,0 +1,170 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2015 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct bt_port; +struct bt_graph; + +enum bt_message_iterator_type { + BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT, + BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT, +}; + +enum bt_self_component_port_input_message_iterator_state { + /* Iterator is not initialized. */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED, + + /* Iterator is active, not at the end yet, and not finalized. */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE, + + /* + * Iterator is ended, not finalized yet: the "next" method + * returns BT_MESSAGE_ITERATOR_STATUS_END. + */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED, + + /* + * Iterator is finalized, but not at the end yet. This means + * that the "next" method can still return queued messages + * before returning the BT_MESSAGE_ITERATOR_STATUS_CANCELED + * status. + */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED, + + /* + * Iterator is finalized and ended: the "next" method always + * returns BT_MESSAGE_ITERATOR_STATUS_CANCELED. + */ + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED, +}; + +struct bt_message_iterator { + struct bt_object base; + enum bt_message_iterator_type type; + GPtrArray *msgs; +}; + +struct bt_self_component_port_input_message_iterator { + struct bt_message_iterator base; + struct bt_component *upstream_component; /* Weak */ + struct bt_port *upstream_port; /* Weak */ + struct bt_connection *connection; /* Weak */ + struct bt_graph *graph; /* Weak */ + + /* + * This hash table keeps the state of a stream as viewed by + * this message iterator. This is used to, in developer + * mode: + * + * * Automatically enqueue "stream begin", "packet begin", + * "packet end", and "stream end" messages depending + * on the stream's state and on the next message returned + * by the upstream component. + * + * * Make sure that, once the message iterator has seen a + * "stream end" message for a given stream, no other + * messages which refer to this stream can be delivered + * by this iterator. + * + * The key (struct bt_stream *) is not owned by this. The + * value is an allocated state structure. + */ + GHashTable *stream_states; + + enum bt_self_component_port_input_message_iterator_state state; + void *user_data; +}; + +struct bt_port_output_message_iterator { + struct bt_message_iterator base; + struct bt_graph *graph; /* Owned by this */ + struct bt_component_sink *colander; /* Owned by this */ + + /* + * Only used temporarily as a bridge between a colander sink and + * the user. + */ + uint64_t count; +}; + +BT_HIDDEN +void bt_self_component_port_input_message_iterator_finalize( + struct bt_self_component_port_input_message_iterator *iterator); + +BT_HIDDEN +void bt_self_component_port_input_message_iterator_set_connection( + struct bt_self_component_port_input_message_iterator *iterator, + struct bt_connection *connection); + +static inline +const char *bt_message_iterator_status_string( + enum bt_message_iterator_status status) +{ + switch (status) { + case BT_MESSAGE_ITERATOR_STATUS_CANCELED: + return "BT_MESSAGE_ITERATOR_STATUS_CANCELED"; + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: + return "BT_MESSAGE_ITERATOR_STATUS_AGAIN"; + case BT_MESSAGE_ITERATOR_STATUS_END: + return "BT_MESSAGE_ITERATOR_STATUS_END"; + case BT_MESSAGE_ITERATOR_STATUS_OK: + return "BT_MESSAGE_ITERATOR_STATUS_OK"; + case BT_MESSAGE_ITERATOR_STATUS_ERROR: + return "BT_MESSAGE_ITERATOR_STATUS_ERROR"; + case BT_MESSAGE_ITERATOR_STATUS_NOMEM: + return "BT_MESSAGE_ITERATOR_STATUS_NOMEM"; + default: + return "(unknown)"; + } +}; + +static inline +const char *bt_self_component_port_input_message_iterator_state_string( + enum bt_self_component_port_input_message_iterator_state state) +{ + switch (state) { + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED"; + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED: + return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED"; + default: + return "(unknown)"; + } +}; + +#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-iterator.h b/include/babeltrace/graph/message-iterator.h similarity index 72% rename from include/babeltrace/graph/notification-iterator.h rename to include/babeltrace/graph/message-iterator.h index bd58398c..b54df9cd 100644 --- a/include/babeltrace/graph/notification-iterator.h +++ b/include/babeltrace/graph/message-iterator.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_H -#define BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_H +#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_H +#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,24 +24,24 @@ * SOFTWARE. */ -/* For bt_notification, bt_notification_iterator */ +/* For bt_message, bt_message_iterator */ #include #ifdef __cplusplus extern "C" { #endif -enum bt_notification_iterator_status { - BT_NOTIFICATION_ITERATOR_STATUS_OK = 0, - BT_NOTIFICATION_ITERATOR_STATUS_END = 1, - BT_NOTIFICATION_ITERATOR_STATUS_AGAIN = 11, - BT_NOTIFICATION_ITERATOR_STATUS_CANCELED = 125, - BT_NOTIFICATION_ITERATOR_STATUS_ERROR = -1, - BT_NOTIFICATION_ITERATOR_STATUS_NOMEM = -12, +enum bt_message_iterator_status { + BT_MESSAGE_ITERATOR_STATUS_OK = 0, + BT_MESSAGE_ITERATOR_STATUS_END = 1, + BT_MESSAGE_ITERATOR_STATUS_AGAIN = 11, + BT_MESSAGE_ITERATOR_STATUS_CANCELED = 125, + BT_MESSAGE_ITERATOR_STATUS_ERROR = -1, + BT_MESSAGE_ITERATOR_STATUS_NOMEM = -12, }; #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_H */ diff --git a/include/babeltrace/graph/notification-packet-const.h b/include/babeltrace/graph/message-packet-const.h similarity index 75% rename from include/babeltrace/graph/notification-packet-const.h rename to include/babeltrace/graph/message-packet-const.h index 48778a83..997b39ef 100644 --- a/include/babeltrace/graph/notification-packet-const.h +++ b/include/babeltrace/graph/message-packet-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,21 +24,21 @@ * SOFTWARE. */ -/* For bt_notification, bt_packet */ +/* For bt_message, bt_packet */ #include #ifdef __cplusplus extern "C" { #endif -extern const bt_packet *bt_notification_packet_beginning_borrow_packet_const( - const bt_notification *notification); +extern const bt_packet *bt_message_packet_beginning_borrow_packet_const( + const bt_message *message); -extern const bt_packet *bt_notification_packet_end_borrow_packet_const( - const bt_notification *notification); +extern const bt_packet *bt_message_packet_end_borrow_packet_const( + const bt_message *message); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_CONST_H */ diff --git a/include/babeltrace/graph/notification-packet-internal.h b/include/babeltrace/graph/message-packet-internal.h similarity index 64% rename from include/babeltrace/graph/notification-packet-internal.h rename to include/babeltrace/graph/message-packet-internal.h index 20fe6134..5a60e006 100644 --- a/include/babeltrace/graph/notification-packet-internal.h +++ b/include/babeltrace/graph/message-packet-internal.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H /* * Copyright 2017-2018 Philippe Proulx @@ -26,35 +26,35 @@ #include #include -#include +#include #include -struct bt_notification_packet_beginning { - struct bt_notification parent; +struct bt_message_packet_beginning { + struct bt_message parent; struct bt_packet *packet; }; -struct bt_notification_packet_end { - struct bt_notification parent; +struct bt_message_packet_end { + struct bt_message parent; struct bt_packet *packet; }; BT_HIDDEN -struct bt_notification *bt_notification_packet_beginning_new( +struct bt_message *bt_message_packet_beginning_new( struct bt_graph *graph); BT_HIDDEN -void bt_notification_packet_beginning_recycle(struct bt_notification *notif); +void bt_message_packet_beginning_recycle(struct bt_message *msg); BT_HIDDEN -void bt_notification_packet_beginning_destroy(struct bt_notification *notif); +void bt_message_packet_beginning_destroy(struct bt_message *msg); BT_HIDDEN -struct bt_notification *bt_notification_packet_end_new(struct bt_graph *graph); +struct bt_message *bt_message_packet_end_new(struct bt_graph *graph); BT_HIDDEN -void bt_notification_packet_end_recycle(struct bt_notification *notif); +void bt_message_packet_end_recycle(struct bt_message *msg); BT_HIDDEN -void bt_notification_packet_end_destroy(struct bt_notification *notif); +void bt_message_packet_end_destroy(struct bt_message *msg); -#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-packet.h b/include/babeltrace/graph/message-packet.h similarity index 68% rename from include/babeltrace/graph/notification-packet.h rename to include/babeltrace/graph/message-packet.h index 0b4cca97..0ee0f6dc 100644 --- a/include/babeltrace/graph/notification-packet.h +++ b/include/babeltrace/graph/message-packet.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_PACKET_H -#define BABELTRACE_GRAPH_NOTIFICATION_PACKET_H +#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_H +#define BABELTRACE_GRAPH_MESSAGE_PACKET_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,7 +24,7 @@ * SOFTWARE. */ -/* For bt_notification, bt_self_notification_iterator, bt_packet */ +/* For bt_message, bt_self_message_iterator, bt_packet */ #include #ifdef __cplusplus @@ -32,23 +32,23 @@ extern "C" { #endif extern -bt_notification *bt_notification_packet_beginning_create( - bt_self_notification_iterator *notification_iterator, +bt_message *bt_message_packet_beginning_create( + bt_self_message_iterator *message_iterator, bt_packet *packet); extern -bt_notification *bt_notification_packet_end_create( - bt_self_notification_iterator *notification_iterator, +bt_message *bt_message_packet_end_create( + bt_self_message_iterator *message_iterator, bt_packet *packet); -extern bt_packet *bt_notification_packet_beginning_borrow_packet( - bt_notification *notification); +extern bt_packet *bt_message_packet_beginning_borrow_packet( + bt_message *message); -extern bt_packet *bt_notification_packet_end_borrow_packet( - bt_notification *notification); +extern bt_packet *bt_message_packet_end_borrow_packet( + bt_message *message); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_H */ diff --git a/include/babeltrace/graph/notification-stream-const.h b/include/babeltrace/graph/message-stream-const.h similarity index 68% rename from include/babeltrace/graph/notification-stream-const.h rename to include/babeltrace/graph/message-stream-const.h index fdbcecfc..9c050e91 100644 --- a/include/babeltrace/graph/notification-stream-const.h +++ b/include/babeltrace/graph/message-stream-const.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H /* * Copyright 2017-2018 Philippe Proulx @@ -24,29 +24,29 @@ * SOFTWARE. */ -/* For bt_notification, bt_clock_value, bt_stream */ +/* For bt_message, bt_clock_value, bt_stream */ #include #ifdef __cplusplus extern "C" { #endif -extern const bt_stream *bt_notification_stream_beginning_borrow_stream_const( - const bt_notification *notification); +extern const bt_stream *bt_message_stream_beginning_borrow_stream_const( + const bt_message *message); extern const bt_clock_value * -bt_notification_stream_beginning_borrow_default_clock_value_const( - const bt_notification *notif); +bt_message_stream_beginning_borrow_default_clock_value_const( + const bt_message *msg); -extern const bt_stream *bt_notification_stream_end_borrow_stream_const( - const bt_notification *notification); +extern const bt_stream *bt_message_stream_end_borrow_stream_const( + const bt_message *message); extern const bt_clock_value * -bt_notification_stream_end_borrow_default_clock_value_const( - const bt_notification *notif); +bt_message_stream_end_borrow_default_clock_value_const( + const bt_message *msg); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_CONST_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_CONST_H */ diff --git a/include/babeltrace/graph/notification-stream-internal.h b/include/babeltrace/graph/message-stream-internal.h similarity index 80% rename from include/babeltrace/graph/notification-stream-internal.h rename to include/babeltrace/graph/message-stream-internal.h index 2cfe2687..b9601b4f 100644 --- a/include/babeltrace/graph/notification-stream-internal.h +++ b/include/babeltrace/graph/message-stream-internal.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H /* * Copyright 2017-2018 Philippe Proulx @@ -26,20 +26,20 @@ #include #include -#include +#include #include #include -struct bt_notification_stream_beginning { - struct bt_notification parent; +struct bt_message_stream_beginning { + struct bt_message parent; struct bt_stream *stream; struct bt_clock_value *default_cv; }; -struct bt_notification_stream_end { - struct bt_notification parent; +struct bt_message_stream_end { + struct bt_message parent; struct bt_stream *stream; struct bt_clock_value *default_cv; }; -#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H */ +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H */ diff --git a/include/babeltrace/graph/message-stream.h b/include/babeltrace/graph/message-stream.h new file mode 100644 index 00000000..f025396e --- /dev/null +++ b/include/babeltrace/graph/message-stream.h @@ -0,0 +1,60 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_H +#define BABELTRACE_GRAPH_MESSAGE_STREAM_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* For bt_message, bt_self_message_iterator, bt_stream */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern +bt_message *bt_message_stream_beginning_create( + bt_self_message_iterator *message_iterator, + bt_stream *stream); + +extern +bt_message *bt_message_stream_end_create( + bt_self_message_iterator *message_iterator, + bt_stream *stream); + +extern bt_stream *bt_message_stream_beginning_borrow_stream( + bt_message *message); + +extern void bt_message_stream_beginning_set_default_clock_value( + bt_message *msg, uint64_t value_cycles); + +extern bt_stream *bt_message_stream_end_borrow_stream( + bt_message *message); + +extern void bt_message_stream_end_set_default_clock_value( + bt_message *msg, uint64_t value_cycles); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_H */ diff --git a/include/babeltrace/graph/notification-internal.h b/include/babeltrace/graph/notification-internal.h deleted file mode 100644 index 1375bc8b..00000000 --- a/include/babeltrace/graph/notification-internal.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_NOTIFICATION_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_NOTIFICATION_INTERNAL_H - -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2015 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct bt_stream *(*get_stream_func)( - struct bt_notification *notification); - -struct bt_notification { - struct bt_object base; - enum bt_notification_type type; - uint64_t seq_num; - bt_bool frozen; - - /* Owned by this; keeps the graph alive while the notif. is alive */ - struct bt_graph *graph; -}; - -#define BT_ASSERT_PRE_NOTIF_IS_TYPE(_notif, _type) \ - BT_ASSERT_PRE(((struct bt_notification *) (_notif))->type == (_type), \ - "Notification has the wrong type: expected-type=%s, " \ - "%![notif-]+n", bt_notification_type_string(_type), \ - (_notif)) - -BT_HIDDEN -void bt_notification_init(struct bt_notification *notification, - enum bt_notification_type type, - bt_object_release_func release, - struct bt_graph *graph); - -static inline -void bt_notification_reset(struct bt_notification *notification) -{ - BT_ASSERT(notification); - -#ifdef BT_DEV_MODE - notification->frozen = BT_FALSE; - notification->seq_num = UINT64_C(-1); -#endif -} - -static inline -struct bt_notification *bt_notification_create_from_pool( - struct bt_object_pool *pool, struct bt_graph *graph) -{ - struct bt_notification *notif = bt_object_pool_create_object(pool); - - if (unlikely(!notif)) { -#ifdef BT_LIB_LOGE - BT_LIB_LOGE("Cannot allocate one notification from notification pool: " - "%![pool-]+o, %![graph-]+g", pool, graph); -#endif - goto error; - } - - if (likely(!notif->graph)) { - notif->graph = graph; - } - - goto end; - -error: - BT_ASSERT(!notif); - -end: - return notif; -} - -static inline void _bt_notification_freeze(struct bt_notification *notification) -{ - notification->frozen = BT_TRUE; -} - -BT_HIDDEN -void bt_notification_unlink_graph(struct bt_notification *notif); - -#ifdef BT_DEV_MODE -# define bt_notification_freeze _bt_notification_freeze -#else -# define bt_notification_freeze(_x) -#endif /* BT_DEV_MODE */ - -static inline -const char *bt_notification_type_string(enum bt_notification_type type) -{ - switch (type) { - case BT_NOTIFICATION_TYPE_EVENT: - return "BT_NOTIFICATION_TYPE_EVENT"; - case BT_NOTIFICATION_TYPE_INACTIVITY: - return "BT_NOTIFICATION_TYPE_INACTIVITY"; - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: - return "BT_NOTIFICATION_TYPE_STREAM_BEGINNING"; - case BT_NOTIFICATION_TYPE_STREAM_END: - return "BT_NOTIFICATION_TYPE_STREAM_END"; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - return "BT_NOTIFICATION_TYPE_PACKET_BEGINNING"; - case BT_NOTIFICATION_TYPE_PACKET_END: - return "BT_NOTIFICATION_TYPE_PACKET_END"; - default: - return "(unknown)"; - } -} - -#endif /* BABELTRACE_GRAPH_NOTIFICATION_NOTIFICATION_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-iterator-internal.h b/include/babeltrace/graph/notification-iterator-internal.h deleted file mode 100644 index 28a322f1..00000000 --- a/include/babeltrace/graph/notification-iterator-internal.h +++ /dev/null @@ -1,170 +0,0 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H -#define BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H - -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2015 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct bt_port; -struct bt_graph; - -enum bt_notification_iterator_type { - BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT, - BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT, -}; - -enum bt_self_component_port_input_notification_iterator_state { - /* Iterator is not initialized. */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED, - - /* Iterator is active, not at the end yet, and not finalized. */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE, - - /* - * Iterator is ended, not finalized yet: the "next" method - * returns BT_NOTIFICATION_ITERATOR_STATUS_END. - */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED, - - /* - * Iterator is finalized, but not at the end yet. This means - * that the "next" method can still return queued notifications - * before returning the BT_NOTIFICATION_ITERATOR_STATUS_CANCELED - * status. - */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED, - - /* - * Iterator is finalized and ended: the "next" method always - * returns BT_NOTIFICATION_ITERATOR_STATUS_CANCELED. - */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED, -}; - -struct bt_notification_iterator { - struct bt_object base; - enum bt_notification_iterator_type type; - GPtrArray *notifs; -}; - -struct bt_self_component_port_input_notification_iterator { - struct bt_notification_iterator base; - struct bt_component *upstream_component; /* Weak */ - struct bt_port *upstream_port; /* Weak */ - struct bt_connection *connection; /* Weak */ - struct bt_graph *graph; /* Weak */ - - /* - * This hash table keeps the state of a stream as viewed by - * this notification iterator. This is used to, in developer - * mode: - * - * * Automatically enqueue "stream begin", "packet begin", - * "packet end", and "stream end" notifications depending - * on the stream's state and on the next notification returned - * by the upstream component. - * - * * Make sure that, once the notification iterator has seen a - * "stream end" notification for a given stream, no other - * notifications which refer to this stream can be delivered - * by this iterator. - * - * The key (struct bt_stream *) is not owned by this. The - * value is an allocated state structure. - */ - GHashTable *stream_states; - - enum bt_self_component_port_input_notification_iterator_state state; - void *user_data; -}; - -struct bt_port_output_notification_iterator { - struct bt_notification_iterator base; - struct bt_graph *graph; /* Owned by this */ - struct bt_component_sink *colander; /* Owned by this */ - - /* - * Only used temporarily as a bridge between a colander sink and - * the user. - */ - uint64_t count; -}; - -BT_HIDDEN -void bt_self_component_port_input_notification_iterator_finalize( - struct bt_self_component_port_input_notification_iterator *iterator); - -BT_HIDDEN -void bt_self_component_port_input_notification_iterator_set_connection( - struct bt_self_component_port_input_notification_iterator *iterator, - struct bt_connection *connection); - -static inline -const char *bt_notification_iterator_status_string( - enum bt_notification_iterator_status status) -{ - switch (status) { - case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED: - return "BT_NOTIFICATION_ITERATOR_STATUS_CANCELED"; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: - return "BT_NOTIFICATION_ITERATOR_STATUS_AGAIN"; - case BT_NOTIFICATION_ITERATOR_STATUS_END: - return "BT_NOTIFICATION_ITERATOR_STATUS_END"; - case BT_NOTIFICATION_ITERATOR_STATUS_OK: - return "BT_NOTIFICATION_ITERATOR_STATUS_OK"; - case BT_NOTIFICATION_ITERATOR_STATUS_ERROR: - return "BT_NOTIFICATION_ITERATOR_STATUS_ERROR"; - case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM: - return "BT_NOTIFICATION_ITERATOR_STATUS_NOMEM"; - default: - return "(unknown)"; - } -}; - -static inline -const char *bt_self_component_port_input_notification_iterator_state_string( - enum bt_self_component_port_input_notification_iterator_state state) -{ - switch (state) { - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE: - return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE"; - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED: - return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED"; - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED: - return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED"; - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED: - return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED"; - default: - return "(unknown)"; - } -}; - -#endif /* BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H */ diff --git a/include/babeltrace/graph/notification-stream.h b/include/babeltrace/graph/notification-stream.h deleted file mode 100644 index ac9ee65b..00000000 --- a/include/babeltrace/graph/notification-stream.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_STREAM_H -#define BABELTRACE_GRAPH_NOTIFICATION_STREAM_H - -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2016 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* For bt_notification, bt_self_notification_iterator, bt_stream */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern -bt_notification *bt_notification_stream_beginning_create( - bt_self_notification_iterator *notification_iterator, - bt_stream *stream); - -extern -bt_notification *bt_notification_stream_end_create( - bt_self_notification_iterator *notification_iterator, - bt_stream *stream); - -extern bt_stream *bt_notification_stream_beginning_borrow_stream( - bt_notification *notification); - -extern void bt_notification_stream_beginning_set_default_clock_value( - bt_notification *notif, uint64_t value_cycles); - -extern bt_stream *bt_notification_stream_end_borrow_stream( - bt_notification *notification); - -extern void bt_notification_stream_end_set_default_clock_value( - bt_notification *notif, uint64_t value_cycles); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_H */ diff --git a/include/babeltrace/graph/port-output-notification-iterator.h b/include/babeltrace/graph/port-output-message-iterator.h similarity index 51% rename from include/babeltrace/graph/port-output-notification-iterator.h rename to include/babeltrace/graph/port-output-message-iterator.h index ceec9141..41d8d288 100644 --- a/include/babeltrace/graph/port-output-notification-iterator.h +++ b/include/babeltrace/graph/port-output-message-iterator.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H -#define BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H +#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H +#define BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H /* * Copyright 2017-2018 Philippe Proulx @@ -25,13 +25,13 @@ #include -/* For enum bt_notification_iterator_status */ -#include +/* For enum bt_message_iterator_status */ +#include /* - * For bt_port, bt_notification, bt_notification_iterator, - * bt_port_output_notification_iterator, bt_graph, bt_port_output, - * bt_notification_array_const + * For bt_port, bt_message, bt_message_iterator, + * bt_port_output_message_iterator, bt_graph, bt_port_output, + * bt_message_array_const */ #include @@ -40,38 +40,38 @@ extern "C" { #endif static inline -bt_notification_iterator * -bt_port_output_notification_iterator_as_notification_iterator( - bt_port_output_notification_iterator *iterator) +bt_message_iterator * +bt_port_output_message_iterator_as_message_iterator( + bt_port_output_message_iterator *iterator) { return (void *) iterator; } -extern bt_port_output_notification_iterator * -bt_port_output_notification_iterator_create( +extern bt_port_output_message_iterator * +bt_port_output_message_iterator_create( bt_graph *graph, const bt_port_output *output_port); -extern enum bt_notification_iterator_status -bt_port_output_notification_iterator_next( - bt_port_output_notification_iterator *iterator, - bt_notification_array_const *notifs, uint64_t *count); +extern enum bt_message_iterator_status +bt_port_output_message_iterator_next( + bt_port_output_message_iterator *iterator, + bt_message_array_const *msgs, uint64_t *count); -extern void bt_port_output_notification_iterator_get_ref( - const bt_port_output_notification_iterator *port_output_notification_iterator); +extern void bt_port_output_message_iterator_get_ref( + const bt_port_output_message_iterator *port_output_message_iterator); -extern void bt_port_output_notification_iterator_put_ref( - const bt_port_output_notification_iterator *port_output_notification_iterator); +extern void bt_port_output_message_iterator_put_ref( + const bt_port_output_message_iterator *port_output_message_iterator); -#define BT_PORT_OUTPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(_var) \ +#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(_var) \ do { \ - bt_port_output_notification_iterator_put_ref(_var); \ + bt_port_output_message_iterator_put_ref(_var); \ (_var) = NULL; \ } while (0) -#define BT_PORT_OUTPUT_NOTIFICATION_ITERATOR_MOVE_REF(_var_dst, _var_src) \ +#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_MOVE_REF(_var_dst, _var_src) \ do { \ - bt_port_output_notification_iterator_put_ref(_var_dst); \ + bt_port_output_message_iterator_put_ref(_var_dst); \ (_var_dst) = (_var_src); \ (_var_src) = NULL; \ } while (0) @@ -80,4 +80,4 @@ extern void bt_port_output_notification_iterator_put_ref( } #endif -#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_NOTIFICATION_ITERATOR_H */ +#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H */ diff --git a/include/babeltrace/graph/self-component-port-input-message-iterator.h b/include/babeltrace/graph/self-component-port-input-message-iterator.h new file mode 100644 index 00000000..c952f520 --- /dev/null +++ b/include/babeltrace/graph/self-component-port-input-message-iterator.h @@ -0,0 +1,86 @@ +#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_H +#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_H + +/* + * Copyright 2017-2018 Philippe Proulx + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +/* For enum bt_message_iterator_status */ +#include + +/* + * For bt_component, bt_message_iterator, + * bt_self_component_port_input_message_iterator, + * bt_self_component_port_input, bt_message_array_const + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline +bt_message_iterator * +bt_self_component_port_input_message_iterator_as_message_iterator( + bt_self_component_port_input_message_iterator *iterator) +{ + return (void *) iterator; +} + +extern bt_self_component_port_input_message_iterator * +bt_self_component_port_input_message_iterator_create( + bt_self_component_port_input *input_port); + +extern bt_component * +bt_self_component_port_input_message_iterator_borrow_component( + bt_self_component_port_input_message_iterator *iterator); + +extern enum bt_message_iterator_status +bt_self_component_port_input_message_iterator_next( + bt_self_component_port_input_message_iterator *iterator, + bt_message_array_const *msgs, uint64_t *count); + +extern void bt_self_component_port_input_message_iterator_get_ref( + const bt_self_component_port_input_message_iterator *self_component_port_input_message_iterator); + +extern void bt_self_component_port_input_message_iterator_put_ref( + const bt_self_component_port_input_message_iterator *self_component_port_input_message_iterator); + +#define BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(_var) \ + do { \ + bt_self_component_port_input_message_iterator_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_self_component_port_input_message_iterator_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_H */ diff --git a/include/babeltrace/graph/self-component-port-input-notification-iterator.h b/include/babeltrace/graph/self-component-port-input-notification-iterator.h deleted file mode 100644 index 0f8712bc..00000000 --- a/include/babeltrace/graph/self-component-port-input-notification-iterator.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H -#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H - -/* - * Copyright 2017-2018 Philippe Proulx - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -/* For enum bt_notification_iterator_status */ -#include - -/* - * For bt_component, bt_notification_iterator, - * bt_self_component_port_input_notification_iterator, - * bt_self_component_port_input, bt_notification_array_const - */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -static inline -bt_notification_iterator * -bt_self_component_port_input_notification_iterator_as_notification_iterator( - bt_self_component_port_input_notification_iterator *iterator) -{ - return (void *) iterator; -} - -extern bt_self_component_port_input_notification_iterator * -bt_self_component_port_input_notification_iterator_create( - bt_self_component_port_input *input_port); - -extern bt_component * -bt_self_component_port_input_notification_iterator_borrow_component( - bt_self_component_port_input_notification_iterator *iterator); - -extern enum bt_notification_iterator_status -bt_self_component_port_input_notification_iterator_next( - bt_self_component_port_input_notification_iterator *iterator, - bt_notification_array_const *notifs, uint64_t *count); - -extern void bt_self_component_port_input_notification_iterator_get_ref( - const bt_self_component_port_input_notification_iterator *self_component_port_input_notification_iterator); - -extern void bt_self_component_port_input_notification_iterator_put_ref( - const bt_self_component_port_input_notification_iterator *self_component_port_input_notification_iterator); - -#define BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(_var) \ - do { \ - bt_self_component_port_input_notification_iterator_put_ref(_var); \ - (_var) = NULL; \ - } while (0) - -#define BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF(_var_dst, _var_src) \ - do { \ - bt_self_component_port_input_notification_iterator_put_ref(_var_dst); \ - (_var_dst) = (_var_src); \ - (_var_src) = NULL; \ - } while (0) - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_H */ diff --git a/include/babeltrace/graph/self-notification-iterator.h b/include/babeltrace/graph/self-message-iterator.h similarity index 51% rename from include/babeltrace/graph/self-notification-iterator.h rename to include/babeltrace/graph/self-message-iterator.h index bac1875a..90143e30 100644 --- a/include/babeltrace/graph/self-notification-iterator.h +++ b/include/babeltrace/graph/self-message-iterator.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H -#define BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H +#ifndef BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H +#define BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H /* * Copyright 2017-2018 Philippe Proulx @@ -23,41 +23,41 @@ * SOFTWARE. */ -/* For BT_NOTIFICATION_ITERATOR_STATUS_* */ -#include +/* For BT_MESSAGE_ITERATOR_STATUS_* */ +#include -/* For bt_self_component, bt_self_notification_iterator, bt_self_port_output */ +/* For bt_self_component, bt_self_message_iterator, bt_self_port_output */ #include #ifdef __cplusplus extern "C" { #endif -enum bt_self_notification_iterator_status { - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK = BT_NOTIFICATION_ITERATOR_STATUS_OK, - BT_SELF_NOTIFICATION_ITERATOR_STATUS_END = BT_NOTIFICATION_ITERATOR_STATUS_END, - BT_SELF_NOTIFICATION_ITERATOR_STATUS_AGAIN = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN, - BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR = BT_NOTIFICATION_ITERATOR_STATUS_ERROR, - BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM, +enum bt_self_message_iterator_status { + BT_SELF_MESSAGE_ITERATOR_STATUS_OK = BT_MESSAGE_ITERATOR_STATUS_OK, + BT_SELF_MESSAGE_ITERATOR_STATUS_END = BT_MESSAGE_ITERATOR_STATUS_END, + BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN = BT_MESSAGE_ITERATOR_STATUS_AGAIN, + BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR = BT_MESSAGE_ITERATOR_STATUS_ERROR, + BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM = BT_MESSAGE_ITERATOR_STATUS_NOMEM, }; extern bt_self_component * -bt_self_notification_iterator_borrow_component( - bt_self_notification_iterator *notification_iterator); +bt_self_message_iterator_borrow_component( + bt_self_message_iterator *message_iterator); extern bt_self_port_output * -bt_self_notification_iterator_borrow_port( - bt_self_notification_iterator *notification_iterator); +bt_self_message_iterator_borrow_port( + bt_self_message_iterator *message_iterator); -extern void bt_self_notification_iterator_set_data( - bt_self_notification_iterator *notification_iterator, +extern void bt_self_message_iterator_set_data( + bt_self_message_iterator *message_iterator, void *user_data); -extern void *bt_self_notification_iterator_get_data( - const bt_self_notification_iterator *notification_iterator); +extern void *bt_self_message_iterator_get_data( + const bt_self_message_iterator *message_iterator); #ifdef __cplusplus } #endif -#endif /* BABELTRACE_GRAPH_SELF_NOTIFICATION_ITERATOR_H */ +#endif /* BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H */ diff --git a/include/babeltrace/lib-logging-internal.h b/include/babeltrace/lib-logging-internal.h index a936488b..5c3fad42 100644 --- a/include/babeltrace/lib-logging-internal.h +++ b/include/babeltrace/lib-logging-internal.h @@ -121,11 +121,11 @@ int bt_lib_log_level; * Value. The parameter type is `struct bt_value *`. * * `n`: - * Notification. The parameter type is `struct bt_notification *`. + * Message. The parameter type is `struct bt_message *`. * * `i`: - * Notification iterator. The parameter type is - * `struct bt_notification_iterator *`. + * Message iterator. The parameter type is + * `struct bt_message_iterator *`. * * `C`: * Component class. The parameter type is `struct diff --git a/include/babeltrace/plugin/plugin-dev.h b/include/babeltrace/plugin/plugin-dev.h index ca6e9080..94bfb700 100644 --- a/include/babeltrace/plugin/plugin-dev.h +++ b/include/babeltrace/plugin/plugin-dev.h @@ -150,12 +150,12 @@ struct __bt_plugin_component_class_descriptor { union { /* BT_COMPONENT_CLASS_TYPE_SOURCE */ struct { - bt_component_class_source_notification_iterator_next_method notif_iter_next; + bt_component_class_source_message_iterator_next_method msg_iter_next; } source; /* BT_COMPONENT_CLASS_TYPE_FILTER */ struct { - bt_component_class_filter_notification_iterator_next_method notif_iter_next; + bt_component_class_filter_message_iterator_next_method msg_iter_next; } filter; /* BT_COMPONENT_CLASS_TYPE_SINK */ @@ -178,8 +178,8 @@ enum __bt_plugin_component_class_descriptor_attribute_type { BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD = 8, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD = 9, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD = 10, - BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD = 11, - BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD = 12, + BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD = 11, + BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD = 12, }; /* Component class attribute (internal use) */ @@ -243,13 +243,13 @@ struct __bt_plugin_component_class_descriptor_attribute { bt_component_class_source_output_port_disconnected_method source_output_port_disconnected_method; bt_component_class_filter_output_port_disconnected_method filter_output_port_disconnected_method; - /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD */ - bt_component_class_source_notification_iterator_init_method source_notif_iter_init_method; - bt_component_class_filter_notification_iterator_init_method filter_notif_iter_init_method; + /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD */ + bt_component_class_source_message_iterator_init_method source_msg_iter_init_method; + bt_component_class_filter_message_iterator_init_method filter_msg_iter_init_method; - /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD */ - bt_component_class_source_notification_iterator_finalize_method source_notif_iter_finalize_method; - bt_component_class_filter_notification_iterator_finalize_method filter_notif_iter_finalize_method; + /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD */ + bt_component_class_source_message_iterator_finalize_method source_msg_iter_finalize_method; + bt_component_class_filter_message_iterator_finalize_method filter_msg_iter_finalize_method; } value; } __attribute__((packed)); @@ -514,16 +514,16 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: ID (any valid C identifier except `auto`). * _comp_class_id: Component class ID (C identifier). * _name: Component class name (C string). - * _notif_iter_next_method: Component class's iterator next method - * (bt_component_class_source_notification_iterator_next_method). + * _msg_iter_next_method: Component class's iterator next method + * (bt_component_class_source_message_iterator_next_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \ +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _msg_iter_next_method) \ static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \ .name = _name, \ .type = BT_COMPONENT_CLASS_TYPE_SOURCE, \ .methods.source = { \ - .notif_iter_next = _notif_iter_next_method, \ + .msg_iter_next = _msg_iter_next_method, \ }, \ }; \ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id @@ -534,16 +534,16 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: ID (any valid C identifier except `auto`). * _comp_class_id: Component class ID (C identifier). * _name: Component class name (C string). - * _notif_iter_next_method: Component class's iterator next method - * (bt_component_class_filter_notification_iterator_next_method). + * _msg_iter_next_method: Component class's iterator next method + * (bt_component_class_filter_message_iterator_next_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _notif_iter_next_method) \ +#define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _msg_iter_next_method) \ static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \ .name = _name, \ .type = BT_COMPONENT_CLASS_TYPE_FILTER, \ .methods.filter = { \ - .notif_iter_next = _notif_iter_next_method, \ + .msg_iter_next = _msg_iter_next_method, \ }, \ }; \ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id @@ -905,10 +905,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator initialization method - * (bt_component_class_source_notification_iterator_init_method). + * (bt_component_class_source_message_iterator_init_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, source, _x) +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD, _id, _comp_class_id, source, _x) /* * Defines an iterator finalize method attribute attached to a specific @@ -917,10 +917,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator finalize method - * (bt_component_class_source_notification_iterator_finalize_method). + * (bt_component_class_source_message_iterator_finalize_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x) +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x) /* * Defines an iterator initialization method attribute attached to a @@ -929,10 +929,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator initialization method - * (bt_component_class_filter_notification_iterator_init_method). + * (bt_component_class_filter_message_iterator_init_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_notif_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x) +#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD, _id, _comp_class_id, filter, _x) /* * Defines an iterator finalize method attribute attached to a specific @@ -941,10 +941,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * _id: Plugin descriptor ID (C identifier). * _comp_class_id: Component class descriptor ID (C identifier). * _x: Iterator finalize method - * (bt_component_class_filter_notification_iterator_finalize_method). + * (bt_component_class_filter_message_iterator_finalize_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_notif_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) +#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) /* * Defines a plugin descriptor with an automatic ID. @@ -1010,11 +1010,11 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * C identifier in this version. * * _name: Component class name (C identifier). - * _notif_iter_next_method: Component class's iterator next method - * (bt_component_class_source_notification_iterator_next_method). + * _msg_iter_next_method: Component class's iterator next method + * (bt_component_class_source_message_iterator_next_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _notif_iter_next_method) \ - BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method) +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _msg_iter_next_method) \ + BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _msg_iter_next_method) /* * Defines a filter component class attached to the automatic plugin @@ -1022,11 +1022,11 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * C identifier in this version. * * _name: Component class name (C identifier). - * _notif_iter_next_method: Component class's iterator next method - * (bt_component_class_filter_notification_iterator_next_method). + * _msg_iter_next_method: Component class's iterator next method + * (bt_component_class_filter_message_iterator_next_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _notif_iter_next_method) \ - BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _notif_iter_next_method) +#define BT_PLUGIN_FILTER_COMPONENT_CLASS(_name, _msg_iter_next_method) \ + BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _msg_iter_next_method) /* * Defines a sink component class attached to the automatic plugin @@ -1341,10 +1341,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator initialization method - * (bt_component_class_source_notification_iterator_init_method). + * (bt_component_class_source_message_iterator_init_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \ - BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x) +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(_name, _x) \ + BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x) /* * Defines an iterator finalize method attribute attached to a source @@ -1353,10 +1353,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator finalize method - * (bt_component_class_source_notification_iterator_finalize_method). + * (bt_component_class_source_message_iterator_finalize_method). */ -#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(_name, _x) \ - BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x) +#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(_name, _x) \ + BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x) /* * Defines an iterator initialization method attribute attached to a @@ -1365,10 +1365,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator initialization method - * (bt_component_class_filter_notification_iterator_init_method). + * (bt_component_class_filter_message_iterator_init_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(_name, _x) \ - BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x) +#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(_name, _x) \ + BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x) /* * Defines an iterator finalize method attribute attached to a filter @@ -1377,10 +1377,10 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * * _name: Component class name (C identifier). * _x: Iterator finalize method - * (bt_component_class_filter_notification_iterator_finalize_method). + * (bt_component_class_filter_message_iterator_finalize_method). */ -#define BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(_name, _x) \ - BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x) +#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(_name, _x) \ + BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(auto, _name, _x) #define BT_PLUGIN_MODULE() \ static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_dummy __BT_PLUGIN_DESCRIPTOR_ATTRS = NULL; \ diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index f63e7d94..bf4c72d9 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -97,8 +97,8 @@ typedef struct bt_field_class_signed_enumeration_mapping_ranges bt_field_class_s typedef struct bt_field_class_unsigned_enumeration_mapping_ranges bt_field_class_unsigned_enumeration_mapping_ranges; typedef struct bt_field_path bt_field_path; typedef struct bt_graph bt_graph; -typedef struct bt_notification bt_notification; -typedef struct bt_notification_iterator bt_notification_iterator; +typedef struct bt_message bt_message; +typedef struct bt_message_iterator bt_message_iterator; typedef struct bt_object bt_object; typedef struct bt_packet bt_packet; typedef struct bt_packet_context_field bt_packet_context_field; @@ -109,7 +109,7 @@ typedef struct bt_plugin_so_shared_lib_handle bt_plugin_so_shared_lib_handle; typedef struct bt_port bt_port; typedef struct bt_port_input bt_port_input; typedef struct bt_port_output bt_port_output; -typedef struct bt_port_output_notification_iterator bt_port_output_notification_iterator; +typedef struct bt_port_output_message_iterator bt_port_output_message_iterator; typedef struct bt_query_executor bt_query_executor; typedef struct bt_self_component bt_self_component; typedef struct bt_self_component_class_filter bt_self_component_class_filter; @@ -118,14 +118,14 @@ typedef struct bt_self_component_class_source bt_self_component_class_source; typedef struct bt_self_component_filter bt_self_component_filter; typedef struct bt_self_component_port bt_self_component_port; typedef struct bt_self_component_port_input bt_self_component_port_input; -typedef struct bt_self_component_port_input_notification_iterator bt_self_component_port_input_notification_iterator; +typedef struct bt_self_component_port_input_message_iterator bt_self_component_port_input_message_iterator; typedef struct bt_self_component_port_output bt_self_component_port_output; typedef struct bt_self_component_sink bt_self_component_sink; typedef struct bt_self_component_source bt_self_component_source; -typedef struct bt_self_notification_iterator bt_self_notification_iterator; +typedef struct bt_self_message_iterator bt_self_message_iterator; +typedef struct bt_self_port bt_self_port; typedef struct bt_self_port_input bt_self_port_input; typedef struct bt_self_port_output bt_self_port_output; -typedef struct bt_self_port bt_self_port; typedef struct bt_stream bt_stream; typedef struct bt_stream_class bt_stream_class; typedef struct bt_trace bt_trace; @@ -133,7 +133,7 @@ typedef struct bt_trace_class bt_trace_class; typedef struct bt_value bt_value; typedef const char * const *bt_field_class_enumeration_mapping_label_array; -typedef const struct bt_notification **bt_notification_array_const; +typedef const struct bt_message **bt_message_array_const; /** @} */ diff --git a/lib/graph/Makefile.am b/lib/graph/Makefile.am index 6be66696..bd373ef7 100644 --- a/lib/graph/Makefile.am +++ b/lib/graph/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = notification +SUBDIRS = message noinst_LTLIBRARIES = libgraph.la @@ -17,4 +17,4 @@ libgraph_la_SOURCES = \ query-executor.c libgraph_la_LIBADD = \ - notification/libgraph-notification.la + message/libgraph-message.la diff --git a/lib/graph/component-class-sink-colander.c b/lib/graph/component-class-sink-colander.c index 58217675..36d764e3 100644 --- a/lib/graph/component-class-sink-colander.c +++ b/lib/graph/component-class-sink-colander.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,9 +38,9 @@ static struct bt_component_class_sink *colander_comp_cls; struct colander_data { - bt_notification_array_const notifs; + bt_message_array_const msgs; uint64_t *count_addr; - struct bt_self_component_port_input_notification_iterator *notif_iter; + struct bt_self_component_port_input_message_iterator *msg_iter; }; static @@ -66,7 +66,7 @@ enum bt_self_component_status colander_init( goto end; } - colander_data->notifs = user_provided_data->notifs; + colander_data->msgs = user_provided_data->msgs; colander_data->count_addr = user_provided_data->count_addr; status = bt_self_component_sink_add_input_port(self_comp, "in", NULL, NULL); @@ -94,7 +94,7 @@ void colander_finalize(struct bt_self_component_sink *self_comp) return; } - BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter); + BT_OBJECT_PUT_REF_AND_RESET(colander_data->msg_iter); g_free(colander_data); } @@ -110,12 +110,12 @@ enum bt_self_component_status colander_input_port_connected( bt_self_component_sink_as_self_component(self_comp)); BT_ASSERT(colander_data); - BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter); - colander_data->notif_iter = - bt_self_component_port_input_notification_iterator_create( + BT_OBJECT_PUT_REF_AND_RESET(colander_data->msg_iter); + colander_data->msg_iter = + bt_self_component_port_input_message_iterator_create( self_port); - if (!colander_data->notif_iter) { - BT_LIB_LOGE("Cannot create notification iterator on " + if (!colander_data->msg_iter) { + BT_LIB_LOGE("Cannot create message iterator on " "self component input port: %![port-]+p", self_port); status = BT_SELF_COMPONENT_STATUS_NOMEM; @@ -131,39 +131,39 @@ enum bt_self_component_status colander_consume( struct bt_self_component_sink *self_comp) { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; - enum bt_notification_iterator_status notif_iter_status; + enum bt_message_iterator_status msg_iter_status; struct colander_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); - bt_notification_array_const notifs; + bt_message_array_const msgs; BT_ASSERT(colander_data); - if (!colander_data->notif_iter) { + if (!colander_data->msg_iter) { BT_LIB_LOGW("Trying to consume without an " - "upstream notification iterator: %![comp-]+c", + "upstream message iterator: %![comp-]+c", self_comp); goto end; } - notif_iter_status = - bt_self_component_port_input_notification_iterator_next( - colander_data->notif_iter, ¬ifs, + msg_iter_status = + bt_self_component_port_input_message_iterator_next( + colander_data->msg_iter, &msgs, colander_data->count_addr); - switch (notif_iter_status) { - case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED: + switch (msg_iter_status) { + case BT_MESSAGE_ITERATOR_STATUS_CANCELED: status = BT_SELF_COMPONENT_STATUS_OK; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: status = BT_SELF_COMPONENT_STATUS_AGAIN; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: status = BT_SELF_COMPONENT_STATUS_END; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_OK: - /* Move notifications to user (count already set) */ - memcpy(colander_data->notifs, notifs, - sizeof(*notifs) * *colander_data->count_addr); + case BT_MESSAGE_ITERATOR_STATUS_OK: + /* Move messages to user (count already set) */ + memcpy(colander_data->msgs, msgs, + sizeof(*msgs) * *colander_data->count_addr); break; default: status = BT_SELF_COMPONENT_STATUS_ERROR; diff --git a/lib/graph/component-class.c b/lib/graph/component-class.c index 12a3eec0..7ecf6a18 100644 --- a/lib/graph/component-class.c +++ b/lib/graph/component-class.c @@ -134,15 +134,15 @@ end: struct bt_component_class_source *bt_component_class_source_create( const char *name, - bt_component_class_source_notification_iterator_next_method method) + bt_component_class_source_message_iterator_next_method method) { struct bt_component_class_source *source_class = NULL; int ret; BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Notification iterator next method"); + BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); BT_LOGD("Creating source component class: " - "name=\"%s\", notif-iter-next-method-addr=%p", + "name=\"%s\", msg-iter-next-method-addr=%p", name, method); source_class = g_new0(struct bt_component_class_source, 1); if (!source_class) { @@ -163,7 +163,7 @@ struct bt_component_class_source *bt_component_class_source_create( goto end; } - source_class->methods.notif_iter_next = method; + source_class->methods.msg_iter_next = method; BT_LIB_LOGD("Created source component class: %!+C", source_class); end: @@ -172,15 +172,15 @@ end: struct bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_component_class_filter_notification_iterator_next_method method) + bt_component_class_filter_message_iterator_next_method method) { struct bt_component_class_filter *filter_class = NULL; int ret; BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Notification iterator next method"); + BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); BT_LOGD("Creating filter component class: " - "name=\"%s\", notif-iter-next-method-addr=%p", + "name=\"%s\", msg-iter-next-method-addr=%p", name, method); filter_class = g_new0(struct bt_component_class_filter, 1); if (!filter_class) { @@ -201,7 +201,7 @@ struct bt_component_class_filter *bt_component_class_filter_create( goto end; } - filter_class->methods.notif_iter_next = method; + filter_class->methods.msg_iter_next = method; BT_LIB_LOGD("Created filter component class: %!+C", filter_class); end: @@ -518,54 +518,54 @@ int bt_component_class_filter_set_output_port_disconnected_method( return 0; } -int bt_component_class_source_set_notification_iterator_init_method( +int bt_component_class_source_set_message_iterator_init_method( struct bt_component_class_source *comp_cls, - bt_component_class_source_notification_iterator_init_method method) + bt_component_class_source_message_iterator_init_method method) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.notif_iter_init = method; - BT_LIB_LOGV("Set source component class's notification iterator initialization method" + comp_cls->methods.msg_iter_init = method; + BT_LIB_LOGV("Set source component class's message iterator initialization method" ": %!+C", comp_cls); return 0; } -int bt_component_class_filter_set_notification_iterator_init_method( +int bt_component_class_filter_set_message_iterator_init_method( struct bt_component_class_filter *comp_cls, - bt_component_class_filter_notification_iterator_init_method method) + bt_component_class_filter_message_iterator_init_method method) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.notif_iter_init = method; - BT_LIB_LOGV("Set filter component class's notification iterator initialization method" + comp_cls->methods.msg_iter_init = method; + BT_LIB_LOGV("Set filter component class's message iterator initialization method" ": %!+C", comp_cls); return 0; } -int bt_component_class_source_set_notification_iterator_finalize_method( +int bt_component_class_source_set_message_iterator_finalize_method( struct bt_component_class_source *comp_cls, - bt_component_class_source_notification_iterator_finalize_method method) + bt_component_class_source_message_iterator_finalize_method method) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.notif_iter_finalize = method; - BT_LIB_LOGV("Set source component class's notification iterator finalization method" + comp_cls->methods.msg_iter_finalize = method; + BT_LIB_LOGV("Set source component class's message iterator finalization method" ": %!+C", comp_cls); return 0; } -int bt_component_class_filter_set_notification_iterator_finalize_method( +int bt_component_class_filter_set_message_iterator_finalize_method( struct bt_component_class_filter *comp_cls, - bt_component_class_filter_notification_iterator_finalize_method method) + bt_component_class_filter_message_iterator_finalize_method method) { BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.notif_iter_finalize = method; - BT_LIB_LOGV("Set filter component class's notification iterator finalization method" + comp_cls->methods.msg_iter_finalize = method; + BT_LIB_LOGV("Set filter component class's message iterator finalization method" ": %!+C", comp_cls); return 0; } diff --git a/lib/graph/component-source.c b/lib/graph/component-source.c index e23200a5..b1e44139 100644 --- a/lib/graph/component-source.c +++ b/lib/graph/component-source.c @@ -32,8 +32,8 @@ #include #include #include -#include -#include +#include +#include #include BT_HIDDEN diff --git a/lib/graph/component.c b/lib/graph/component.c index eb911861..13c2aa0d 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -483,7 +483,7 @@ void remove_port_by_index(struct bt_component *component, * below (in which its component is `NULL` as expected because * of the bt_object_set_parent() call below). * - * To avoid a destroyed port during the notification callback, + * To avoid a destroyed port during the message callback, * get a reference now, and put it (destroying the port if its * reference count is 0 at this point) after notifying the * graph's user. diff --git a/lib/graph/connection.c b/lib/graph/connection.c index ebe03903..84b1159f 100644 --- a/lib/graph/connection.c +++ b/lib/graph/connection.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -46,13 +46,13 @@ void destroy_connection(struct bt_object *obj) BT_LIB_LOGD("Destroying connection: %!+x", connection); /* - * Make sure that each notification iterator which was created + * Make sure that each message iterator which was created * for this connection is finalized before we destroy it. Once a - * notification iterator is finalized, all its method return - * NULL or the BT_NOTIFICATION_ITERATOR_STATUS_CANCELED status. + * message iterator is finalized, all its method return + * NULL or the BT_MESSAGE_ITERATOR_STATUS_CANCELED status. * * Because connections are destroyed before components within a - * graph, this ensures that notification iterators are always + * graph, this ensures that message iterators are always * finalized before their upstream component. * * Ending the connection does exactly this. We pass `false` to @@ -87,7 +87,7 @@ void try_remove_connection_from_graph(struct bt_connection *connection) * At this point we know that: * * 1. The connection is ended (ports were disconnected). - * 2. All the notification iterators that this connection + * 2. All the message iterators that this connection * created, if any, are finalized. * 3. The connection's reference count is 0, so only the * parent (graph) owns this connection after this call. @@ -168,7 +168,7 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) conn, try_remove_from_graph); /* - * Any of the following notification callback functions could + * Any of the following message callback functions could * remove one of the connection's ports from its component. To * make sure that at least logging in called functions works * with existing objects, get a local reference on both ports. @@ -194,29 +194,29 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) conn->upstream_port = NULL; } - if (downstream_comp && conn->notified_downstream_port_connected && - !conn->notified_downstream_port_disconnected) { + if (downstream_comp && conn->msgied_downstream_port_connected && + !conn->msgied_downstream_port_disconnected) { /* bt_component_port_disconnected() logs details */ bt_component_port_disconnected(downstream_comp, downstream_port); - conn->notified_downstream_port_disconnected = true; + conn->msgied_downstream_port_disconnected = true; } - if (upstream_comp && conn->notified_upstream_port_connected && - !conn->notified_upstream_port_disconnected) { + if (upstream_comp && conn->msgied_upstream_port_connected && + !conn->msgied_upstream_port_disconnected) { /* bt_component_port_disconnected() logs details */ bt_component_port_disconnected(upstream_comp, upstream_port); - conn->notified_upstream_port_disconnected = true; + conn->msgied_upstream_port_disconnected = true; } BT_ASSERT(graph); - if (conn->notified_graph_ports_connected && - !conn->notified_graph_ports_disconnected) { + if (conn->msgied_graph_ports_connected && + !conn->msgied_graph_ports_disconnected) { /* bt_graph_notify_ports_disconnected() logs details */ bt_graph_notify_ports_disconnected(graph, upstream_comp, downstream_comp, upstream_port, downstream_port); - conn->notified_graph_ports_disconnected = true; + conn->msgied_graph_ports_disconnected = true; } /* @@ -228,15 +228,15 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) /* * Because this connection is ended, finalize (cancel) each - * notification iterator created from it. + * message iterator created from it. */ for (i = 0; i < conn->iterators->len; i++) { - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = g_ptr_array_index(conn->iterators, i); - BT_LIB_LOGD("Finalizing notification iterator created by " + BT_LIB_LOGD("Finalizing message iterator created by " "this ended connection: %![iter-]+i", iterator); - bt_self_component_port_input_notification_iterator_finalize( + bt_self_component_port_input_message_iterator_finalize( iterator); /* @@ -244,7 +244,7 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph) * from this connection's iterators on destruction * because this connection won't exist anymore. */ - bt_self_component_port_input_notification_iterator_set_connection( + bt_self_component_port_input_message_iterator_set_connection( iterator, NULL); } @@ -271,10 +271,10 @@ const struct bt_port_input *bt_connection_borrow_downstream_port_const( BT_HIDDEN void bt_connection_remove_iterator(struct bt_connection *conn, - struct bt_self_component_port_input_notification_iterator *iterator) + struct bt_self_component_port_input_message_iterator *iterator) { g_ptr_array_remove(conn->iterators, iterator); - BT_LIB_LOGV("Removed notification iterator from connection: " + BT_LIB_LOGV("Removed message iterator from connection: " "%![conn-]+x, %![iter-]+i", conn, iterator); try_remove_connection_from_graph(conn); } diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 3588c54a..3b48c561 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -35,9 +35,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -119,14 +119,14 @@ void destroy_graph(struct bt_object *obj) * * 1. We put and destroy a connection. * 2. This connection's destructor finalizes its active - * notification iterators. - * 3. A notification iterator's finalization function gets a + * message iterators. + * 3. A message iterator's finalization function gets a * new reference on its component (reference count goes from * 0 to 1). * 4. Since this component's reference count goes to 1, it takes * a reference on its parent (this graph). This graph's * reference count goes from 0 to 1. - * 5. The notification iterator's finalization function puts its + * 5. The message iterator's finalization function puts its * component reference (reference count goes from 1 to 0). * 6. Since this component's reference count goes from 1 to 0, * it puts its parent (this graph). This graph's reference @@ -143,7 +143,7 @@ void destroy_graph(struct bt_object *obj) /* * Cancel the graph to disallow some operations, like creating - * notification iterators and adding ports to components. + * message iterators and adding ports to components. */ (void) bt_graph_cancel((void *) graph); @@ -177,9 +177,9 @@ void destroy_graph(struct bt_object *obj) CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_disconnected, graph->listeners.filter_sink_ports_disconnected); - if (graph->notifications) { - g_ptr_array_free(graph->notifications, TRUE); - graph->notifications = NULL; + if (graph->messages) { + g_ptr_array_free(graph->messages, TRUE); + graph->messages = NULL; } if (graph->connections) { @@ -275,37 +275,37 @@ void destroy_graph(struct bt_object *obj) graph->listeners.filter_sink_ports_disconnected = NULL; } - bt_object_pool_finalize(&graph->event_notif_pool); - bt_object_pool_finalize(&graph->packet_begin_notif_pool); - bt_object_pool_finalize(&graph->packet_end_notif_pool); + bt_object_pool_finalize(&graph->event_msg_pool); + bt_object_pool_finalize(&graph->packet_begin_msg_pool); + bt_object_pool_finalize(&graph->packet_end_msg_pool); g_free(graph); } static -void destroy_notification_event(struct bt_notification *notif, +void destroy_message_event(struct bt_message *msg, struct bt_graph *graph) { - bt_notification_event_destroy(notif); + bt_message_event_destroy(msg); } static -void destroy_notification_packet_begin(struct bt_notification *notif, +void destroy_message_packet_begin(struct bt_message *msg, struct bt_graph *graph) { - bt_notification_packet_beginning_destroy(notif); + bt_message_packet_beginning_destroy(msg); } static -void destroy_notification_packet_end(struct bt_notification *notif, +void destroy_message_packet_end(struct bt_message *msg, struct bt_graph *graph) { - bt_notification_packet_end_destroy(notif); + bt_message_packet_end_destroy(msg); } static -void notify_notification_graph_is_destroyed(struct bt_notification *notif) +void notify_message_graph_is_destroyed(struct bt_message *msg) { - bt_notification_unlink_graph(notif); + bt_message_unlink_graph(msg); } struct bt_graph *bt_graph_create(void) @@ -452,38 +452,38 @@ struct bt_graph *bt_graph_create(void) goto error; } - ret = bt_object_pool_initialize(&graph->event_notif_pool, - (bt_object_pool_new_object_func) bt_notification_event_new, - (bt_object_pool_destroy_object_func) destroy_notification_event, + ret = bt_object_pool_initialize(&graph->event_msg_pool, + (bt_object_pool_new_object_func) bt_message_event_new, + (bt_object_pool_destroy_object_func) destroy_message_event, graph); if (ret) { - BT_LOGE("Failed to initialize event notification pool: ret=%d", + BT_LOGE("Failed to initialize event message pool: ret=%d", ret); goto error; } - ret = bt_object_pool_initialize(&graph->packet_begin_notif_pool, - (bt_object_pool_new_object_func) bt_notification_packet_beginning_new, - (bt_object_pool_destroy_object_func) destroy_notification_packet_begin, + ret = bt_object_pool_initialize(&graph->packet_begin_msg_pool, + (bt_object_pool_new_object_func) bt_message_packet_beginning_new, + (bt_object_pool_destroy_object_func) destroy_message_packet_begin, graph); if (ret) { - BT_LOGE("Failed to initialize packet beginning notification pool: ret=%d", + BT_LOGE("Failed to initialize packet beginning message pool: ret=%d", ret); goto error; } - ret = bt_object_pool_initialize(&graph->packet_end_notif_pool, - (bt_object_pool_new_object_func) bt_notification_packet_end_new, - (bt_object_pool_destroy_object_func) destroy_notification_packet_end, + ret = bt_object_pool_initialize(&graph->packet_end_msg_pool, + (bt_object_pool_new_object_func) bt_message_packet_end_new, + (bt_object_pool_destroy_object_func) destroy_message_packet_end, graph); if (ret) { - BT_LOGE("Failed to initialize packet end notification pool: ret=%d", + BT_LOGE("Failed to initialize packet end message pool: ret=%d", ret); goto error; } - graph->notifications = g_ptr_array_new_with_free_func( - (GDestroyNotify) notify_notification_graph_is_destroyed); + graph->messages = g_ptr_array_new_with_free_func( + (GDestroyNotify) notify_message_graph_is_destroyed); BT_LIB_LOGD("Created graph object: %!+g", graph); end: @@ -608,7 +608,7 @@ enum bt_graph_status bt_graph_connect_ports( goto end; } - connection->notified_upstream_port_connected = true; + connection->msgied_upstream_port_connected = true; BT_LIB_LOGD("Notifying downstream component that its port is connected: " "%![comp-]+c, %![port-]+p", downstream_component, downstream_port); @@ -626,14 +626,14 @@ enum bt_graph_status bt_graph_connect_ports( goto end; } - connection->notified_downstream_port_connected = true; + connection->msgied_downstream_port_connected = true; /* * Notify the graph's creator that both ports are connected. */ BT_LOGD_STR("Notifying graph's user that new component ports are connected."); bt_graph_notify_ports_connected(graph, upstream_port, downstream_port); - connection->notified_graph_ports_connected = true; + connection->msgied_graph_ports_connected = true; BT_LIB_LOGD("Connected component ports within graph: " "%![graph-]+g, %![up-comp-]+c, %![down-comp-]+c, " "%![up-port-]+p, %![down-port-]+p", @@ -1920,21 +1920,21 @@ end: } BT_HIDDEN -void bt_graph_add_notification(struct bt_graph *graph, - struct bt_notification *notif) +void bt_graph_add_message(struct bt_graph *graph, + struct bt_message *msg) { BT_ASSERT(graph); - BT_ASSERT(notif); + BT_ASSERT(msg); /* * It's okay not to take a reference because, when a - * notification's reference count drops to 0, either: + * message's reference count drops to 0, either: * * * It is recycled back to one of this graph's pool. * * It is destroyed because it doesn't have any link to any * graph, which means the original graph is already destroyed. */ - g_ptr_array_add(graph->notifications, notif); + g_ptr_array_add(graph->messages, msg); } void bt_graph_get_ref(const struct bt_graph *graph) diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index db774dfd..2c2fcadb 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -21,7 +21,7 @@ * SOFTWARE. */ -#define BT_LOG_TAG "NOTIF-ITER" +#define BT_LOG_TAG "MSG-ITER" #include #include @@ -39,18 +39,18 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -66,12 +66,12 @@ * TODO: Use graph's state (number of active iterators, etc.) and * possibly system specifications to make a better guess than this. */ -#define NOTIF_BATCH_SIZE 15 +#define MSG_BATCH_SIZE 15 struct stream_state { const struct bt_stream *stream; /* owned by this */ const struct bt_packet *cur_packet; /* owned by this */ - uint64_t expected_notif_seq_num; + uint64_t expected_msg_seq_num; bt_bool is_ended; }; @@ -116,32 +116,32 @@ end: } static -void destroy_base_notification_iterator(struct bt_object *obj) +void destroy_base_message_iterator(struct bt_object *obj) { - struct bt_notification_iterator *iterator = (void *) obj; + struct bt_message_iterator *iterator = (void *) obj; BT_ASSERT(iterator); - if (iterator->notifs) { - g_ptr_array_free(iterator->notifs, TRUE); - iterator->notifs = NULL; + if (iterator->msgs) { + g_ptr_array_free(iterator->msgs, TRUE); + iterator->msgs = NULL; } g_free(iterator); } static -void bt_self_component_port_input_notification_iterator_destroy(struct bt_object *obj) +void bt_self_component_port_input_message_iterator_destroy(struct bt_object *obj) { - struct bt_self_component_port_input_notification_iterator *iterator; + struct bt_self_component_port_input_message_iterator *iterator; BT_ASSERT(obj); /* - * The notification iterator's reference count is 0 if we're + * The message iterator's reference count is 0 if we're * here. Increment it to avoid a double-destroy (possibly * infinitely recursive). This could happen for example if the - * notification iterator's finalization function does + * message iterator's finalization function does * bt_object_get_ref() (or anything that causes * bt_object_get_ref() to be called) on itself (ref. count goes * from 0 to 1), and then bt_object_put_ref(): the reference @@ -150,16 +150,16 @@ void bt_self_component_port_input_notification_iterator_destroy(struct bt_object */ obj->ref_count++; iterator = (void *) obj; - BT_LIB_LOGD("Destroying self component input port notification iterator object: " + BT_LIB_LOGD("Destroying self component input port message iterator object: " "%!+i", iterator); - bt_self_component_port_input_notification_iterator_finalize(iterator); + bt_self_component_port_input_message_iterator_finalize(iterator); if (iterator->stream_states) { /* * Remove our destroy listener from each stream which * has a state in this iterator. Otherwise the destroy * listener would be called with an invalid/other - * notification iterator object. + * message iterator object. */ g_hash_table_destroy(iterator->stream_states); iterator->stream_states = NULL; @@ -175,12 +175,12 @@ void bt_self_component_port_input_notification_iterator_destroy(struct bt_object iterator->connection = NULL; } - destroy_base_notification_iterator(obj); + destroy_base_message_iterator(obj); } BT_HIDDEN -void bt_self_component_port_input_notification_iterator_finalize( - struct bt_self_component_port_input_notification_iterator *iterator) +void bt_self_component_port_input_message_iterator_finalize( + struct bt_self_component_port_input_message_iterator *iterator) { typedef void (*method_t)(void *); @@ -190,31 +190,31 @@ void bt_self_component_port_input_notification_iterator_finalize( BT_ASSERT(iterator); switch (iterator->state) { - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED: + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED: /* Skip user finalization if user initialization failed */ - BT_LIB_LOGD("Not finalizing non-initialized notification iterator: " + BT_LIB_LOGD("Not finalizing non-initialized message iterator: " "%!+i", iterator); return; - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED: - case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED: + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED: + case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED: /* Already finalized */ - BT_LIB_LOGD("Not finalizing notification iterator: already finalized: " + BT_LIB_LOGD("Not finalizing message iterator: already finalized: " "%!+i", iterator); return; default: break; } - BT_LIB_LOGD("Finalizing notification iterator: %!+i", iterator); + BT_LIB_LOGD("Finalizing message iterator: %!+i", iterator); - if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED) { - BT_LIB_LOGD("Updating notification iterator's state: " - "new-state=BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED"); - iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED; + if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED) { + BT_LIB_LOGD("Updating message iterator's state: " + "new-state=BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED"); + iterator->state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED; } else { - BT_LIB_LOGD("Updating notification iterator's state: " - "new-state=BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED"); - iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED; + BT_LIB_LOGD("Updating message iterator's state: " + "new-state=BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED"); + iterator->state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED; } BT_ASSERT(iterator->upstream_component); @@ -227,7 +227,7 @@ void bt_self_component_port_input_notification_iterator_finalize( struct bt_component_class_source *src_comp_cls = (void *) comp_class; - method = (method_t) src_comp_cls->methods.notif_iter_finalize; + method = (method_t) src_comp_cls->methods.msg_iter_finalize; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -235,7 +235,7 @@ void bt_self_component_port_input_notification_iterator_finalize( struct bt_component_class_filter *flt_comp_cls = (void *) comp_class; - method = (method_t) flt_comp_cls->methods.notif_iter_finalize; + method = (method_t) flt_comp_cls->methods.msg_iter_finalize; break; } default: @@ -251,73 +251,73 @@ void bt_self_component_port_input_notification_iterator_finalize( iterator->upstream_component = NULL; iterator->upstream_port = NULL; - BT_LIB_LOGD("Finalized notification iterator: %!+i", iterator); + BT_LIB_LOGD("Finalized message iterator: %!+i", iterator); } BT_HIDDEN -void bt_self_component_port_input_notification_iterator_set_connection( - struct bt_self_component_port_input_notification_iterator *iterator, +void bt_self_component_port_input_message_iterator_set_connection( + struct bt_self_component_port_input_message_iterator *iterator, struct bt_connection *connection) { BT_ASSERT(iterator); iterator->connection = connection; - BT_LIB_LOGV("Set notification iterator's connection: " + BT_LIB_LOGV("Set message iterator's connection: " "%![iter-]+i, %![conn-]+x", iterator, connection); } static -int init_notification_iterator(struct bt_notification_iterator *iterator, - enum bt_notification_iterator_type type, +int init_message_iterator(struct bt_message_iterator *iterator, + enum bt_message_iterator_type type, bt_object_release_func destroy) { int ret = 0; bt_object_init_shared(&iterator->base, destroy); iterator->type = type; - iterator->notifs = g_ptr_array_new(); - if (!iterator->notifs) { + iterator->msgs = g_ptr_array_new(); + if (!iterator->msgs) { BT_LOGE_STR("Failed to allocate a GPtrArray."); ret = -1; goto end; } - g_ptr_array_set_size(iterator->notifs, NOTIF_BATCH_SIZE); + g_ptr_array_set_size(iterator->msgs, MSG_BATCH_SIZE); end: return ret; } static -struct bt_self_component_port_input_notification_iterator * -bt_self_component_port_input_notification_iterator_create_initial( +struct bt_self_component_port_input_message_iterator * +bt_self_component_port_input_message_iterator_create_initial( struct bt_component *upstream_comp, struct bt_port *upstream_port) { int ret; - struct bt_self_component_port_input_notification_iterator *iterator = NULL; + struct bt_self_component_port_input_message_iterator *iterator = NULL; BT_ASSERT(upstream_comp); BT_ASSERT(upstream_port); BT_ASSERT(bt_port_is_connected(upstream_port)); - BT_LIB_LOGD("Creating initial notification iterator on self component input port: " + BT_LIB_LOGD("Creating initial message iterator on self component input port: " "%![up-comp-]+c, %![up-port-]+p", upstream_comp, upstream_port); BT_ASSERT(bt_component_get_class_type(upstream_comp) == BT_COMPONENT_CLASS_TYPE_SOURCE || bt_component_get_class_type(upstream_comp) == BT_COMPONENT_CLASS_TYPE_FILTER); iterator = g_new0( - struct bt_self_component_port_input_notification_iterator, 1); + struct bt_self_component_port_input_message_iterator, 1); if (!iterator) { BT_LOGE_STR("Failed to allocate one self component input port " - "notification iterator."); + "message iterator."); goto end; } - ret = init_notification_iterator((void *) iterator, - BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT, - bt_self_component_port_input_notification_iterator_destroy); + ret = init_message_iterator((void *) iterator, + BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT, + bt_self_component_port_input_message_iterator_destroy); if (ret) { - /* init_notification_iterator() logs errors */ + /* init_message_iterator() logs errors */ BT_OBJECT_PUT_REF_AND_RESET(iterator); goto end; } @@ -334,8 +334,8 @@ bt_self_component_port_input_notification_iterator_create_initial( iterator->upstream_port = upstream_port; iterator->connection = iterator->upstream_port->connection; iterator->graph = bt_component_borrow_graph(upstream_comp); - iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED; - BT_LIB_LOGD("Created initial notification iterator on self component input port: " + iterator->state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED; + BT_LIB_LOGD("Created initial message iterator on self component input port: " "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i", upstream_port, upstream_comp, iterator); @@ -343,15 +343,15 @@ end: return iterator; } -struct bt_self_component_port_input_notification_iterator * -bt_self_component_port_input_notification_iterator_create( +struct bt_self_component_port_input_message_iterator * +bt_self_component_port_input_message_iterator_create( struct bt_self_component_port_input *self_port) { - typedef enum bt_self_notification_iterator_status (*init_method_t)( + typedef enum bt_self_message_iterator_status (*init_method_t)( void *, void *, void *); init_method_t init_method = NULL; - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = NULL; struct bt_port *port = (void *) self_port; struct bt_port *upstream_port; @@ -378,11 +378,11 @@ bt_self_component_port_input_notification_iterator_create( BT_COMPONENT_CLASS_TYPE_SOURCE || upstream_comp->class->type == BT_COMPONENT_CLASS_TYPE_FILTER); - iterator = bt_self_component_port_input_notification_iterator_create_initial( + iterator = bt_self_component_port_input_message_iterator_create_initial( upstream_comp, upstream_port); if (!iterator) { BT_LOGW_STR("Cannot create self component input port " - "notification iterator."); + "message iterator."); goto end; } @@ -393,7 +393,7 @@ bt_self_component_port_input_notification_iterator_create( (void *) upstream_comp_cls; init_method = - (init_method_t) src_comp_cls->methods.notif_iter_init; + (init_method_t) src_comp_cls->methods.msg_iter_init; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -402,7 +402,7 @@ bt_self_component_port_input_notification_iterator_create( (void *) upstream_comp_cls; init_method = - (init_method_t) flt_comp_cls->methods.notif_iter_init; + (init_method_t) flt_comp_cls->methods.msg_iter_init; break; } default: @@ -417,16 +417,16 @@ bt_self_component_port_input_notification_iterator_create( iter_status = init_method(iterator, upstream_comp, upstream_port); BT_LOGD("User method returned: status=%s", - bt_notification_iterator_status_string(iter_status)); - if (iter_status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + bt_message_iterator_status_string(iter_status)); + if (iter_status != BT_MESSAGE_ITERATOR_STATUS_OK) { BT_LOGW_STR("Initialization method failed."); goto end; } } - iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE; + iterator->state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE; g_ptr_array_add(port->connection->iterators, iterator); - BT_LIB_LOGD("Created notification iterator on self component input port: " + BT_LIB_LOGD("Created message iterator on self component input port: " "%![up-port-]+p, %![up-comp-]+c, %![iter-]+i", upstream_port, upstream_comp, iterator); @@ -434,54 +434,54 @@ end: return iterator; } -void *bt_self_notification_iterator_get_data( - const struct bt_self_notification_iterator *self_iterator) +void *bt_self_message_iterator_get_data( + const struct bt_self_message_iterator *self_iterator) { - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = (void *) self_iterator; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); return iterator->user_data; } -void bt_self_notification_iterator_set_data( - struct bt_self_notification_iterator *self_iterator, void *data) +void bt_self_message_iterator_set_data( + struct bt_self_message_iterator *self_iterator, void *data) { - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = (void *) self_iterator; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); iterator->user_data = data; - BT_LIB_LOGV("Set notification iterator's user data: " + BT_LIB_LOGV("Set message iterator's user data: " "%!+i, user-data-addr=%p", iterator, data); } BT_ASSERT_PRE_FUNC static inline -void bt_notification_borrow_packet_stream(const struct bt_notification *notif, +void bt_message_borrow_packet_stream(const struct bt_message *msg, const struct bt_stream **stream, const struct bt_packet **packet) { - BT_ASSERT(notif); + BT_ASSERT(msg); - switch (notif->type) { - case BT_NOTIFICATION_TYPE_EVENT: + switch (msg->type) { + case BT_MESSAGE_TYPE_EVENT: *packet = bt_event_borrow_packet_const( - bt_notification_event_borrow_event_const(notif)); + bt_message_event_borrow_event_const(msg)); *stream = bt_packet_borrow_stream_const(*packet); break; - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: - *stream = bt_notification_stream_beginning_borrow_stream_const(notif); + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + *stream = bt_message_stream_beginning_borrow_stream_const(msg); break; - case BT_NOTIFICATION_TYPE_STREAM_END: - *stream = bt_notification_stream_end_borrow_stream_const(notif); + case BT_MESSAGE_TYPE_STREAM_END: + *stream = bt_message_stream_end_borrow_stream_const(msg); break; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - *packet = bt_notification_packet_beginning_borrow_packet_const(notif); + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + *packet = bt_message_packet_beginning_borrow_packet_const(msg); *stream = bt_packet_borrow_stream_const(*packet); break; - case BT_NOTIFICATION_TYPE_PACKET_END: - *packet = bt_notification_packet_end_borrow_packet_const(notif); + case BT_MESSAGE_TYPE_PACKET_END: + *packet = bt_message_packet_end_borrow_packet_const(msg); *stream = bt_packet_borrow_stream_const(*packet); break; default: @@ -491,51 +491,51 @@ void bt_notification_borrow_packet_stream(const struct bt_notification *notif, BT_ASSERT_PRE_FUNC static inline -bool validate_notification( - struct bt_self_component_port_input_notification_iterator *iterator, - const struct bt_notification *c_notif) +bool validate_message( + struct bt_self_component_port_input_message_iterator *iterator, + const struct bt_message *c_msg) { bool is_valid = true; struct stream_state *stream_state; const struct bt_stream *stream = NULL; const struct bt_packet *packet = NULL; - struct bt_notification *notif = (void *) c_notif; + struct bt_message *msg = (void *) c_msg; - BT_ASSERT(notif); - bt_notification_borrow_packet_stream(c_notif, &stream, &packet); + BT_ASSERT(msg); + bt_message_borrow_packet_stream(c_msg, &stream, &packet); if (!stream) { - /* we don't care about notifications not attached to streams */ + /* we don't care about messages not attached to streams */ goto end; } stream_state = g_hash_table_lookup(iterator->stream_states, stream); if (!stream_state) { /* - * No stream state for this stream: this notification - * MUST be a BT_NOTIFICATION_TYPE_STREAM_BEGINNING notification + * No stream state for this stream: this message + * MUST be a BT_MESSAGE_TYPE_STREAM_BEGINNING message * and its sequence number must be 0. */ - if (c_notif->type != BT_NOTIFICATION_TYPE_STREAM_BEGINNING) { - BT_ASSERT_PRE_MSG("Unexpected notification: missing a " - "BT_NOTIFICATION_TYPE_STREAM_BEGINNING " - "notification prior to this notification: " + if (c_msg->type != BT_MESSAGE_TYPE_STREAM_BEGINNING) { + BT_ASSERT_PRE_MSG("Unexpected message: missing a " + "BT_MESSAGE_TYPE_STREAM_BEGINNING " + "message prior to this message: " "%![stream-]+s", stream); is_valid = false; goto end; } - if (c_notif->seq_num == -1ULL) { - notif->seq_num = 0; + if (c_msg->seq_num == -1ULL) { + msg->seq_num = 0; } - if (c_notif->seq_num != 0) { - BT_ASSERT_PRE_MSG("Unexpected notification sequence " - "number for this notification iterator: " - "this is the first notification for this " + if (c_msg->seq_num != 0) { + BT_ASSERT_PRE_MSG("Unexpected message sequence " + "number for this message iterator: " + "this is the first message for this " "stream, expecting sequence number 0: " "seq-num=%" PRIu64 ", %![stream-]+s", - c_notif->seq_num, stream); + c_msg->seq_num, stream); is_valid = false; goto end; } @@ -547,15 +547,15 @@ bool validate_notification( g_hash_table_insert(iterator->stream_states, (void *) stream, stream_state); - stream_state->expected_notif_seq_num++; + stream_state->expected_msg_seq_num++; goto end; } if (stream_state->is_ended) { /* - * There's a new notification which has a reference to a + * There's a new message which has a reference to a * stream which, from this iterator's point of view, is - * ended ("end of stream" notification was returned). + * ended ("end of stream" message was returned). * This is bad: the API guarantees that it can never * happen. */ @@ -565,85 +565,85 @@ bool validate_notification( goto end; } - if (c_notif->seq_num == -1ULL) { - notif->seq_num = stream_state->expected_notif_seq_num; + if (c_msg->seq_num == -1ULL) { + msg->seq_num = stream_state->expected_msg_seq_num; } - if (c_notif->seq_num != -1ULL && - c_notif->seq_num != stream_state->expected_notif_seq_num) { - BT_ASSERT_PRE_MSG("Unexpected notification sequence number: " + if (c_msg->seq_num != -1ULL && + c_msg->seq_num != stream_state->expected_msg_seq_num) { + BT_ASSERT_PRE_MSG("Unexpected message sequence number: " "seq-num=%" PRIu64 ", " "expected-seq-num=%" PRIu64 ", %![stream-]+s", - c_notif->seq_num, stream_state->expected_notif_seq_num, + c_msg->seq_num, stream_state->expected_msg_seq_num, stream); is_valid = false; goto end; } - switch (c_notif->type) { - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: - BT_ASSERT_PRE_MSG("Unexpected BT_NOTIFICATION_TYPE_STREAM_BEGINNING " - "notification at this point: notif-seq-num=%" PRIu64 ", " - "%![stream-]+s", c_notif->seq_num, stream); + switch (c_msg->type) { + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + BT_ASSERT_PRE_MSG("Unexpected BT_MESSAGE_TYPE_STREAM_BEGINNING " + "message at this point: msg-seq-num=%" PRIu64 ", " + "%![stream-]+s", c_msg->seq_num, stream); is_valid = false; goto end; - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_END: if (stream_state->cur_packet) { - BT_ASSERT_PRE_MSG("Unexpected BT_NOTIFICATION_TYPE_STREAM_END " - "notification: missing a " - "BT_NOTIFICATION_TYPE_PACKET_END notification " - "prior to this notification: " - "notif-seq-num=%" PRIu64 ", " - "%![stream-]+s", c_notif->seq_num, stream); + BT_ASSERT_PRE_MSG("Unexpected BT_MESSAGE_TYPE_STREAM_END " + "message: missing a " + "BT_MESSAGE_TYPE_PACKET_END message " + "prior to this message: " + "msg-seq-num=%" PRIu64 ", " + "%![stream-]+s", c_msg->seq_num, stream); is_valid = false; goto end; } - stream_state->expected_notif_seq_num++; + stream_state->expected_msg_seq_num++; stream_state->is_ended = true; goto end; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + case BT_MESSAGE_TYPE_PACKET_BEGINNING: if (stream_state->cur_packet) { - BT_ASSERT_PRE_MSG("Unexpected BT_NOTIFICATION_TYPE_PACKET_BEGINNING " - "notification at this point: missing a " - "BT_NOTIFICATION_TYPE_PACKET_END notification " - "prior to this notification: " - "notif-seq-num=%" PRIu64 ", %![stream-]+s, " - "%![packet-]+a", c_notif->seq_num, stream, + BT_ASSERT_PRE_MSG("Unexpected BT_MESSAGE_TYPE_PACKET_BEGINNING " + "message at this point: missing a " + "BT_MESSAGE_TYPE_PACKET_END message " + "prior to this message: " + "msg-seq-num=%" PRIu64 ", %![stream-]+s, " + "%![packet-]+a", c_msg->seq_num, stream, packet); is_valid = false; goto end; } - stream_state->expected_notif_seq_num++; + stream_state->expected_msg_seq_num++; stream_state->cur_packet = packet; bt_object_get_no_null_check(stream_state->cur_packet); goto end; - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_PACKET_END: if (!stream_state->cur_packet) { - BT_ASSERT_PRE_MSG("Unexpected BT_NOTIFICATION_TYPE_PACKET_END " - "notification at this point: missing a " - "BT_NOTIFICATION_TYPE_PACKET_BEGINNING notification " - "prior to this notification: " - "notif-seq-num=%" PRIu64 ", %![stream-]+s, " - "%![packet-]+a", c_notif->seq_num, stream, + BT_ASSERT_PRE_MSG("Unexpected BT_MESSAGE_TYPE_PACKET_END " + "message at this point: missing a " + "BT_MESSAGE_TYPE_PACKET_BEGINNING message " + "prior to this message: " + "msg-seq-num=%" PRIu64 ", %![stream-]+s, " + "%![packet-]+a", c_msg->seq_num, stream, packet); is_valid = false; goto end; } - stream_state->expected_notif_seq_num++; + stream_state->expected_msg_seq_num++; BT_OBJECT_PUT_REF_AND_RESET(stream_state->cur_packet); goto end; - case BT_NOTIFICATION_TYPE_EVENT: + case BT_MESSAGE_TYPE_EVENT: if (packet != stream_state->cur_packet) { BT_ASSERT_PRE_MSG("Unexpected packet for " - "BT_NOTIFICATION_TYPE_EVENT notification: " - "notif-seq-num=%" PRIu64 ", %![stream-]+s, " - "%![notif-packet-]+a, %![expected-packet-]+a", - c_notif->seq_num, stream, + "BT_MESSAGE_TYPE_EVENT message: " + "msg-seq-num=%" PRIu64 ", %![stream-]+s, " + "%![msg-packet-]+a, %![expected-packet-]+a", + c_msg->seq_num, stream, stream_state->cur_packet, packet); is_valid = false; goto end; } - stream_state->expected_notif_seq_num++; + stream_state->expected_msg_seq_num++; goto end; default: break; @@ -655,17 +655,17 @@ end: BT_ASSERT_PRE_FUNC static inline -bool validate_notifications( - struct bt_self_component_port_input_notification_iterator *iterator, +bool validate_messages( + struct bt_self_component_port_input_message_iterator *iterator, uint64_t count) { bool ret = true; - bt_notification_array_const notifs = - (void *) iterator->base.notifs->pdata; + bt_message_array_const msgs = + (void *) iterator->base.msgs->pdata; uint64_t i; for (i = 0; i < count; i++) { - ret = validate_notification(iterator, notifs[i]); + ret = validate_message(iterator, msgs[i]); if (!ret) { break; } @@ -675,8 +675,8 @@ bool validate_notifications( } BT_ASSERT_PRE_FUNC -static inline bool self_comp_port_input_notif_iter_can_end( - struct bt_self_component_port_input_notification_iterator *iterator) +static inline bool self_comp_port_input_msg_iter_can_end( + struct bt_self_component_port_input_message_iterator *iterator) { GHashTableIter iter; gpointer stream_key, state_value; @@ -684,7 +684,7 @@ static inline bool self_comp_port_input_notif_iter_can_end( /* * Verify that this iterator received a - * BT_NOTIFICATION_TYPE_STREAM_END notification for each stream + * BT_MESSAGE_TYPE_STREAM_END message for each stream * which has a state. */ @@ -697,7 +697,7 @@ static inline bool self_comp_port_input_notif_iter_can_end( BT_ASSERT(stream_key); if (!stream_state->is_ended) { - BT_ASSERT_PRE_MSG("Ending notification iterator, " + BT_ASSERT_PRE_MSG("Ending message iterator, " "but stream is not ended: " "%![stream-]s", stream_key); ret = false; @@ -709,29 +709,29 @@ end: return ret; } -enum bt_notification_iterator_status -bt_self_component_port_input_notification_iterator_next( - struct bt_self_component_port_input_notification_iterator *iterator, - bt_notification_array_const *notifs, uint64_t *user_count) +enum bt_message_iterator_status +bt_self_component_port_input_message_iterator_next( + struct bt_self_component_port_input_message_iterator *iterator, + bt_message_array_const *msgs, uint64_t *user_count) { - typedef enum bt_self_notification_iterator_status (*method_t)( - void *, bt_notification_array_const, uint64_t, uint64_t *); + typedef enum bt_self_message_iterator_status (*method_t)( + void *, bt_message_array_const, uint64_t, uint64_t *); method_t method = NULL; struct bt_component_class *comp_cls; - int status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + int status = BT_MESSAGE_ITERATOR_STATUS_OK; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(notifs, "Notification array (output)"); - BT_ASSERT_PRE_NON_NULL(user_count, "Notification count (output)"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(msgs, "Message array (output)"); + BT_ASSERT_PRE_NON_NULL(user_count, "Message count (output)"); BT_ASSERT_PRE(iterator->state == - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE, - "Notification iterator's \"next\" called, but " + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE, + "Message iterator's \"next\" called, but " "iterator is in the wrong state: %!+i", iterator); BT_ASSERT(iterator->upstream_component); BT_ASSERT(iterator->upstream_component->class); BT_LIB_LOGD("Getting next self component input port " - "notification iterator's notifications: %!+i", iterator); + "message iterator's messages: %!+i", iterator); comp_cls = iterator->upstream_component->class; /* Pick the appropriate "next" method */ @@ -741,7 +741,7 @@ bt_self_component_port_input_notification_iterator_next( struct bt_component_class_source *src_comp_cls = (void *) comp_cls; - method = (method_t) src_comp_cls->methods.notif_iter_next; + method = (method_t) src_comp_cls->methods.msg_iter_next; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -749,7 +749,7 @@ bt_self_component_port_input_notification_iterator_next( struct bt_component_class_filter *flt_comp_cls = (void *) comp_cls; - method = (method_t) flt_comp_cls->methods.notif_iter_next; + method = (method_t) flt_comp_cls->methods.msg_iter_next; break; } default: @@ -757,68 +757,68 @@ bt_self_component_port_input_notification_iterator_next( } /* - * Call the user's "next" method to get the next notifications + * Call the user's "next" method to get the next messages * and status. */ BT_ASSERT(method); BT_LOGD_STR("Calling user's \"next\" method."); status = method(iterator, - (void *) iterator->base.notifs->pdata, - NOTIF_BATCH_SIZE, user_count); + (void *) iterator->base.msgs->pdata, + MSG_BATCH_SIZE, user_count); BT_LOGD("User method returned: status=%s", - bt_notification_iterator_status_string(status)); + bt_message_iterator_status_string(status)); if (status < 0) { BT_LOGW_STR("User method failed."); goto end; } - if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED || - iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED) { + if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED || + iterator->state == BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED_AND_ENDED) { /* * The user's "next" method, somehow, cancelled its own - * notification iterator. This can happen, for example, + * message iterator. This can happen, for example, * when the user's method removes the port on which * there's the connection from which the iterator was * created. In this case, said connection is ended, and - * all its notification iterators are finalized. + * all its message iterators are finalized. * - * Only bt_object_put_ref() the returned notification if - * the status is BT_NOTIFICATION_ITERATOR_STATUS_OK + * Only bt_object_put_ref() the returned message if + * the status is BT_MESSAGE_ITERATOR_STATUS_OK * because otherwise this field could be garbage. */ - if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { + if (status == BT_MESSAGE_ITERATOR_STATUS_OK) { uint64_t i; - bt_notification_array_const notifs = - (void *) iterator->base.notifs->pdata; + bt_message_array_const msgs = + (void *) iterator->base.msgs->pdata; for (i = 0; i < *user_count; i++) { - bt_object_put_ref(notifs[i]); + bt_object_put_ref(msgs[i]); } } - status = BT_NOTIFICATION_ITERATOR_STATUS_CANCELED; + status = BT_MESSAGE_ITERATOR_STATUS_CANCELED; goto end; } switch (status) { - case BT_NOTIFICATION_ITERATOR_STATUS_OK: - BT_ASSERT_PRE(validate_notifications(iterator, *user_count), - "Notifications are invalid at this point: " - "%![notif-iter-]+i, count=%" PRIu64, + case BT_MESSAGE_ITERATOR_STATUS_OK: + BT_ASSERT_PRE(validate_messages(iterator, *user_count), + "Messages are invalid at this point: " + "%![msg-iter-]+i, count=%" PRIu64, iterator, *user_count); - *notifs = (void *) iterator->base.notifs->pdata; + *msgs = (void *) iterator->base.msgs->pdata; break; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_END: - BT_ASSERT_PRE(self_comp_port_input_notif_iter_can_end(iterator), - "Notification iterator cannot end at this point: " + case BT_MESSAGE_ITERATOR_STATUS_END: + BT_ASSERT_PRE(self_comp_port_input_msg_iter_can_end(iterator), + "Message iterator cannot end at this point: " "%!+i", iterator); BT_ASSERT(iterator->state == - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE); - iterator->state = BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED; + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE); + iterator->state = BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ENDED; BT_LOGD("Set new status: status=%s", - bt_notification_iterator_status_string(status)); + bt_message_iterator_status_string(status)); goto end; default: /* Unknown non-error status */ @@ -829,19 +829,19 @@ end: return status; } -enum bt_notification_iterator_status -bt_port_output_notification_iterator_next( - struct bt_port_output_notification_iterator *iterator, - bt_notification_array_const *notifs_to_user, +enum bt_message_iterator_status +bt_port_output_message_iterator_next( + struct bt_port_output_message_iterator *iterator, + bt_message_array_const *msgs_to_user, uint64_t *count_to_user) { - enum bt_notification_iterator_status status; + enum bt_message_iterator_status status; enum bt_graph_status graph_status; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(notifs_to_user, "Notification array (output)"); - BT_ASSERT_PRE_NON_NULL(count_to_user, "Notification count (output)"); - BT_LIB_LOGD("Getting next output port notification iterator's notifications: " + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(msgs_to_user, "Message array (output)"); + BT_ASSERT_PRE_NON_NULL(count_to_user, "Message count (output)"); + BT_LIB_LOGD("Getting next output port message iterator's messages: " "%!+i", iterator); graph_status = bt_graph_consume_sink_no_check(iterator->graph, @@ -854,71 +854,71 @@ bt_port_output_notification_iterator_next( status = (int) graph_status; break; case BT_GRAPH_STATUS_OK: - status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + status = BT_MESSAGE_ITERATOR_STATUS_OK; /* - * On success, the colander sink moves the notifications + * On success, the colander sink moves the messages * to this iterator's array and sets this iterator's - * notification count: move them to the user. + * message count: move them to the user. */ - *notifs_to_user = (void *) iterator->base.notifs->pdata; + *msgs_to_user = (void *) iterator->base.msgs->pdata; *count_to_user = iterator->count; break; default: /* Other errors */ - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; } return status; } -struct bt_component *bt_self_component_port_input_notification_iterator_borrow_component( - struct bt_self_component_port_input_notification_iterator *iterator) +struct bt_component *bt_self_component_port_input_message_iterator_borrow_component( + struct bt_self_component_port_input_message_iterator *iterator) { - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); return iterator->upstream_component; } -struct bt_self_component *bt_self_notification_iterator_borrow_component( - struct bt_self_notification_iterator *self_iterator) +struct bt_self_component *bt_self_message_iterator_borrow_component( + struct bt_self_message_iterator *self_iterator) { - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = (void *) self_iterator; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); return (void *) iterator->upstream_component; } -struct bt_self_port_output *bt_self_notification_iterator_borrow_port( - struct bt_self_notification_iterator *self_iterator) +struct bt_self_port_output *bt_self_message_iterator_borrow_port( + struct bt_self_message_iterator *self_iterator) { - struct bt_self_component_port_input_notification_iterator *iterator = + struct bt_self_component_port_input_message_iterator *iterator = (void *) self_iterator; - BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator"); + BT_ASSERT_PRE_NON_NULL(iterator, "Message iterator"); return (void *) iterator->upstream_port; } static -void bt_port_output_notification_iterator_destroy(struct bt_object *obj) +void bt_port_output_message_iterator_destroy(struct bt_object *obj) { - struct bt_port_output_notification_iterator *iterator = (void *) obj; + struct bt_port_output_message_iterator *iterator = (void *) obj; - BT_LIB_LOGD("Destroying output port notification iterator object: %!+i", + BT_LIB_LOGD("Destroying output port message iterator object: %!+i", iterator); BT_LOGD_STR("Putting graph."); BT_OBJECT_PUT_REF_AND_RESET(iterator->graph); BT_LOGD_STR("Putting colander sink component."); BT_OBJECT_PUT_REF_AND_RESET(iterator->colander); - destroy_base_notification_iterator(obj); + destroy_base_message_iterator(obj); } -struct bt_port_output_notification_iterator * -bt_port_output_notification_iterator_create( +struct bt_port_output_message_iterator * +bt_port_output_message_iterator_create( struct bt_graph *graph, const struct bt_port_output *output_port) { - struct bt_port_output_notification_iterator *iterator = NULL; + struct bt_port_output_message_iterator *iterator = NULL; struct bt_component_class_sink *colander_comp_cls = NULL; struct bt_component *output_port_comp = NULL; struct bt_component_sink *colander_comp; @@ -938,20 +938,20 @@ bt_port_output_notification_iterator_create( "Output port is not part of graph: %![graph-]+g, %![port-]+p", graph, output_port); - /* Create notification iterator */ - BT_LIB_LOGD("Creating notification iterator on output port: " + /* Create message iterator */ + BT_LIB_LOGD("Creating message iterator on output port: " "%![port-]+p, %![comp-]+c", output_port, output_port_comp); - iterator = g_new0(struct bt_port_output_notification_iterator, 1); + iterator = g_new0(struct bt_port_output_message_iterator, 1); if (!iterator) { - BT_LOGE_STR("Failed to allocate one output port notification iterator."); + BT_LOGE_STR("Failed to allocate one output port message iterator."); goto error; } - ret = init_notification_iterator((void *) iterator, - BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT, - bt_port_output_notification_iterator_destroy); + ret = init_message_iterator((void *) iterator, + BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT, + bt_port_output_message_iterator_destroy); if (ret) { - /* init_notification_iterator() logs errors */ + /* init_message_iterator() logs errors */ BT_OBJECT_PUT_REF_AND_RESET(iterator); goto end; } @@ -965,7 +965,7 @@ bt_port_output_notification_iterator_create( iterator->graph = graph; bt_object_get_no_null_check(iterator->graph); - colander_data.notifs = (void *) iterator->base.notifs->pdata; + colander_data.msgs = (void *) iterator->base.msgs->pdata; colander_data.count_addr = &iterator->count; /* Hope that nobody uses this very unique name */ @@ -1001,10 +1001,10 @@ bt_port_output_notification_iterator_create( /* * At this point everything went fine. Make the graph - * nonconsumable forever so that only this notification iterator + * nonconsumable forever so that only this message iterator * can consume (thanks to bt_graph_consume_sink_no_check()). - * This avoids leaking the notification created by the colander - * sink and moved to the notification iterator's notification + * This avoids leaking the message created by the colander + * sink and moved to the message iterator's message * member. */ bt_graph_set_can_consume(iterator->graph, false); @@ -1041,26 +1041,26 @@ end: return (void *) iterator; } -void bt_port_output_notification_iterator_get_ref( - const struct bt_port_output_notification_iterator *iterator) +void bt_port_output_message_iterator_get_ref( + const struct bt_port_output_message_iterator *iterator) { bt_object_get_ref(iterator); } -void bt_port_output_notification_iterator_put_ref( - const struct bt_port_output_notification_iterator *iterator) +void bt_port_output_message_iterator_put_ref( + const struct bt_port_output_message_iterator *iterator) { bt_object_put_ref(iterator); } -void bt_self_component_port_input_notification_iterator_get_ref( - const struct bt_self_component_port_input_notification_iterator *iterator) +void bt_self_component_port_input_message_iterator_get_ref( + const struct bt_self_component_port_input_message_iterator *iterator) { bt_object_get_ref(iterator); } -void bt_self_component_port_input_notification_iterator_put_ref( - const struct bt_self_component_port_input_notification_iterator *iterator) +void bt_self_component_port_input_message_iterator_put_ref( + const struct bt_self_component_port_input_message_iterator *iterator) { bt_object_put_ref(iterator); } diff --git a/lib/graph/message/Makefile.am b/lib/graph/message/Makefile.am new file mode 100644 index 00000000..d111f5b8 --- /dev/null +++ b/lib/graph/message/Makefile.am @@ -0,0 +1,8 @@ +noinst_LTLIBRARIES = libgraph-message.la + +libgraph_message_la_SOURCES = \ + message.c \ + packet.c \ + event.c \ + stream.c \ + inactivity.c diff --git a/lib/graph/notification/discarded-events.c b/lib/graph/message/discarded-events.c similarity index 54% rename from lib/graph/notification/discarded-events.c rename to lib/graph/message/discarded-events.c index e1dcbfa5..e594fe1d 100644 --- a/lib/graph/notification/discarded-events.c +++ b/lib/graph/message/discarded-events.c @@ -20,37 +20,37 @@ * SOFTWARE. */ -#include -#include -#include +#include +#include +#include #include struct bt_clock_value * -bt_notification_discarded_events_borrow_begin_clock_value( - struct bt_notification *notification) +bt_message_discarded_events_borrow_begin_clock_value( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_begin_clock_value( - BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification); + return bt_message_discarded_elements_borrow_begin_clock_value( + BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } struct bt_clock_value * -bt_notification_discarded_events_borrow_end_clock_value( - struct bt_notification *notification) +bt_message_discarded_events_borrow_end_clock_value( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_end_clock_value( - BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification); + return bt_message_discarded_elements_borrow_end_clock_value( + BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } -int64_t bt_notification_discarded_events_get_count( - struct bt_notification *notification) +int64_t bt_message_discarded_events_get_count( + struct bt_message *message) { - return bt_notification_discarded_elements_get_count( - BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification); + return bt_message_discarded_elements_get_count( + BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } -struct bt_stream *bt_notification_discarded_events_borrow_stream( - struct bt_notification *notification) +struct bt_stream *bt_message_discarded_events_borrow_stream( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_stream( - BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification); + return bt_message_discarded_elements_borrow_stream( + BT_MESSAGE_TYPE_DISCARDED_EVENTS, message); } diff --git a/lib/graph/notification/discarded-packets.c b/lib/graph/message/discarded-packets.c similarity index 54% rename from lib/graph/notification/discarded-packets.c rename to lib/graph/message/discarded-packets.c index 232164ac..953ba04c 100644 --- a/lib/graph/notification/discarded-packets.c +++ b/lib/graph/message/discarded-packets.c @@ -20,37 +20,37 @@ * SOFTWARE. */ -#include -#include -#include +#include +#include +#include #include struct bt_clock_value * -bt_notification_discarded_packets_borrow_begin_clock_value( - struct bt_notification *notification) +bt_message_discarded_packets_borrow_begin_clock_value( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_begin_clock_value( - BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification); + return bt_message_discarded_elements_borrow_begin_clock_value( + BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } struct bt_clock_value * -bt_notification_discarded_packets_borrow_end_clock_value( - struct bt_notification *notification) +bt_message_discarded_packets_borrow_end_clock_value( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_end_clock_value( - BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification); + return bt_message_discarded_elements_borrow_end_clock_value( + BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } -int64_t bt_notification_discarded_packets_get_count( - struct bt_notification *notification) +int64_t bt_message_discarded_packets_get_count( + struct bt_message *message) { - return bt_notification_discarded_elements_get_count( - BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification); + return bt_message_discarded_elements_get_count( + BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } -struct bt_stream *bt_notification_discarded_packets_borrow_stream( - struct bt_notification *notification) +struct bt_stream *bt_message_discarded_packets_borrow_stream( + struct bt_message *message) { - return bt_notification_discarded_elements_borrow_stream( - BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification); + return bt_message_discarded_elements_borrow_stream( + BT_MESSAGE_TYPE_DISCARDED_PACKETS, message); } diff --git a/lib/graph/message/event.c b/lib/graph/message/event.c new file mode 100644 index 00000000..b6517f82 --- /dev/null +++ b/lib/graph/message/event.c @@ -0,0 +1,201 @@ +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "MSG-EVENT" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BT_ASSERT_PRE_FUNC +static inline bool event_class_has_trace(struct bt_event_class *event_class) +{ + struct bt_stream_class *stream_class; + + stream_class = bt_event_class_borrow_stream_class(event_class); + BT_ASSERT(stream_class); + return bt_stream_class_borrow_trace_class(stream_class) != NULL; +} + +BT_HIDDEN +struct bt_message *bt_message_event_new( + struct bt_graph *graph) +{ + struct bt_message_event *message = NULL; + + message = g_new0(struct bt_message_event, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one event message."); + goto error; + } + + bt_message_init(&message->parent, BT_MESSAGE_TYPE_EVENT, + (bt_object_release_func) bt_message_event_recycle, graph); + goto end; + +error: + BT_OBJECT_PUT_REF_AND_RESET(message); + +end: + return (void *) message; +} + +struct bt_message *bt_message_event_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_event_class *event_class, + struct bt_packet *packet) +{ + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; + struct bt_message_event *message = NULL; + struct bt_event *event; + + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); + BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + BT_ASSERT_PRE(event_class_has_trace(event_class), + "Event class is not part of a trace: %!+E", event_class); + BT_LIB_LOGD("Creating event message object: %![ec-]+E", + event_class); + event = bt_event_create(event_class, packet); + if (unlikely(!event)) { + BT_LIB_LOGE("Cannot create event from event class: " + "%![ec-]+E", event_class); + goto error; + } + + /* + * Create message from pool _after_ we have everything + * (in this case, a valid event object) so that we never have an + * error condition with a non-NULL message object. + * Otherwise: + * + * * We cannot recycle the message on error because + * bt_message_event_recycle() expects a complete + * message (and the event or clock class priority map + * object could be unset). + * + * * We cannot destroy the message because we would need + * to notify the graph (pool owner) so that it removes the + * message from its message array. + */ + message = (void *) bt_message_create_from_pool( + &msg_iter->graph->event_msg_pool, msg_iter->graph); + if (unlikely(!message)) { + /* bt_message_create_from_pool() logs errors */ + goto error; + } + + BT_ASSERT(!message->event); + message->event = event; + bt_packet_set_is_frozen(packet, true); + bt_event_class_freeze(event_class); + BT_LIB_LOGD("Created event message object: " + "%![msg-]+n, %![event-]+e", message, event); + goto end; + +error: + BT_ASSERT(!message); + bt_event_destroy(event); + +end: + return (void *) message; +} + +BT_HIDDEN +void bt_message_event_destroy(struct bt_message *msg) +{ + struct bt_message_event *event_msg = (void *) msg; + + BT_LIB_LOGD("Destroying event message: %!+n", msg); + + if (event_msg->event) { + BT_LIB_LOGD("Recycling event: %!+e", event_msg->event); + bt_event_recycle(event_msg->event); + event_msg->event = NULL; + } + + g_free(msg); +} + +BT_HIDDEN +void bt_message_event_recycle(struct bt_message *msg) +{ + struct bt_message_event *event_msg = (void *) msg; + struct bt_graph *graph; + + BT_ASSERT(event_msg); + + if (unlikely(!msg->graph)) { + bt_message_event_destroy(msg); + return; + } + + BT_LIB_LOGD("Recycling event message: %![msg-]+n, %![event-]+e", + msg, event_msg->event); + bt_message_reset(msg); + BT_ASSERT(event_msg->event); + bt_event_recycle(event_msg->event); + event_msg->event = NULL; + graph = msg->graph; + msg->graph = NULL; + bt_object_pool_recycle_object(&graph->event_msg_pool, msg); +} + +static inline +struct bt_event *borrow_event(struct bt_message *message) +{ + struct bt_message_event *event_message; + + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_EVENT); + event_message = container_of(message, + struct bt_message_event, parent); + return event_message->event; +} + +struct bt_event *bt_message_event_borrow_event( + struct bt_message *message) +{ + return borrow_event(message); +} + +const struct bt_event *bt_message_event_borrow_event_const( + const struct bt_message *message) +{ + return borrow_event((void *) message); +} diff --git a/lib/graph/message/inactivity.c b/lib/graph/message/inactivity.c new file mode 100644 index 00000000..0b7dff90 --- /dev/null +++ b/lib/graph/message/inactivity.c @@ -0,0 +1,111 @@ +/* + * Copyright 2017-2018 Philippe Proulx + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "MSG-INACTIVITY" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static +void bt_message_inactivity_destroy(struct bt_object *obj) +{ + struct bt_message_inactivity *message = + (struct bt_message_inactivity *) obj; + + BT_LIB_LOGD("Destroying inactivity message: %!+n", message); + + if (message->default_cv) { + bt_clock_value_recycle(message->default_cv); + } + + g_free(message); +} + +struct bt_message *bt_message_inactivity_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_clock_class *default_clock_class) +{ + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; + struct bt_message_inactivity *message; + struct bt_message *ret_msg = NULL; + + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class"); + BT_LIB_LOGD("Creating inactivity message object: " + "%![iter-]+i, %![default-cc-]+K", msg_iter, + default_clock_class); + message = g_new0(struct bt_message_inactivity, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one inactivity message."); + goto error; + } + bt_message_init(&message->parent, + BT_MESSAGE_TYPE_INACTIVITY, + bt_message_inactivity_destroy, NULL); + ret_msg = &message->parent; + message->default_cv = bt_clock_value_create(default_clock_class); + if (!message->default_cv) { + goto error; + } + + BT_LIB_LOGD("Created inactivity message object: %!+n", ret_msg); + goto end; + +error: + BT_OBJECT_PUT_REF_AND_RESET(ret_msg); + +end: + return (void *) ret_msg; +} + +void bt_message_inactivity_set_default_clock_value( + struct bt_message *msg, uint64_t value_cycles) +{ + struct bt_message_inactivity *inactivity = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY); + BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); + bt_clock_value_set_value_inline(inactivity->default_cv, value_cycles); + BT_LIB_LOGV("Set inactivity message's default clock value: " + "%![msg-]+n, value=%" PRIu64, msg, value_cycles); +} + +const struct bt_clock_value * +bt_message_inactivity_borrow_default_clock_value_const( + const struct bt_message *msg) +{ + struct bt_message_inactivity *inactivity = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY); + return inactivity->default_cv; +} diff --git a/lib/graph/notification/notification.c b/lib/graph/message/message.c similarity index 59% rename from lib/graph/notification/notification.c rename to lib/graph/message/message.c index 7a2d859b..64e85511 100644 --- a/lib/graph/notification/notification.c +++ b/lib/graph/message/message.c @@ -21,65 +21,65 @@ * SOFTWARE. */ -#define BT_LOG_TAG "NOTIF" +#define BT_LOG_TAG "MSG" #include #include #include -#include -#include +#include +#include #include BT_ASSERT_PRE_FUNC -static inline void _init_seq_num(struct bt_notification *notification) +static inline void _init_seq_num(struct bt_message *message) { - notification->seq_num = UINT64_C(-1); + message->seq_num = UINT64_C(-1); } #ifdef BT_DEV_MODE # define init_seq_num _init_seq_num #else -# define init_seq_num(_notif) +# define init_seq_num(_msg) #endif /* BT_DEV_MODE */ BT_HIDDEN -void bt_notification_init(struct bt_notification *notification, - enum bt_notification_type type, +void bt_message_init(struct bt_message *message, + enum bt_message_type type, bt_object_release_func release, struct bt_graph *graph) { BT_ASSERT(type >= 0 && - type <= BT_NOTIFICATION_TYPE_PACKET_END); - notification->type = type; - init_seq_num(notification); - bt_object_init_shared(¬ification->base, release); - notification->graph = graph; + type <= BT_MESSAGE_TYPE_PACKET_END); + message->type = type; + init_seq_num(message); + bt_object_init_shared(&message->base, release); + message->graph = graph; if (graph) { - bt_graph_add_notification(graph, notification); + bt_graph_add_message(graph, message); } } -enum bt_notification_type bt_notification_get_type( - const struct bt_notification *notification) +enum bt_message_type bt_message_get_type( + const struct bt_message *message) { - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - return notification->type; + BT_ASSERT_PRE_NON_NULL(message, "Message"); + return message->type; } BT_HIDDEN -void bt_notification_unlink_graph(struct bt_notification *notif) +void bt_message_unlink_graph(struct bt_message *msg) { - BT_ASSERT(notif); - notif->graph = NULL; + BT_ASSERT(msg); + msg->graph = NULL; } -void bt_notification_get_ref(const struct bt_notification *notification) +void bt_message_get_ref(const struct bt_message *message) { - bt_object_get_ref(notification); + bt_object_get_ref(message); } -void bt_notification_put_ref(const struct bt_notification *notification) +void bt_message_put_ref(const struct bt_message *message) { - bt_object_put_ref(notification); + bt_object_put_ref(message); } diff --git a/lib/graph/message/packet.c b/lib/graph/message/packet.c new file mode 100644 index 00000000..22894c9b --- /dev/null +++ b/lib/graph/message/packet.c @@ -0,0 +1,271 @@ +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "MSG-PACKET" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BT_HIDDEN +struct bt_message *bt_message_packet_beginning_new(struct bt_graph *graph) +{ + struct bt_message_packet_beginning *message; + + message = g_new0(struct bt_message_packet_beginning, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one packet beginning message."); + goto error; + } + + bt_message_init(&message->parent, + BT_MESSAGE_TYPE_PACKET_BEGINNING, + (bt_object_release_func) bt_message_packet_beginning_recycle, + graph); + goto end; + +error: + BT_OBJECT_PUT_REF_AND_RESET(message); + +end: + return (void *) message; +} + +struct bt_message *bt_message_packet_beginning_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_packet *packet) +{ + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; + struct bt_message_packet_beginning *message = NULL; + struct bt_stream *stream; + struct bt_stream_class *stream_class; + + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + stream = bt_packet_borrow_stream(packet); + BT_ASSERT(stream); + stream_class = bt_stream_borrow_class(stream); + BT_ASSERT(stream_class); + BT_LIB_LOGD("Creating packet beginning message object: " + "%![packet-]+a, %![stream-]+s, %![sc-]+S", + packet, stream, stream_class); + message = (void *) bt_message_create_from_pool( + &msg_iter->graph->packet_begin_msg_pool, msg_iter->graph); + if (!message) { + /* bt_message_create_from_pool() logs errors */ + goto end; + } + + BT_ASSERT(!message->packet); + message->packet = packet; + bt_object_get_no_null_check_no_parent_check( + &message->packet->base); + bt_packet_set_is_frozen(packet, true); + BT_LIB_LOGD("Created packet beginning message object: " + "%![msg-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", + message, packet, stream, stream_class); + goto end; + +end: + return (void *) message; +} + +BT_HIDDEN +void bt_message_packet_beginning_destroy(struct bt_message *msg) +{ + struct bt_message_packet_beginning *packet_begin_msg = (void *) msg; + + BT_LIB_LOGD("Destroying packet beginning message: %!+n", msg); + BT_LIB_LOGD("Putting packet: %!+a", packet_begin_msg->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_begin_msg->packet); + g_free(msg); +} + +BT_HIDDEN +void bt_message_packet_beginning_recycle(struct bt_message *msg) +{ + struct bt_message_packet_beginning *packet_begin_msg = (void *) msg; + struct bt_graph *graph; + + BT_ASSERT(packet_begin_msg); + + if (unlikely(!msg->graph)) { + bt_message_packet_beginning_destroy(msg); + return; + } + + BT_LIB_LOGD("Recycling packet beginning message: %!+n", msg); + bt_message_reset(msg); + bt_object_put_no_null_check(&packet_begin_msg->packet->base); + packet_begin_msg->packet = NULL; + graph = msg->graph; + msg->graph = NULL; + bt_object_pool_recycle_object(&graph->packet_begin_msg_pool, msg); +} + +struct bt_packet *bt_message_packet_beginning_borrow_packet( + struct bt_message *message) +{ + struct bt_message_packet_beginning *packet_begin; + + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_PACKET_BEGINNING); + packet_begin = (void *) message; + return packet_begin->packet; +} + +const struct bt_packet *bt_message_packet_beginning_borrow_packet_const( + const struct bt_message *message) +{ + return bt_message_packet_beginning_borrow_packet( + (void *) message); +} + +BT_HIDDEN +struct bt_message *bt_message_packet_end_new(struct bt_graph *graph) +{ + struct bt_message_packet_end *message; + + message = g_new0(struct bt_message_packet_end, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one packet end message."); + goto error; + } + + bt_message_init(&message->parent, + BT_MESSAGE_TYPE_PACKET_END, + (bt_object_release_func) bt_message_packet_end_recycle, + graph); + goto end; + +error: + BT_OBJECT_PUT_REF_AND_RESET(message); + +end: + return (void *) message; +} + +struct bt_message *bt_message_packet_end_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_packet *packet) +{ + struct bt_self_component_port_input_message_iterator *msg_iter = + (void *) self_msg_iter; + struct bt_message_packet_end *message = NULL; + struct bt_stream *stream; + struct bt_stream_class *stream_class; + + BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + stream = bt_packet_borrow_stream(packet); + BT_ASSERT(stream); + stream_class = bt_stream_borrow_class(stream); + BT_ASSERT(stream_class); + BT_LIB_LOGD("Creating packet end message object: " + "%![packet-]+a, %![stream-]+s, %![sc-]+S", + packet, stream, stream_class); + message = (void *) bt_message_create_from_pool( + &msg_iter->graph->packet_end_msg_pool, msg_iter->graph); + if (!message) { + /* bt_message_create_from_pool() logs errors */ + goto end; + } + + BT_ASSERT(!message->packet); + message->packet = packet; + bt_object_get_no_null_check_no_parent_check( + &message->packet->base); + bt_packet_set_is_frozen(packet, true); + BT_LIB_LOGD("Created packet end message object: " + "%![msg-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", + message, packet, stream, stream_class); + goto end; + +end: + return (void *) message; +} + +BT_HIDDEN +void bt_message_packet_end_destroy(struct bt_message *msg) +{ + struct bt_message_packet_end *packet_end_msg = (void *) msg; + + BT_LIB_LOGD("Destroying packet end message: %!+n", msg); + BT_LIB_LOGD("Putting packet: %!+a", packet_end_msg->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_end_msg->packet); + g_free(msg); +} + +BT_HIDDEN +void bt_message_packet_end_recycle(struct bt_message *msg) +{ + struct bt_message_packet_end *packet_end_msg = (void *) msg; + struct bt_graph *graph; + + BT_ASSERT(packet_end_msg); + + if (!msg->graph) { + bt_message_packet_end_destroy(msg); + return; + } + + BT_LIB_LOGD("Recycling packet end message: %!+n", msg); + bt_message_reset(msg); + BT_OBJECT_PUT_REF_AND_RESET(packet_end_msg->packet); + graph = msg->graph; + msg->graph = NULL; + bt_object_pool_recycle_object(&graph->packet_end_msg_pool, msg); +} + +struct bt_packet *bt_message_packet_end_borrow_packet( + struct bt_message *message) +{ + struct bt_message_packet_end *packet_end; + + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_PACKET_END); + packet_end = (void *) message; + return packet_end->packet; +} + +const struct bt_packet *bt_message_packet_end_borrow_packet_const( + const struct bt_message *message) +{ + return bt_message_packet_end_borrow_packet( + (void *) message); +} diff --git a/lib/graph/message/stream.c b/lib/graph/message/stream.c new file mode 100644 index 00000000..46039696 --- /dev/null +++ b/lib/graph/message/stream.c @@ -0,0 +1,240 @@ +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2016 Jérémie Galarneau + * + * 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: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define BT_LOG_TAG "MSG-STREAM" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static +void bt_message_stream_end_destroy(struct bt_object *obj) +{ + struct bt_message_stream_end *message = + (struct bt_message_stream_end *) obj; + + BT_LIB_LOGD("Destroying stream end message: %!+n", + message); + BT_LIB_LOGD("Putting stream: %!+s", message->stream); + BT_OBJECT_PUT_REF_AND_RESET(message->stream); + + if (message->default_cv) { + bt_clock_value_recycle(message->default_cv); + message->default_cv = NULL; + } + + g_free(message); +} + +struct bt_message *bt_message_stream_end_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) +{ + struct bt_message_stream_end *message; + struct bt_stream_class *stream_class; + + BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + stream_class = bt_stream_borrow_class(stream); + BT_ASSERT(stream_class); + BT_LIB_LOGD("Creating stream end message object: " + "%![stream-]+s, %![sc-]+S", stream, stream_class); + message = g_new0(struct bt_message_stream_end, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one stream end message."); + goto error; + } + + bt_message_init(&message->parent, + BT_MESSAGE_TYPE_STREAM_END, + bt_message_stream_end_destroy, NULL); + message->stream = stream; + bt_object_get_no_null_check(message->stream); + BT_LIB_LOGD("Created stream end message object: " + "%![msg-]+n, %![stream-]+s, %![sc-]+S", message, + stream, stream_class); + + return (void *) &message->parent; +error: + return NULL; +} + +struct bt_stream *bt_message_stream_end_borrow_stream( + struct bt_message *message) +{ + struct bt_message_stream_end *stream_end; + + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_STREAM_END); + stream_end = (void *) message; + return stream_end->stream; +} + +const struct bt_stream *bt_message_stream_end_borrow_stream_const( + const struct bt_message *message) +{ + return bt_message_stream_end_borrow_stream( + (void *) message); +} + +void bt_message_stream_end_set_default_clock_value( + struct bt_message *msg, uint64_t value_cycles) +{ + struct bt_message_stream_end *se_msg = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END); + BT_ASSERT_PRE(se_msg->stream->class->default_clock_class, + "Message's stream class has no default clock class: " + "%![msg-]+n, %![sc-]+S", msg, se_msg->stream->class); + + /* TODO: have the object already created */ + se_msg->default_cv = bt_clock_value_create( + se_msg->stream->class->default_clock_class); + BT_ASSERT(se_msg->default_cv); + bt_clock_value_set_value_inline(se_msg->default_cv, value_cycles); + BT_LIB_LOGV("Set message's default clock value: %![msg-]+n, " + "value=%" PRIu64, value_cycles); +} + +struct bt_clock_value *bt_message_stream_end_borrow_default_clock_value( + struct bt_message *msg) +{ + struct bt_message_stream_end *stream_end = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END); + return stream_end->default_cv; +} + +static +void bt_message_stream_beginning_destroy(struct bt_object *obj) +{ + struct bt_message_stream_beginning *message = + (struct bt_message_stream_beginning *) obj; + + BT_LIB_LOGD("Destroying stream beginning message: %!+n", + message); + BT_LIB_LOGD("Putting stream: %!+s", message->stream); + BT_OBJECT_PUT_REF_AND_RESET(message->stream); + + if (message->default_cv) { + bt_clock_value_recycle(message->default_cv); + message->default_cv = NULL; + } + + g_free(message); +} + +struct bt_message *bt_message_stream_beginning_create( + struct bt_self_message_iterator *self_msg_iter, + struct bt_stream *stream) +{ + struct bt_message_stream_beginning *message; + struct bt_stream_class *stream_class; + + BT_ASSERT_PRE_NON_NULL(self_msg_iter, "Message iterator"); + BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + stream_class = bt_stream_borrow_class(stream); + BT_ASSERT(stream_class); + BT_LIB_LOGD("Creating stream beginning message object: " + "%![stream-]+s, %![sc-]+S", stream, stream_class); + message = g_new0(struct bt_message_stream_beginning, 1); + if (!message) { + BT_LOGE_STR("Failed to allocate one stream beginning message."); + goto error; + } + + bt_message_init(&message->parent, + BT_MESSAGE_TYPE_STREAM_BEGINNING, + bt_message_stream_beginning_destroy, NULL); + message->stream = stream; + bt_object_get_no_null_check(message->stream); + BT_LIB_LOGD("Created stream beginning message object: " + "%![msg-]+n, %![stream-]+s, %![sc-]+S", message, + stream, stream_class); + return (void *) &message->parent; +error: + return NULL; +} + +struct bt_stream *bt_message_stream_beginning_borrow_stream( + struct bt_message *message) +{ + struct bt_message_stream_beginning *stream_begin; + + BT_ASSERT_PRE_NON_NULL(message, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_MESSAGE_TYPE_STREAM_BEGINNING); + stream_begin = (void *) message; + return stream_begin->stream; +} + +const struct bt_stream *bt_message_stream_beginning_borrow_stream_const( + const struct bt_message *message) +{ + return bt_message_stream_beginning_borrow_stream( + (void *) message); +} + +void bt_message_stream_beginning_set_default_clock_value( + struct bt_message *msg, + uint64_t value_cycles) +{ + struct bt_message_stream_beginning *sb_msg = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_BEGINNING); + BT_ASSERT_PRE(sb_msg->stream->class->default_clock_class, + "Message's stream class has no default clock class: " + "%![msg-]+n, %![sc-]+S", msg, sb_msg->stream->class); + + /* TODO: have the object already created */ + sb_msg->default_cv = bt_clock_value_create( + sb_msg->stream->class->default_clock_class); + BT_ASSERT(sb_msg->default_cv); + bt_clock_value_set_value_inline(sb_msg->default_cv, value_cycles); + BT_LIB_LOGV("Set message's default clock value: %![msg-]+n, " + "value=%" PRIu64, value_cycles); +} + +struct bt_clock_value *bt_message_stream_beginning_borrow_default_clock_value( + struct bt_message *msg) +{ + struct bt_message_stream_beginning *stream_begin = (void *) msg; + + BT_ASSERT_PRE_NON_NULL(msg, "Message"); + BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_BEGINNING); + return stream_begin->default_cv; +} diff --git a/lib/graph/notification/Makefile.am b/lib/graph/notification/Makefile.am deleted file mode 100644 index dc253eb8..00000000 --- a/lib/graph/notification/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -noinst_LTLIBRARIES = libgraph-notification.la - -libgraph_notification_la_SOURCES = \ - notification.c \ - packet.c \ - event.c \ - stream.c \ - inactivity.c diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c deleted file mode 100644 index 3321af22..00000000 --- a/lib/graph/notification/event.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2016 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "NOTIF-EVENT" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BT_ASSERT_PRE_FUNC -static inline bool event_class_has_trace(struct bt_event_class *event_class) -{ - struct bt_stream_class *stream_class; - - stream_class = bt_event_class_borrow_stream_class(event_class); - BT_ASSERT(stream_class); - return bt_stream_class_borrow_trace_class(stream_class) != NULL; -} - -BT_HIDDEN -struct bt_notification *bt_notification_event_new( - struct bt_graph *graph) -{ - struct bt_notification_event *notification = NULL; - - notification = g_new0(struct bt_notification_event, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one event notification."); - goto error; - } - - bt_notification_init(¬ification->parent, BT_NOTIFICATION_TYPE_EVENT, - (bt_object_release_func) bt_notification_event_recycle, graph); - goto end; - -error: - BT_OBJECT_PUT_REF_AND_RESET(notification); - -end: - return (void *) notification; -} - -struct bt_notification *bt_notification_event_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_event_class *event_class, - struct bt_packet *packet) -{ - struct bt_self_component_port_input_notification_iterator *notif_iter = - (void *) self_notif_iter; - struct bt_notification_event *notification = NULL; - struct bt_event *event; - - BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - BT_ASSERT_PRE(event_class_has_trace(event_class), - "Event class is not part of a trace: %!+E", event_class); - BT_LIB_LOGD("Creating event notification object: %![ec-]+E", - event_class); - event = bt_event_create(event_class, packet); - if (unlikely(!event)) { - BT_LIB_LOGE("Cannot create event from event class: " - "%![ec-]+E", event_class); - goto error; - } - - /* - * Create notification from pool _after_ we have everything - * (in this case, a valid event object) so that we never have an - * error condition with a non-NULL notification object. - * Otherwise: - * - * * We cannot recycle the notification on error because - * bt_notification_event_recycle() expects a complete - * notification (and the event or clock class priority map - * object could be unset). - * - * * We cannot destroy the notification because we would need - * to notify the graph (pool owner) so that it removes the - * notification from its notification array. - */ - notification = (void *) bt_notification_create_from_pool( - ¬if_iter->graph->event_notif_pool, notif_iter->graph); - if (unlikely(!notification)) { - /* bt_notification_create_from_pool() logs errors */ - goto error; - } - - BT_ASSERT(!notification->event); - notification->event = event; - bt_packet_set_is_frozen(packet, true); - bt_event_class_freeze(event_class); - BT_LIB_LOGD("Created event notification object: " - "%![notif-]+n, %![event-]+e", notification, event); - goto end; - -error: - BT_ASSERT(!notification); - bt_event_destroy(event); - -end: - return (void *) notification; -} - -BT_HIDDEN -void bt_notification_event_destroy(struct bt_notification *notif) -{ - struct bt_notification_event *event_notif = (void *) notif; - - BT_LIB_LOGD("Destroying event notification: %!+n", notif); - - if (event_notif->event) { - BT_LIB_LOGD("Recycling event: %!+e", event_notif->event); - bt_event_recycle(event_notif->event); - event_notif->event = NULL; - } - - g_free(notif); -} - -BT_HIDDEN -void bt_notification_event_recycle(struct bt_notification *notif) -{ - struct bt_notification_event *event_notif = (void *) notif; - struct bt_graph *graph; - - BT_ASSERT(event_notif); - - if (unlikely(!notif->graph)) { - bt_notification_event_destroy(notif); - return; - } - - BT_LIB_LOGD("Recycling event notification: %![notif-]+n, %![event-]+e", - notif, event_notif->event); - bt_notification_reset(notif); - BT_ASSERT(event_notif->event); - bt_event_recycle(event_notif->event); - event_notif->event = NULL; - graph = notif->graph; - notif->graph = NULL; - bt_object_pool_recycle_object(&graph->event_notif_pool, notif); -} - -static inline -struct bt_event *borrow_event(struct bt_notification *notification) -{ - struct bt_notification_event *event_notification; - - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, BT_NOTIFICATION_TYPE_EVENT); - event_notification = container_of(notification, - struct bt_notification_event, parent); - return event_notification->event; -} - -struct bt_event *bt_notification_event_borrow_event( - struct bt_notification *notification) -{ - return borrow_event(notification); -} - -const struct bt_event *bt_notification_event_borrow_event_const( - const struct bt_notification *notification) -{ - return borrow_event((void *) notification); -} diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c deleted file mode 100644 index 47d759d4..00000000 --- a/lib/graph/notification/inactivity.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "NOTIF-INACTIVITY" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static -void bt_notification_inactivity_destroy(struct bt_object *obj) -{ - struct bt_notification_inactivity *notification = - (struct bt_notification_inactivity *) obj; - - BT_LIB_LOGD("Destroying inactivity notification: %!+n", notification); - - if (notification->default_cv) { - bt_clock_value_recycle(notification->default_cv); - } - - g_free(notification); -} - -struct bt_notification *bt_notification_inactivity_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_clock_class *default_clock_class) -{ - struct bt_self_component_port_input_notification_iterator *notif_iter = - (void *) self_notif_iter; - struct bt_notification_inactivity *notification; - struct bt_notification *ret_notif = NULL; - - BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class"); - BT_LIB_LOGD("Creating inactivity notification object: " - "%![iter-]+i, %![default-cc-]+K", notif_iter, - default_clock_class); - notification = g_new0(struct bt_notification_inactivity, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one inactivity notification."); - goto error; - } - bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_INACTIVITY, - bt_notification_inactivity_destroy, NULL); - ret_notif = ¬ification->parent; - notification->default_cv = bt_clock_value_create(default_clock_class); - if (!notification->default_cv) { - goto error; - } - - BT_LIB_LOGD("Created inactivity notification object: %!+n", ret_notif); - goto end; - -error: - BT_OBJECT_PUT_REF_AND_RESET(ret_notif); - -end: - return (void *) ret_notif; -} - -void bt_notification_inactivity_set_default_clock_value( - struct bt_notification *notif, uint64_t value_cycles) -{ - struct bt_notification_inactivity *inactivity = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_INACTIVITY); - BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif); - bt_clock_value_set_value_inline(inactivity->default_cv, value_cycles); - BT_LIB_LOGV("Set inactivity notification's default clock value: " - "%![notif-]+n, value=%" PRIu64, notif, value_cycles); -} - -const struct bt_clock_value * -bt_notification_inactivity_borrow_default_clock_value_const( - const struct bt_notification *notif) -{ - struct bt_notification_inactivity *inactivity = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_INACTIVITY); - return inactivity->default_cv; -} diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c deleted file mode 100644 index f548f8c5..00000000 --- a/lib/graph/notification/packet.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2016 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "NOTIF-PACKET" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -BT_HIDDEN -struct bt_notification *bt_notification_packet_beginning_new(struct bt_graph *graph) -{ - struct bt_notification_packet_beginning *notification; - - notification = g_new0(struct bt_notification_packet_beginning, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one packet beginning notification."); - goto error; - } - - bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_PACKET_BEGINNING, - (bt_object_release_func) bt_notification_packet_beginning_recycle, - graph); - goto end; - -error: - BT_OBJECT_PUT_REF_AND_RESET(notification); - -end: - return (void *) notification; -} - -struct bt_notification *bt_notification_packet_beginning_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_packet *packet) -{ - struct bt_self_component_port_input_notification_iterator *notif_iter = - (void *) self_notif_iter; - struct bt_notification_packet_beginning *notification = NULL; - struct bt_stream *stream; - struct bt_stream_class *stream_class; - - BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - stream = bt_packet_borrow_stream(packet); - BT_ASSERT(stream); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating packet beginning notification object: " - "%![packet-]+a, %![stream-]+s, %![sc-]+S", - packet, stream, stream_class); - notification = (void *) bt_notification_create_from_pool( - ¬if_iter->graph->packet_begin_notif_pool, notif_iter->graph); - if (!notification) { - /* bt_notification_create_from_pool() logs errors */ - goto end; - } - - BT_ASSERT(!notification->packet); - notification->packet = packet; - bt_object_get_no_null_check_no_parent_check( - ¬ification->packet->base); - bt_packet_set_is_frozen(packet, true); - BT_LIB_LOGD("Created packet beginning notification object: " - "%![notif-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", - notification, packet, stream, stream_class); - goto end; - -end: - return (void *) notification; -} - -BT_HIDDEN -void bt_notification_packet_beginning_destroy(struct bt_notification *notif) -{ - struct bt_notification_packet_beginning *packet_begin_notif = (void *) notif; - - BT_LIB_LOGD("Destroying packet beginning notification: %!+n", notif); - BT_LIB_LOGD("Putting packet: %!+a", packet_begin_notif->packet); - BT_OBJECT_PUT_REF_AND_RESET(packet_begin_notif->packet); - g_free(notif); -} - -BT_HIDDEN -void bt_notification_packet_beginning_recycle(struct bt_notification *notif) -{ - struct bt_notification_packet_beginning *packet_begin_notif = (void *) notif; - struct bt_graph *graph; - - BT_ASSERT(packet_begin_notif); - - if (unlikely(!notif->graph)) { - bt_notification_packet_beginning_destroy(notif); - return; - } - - BT_LIB_LOGD("Recycling packet beginning notification: %!+n", notif); - bt_notification_reset(notif); - bt_object_put_no_null_check(&packet_begin_notif->packet->base); - packet_begin_notif->packet = NULL; - graph = notif->graph; - notif->graph = NULL; - bt_object_pool_recycle_object(&graph->packet_begin_notif_pool, notif); -} - -struct bt_packet *bt_notification_packet_beginning_borrow_packet( - struct bt_notification *notification) -{ - struct bt_notification_packet_beginning *packet_begin; - - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, - BT_NOTIFICATION_TYPE_PACKET_BEGINNING); - packet_begin = (void *) notification; - return packet_begin->packet; -} - -const struct bt_packet *bt_notification_packet_beginning_borrow_packet_const( - const struct bt_notification *notification) -{ - return bt_notification_packet_beginning_borrow_packet( - (void *) notification); -} - -BT_HIDDEN -struct bt_notification *bt_notification_packet_end_new(struct bt_graph *graph) -{ - struct bt_notification_packet_end *notification; - - notification = g_new0(struct bt_notification_packet_end, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one packet end notification."); - goto error; - } - - bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_PACKET_END, - (bt_object_release_func) bt_notification_packet_end_recycle, - graph); - goto end; - -error: - BT_OBJECT_PUT_REF_AND_RESET(notification); - -end: - return (void *) notification; -} - -struct bt_notification *bt_notification_packet_end_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_packet *packet) -{ - struct bt_self_component_port_input_notification_iterator *notif_iter = - (void *) self_notif_iter; - struct bt_notification_packet_end *notification = NULL; - struct bt_stream *stream; - struct bt_stream_class *stream_class; - - BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - stream = bt_packet_borrow_stream(packet); - BT_ASSERT(stream); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating packet end notification object: " - "%![packet-]+a, %![stream-]+s, %![sc-]+S", - packet, stream, stream_class); - notification = (void *) bt_notification_create_from_pool( - ¬if_iter->graph->packet_end_notif_pool, notif_iter->graph); - if (!notification) { - /* bt_notification_create_from_pool() logs errors */ - goto end; - } - - BT_ASSERT(!notification->packet); - notification->packet = packet; - bt_object_get_no_null_check_no_parent_check( - ¬ification->packet->base); - bt_packet_set_is_frozen(packet, true); - BT_LIB_LOGD("Created packet end notification object: " - "%![notif-]+n, %![packet-]+a, %![stream-]+s, %![sc-]+S", - notification, packet, stream, stream_class); - goto end; - -end: - return (void *) notification; -} - -BT_HIDDEN -void bt_notification_packet_end_destroy(struct bt_notification *notif) -{ - struct bt_notification_packet_end *packet_end_notif = (void *) notif; - - BT_LIB_LOGD("Destroying packet end notification: %!+n", notif); - BT_LIB_LOGD("Putting packet: %!+a", packet_end_notif->packet); - BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet); - g_free(notif); -} - -BT_HIDDEN -void bt_notification_packet_end_recycle(struct bt_notification *notif) -{ - struct bt_notification_packet_end *packet_end_notif = (void *) notif; - struct bt_graph *graph; - - BT_ASSERT(packet_end_notif); - - if (!notif->graph) { - bt_notification_packet_end_destroy(notif); - return; - } - - BT_LIB_LOGD("Recycling packet end notification: %!+n", notif); - bt_notification_reset(notif); - BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet); - graph = notif->graph; - notif->graph = NULL; - bt_object_pool_recycle_object(&graph->packet_end_notif_pool, notif); -} - -struct bt_packet *bt_notification_packet_end_borrow_packet( - struct bt_notification *notification) -{ - struct bt_notification_packet_end *packet_end; - - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, - BT_NOTIFICATION_TYPE_PACKET_END); - packet_end = (void *) notification; - return packet_end->packet; -} - -const struct bt_packet *bt_notification_packet_end_borrow_packet_const( - const struct bt_notification *notification) -{ - return bt_notification_packet_end_borrow_packet( - (void *) notification); -} diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c deleted file mode 100644 index 61ff2780..00000000 --- a/lib/graph/notification/stream.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2016 Jérémie Galarneau - * - * 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: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "NOTIF-STREAM" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static -void bt_notification_stream_end_destroy(struct bt_object *obj) -{ - struct bt_notification_stream_end *notification = - (struct bt_notification_stream_end *) obj; - - BT_LIB_LOGD("Destroying stream end notification: %!+n", - notification); - BT_LIB_LOGD("Putting stream: %!+s", notification->stream); - BT_OBJECT_PUT_REF_AND_RESET(notification->stream); - - if (notification->default_cv) { - bt_clock_value_recycle(notification->default_cv); - notification->default_cv = NULL; - } - - g_free(notification); -} - -struct bt_notification *bt_notification_stream_end_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_stream *stream) -{ - struct bt_notification_stream_end *notification; - struct bt_stream_class *stream_class; - - BT_ASSERT_PRE_NON_NULL(self_notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(stream, "Stream"); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating stream end notification object: " - "%![stream-]+s, %![sc-]+S", stream, stream_class); - notification = g_new0(struct bt_notification_stream_end, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one stream end notification."); - goto error; - } - - bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_STREAM_END, - bt_notification_stream_end_destroy, NULL); - notification->stream = stream; - bt_object_get_no_null_check(notification->stream); - BT_LIB_LOGD("Created stream end notification object: " - "%![notif-]+n, %![stream-]+s, %![sc-]+S", notification, - stream, stream_class); - - return (void *) ¬ification->parent; -error: - return NULL; -} - -struct bt_stream *bt_notification_stream_end_borrow_stream( - struct bt_notification *notification) -{ - struct bt_notification_stream_end *stream_end; - - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, - BT_NOTIFICATION_TYPE_STREAM_END); - stream_end = (void *) notification; - return stream_end->stream; -} - -const struct bt_stream *bt_notification_stream_end_borrow_stream_const( - const struct bt_notification *notification) -{ - return bt_notification_stream_end_borrow_stream( - (void *) notification); -} - -void bt_notification_stream_end_set_default_clock_value( - struct bt_notification *notif, uint64_t value_cycles) -{ - struct bt_notification_stream_end *se_notif = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_END); - BT_ASSERT_PRE(se_notif->stream->class->default_clock_class, - "Notification's stream class has no default clock class: " - "%![notif-]+n, %![sc-]+S", notif, se_notif->stream->class); - - /* TODO: have the object already created */ - se_notif->default_cv = bt_clock_value_create( - se_notif->stream->class->default_clock_class); - BT_ASSERT(se_notif->default_cv); - bt_clock_value_set_value_inline(se_notif->default_cv, value_cycles); - BT_LIB_LOGV("Set notification's default clock value: %![notif-]+n, " - "value=%" PRIu64, value_cycles); -} - -struct bt_clock_value *bt_notification_stream_end_borrow_default_clock_value( - struct bt_notification *notif) -{ - struct bt_notification_stream_end *stream_end = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_END); - return stream_end->default_cv; -} - -static -void bt_notification_stream_beginning_destroy(struct bt_object *obj) -{ - struct bt_notification_stream_beginning *notification = - (struct bt_notification_stream_beginning *) obj; - - BT_LIB_LOGD("Destroying stream beginning notification: %!+n", - notification); - BT_LIB_LOGD("Putting stream: %!+s", notification->stream); - BT_OBJECT_PUT_REF_AND_RESET(notification->stream); - - if (notification->default_cv) { - bt_clock_value_recycle(notification->default_cv); - notification->default_cv = NULL; - } - - g_free(notification); -} - -struct bt_notification *bt_notification_stream_beginning_create( - struct bt_self_notification_iterator *self_notif_iter, - struct bt_stream *stream) -{ - struct bt_notification_stream_beginning *notification; - struct bt_stream_class *stream_class; - - BT_ASSERT_PRE_NON_NULL(self_notif_iter, "Notification iterator"); - BT_ASSERT_PRE_NON_NULL(stream, "Stream"); - stream_class = bt_stream_borrow_class(stream); - BT_ASSERT(stream_class); - BT_LIB_LOGD("Creating stream beginning notification object: " - "%![stream-]+s, %![sc-]+S", stream, stream_class); - notification = g_new0(struct bt_notification_stream_beginning, 1); - if (!notification) { - BT_LOGE_STR("Failed to allocate one stream beginning notification."); - goto error; - } - - bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_STREAM_BEGINNING, - bt_notification_stream_beginning_destroy, NULL); - notification->stream = stream; - bt_object_get_no_null_check(notification->stream); - BT_LIB_LOGD("Created stream beginning notification object: " - "%![notif-]+n, %![stream-]+s, %![sc-]+S", notification, - stream, stream_class); - return (void *) ¬ification->parent; -error: - return NULL; -} - -struct bt_stream *bt_notification_stream_beginning_borrow_stream( - struct bt_notification *notification) -{ - struct bt_notification_stream_beginning *stream_begin; - - BT_ASSERT_PRE_NON_NULL(notification, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, - BT_NOTIFICATION_TYPE_STREAM_BEGINNING); - stream_begin = (void *) notification; - return stream_begin->stream; -} - -const struct bt_stream *bt_notification_stream_beginning_borrow_stream_const( - const struct bt_notification *notification) -{ - return bt_notification_stream_beginning_borrow_stream( - (void *) notification); -} - -void bt_notification_stream_beginning_set_default_clock_value( - struct bt_notification *notif, - uint64_t value_cycles) -{ - struct bt_notification_stream_beginning *sb_notif = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_HOT(notif, "Notification", ": %!+n", notif); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_BEGINNING); - BT_ASSERT_PRE(sb_notif->stream->class->default_clock_class, - "Notification's stream class has no default clock class: " - "%![notif-]+n, %![sc-]+S", notif, sb_notif->stream->class); - - /* TODO: have the object already created */ - sb_notif->default_cv = bt_clock_value_create( - sb_notif->stream->class->default_clock_class); - BT_ASSERT(sb_notif->default_cv); - bt_clock_value_set_value_inline(sb_notif->default_cv, value_cycles); - BT_LIB_LOGV("Set notification's default clock value: %![notif-]+n, " - "value=%" PRIu64, value_cycles); -} - -struct bt_clock_value *bt_notification_stream_beginning_borrow_default_clock_value( - struct bt_notification *notif) -{ - struct bt_notification_stream_beginning *stream_begin = (void *) notif; - - BT_ASSERT_PRE_NON_NULL(notif, "Notification"); - BT_ASSERT_PRE_NOTIF_IS_TYPE(notif, BT_NOTIFICATION_TYPE_STREAM_BEGINNING); - return stream_begin->default_cv; -} diff --git a/lib/lib-logging.c b/lib/lib-logging.c index d3d709bb..d418310f 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -61,12 +61,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -900,78 +900,78 @@ static inline void format_value(char **buf_ch, bool extended, } } -static inline void format_notification(char **buf_ch, bool extended, - const char *prefix, const struct bt_notification *notif) +static inline void format_message(char **buf_ch, bool extended, + const char *prefix, const struct bt_message *msg) { char tmp_prefix[64]; BUF_APPEND(", %stype=%s", - PRFIELD(bt_notification_type_string(notif->type))); + PRFIELD(bt_message_type_string(msg->type))); if (!extended) { return; } BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p", - PRFIELD(notif->frozen), PRFIELD(notif->graph)); + PRFIELD(msg->frozen), PRFIELD(msg->graph)); - switch (notif->type) { - case BT_NOTIFICATION_TYPE_EVENT: + switch (msg->type) { + case BT_MESSAGE_TYPE_EVENT: { - const struct bt_notification_event *notif_event = - (const void *) notif; + const struct bt_message_event *msg_event = + (const void *) msg; - if (notif_event->event) { + if (msg_event->event) { SET_TMP_PREFIX("event-"); - format_event(buf_ch, true, tmp_prefix, notif_event->event); + format_event(buf_ch, true, tmp_prefix, msg_event->event); } break; } - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_BEGINNING: { - const struct bt_notification_stream_beginning *notif_stream = - (const void *) notif; + const struct bt_message_stream_beginning *msg_stream = + (const void *) msg; - if (notif_stream->stream) { + if (msg_stream->stream) { SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); + format_stream(buf_ch, true, tmp_prefix, msg_stream->stream); } break; } - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_END: { - const struct bt_notification_stream_end *notif_stream = - (const void *) notif; + const struct bt_message_stream_end *msg_stream = + (const void *) msg; - if (notif_stream->stream) { + if (msg_stream->stream) { SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); + format_stream(buf_ch, true, tmp_prefix, msg_stream->stream); } break; } - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + case BT_MESSAGE_TYPE_PACKET_BEGINNING: { - const struct bt_notification_packet_beginning *notif_packet = - (const void *) notif; + const struct bt_message_packet_beginning *msg_packet = + (const void *) msg; - if (notif_packet->packet) { + if (msg_packet->packet) { SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); + format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); } break; } - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_PACKET_END: { - const struct bt_notification_packet_end *notif_packet = - (const void *) notif; + const struct bt_message_packet_end *msg_packet = + (const void *) msg; - if (notif_packet->packet) { + if (msg_packet->packet) { SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); + format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); } break; @@ -1113,26 +1113,26 @@ static inline void format_graph(char **buf_ch, bool extended, SET_TMP_PREFIX("en-pool-"); format_object_pool(buf_ch, extended, prefix, - &graph->event_notif_pool); + &graph->event_msg_pool); SET_TMP_PREFIX("pbn-pool-"); format_object_pool(buf_ch, extended, prefix, - &graph->packet_begin_notif_pool); + &graph->packet_begin_msg_pool); SET_TMP_PREFIX("pen-pool-"); format_object_pool(buf_ch, extended, prefix, - &graph->packet_end_notif_pool); + &graph->packet_end_msg_pool); } -static inline void format_notification_iterator(char **buf_ch, +static inline void format_message_iterator(char **buf_ch, bool extended, const char *prefix, - const struct bt_notification_iterator *iterator) + const struct bt_message_iterator *iterator) { const char *type; char tmp_prefix[64]; - if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) { - type = "BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT"; - } else if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT) { - type = "BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT"; + if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) { + type = "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT"; + } else if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT) { + type = "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT"; } else { type = "(unknown)"; } @@ -1140,9 +1140,9 @@ static inline void format_notification_iterator(char **buf_ch, BUF_APPEND(", %stype=%s", PRFIELD(type)); switch (iterator->type) { - case BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT: + case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT: { - const struct bt_self_component_port_input_notification_iterator * + const struct bt_self_component_port_input_message_iterator * port_in_iter = (const void *) iterator; if (port_in_iter->upstream_component) { @@ -1164,9 +1164,9 @@ static inline void format_notification_iterator(char **buf_ch, } break; } - case BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT: + case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT: { - const struct bt_port_output_notification_iterator *port_out_iter = + const struct bt_port_output_message_iterator *port_out_iter = (const void *) iterator; if (port_out_iter->graph) { @@ -1338,10 +1338,10 @@ static inline void handle_conversion_specifier_bt(void *priv_data, format_value(buf_ch, extended, prefix, obj); break; case 'n': - format_notification(buf_ch, extended, prefix, obj); + format_message(buf_ch, extended, prefix, obj); break; case 'i': - format_notification_iterator(buf_ch, extended, prefix, obj); + format_message_iterator(buf_ch, extended, prefix, obj); break; case 'C': format_component_class(buf_ch, extended, prefix, obj); diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index cf0b66f1..f785554d 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -291,8 +291,8 @@ enum bt_plugin_status bt_plugin_so_init( bt_component_class_source_accept_output_port_connection_method accept_output_port_connection; bt_component_class_source_output_port_connected_method output_port_connected; bt_component_class_source_output_port_disconnected_method output_port_disconnected; - bt_component_class_source_notification_iterator_init_method notif_iter_init; - bt_component_class_source_notification_iterator_finalize_method notif_iter_finalize; + bt_component_class_source_message_iterator_init_method msg_iter_init; + bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; } source; struct { @@ -305,8 +305,8 @@ enum bt_plugin_status bt_plugin_so_init( bt_component_class_filter_output_port_connected_method output_port_connected; bt_component_class_filter_input_port_disconnected_method input_port_disconnected; bt_component_class_filter_output_port_disconnected_method output_port_disconnected; - bt_component_class_filter_notification_iterator_init_method notif_iter_init; - bt_component_class_filter_notification_iterator_finalize_method notif_iter_finalize; + bt_component_class_filter_message_iterator_init_method msg_iter_init; + bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; } filter; struct { @@ -613,29 +613,29 @@ enum bt_plugin_status bt_plugin_so_init( abort(); } break; - case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD: + case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - cc_full_descr->methods.source.notif_iter_init = - cur_cc_descr_attr->value.source_notif_iter_init_method; + cc_full_descr->methods.source.msg_iter_init = + cur_cc_descr_attr->value.source_msg_iter_init_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: - cc_full_descr->methods.filter.notif_iter_init = - cur_cc_descr_attr->value.filter_notif_iter_init_method; + cc_full_descr->methods.filter.msg_iter_init = + cur_cc_descr_attr->value.filter_msg_iter_init_method; break; default: abort(); } break; - case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_FINALIZE_METHOD: + case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - cc_full_descr->methods.source.notif_iter_finalize = - cur_cc_descr_attr->value.source_notif_iter_finalize_method; + cc_full_descr->methods.source.msg_iter_finalize = + cur_cc_descr_attr->value.source_msg_iter_finalize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: - cc_full_descr->methods.filter.notif_iter_finalize = - cur_cc_descr_attr->value.filter_notif_iter_finalize_method; + cc_full_descr->methods.filter.msg_iter_finalize = + cur_cc_descr_attr->value.filter_msg_iter_finalize_method; break; default: abort(); @@ -711,14 +711,14 @@ enum bt_plugin_status bt_plugin_so_init( case BT_COMPONENT_CLASS_TYPE_SOURCE: src_comp_class = bt_component_class_source_create( cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.notif_iter_next); + cc_full_descr->descriptor->methods.source.msg_iter_next); comp_class = bt_component_class_source_as_component_class( src_comp_class); break; case BT_COMPONENT_CLASS_TYPE_FILTER: flt_comp_class = bt_component_class_filter_create( cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.notif_iter_next); + cc_full_descr->descriptor->methods.source.msg_iter_next); comp_class = bt_component_class_filter_as_component_class( flt_comp_class); break; @@ -851,24 +851,24 @@ enum bt_plugin_status bt_plugin_so_init( } } - if (cc_full_descr->methods.source.notif_iter_init) { - ret = bt_component_class_source_set_notification_iterator_init_method( + if (cc_full_descr->methods.source.msg_iter_init) { + ret = bt_component_class_source_set_message_iterator_init_method( src_comp_class, - cc_full_descr->methods.source.notif_iter_init); + cc_full_descr->methods.source.msg_iter_init); if (ret) { - BT_LOGE_STR("Cannot set source component class's notification iterator initialization method."); + BT_LOGE_STR("Cannot set source component class's message iterator initialization method."); status = BT_PLUGIN_STATUS_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; } } - if (cc_full_descr->methods.source.notif_iter_finalize) { - ret = bt_component_class_source_set_notification_iterator_finalize_method( + if (cc_full_descr->methods.source.msg_iter_finalize) { + ret = bt_component_class_source_set_message_iterator_finalize_method( src_comp_class, - cc_full_descr->methods.source.notif_iter_finalize); + cc_full_descr->methods.source.msg_iter_finalize); if (ret) { - BT_LOGE_STR("Cannot set source component class's notification iterator finalization method."); + BT_LOGE_STR("Cannot set source component class's message iterator finalization method."); status = BT_PLUGIN_STATUS_ERROR; BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); goto end; @@ -985,24 +985,24 @@ enum bt_plugin_status bt_plugin_so_init( } } - if (cc_full_descr->methods.filter.notif_iter_init) { - ret = bt_component_class_filter_set_notification_iterator_init_method( + if (cc_full_descr->methods.filter.msg_iter_init) { + ret = bt_component_class_filter_set_message_iterator_init_method( flt_comp_class, - cc_full_descr->methods.filter.notif_iter_init); + cc_full_descr->methods.filter.msg_iter_init); if (ret) { - BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method."); + BT_LOGE_STR("Cannot set filter component class's message iterator initialization method."); status = BT_PLUGIN_STATUS_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } } - if (cc_full_descr->methods.filter.notif_iter_finalize) { - ret = bt_component_class_filter_set_notification_iterator_finalize_method( + if (cc_full_descr->methods.filter.msg_iter_finalize) { + ret = bt_component_class_filter_set_message_iterator_finalize_method( flt_comp_class, - cc_full_descr->methods.filter.notif_iter_finalize); + cc_full_descr->methods.filter.msg_iter_finalize); if (ret) { - BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method."); + BT_LOGE_STR("Cannot set filter component class's message iterator finalization method."); status = BT_PLUGIN_STATUS_ERROR; BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; diff --git a/plugins/ctf/common/Makefile.am b/plugins/ctf/common/Makefile.am index 5ac77494..5b70fb4f 100644 --- a/plugins/ctf/common/Makefile.am +++ b/plugins/ctf/common/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = metadata bfcr notif-iter utils +SUBDIRS = metadata bfcr msg-iter utils noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-common.la libbabeltrace_plugin_ctf_common_la_SOURCES = print.h @@ -6,5 +6,5 @@ libbabeltrace_plugin_ctf_common_la_LIBADD = \ $(builddir)/metadata/libctf-parser.la \ $(builddir)/metadata/libctf-ast.la \ $(builddir)/bfcr/libctf-bfcr.la \ - $(builddir)/notif-iter/libctf-notif-iter.la \ + $(builddir)/msg-iter/libctf-msg-iter.la \ $(builddir)/utils/libctf-utils.la diff --git a/plugins/ctf/common/bfcr/bfcr.h b/plugins/ctf/common/bfcr/bfcr.h index 2ffbce5f..466db579 100644 --- a/plugins/ctf/common/bfcr/bfcr.h +++ b/plugins/ctf/common/bfcr/bfcr.h @@ -112,7 +112,7 @@ struct bt_bfcr_cbs { * to class reader's user). * * Any member of this structure may be set to \c NULL, should - * a specific notification be not needed. + * a specific message be not needed. */ struct { /** diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index 8196e5c1..08c1e03b 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -4713,7 +4713,7 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) /* * Old versions of LTTng forgot to set its clock class * as absolute, even if it is. This is important because - * it's a condition to be able to sort notifications + * it's a condition to be able to sort messages * from different sources. */ bt_clock_class_set_is_absolute(clock, BT_TRUE); diff --git a/plugins/ctf/common/msg-iter/Makefile.am b/plugins/ctf/common/msg-iter/Makefile.am new file mode 100644 index 00000000..7c3c2087 --- /dev/null +++ b/plugins/ctf/common/msg-iter/Makefile.am @@ -0,0 +1,7 @@ +noinst_LTLIBRARIES = libctf-msg-iter.la + +libctf_msg_iter_la_SOURCES = \ + msg-iter.c \ + msg-iter.h \ + logging.c \ + logging.h diff --git a/plugins/ctf/common/notif-iter/logging.c b/plugins/ctf/common/msg-iter/logging.c similarity index 88% rename from plugins/ctf/common/notif-iter/logging.c rename to plugins/ctf/common/msg-iter/logging.c index 082d4446..31005ba6 100644 --- a/plugins/ctf/common/notif-iter/logging.c +++ b/plugins/ctf/common/msg-iter/logging.c @@ -20,8 +20,8 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL ctf_notif_iter_log_level +#define BT_LOG_OUTPUT_LEVEL ctf_msg_iter_log_level #include -BT_LOG_INIT_LOG_LEVEL(ctf_notif_iter_log_level, - "BABELTRACE_PLUGIN_CTF_NOTIF_ITER_LOG_LEVEL"); +BT_LOG_INIT_LOG_LEVEL(ctf_msg_iter_log_level, + "BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL"); diff --git a/plugins/ctf/common/notif-iter/logging.h b/plugins/ctf/common/msg-iter/logging.h similarity index 84% rename from plugins/ctf/common/notif-iter/logging.h rename to plugins/ctf/common/msg-iter/logging.h index 74f3c8f8..bd7614c9 100644 --- a/plugins/ctf/common/notif-iter/logging.h +++ b/plugins/ctf/common/msg-iter/logging.h @@ -1,5 +1,5 @@ -#ifndef CTF_NOTIF_ITER_LOGGING_H -#define CTF_NOTIF_ITER_LOGGING_H +#ifndef CTF_MSG_ITER_LOGGING_H +#define CTF_MSG_ITER_LOGGING_H /* * Copyright (c) 2017 Philippe Proulx @@ -23,9 +23,9 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL ctf_notif_iter_log_level +#define BT_LOG_OUTPUT_LEVEL ctf_msg_iter_log_level #include -BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_notif_iter_log_level); +BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_msg_iter_log_level); -#endif /* CTF_NOTIF_ITER_LOGGING_H */ +#endif /* CTF_MSG_ITER_LOGGING_H */ diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/msg-iter/msg-iter.c similarity index 81% rename from plugins/ctf/common/notif-iter/notif-iter.c rename to plugins/ctf/common/msg-iter/msg-iter.c index 3d377d35..4843f275 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/msg-iter/msg-iter.c @@ -1,5 +1,5 @@ /* - * Babeltrace - CTF notification iterator + * Babeltrace - CTF message iterator * * Copyright (c) 2015-2018 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015-2018 Philippe Proulx @@ -23,7 +23,7 @@ * SOFTWARE. */ -#define BT_LOG_TAG "PLUGIN-CTF-NOTIF-ITER" +#define BT_LOG_TAG "PLUGIN-CTF-MSG-ITER" #include "logging.h" #include @@ -38,10 +38,10 @@ #include #include -#include "notif-iter.h" +#include "msg-iter.h" #include "../bfcr/bfcr.h" -struct bt_notif_iter; +struct bt_msg_iter; /* A visit stack entry */ struct stack_entry { @@ -80,8 +80,8 @@ enum state { STATE_DSCOPE_STREAM_PACKET_CONTEXT_BEGIN, STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE, STATE_AFTER_STREAM_PACKET_CONTEXT, - STATE_EMIT_NOTIF_NEW_STREAM, - STATE_EMIT_NOTIF_NEW_PACKET, + STATE_EMIT_MSG_NEW_STREAM, + STATE_EMIT_MSG_NEW_PACKET, STATE_DSCOPE_EVENT_HEADER_BEGIN, STATE_DSCOPE_EVENT_HEADER_CONTINUE, STATE_AFTER_EVENT_HEADER, @@ -91,19 +91,19 @@ enum state { STATE_DSCOPE_EVENT_SPEC_CONTEXT_CONTINUE, STATE_DSCOPE_EVENT_PAYLOAD_BEGIN, STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE, - STATE_EMIT_NOTIF_EVENT, - STATE_EMIT_NOTIF_END_OF_PACKET, + STATE_EMIT_MSG_EVENT, + STATE_EMIT_MSG_END_OF_PACKET, STATE_DONE, STATE_SKIP_PACKET_PADDING, }; -/* CTF notification iterator */ -struct bt_notif_iter { +/* CTF message iterator */ +struct bt_msg_iter { /* Visit stack */ struct stack *stack; - /* Current notification iterator to create notifications (weak) */ - bt_self_notification_iterator *notif_iter; + /* Current message iterator to create messages (weak) */ + bt_self_message_iterator *msg_iter; /* * Current dynamic scope field pointer. @@ -144,8 +144,8 @@ struct bt_notif_iter { /* Current event (NULL if not created yet) */ bt_event *event; - /* Current event notification (NULL if not created yet) */ - bt_notification *event_notif; + /* Current event message (NULL if not created yet) */ + bt_message *event_msg; /* Database of current dynamic scopes */ struct { @@ -183,7 +183,7 @@ struct bt_notif_iter { /* Current medium data */ struct { - struct bt_notif_iter_medium_ops medops; + struct bt_msg_iter_medium_ops medops; size_t max_request_sz; void *data; } medium; @@ -245,10 +245,10 @@ const char *state_string(enum state state) return "STATE_DSCOPE_STREAM_PACKET_CONTEXT_CONTINUE"; case STATE_AFTER_STREAM_PACKET_CONTEXT: return "STATE_AFTER_STREAM_PACKET_CONTEXT"; - case STATE_EMIT_NOTIF_NEW_PACKET: - return "STATE_EMIT_NOTIF_NEW_PACKET"; - case STATE_EMIT_NOTIF_NEW_STREAM: - return "STATE_EMIT_NOTIF_NEW_STREAM"; + case STATE_EMIT_MSG_NEW_PACKET: + return "STATE_EMIT_MSG_NEW_PACKET"; + case STATE_EMIT_MSG_NEW_STREAM: + return "STATE_EMIT_MSG_NEW_STREAM"; case STATE_DSCOPE_EVENT_HEADER_BEGIN: return "STATE_DSCOPE_EVENT_HEADER_BEGIN"; case STATE_DSCOPE_EVENT_HEADER_CONTINUE: @@ -267,10 +267,10 @@ const char *state_string(enum state state) return "STATE_DSCOPE_EVENT_PAYLOAD_BEGIN"; case STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE: return "STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE"; - case STATE_EMIT_NOTIF_EVENT: - return "STATE_EMIT_NOTIF_EVENT"; - case STATE_EMIT_NOTIF_END_OF_PACKET: - return "STATE_EMIT_NOTIF_END_OF_PACKET"; + case STATE_EMIT_MSG_EVENT: + return "STATE_EMIT_MSG_EVENT"; + case STATE_EMIT_MSG_END_OF_PACKET: + return "STATE_EMIT_MSG_END_OF_PACKET"; case STATE_DONE: return "STATE_DONE"; case STATE_SKIP_PACKET_PADDING: @@ -281,10 +281,10 @@ const char *state_string(enum state state) } static -int bt_notif_iter_switch_packet(struct bt_notif_iter *notit); +int bt_msg_iter_switch_packet(struct bt_msg_iter *notit); static -struct stack *stack_new(struct bt_notif_iter *notit) +struct stack *stack_new(struct bt_msg_iter *notit) { struct stack *stack = NULL; @@ -386,33 +386,33 @@ void stack_clear(struct stack *stack) } static inline -enum bt_notif_iter_status notif_iter_status_from_m_status( - enum bt_notif_iter_medium_status m_status) +enum bt_msg_iter_status msg_iter_status_from_m_status( + enum bt_msg_iter_medium_status m_status) { /* They are the same */ return (int) m_status; } static inline -size_t buf_size_bits(struct bt_notif_iter *notit) +size_t buf_size_bits(struct bt_msg_iter *notit) { return notit->buf.sz * 8; } static inline -size_t buf_available_bits(struct bt_notif_iter *notit) +size_t buf_available_bits(struct bt_msg_iter *notit) { return buf_size_bits(notit) - notit->buf.at; } static inline -size_t packet_at(struct bt_notif_iter *notit) +size_t packet_at(struct bt_msg_iter *notit) { return notit->buf.packet_offset + notit->buf.at; } static inline -void buf_consume_bits(struct bt_notif_iter *notit, size_t incr) +void buf_consume_bits(struct bt_msg_iter *notit, size_t incr) { BT_LOGV("Advancing cursor: notit-addr=%p, cur-before=%zu, cur-after=%zu", notit, notit->buf.at, notit->buf.at + incr); @@ -420,12 +420,12 @@ void buf_consume_bits(struct bt_notif_iter *notit, size_t incr) } static -enum bt_notif_iter_status request_medium_bytes( - struct bt_notif_iter *notit) +enum bt_msg_iter_status request_medium_bytes( + struct bt_msg_iter *notit) { uint8_t *buffer_addr = NULL; size_t buffer_sz = 0; - enum bt_notif_iter_medium_status m_status; + enum bt_msg_iter_medium_status m_status; BT_LOGV("Calling user function (request bytes): notit-addr=%p, " "request-size=%zu", notit, notit->medium.max_request_sz); @@ -433,9 +433,9 @@ enum bt_notif_iter_status request_medium_bytes( notit->medium.max_request_sz, &buffer_addr, &buffer_sz, notit->medium.data); BT_LOGV("User function returned: status=%s, buf-addr=%p, buf-size=%zu", - bt_notif_iter_medium_status_string(m_status), + bt_msg_iter_medium_status_string(m_status), buffer_addr, buffer_sz); - if (m_status == BT_NOTIF_ITER_MEDIUM_STATUS_OK) { + if (m_status == BT_MSG_ITER_MEDIUM_STATUS_OK) { BT_ASSERT(buffer_sz != 0); /* New packet offset is old one + old size (in bits) */ @@ -457,7 +457,7 @@ enum bt_notif_iter_status request_medium_bytes( notit->buf.sz, notit->buf.addr); BT_LOGV_MEM(buffer_addr, buffer_sz, "Returned bytes at %p:", buffer_addr); - } else if (m_status == BT_NOTIF_ITER_MEDIUM_STATUS_EOF) { + } else if (m_status == BT_MSG_ITER_MEDIUM_STATUS_EOF) { /* * User returned end of stream: validate that we're not * in the middle of a packet header, packet context, or @@ -480,33 +480,33 @@ enum bt_notif_iter_status request_medium_bytes( } /* All other states are invalid */ - BT_LOGW("User function returned %s, but notification iterator is in an unexpected state: " + BT_LOGW("User function returned %s, but message iterator is in an unexpected state: " "state=%s, cur-packet-size=%" PRId64 ", cur=%zu, " "packet-cur=%zu, last-eh-at=%zu", - bt_notif_iter_medium_status_string(m_status), + bt_msg_iter_medium_status_string(m_status), state_string(notit->state), notit->cur_exp_packet_total_size, notit->buf.at, packet_at(notit), notit->buf.last_eh_at); - m_status = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR; + m_status = BT_MSG_ITER_MEDIUM_STATUS_ERROR; } else if (m_status < 0) { BT_LOGW("User function failed: status=%s", - bt_notif_iter_medium_status_string(m_status)); + bt_msg_iter_medium_status_string(m_status)); } end: - return notif_iter_status_from_m_status(m_status); + return msg_iter_status_from_m_status(m_status); } static inline -enum bt_notif_iter_status buf_ensure_available_bits( - struct bt_notif_iter *notit) +enum bt_msg_iter_status buf_ensure_available_bits( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; if (unlikely(buf_available_bits(notit) == 0)) { /* - * This _cannot_ return BT_NOTIF_ITER_STATUS_OK + * This _cannot_ return BT_MSG_ITER_STATUS_OK * _and_ no bits. */ status = request_medium_bytes(notit); @@ -516,13 +516,13 @@ enum bt_notif_iter_status buf_ensure_available_bits( } static -enum bt_notif_iter_status read_dscope_begin_state( - struct bt_notif_iter *notit, +enum bt_msg_iter_status read_dscope_begin_state( + struct bt_msg_iter *notit, struct ctf_field_class *dscope_fc, enum state done_state, enum state continue_state, bt_field *dscope_field) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; enum bt_bfcr_status bfcr_status; size_t consumed_bits; @@ -548,7 +548,7 @@ enum bt_notif_iter_status read_dscope_begin_state( BT_LOGW("BFCR failed to start: notit-addr=%p, bfcr-addr=%p, " "status=%s", notit, notit->bfcr, bt_bfcr_status_string(bfcr_status)); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -560,10 +560,10 @@ end: } static -enum bt_notif_iter_status read_dscope_continue_state( - struct bt_notif_iter *notit, enum state done_state) +enum bt_msg_iter_status read_dscope_continue_state( + struct bt_msg_iter *notit, enum state done_state) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; enum bt_bfcr_status bfcr_status; size_t consumed_bits; @@ -571,15 +571,15 @@ enum bt_notif_iter_status read_dscope_continue_state( notit, notit->bfcr); status = buf_ensure_available_bits(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { if (status < 0) { BT_LOGW("Cannot ensure that buffer has at least one byte: " - "notif-addr=%p, status=%s", - notit, bt_notif_iter_status_string(status)); + "msg-addr=%p, status=%s", + notit, bt_msg_iter_status_string(status)); } else { BT_LOGV("Cannot ensure that buffer has at least one byte: " - "notif-addr=%p, status=%s", - notit, bt_notif_iter_status_string(status)); + "msg-addr=%p, status=%s", + notit, bt_msg_iter_status_string(status)); } goto end; @@ -603,7 +603,7 @@ enum bt_notif_iter_status read_dscope_continue_state( BT_LOGW("BFCR failed to continue: notit-addr=%p, bfcr-addr=%p, " "status=%s", notit, notit->bfcr, bt_bfcr_status_string(bfcr_status)); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -614,7 +614,7 @@ end: } static -void release_event_dscopes(struct bt_notif_iter *notit) +void release_event_dscopes(struct bt_msg_iter *notit) { notit->dscopes.event_header = NULL; @@ -629,7 +629,7 @@ void release_event_dscopes(struct bt_notif_iter *notit) } static -void release_all_dscopes(struct bt_notif_iter *notit) +void release_all_dscopes(struct bt_msg_iter *notit) { notit->dscopes.trace_packet_header = NULL; @@ -649,15 +649,15 @@ void release_all_dscopes(struct bt_notif_iter *notit) } static -enum bt_notif_iter_status read_packet_header_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_packet_header_begin_state( + struct bt_msg_iter *notit) { struct ctf_field_class *packet_header_fc = NULL; - enum bt_notif_iter_status ret = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status ret = BT_MSG_ITER_STATUS_OK; - if (bt_notif_iter_switch_packet(notit)) { + if (bt_msg_iter_switch_packet(notit)) { BT_LOGW("Cannot switch packet: notit-addr=%p", notit); - ret = BT_NOTIF_ITER_STATUS_ERROR; + ret = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -686,7 +686,7 @@ enum bt_notif_iter_status read_packet_header_begin_state( notit->meta.tc->ir_tc); if (!notit->packet_header_field) { BT_LOGE_STR("Cannot create packet header field wrapper from trace class."); - ret = BT_NOTIF_ITER_STATUS_ERROR; + ret = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -718,17 +718,17 @@ end: } static -enum bt_notif_iter_status read_packet_header_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_packet_header_continue_state( + struct bt_msg_iter *notit) { return read_dscope_continue_state(notit, STATE_AFTER_TRACE_PACKET_HEADER); } static inline -enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_stream_class(struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_stream_class *new_stream_class = NULL; if (notit->cur_stream_class_id == -1) { @@ -740,7 +740,7 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) BT_LOGW("Need exactly one stream class since there's " "no stream class ID field: " "notit-addr=%p", notit); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -755,7 +755,7 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) "notit-addr=%p, stream-class-id=%" PRIu64 ", " "trace-class-addr=%p", notit, notit->cur_stream_class_id, notit->meta.tc); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -772,7 +772,7 @@ enum bt_notif_iter_status set_current_stream_class(struct bt_notif_iter *notit) new_stream_class, new_stream_class->id, notit->meta.tc); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } } else { @@ -789,9 +789,9 @@ end: } static inline -enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_stream(struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; bt_stream *stream = NULL; BT_LOGV("Calling user function (get stream): notit-addr=%p, " @@ -806,14 +806,14 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) if (!stream) { BT_LOGW_STR("User function failed to return a stream object " "for the given stream class."); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } if (notit->stream && stream != notit->stream) { BT_LOGW("User function returned a different stream than the " "previous one for the same sequence of packets."); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -825,12 +825,12 @@ end: } static inline -enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_packet(struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; bt_packet *packet = NULL; - BT_LOGV("Creating packet for packet notification: " + BT_LOGV("Creating packet for packet message: " "notit-addr=%p", notit); BT_LOGV("Creating packet from stream: " "notit-addr=%p, stream-addr=%p, " @@ -856,7 +856,7 @@ enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) error: BT_PACKET_PUT_REF_AND_RESET(packet); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; end: BT_PACKET_MOVE_REF(notit->packet, packet); @@ -864,13 +864,13 @@ end: } static -enum bt_notif_iter_status after_packet_header_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status after_packet_header_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status; + enum bt_msg_iter_status status; status = set_current_stream_class(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } @@ -881,10 +881,10 @@ end: } static -enum bt_notif_iter_status read_packet_context_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_packet_context_begin_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_field_class *packet_context_fc; BT_ASSERT(notit->meta.sc); @@ -909,14 +909,14 @@ enum bt_notif_iter_status read_packet_context_begin_state( * packet is created from a stream, and this API must be * able to return the packet header and context fields * without creating a stream - * (bt_notif_iter_borrow_packet_header_context_fields()). + * (bt_msg_iter_borrow_packet_header_context_fields()). */ notit->packet_context_field = bt_packet_context_field_create( notit->meta.sc->ir_sc); if (!notit->packet_context_field) { BT_LOGE_STR("Cannot create packet context field wrapper from stream class."); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -949,18 +949,18 @@ end: } static -enum bt_notif_iter_status read_packet_context_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_packet_context_continue_state( + struct bt_msg_iter *notit) { return read_dscope_continue_state(notit, STATE_AFTER_STREAM_PACKET_CONTEXT); } static -enum bt_notif_iter_status set_current_packet_content_sizes( - struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_packet_content_sizes( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; if (notit->cur_exp_packet_total_size == -1) { if (notit->cur_exp_packet_content_size != -1) { @@ -970,7 +970,7 @@ enum bt_notif_iter_status set_current_packet_content_sizes( notit, notit->dscopes.stream_packet_context, notit->cur_exp_packet_total_size, notit->cur_exp_packet_content_size); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } } else { @@ -989,7 +989,7 @@ enum bt_notif_iter_status set_current_packet_content_sizes( notit, notit->dscopes.stream_packet_context, notit->cur_exp_packet_total_size, notit->cur_exp_packet_content_size); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -1002,20 +1002,20 @@ end: } static -enum bt_notif_iter_status after_packet_context_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status after_packet_context_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status; + enum bt_msg_iter_status status; status = set_current_packet_content_sizes(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } if (notit->stream_begin_emitted) { - notit->state = STATE_EMIT_NOTIF_NEW_PACKET; + notit->state = STATE_EMIT_MSG_NEW_PACKET; } else { - notit->state = STATE_EMIT_NOTIF_NEW_STREAM; + notit->state = STATE_EMIT_MSG_NEW_STREAM; } end: @@ -1023,10 +1023,10 @@ end: } static -enum bt_notif_iter_status read_event_header_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_header_begin_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_field_class *event_header_fc = NULL; /* Reset the position of the last event header */ @@ -1040,7 +1040,7 @@ enum bt_notif_iter_status read_event_header_begin_state( /* No more events! */ BT_LOGV("Reached end of packet: notit-addr=%p, " "cur=%zu", notit, packet_at(notit)); - notit->state = STATE_EMIT_NOTIF_END_OF_PACKET; + notit->state = STATE_EMIT_MSG_END_OF_PACKET; goto end; } else if (unlikely(packet_at(notit) > notit->cur_exp_packet_content_size)) { @@ -1050,7 +1050,7 @@ enum bt_notif_iter_status read_event_header_begin_state( "cur=%zu", notit, notit->cur_exp_packet_content_size, packet_at(notit)); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } } else { @@ -1059,19 +1059,19 @@ enum bt_notif_iter_status read_event_header_begin_state( * nothing else for us. */ status = buf_ensure_available_bits(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { /* * If this function returns - * `BT_NOTIF_ITER_STATUS_EOF`: + * `BT_MSG_ITER_STATUS_EOF`: * - * 1. bt_notif_iter_get_next_notification() - * emits a "packet end" notification. This + * 1. bt_msg_iter_get_next_message() + * emits a "packet end" message. This * resets the current packet. The state * remains unchanged otherwise. * 2. This function is called again. It returns - * `BT_NOTIF_ITER_STATUS_EOF` again. - * 3. bt_notif_iter_get_next_notification() - * emits a "stream end" notification because + * `BT_MSG_ITER_STATUS_EOF` again. + * 3. bt_msg_iter_get_next_message() + * emits a "stream end" message because * there's no current packet. It sets the * current state to `STATE_DONE`. */ @@ -1094,7 +1094,7 @@ enum bt_notif_iter_status read_event_header_begin_state( notit->meta.sc->ir_sc); if (!notit->event_header_field) { BT_LOGE_STR("Cannot create event header field wrapper from trace class."); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -1129,17 +1129,17 @@ end: } static -enum bt_notif_iter_status read_event_header_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_header_continue_state( + struct bt_msg_iter *notit) { return read_dscope_continue_state(notit, STATE_AFTER_EVENT_HEADER); } static inline -enum bt_notif_iter_status set_current_event_class(struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_event_class(struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_event_class *new_event_class = NULL; @@ -1152,7 +1152,7 @@ enum bt_notif_iter_status set_current_event_class(struct bt_notif_iter *notit) BT_LOGW("Need exactly one event class since there's " "no event class ID field: " "notit-addr=%p", notit); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -1169,7 +1169,7 @@ enum bt_notif_iter_status set_current_event_class(struct bt_notif_iter *notit) "trace-class-addr=%p", notit, notit->meta.sc->id, notit->cur_event_class_id, notit->meta.tc); - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -1186,24 +1186,24 @@ end: } static inline -enum bt_notif_iter_status set_current_event_notification( - struct bt_notif_iter *notit) +enum bt_msg_iter_status set_current_event_message( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; - bt_notification *notif = NULL; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; + bt_message *msg = NULL; BT_ASSERT(notit->meta.ec); BT_ASSERT(notit->packet); - BT_LOGV("Creating event notification from event class and packet: " + BT_LOGV("Creating event message from event class and packet: " "notit-addr=%p, ec-addr=%p, ec-name=\"%s\", packet-addr=%p", notit, notit->meta.ec, notit->meta.ec->name->str, notit->packet); - BT_ASSERT(notit->notif_iter); - notif = bt_notification_event_create(notit->notif_iter, + BT_ASSERT(notit->msg_iter); + msg = bt_message_event_create(notit->msg_iter, notit->meta.ec->ir_ec, notit->packet); - if (!notif) { - BT_LOGE("Cannot create event notification: " + if (!msg) { + BT_LOGE("Cannot create event message: " "notit-addr=%p, ec-addr=%p, ec-name=\"%s\", " "packet-addr=%p", notit, notit->meta.ec, @@ -1215,32 +1215,32 @@ enum bt_notif_iter_status set_current_event_notification( goto end; error: - BT_NOTIFICATION_PUT_REF_AND_RESET(notif); - status = BT_NOTIF_ITER_STATUS_ERROR; + BT_MESSAGE_PUT_REF_AND_RESET(msg); + status = BT_MSG_ITER_STATUS_ERROR; end: - BT_NOTIFICATION_MOVE_REF(notit->event_notif, notif); + BT_MESSAGE_MOVE_REF(notit->event_msg, msg); return status; } static -enum bt_notif_iter_status after_event_header_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status after_event_header_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status; + enum bt_msg_iter_status status; status = set_current_event_class(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } - status = set_current_event_notification(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + status = set_current_event_message(notit); + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } - notit->event = bt_notification_event_borrow_event( - notit->event_notif); + notit->event = bt_message_event_borrow_event( + notit->event_msg); BT_ASSERT(notit->event); if (notit->event_header_field) { @@ -1250,7 +1250,7 @@ enum bt_notif_iter_status after_event_header_state( ret = bt_event_move_header_field(notit->event, notit->event_header_field); if (ret) { - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -1272,10 +1272,10 @@ end: } static -enum bt_notif_iter_status read_event_common_context_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_common_context_begin_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_field_class *event_common_context_fc; event_common_context_fc = notit->meta.sc->event_common_context_fc; @@ -1317,18 +1317,18 @@ end: } static -enum bt_notif_iter_status read_event_common_context_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_common_context_continue_state( + struct bt_msg_iter *notit) { return read_dscope_continue_state(notit, STATE_DSCOPE_EVENT_SPEC_CONTEXT_BEGIN); } static -enum bt_notif_iter_status read_event_spec_context_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_spec_context_begin_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_field_class *event_spec_context_fc; event_spec_context_fc = notit->meta.ec->spec_context_fc; @@ -1373,23 +1373,23 @@ end: } static -enum bt_notif_iter_status read_event_spec_context_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_spec_context_continue_state( + struct bt_msg_iter *notit) { return read_dscope_continue_state(notit, STATE_DSCOPE_EVENT_PAYLOAD_BEGIN); } static -enum bt_notif_iter_status read_event_payload_begin_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_payload_begin_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; struct ctf_field_class *event_payload_fc; event_payload_fc = notit->meta.ec->payload_fc; if (!event_payload_fc) { - notit->state = STATE_EMIT_NOTIF_EVENT; + notit->state = STATE_EMIT_MSG_EVENT; goto end; } @@ -1410,7 +1410,7 @@ enum bt_notif_iter_status read_event_payload_begin_state( notit->meta.ec->id, event_payload_fc); status = read_dscope_begin_state(notit, event_payload_fc, - STATE_EMIT_NOTIF_EVENT, + STATE_EMIT_MSG_EVENT, STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE, notit->dscopes.event_payload); if (status < 0) { @@ -1429,17 +1429,17 @@ end: } static -enum bt_notif_iter_status read_event_payload_continue_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status read_event_payload_continue_state( + struct bt_msg_iter *notit) { - return read_dscope_continue_state(notit, STATE_EMIT_NOTIF_EVENT); + return read_dscope_continue_state(notit, STATE_EMIT_MSG_EVENT); } static -enum bt_notif_iter_status skip_packet_padding_state( - struct bt_notif_iter *notit) +enum bt_msg_iter_status skip_packet_padding_state( + struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; size_t bits_to_skip; BT_ASSERT(notit->cur_exp_packet_total_size > 0); @@ -1453,7 +1453,7 @@ enum bt_notif_iter_status skip_packet_padding_state( BT_LOGV("Trying to skip %zu bits of padding: notit-addr=%p, size=%zu", bits_to_skip, notit, bits_to_skip); status = buf_ensure_available_bits(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } @@ -1474,9 +1474,9 @@ end: } static inline -enum bt_notif_iter_status handle_state(struct bt_notif_iter *notit) +enum bt_msg_iter_status handle_state(struct bt_msg_iter *notit) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; const enum state state = notit->state; BT_LOGV("Handling state: notit-addr=%p, state=%s", @@ -1505,10 +1505,10 @@ enum bt_notif_iter_status handle_state(struct bt_notif_iter *notit) case STATE_AFTER_STREAM_PACKET_CONTEXT: status = after_packet_context_state(notit); break; - case STATE_EMIT_NOTIF_NEW_STREAM: - notit->state = STATE_EMIT_NOTIF_NEW_PACKET; + case STATE_EMIT_MSG_NEW_STREAM: + notit->state = STATE_EMIT_MSG_NEW_PACKET; break; - case STATE_EMIT_NOTIF_NEW_PACKET: + case STATE_EMIT_MSG_NEW_PACKET: notit->state = STATE_DSCOPE_EVENT_HEADER_BEGIN; break; case STATE_DSCOPE_EVENT_HEADER_BEGIN: @@ -1538,42 +1538,42 @@ enum bt_notif_iter_status handle_state(struct bt_notif_iter *notit) case STATE_DSCOPE_EVENT_PAYLOAD_CONTINUE: status = read_event_payload_continue_state(notit); break; - case STATE_EMIT_NOTIF_EVENT: + case STATE_EMIT_MSG_EVENT: notit->state = STATE_DSCOPE_EVENT_HEADER_BEGIN; break; case STATE_SKIP_PACKET_PADDING: status = skip_packet_padding_state(notit); break; - case STATE_EMIT_NOTIF_END_OF_PACKET: + case STATE_EMIT_MSG_END_OF_PACKET: notit->state = STATE_SKIP_PACKET_PADDING; break; default: - BT_LOGD("Unknown CTF plugin notification iterator state: " + BT_LOGD("Unknown CTF plugin message iterator state: " "notit-addr=%p, state=%d", notit, notit->state); abort(); } BT_LOGV("Handled state: notit-addr=%p, status=%s, " "prev-state=%s, cur-state=%s", - notit, bt_notif_iter_status_string(status), + notit, bt_msg_iter_status_string(status), state_string(state), state_string(notit->state)); return status; } /** - * Resets the internal state of a CTF notification iterator. + * Resets the internal state of a CTF message iterator. */ BT_HIDDEN -void bt_notif_iter_reset(struct bt_notif_iter *notit) +void bt_msg_iter_reset(struct bt_msg_iter *notit) { BT_ASSERT(notit); - BT_LOGD("Resetting notification iterator: addr=%p", notit); + BT_LOGD("Resetting message iterator: addr=%p", notit); stack_clear(notit->stack); notit->meta.sc = NULL; notit->meta.ec = NULL; BT_PACKET_PUT_REF_AND_RESET(notit->packet); BT_STREAM_PUT_REF_AND_RESET(notit->stream); - BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); + BT_MESSAGE_PUT_REF_AND_RESET(notit->event_msg); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1608,13 +1608,13 @@ void bt_notif_iter_reset(struct bt_notif_iter *notit) } static -int bt_notif_iter_switch_packet(struct bt_notif_iter *notit) +int bt_msg_iter_switch_packet(struct bt_msg_iter *notit) { int ret = 0; /* * We don't put the stream class here because we need to make - * sure that all the packets processed by the same notification + * sure that all the packets processed by the same message * iterator refer to the same stream class (the first one). */ BT_ASSERT(notit); @@ -1629,7 +1629,7 @@ int bt_notif_iter_switch_packet(struct bt_notif_iter *notit) stack_clear(notit->stack); notit->meta.ec = NULL; BT_PACKET_PUT_REF_AND_RESET(notit->packet); - BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); + BT_MESSAGE_PUT_REF_AND_RESET(notit->event_msg); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1671,7 +1671,7 @@ end: } static -bt_field *borrow_next_field(struct bt_notif_iter *notit) +bt_field *borrow_next_field(struct bt_msg_iter *notit) { bt_field *next_field = NULL; bt_field *base_field; @@ -1717,7 +1717,7 @@ bt_field *borrow_next_field(struct bt_notif_iter *notit) } static -void update_default_clock(struct bt_notif_iter *notit, uint64_t new_val, +void update_default_clock(struct bt_msg_iter *notit, uint64_t new_val, uint64_t new_val_size) { uint64_t new_val_mask; @@ -1762,7 +1762,7 @@ static enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, struct ctf_field_class *fc, void *data) { - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; struct ctf_field_class_int *int_fc = (void *) fc; @@ -1850,7 +1850,7 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value, struct ctf_field_class *fc, void *data) { int ret; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *string_field = NULL; struct ctf_field_class_int *int_fc = (void *) fc; @@ -1902,7 +1902,7 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; struct ctf_field_class_int *int_fc = (void *) fc; BT_LOGV("Signed integer function called from BFCR: " @@ -1940,7 +1940,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; BT_LOGV("Floating point number function called from BFCR: " "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -1962,7 +1962,7 @@ enum bt_bfcr_status bfcr_string_begin_cb( struct ctf_field_class *fc, void *data) { bt_field *field = NULL; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; int ret; BT_LOGV("String (beginning) function called from BFCR: " @@ -1994,7 +1994,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value, { enum bt_bfcr_status status = BT_BFCR_STATUS_OK; bt_field *field = NULL; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; int ret; BT_LOGV("String (substring) function called from BFCR: " @@ -2024,7 +2024,7 @@ static enum bt_bfcr_status bfcr_string_end_cb( struct ctf_field_class *fc, void *data) { - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; BT_LOGV("String (end) function called from BFCR: " "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2043,7 +2043,7 @@ enum bt_bfcr_status bfcr_string_end_cb( enum bt_bfcr_status bfcr_compound_begin_cb( struct ctf_field_class *fc, void *data) { - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; bt_field *field; BT_LOGV("Compound (beginning) function called from BFCR: " @@ -2097,7 +2097,7 @@ end: enum bt_bfcr_status bfcr_compound_end_cb( struct ctf_field_class *fc, void *data) { - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; BT_LOGV("Compound (end) function called from BFCR: " "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, " @@ -2145,7 +2145,7 @@ static int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data) { bt_field *seq_field; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; struct ctf_field_class_sequence *seq_fc = (void *) fc; int64_t length = -1; int ret; @@ -2171,7 +2171,7 @@ struct ctf_field_class *bfcr_borrow_variant_selected_field_class_cb( int ret; uint64_t i; int64_t option_index = -1; - struct bt_notif_iter *notit = data; + struct bt_msg_iter *notit = data; struct ctf_field_class_variant *var_fc = (void *) fc; struct ctf_named_field_class *selected_option = NULL; struct ctf_field_class *ret_fc = NULL; @@ -2244,11 +2244,11 @@ end: } static -void set_event_default_clock_value(struct bt_notif_iter *notit) +void set_event_default_clock_value(struct bt_msg_iter *notit) { bt_event *event = - bt_notification_event_borrow_event( - notit->event_notif); + bt_message_event_borrow_event( + notit->event_msg); bt_stream_class *sc = notit->meta.sc->ir_sc; BT_ASSERT(event); @@ -2260,68 +2260,68 @@ void set_event_default_clock_value(struct bt_notif_iter *notit) } static -void notify_new_stream(struct bt_notif_iter *notit, - bt_notification **notification) +void notify_new_stream(struct bt_msg_iter *notit, + bt_message **message) { - enum bt_notif_iter_status status; - bt_notification *ret = NULL; + enum bt_msg_iter_status status; + bt_message *ret = NULL; status = set_current_stream(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { - BT_NOTIFICATION_PUT_REF_AND_RESET(ret); + if (status != BT_MSG_ITER_STATUS_OK) { + BT_MESSAGE_PUT_REF_AND_RESET(ret); goto end; } BT_ASSERT(notit->stream); - BT_ASSERT(notit->notif_iter); - ret = bt_notification_stream_beginning_create(notit->notif_iter, + BT_ASSERT(notit->msg_iter); + ret = bt_message_stream_beginning_create(notit->msg_iter, notit->stream); if (!ret) { - BT_LOGE("Cannot create stream beginning notification: " + BT_LOGE("Cannot create stream beginning message: " "notit-addr=%p, stream-addr=%p", notit, notit->stream); return; } end: - *notification = ret; + *message = ret; } static -void notify_end_of_stream(struct bt_notif_iter *notit, - bt_notification **notification) +void notify_end_of_stream(struct bt_msg_iter *notit, + bt_message **message) { - bt_notification *ret; + bt_message *ret; if (!notit->stream) { - BT_LOGE("Cannot create stream for stream notification: " + BT_LOGE("Cannot create stream for stream message: " "notit-addr=%p", notit); return; } - BT_ASSERT(notit->notif_iter); - ret = bt_notification_stream_end_create(notit->notif_iter, + BT_ASSERT(notit->msg_iter); + ret = bt_message_stream_end_create(notit->msg_iter, notit->stream); if (!ret) { - BT_LOGE("Cannot create stream beginning notification: " + BT_LOGE("Cannot create stream beginning message: " "notit-addr=%p, stream-addr=%p", notit, notit->stream); return; } - *notification = ret; + *message = ret; } static -void notify_new_packet(struct bt_notif_iter *notit, - bt_notification **notification) +void notify_new_packet(struct bt_msg_iter *notit, + bt_message **message) { int ret; - enum bt_notif_iter_status status; - bt_notification *notif = NULL; + enum bt_msg_iter_status status; + bt_message *msg = NULL; const bt_stream_class *sc; status = set_current_packet(notit); - if (status != BT_NOTIF_ITER_STATUS_OK) { + if (status != BT_MSG_ITER_STATUS_OK) { goto end; } @@ -2391,27 +2391,27 @@ void notify_new_packet(struct bt_notif_iter *notit, notit->dscopes.stream_packet_context); } - BT_ASSERT(notit->notif_iter); - notif = bt_notification_packet_beginning_create(notit->notif_iter, + BT_ASSERT(notit->msg_iter); + msg = bt_message_packet_beginning_create(notit->msg_iter, notit->packet); - if (!notif) { - BT_LOGE("Cannot create packet beginning notification: " + if (!msg) { + BT_LOGE("Cannot create packet beginning message: " "notit-addr=%p, packet-addr=%p", notit, notit->packet); goto end; } - *notification = notif; + *message = msg; end: return; } static -void notify_end_of_packet(struct bt_notif_iter *notit, - bt_notification **notification) +void notify_end_of_packet(struct bt_msg_iter *notit, + bt_message **message) { - bt_notification *notif; + bt_message *msg; if (!notit->packet) { return; @@ -2422,11 +2422,11 @@ void notify_end_of_packet(struct bt_notif_iter *notit, notit->default_clock_val = notit->snapshots.end_clock; } - BT_ASSERT(notit->notif_iter); - notif = bt_notification_packet_end_create(notit->notif_iter, + BT_ASSERT(notit->msg_iter); + msg = bt_message_packet_end_create(notit->msg_iter, notit->packet); - if (!notif) { - BT_LOGE("Cannot create packet end notification: " + if (!msg) { + BT_LOGE("Cannot create packet end message: " "notit-addr=%p, packet-addr=%p", notit, notit->packet); return; @@ -2434,15 +2434,15 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } BT_PACKET_PUT_REF_AND_RESET(notit->packet); - *notification = notif; + *message = msg; } BT_HIDDEN -struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, +struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc, size_t max_request_sz, - struct bt_notif_iter_medium_ops medops, void *data) + struct bt_msg_iter_medium_ops medops, void *data) { - struct bt_notif_iter *notit = NULL; + struct bt_msg_iter *notit = NULL; struct bt_bfcr_cbs cbs = { .classes = { .signed_int = bfcr_signed_int_cb, @@ -2463,12 +2463,12 @@ struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, BT_ASSERT(tc); BT_ASSERT(medops.request_bytes); BT_ASSERT(medops.borrow_stream); - BT_LOGD("Creating CTF plugin notification iterator: " + BT_LOGD("Creating CTF plugin message iterator: " "trace-addr=%p, max-request-size=%zu, " "data=%p", tc, max_request_sz, data); - notit = g_new0(struct bt_notif_iter, 1); + notit = g_new0(struct bt_msg_iter, 1); if (!notit) { - BT_LOGE_STR("Failed to allocate one CTF plugin notification iterator."); + BT_LOGE_STR("Failed to allocate one CTF plugin message iterator."); goto end; } notit->meta.tc = tc; @@ -2490,8 +2490,8 @@ struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, goto error; } - bt_notif_iter_reset(notit); - BT_LOGD("Created CTF plugin notification iterator: " + bt_msg_iter_reset(notit); + BT_LOGD("Created CTF plugin message iterator: " "trace-addr=%p, max-request-size=%zu, " "data=%p, notit-addr=%p", tc, max_request_sz, data, notit); @@ -2501,18 +2501,18 @@ end: return notit; error: - bt_notif_iter_destroy(notit); + bt_msg_iter_destroy(notit); notit = NULL; goto end; } -void bt_notif_iter_destroy(struct bt_notif_iter *notit) +void bt_msg_iter_destroy(struct bt_msg_iter *notit) { BT_PACKET_PUT_REF_AND_RESET(notit->packet); BT_STREAM_PUT_REF_AND_RESET(notit->stream); release_all_dscopes(notit); - BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit); + BT_LOGD("Destroying CTF plugin message iterator: addr=%p", notit); if (notit->stack) { BT_LOGD_STR("Destroying field stack."); @@ -2531,53 +2531,53 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notit) g_free(notit); } -enum bt_notif_iter_status bt_notif_iter_get_next_notification( - struct bt_notif_iter *notit, - bt_self_notification_iterator *notif_iter, - bt_notification **notification) +enum bt_msg_iter_status bt_msg_iter_get_next_message( + struct bt_msg_iter *notit, + bt_self_message_iterator *msg_iter, + bt_message **message) { - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; BT_ASSERT(notit); - BT_ASSERT(notification); + BT_ASSERT(message); if (notit->state == STATE_DONE) { - status = BT_NOTIF_ITER_STATUS_EOF; + status = BT_MSG_ITER_STATUS_EOF; goto end; } - notit->notif_iter = notif_iter; + notit->msg_iter = msg_iter; - BT_LOGV("Getting next notification: notit-addr=%p", notit); + BT_LOGV("Getting next message: notit-addr=%p", notit); while (true) { status = handle_state(notit); - if (status == BT_NOTIF_ITER_STATUS_AGAIN) { - BT_LOGV_STR("Medium returned BT_NOTIF_ITER_STATUS_AGAIN."); + if (status == BT_MSG_ITER_STATUS_AGAIN) { + BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_AGAIN."); goto end; } - if (status != BT_NOTIF_ITER_STATUS_OK) { - if (status == BT_NOTIF_ITER_STATUS_EOF) { + if (status != BT_MSG_ITER_STATUS_OK) { + if (status == BT_MSG_ITER_STATUS_EOF) { enum state next_state = notit->state; - BT_LOGV_STR("Medium returned BT_NOTIF_ITER_STATUS_EOF."); + BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_EOF."); if (notit->packet) { notify_end_of_packet(notit, - notification); + message); } else { notify_end_of_stream(notit, - notification); + message); next_state = STATE_DONE; } - if (!*notification) { - status = BT_NOTIF_ITER_STATUS_ERROR; + if (!*message) { + status = BT_MSG_ITER_STATUS_ERROR; goto end; } - status = BT_NOTIF_ITER_STATUS_OK; + status = BT_MSG_ITER_STATUS_OK; notit->state = next_state; } else { BT_LOGW("Cannot handle state: " @@ -2589,37 +2589,37 @@ enum bt_notif_iter_status bt_notif_iter_get_next_notification( } switch (notit->state) { - case STATE_EMIT_NOTIF_NEW_STREAM: + case STATE_EMIT_MSG_NEW_STREAM: /* notify_new_stream() logs errors */ - notify_new_stream(notit, notification); + notify_new_stream(notit, message); - if (!*notification) { - status = BT_NOTIF_ITER_STATUS_ERROR; + if (!*message) { + status = BT_MSG_ITER_STATUS_ERROR; } notit->stream_begin_emitted = true; goto end; - case STATE_EMIT_NOTIF_NEW_PACKET: + case STATE_EMIT_MSG_NEW_PACKET: /* notify_new_packet() logs errors */ - notify_new_packet(notit, notification); + notify_new_packet(notit, message); - if (!*notification) { - status = BT_NOTIF_ITER_STATUS_ERROR; + if (!*message) { + status = BT_MSG_ITER_STATUS_ERROR; } goto end; - case STATE_EMIT_NOTIF_EVENT: - BT_ASSERT(notit->event_notif); + case STATE_EMIT_MSG_EVENT: + BT_ASSERT(notit->event_msg); set_event_default_clock_value(notit); - *notification = notit->event_notif; - notit->event_notif = NULL; + *message = notit->event_msg; + notit->event_msg = NULL; goto end; - case STATE_EMIT_NOTIF_END_OF_PACKET: + case STATE_EMIT_MSG_END_OF_PACKET: /* notify_end_of_packet() logs errors */ - notify_end_of_packet(notit, notification); + notify_end_of_packet(notit, message); - if (!*notification) { - status = BT_NOTIF_ITER_STATUS_ERROR; + if (!*message) { + status = BT_MSG_ITER_STATUS_ERROR; } goto end; @@ -2634,30 +2634,30 @@ end: } BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( - struct bt_notif_iter *notit, +enum bt_msg_iter_status bt_msg_iter_borrow_packet_header_context_fields( + struct bt_msg_iter *notit, bt_field **packet_header_field, bt_field **packet_context_field) { int ret; - enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK; + enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; BT_ASSERT(notit); - if (notit->state == STATE_EMIT_NOTIF_NEW_PACKET) { + if (notit->state == STATE_EMIT_MSG_NEW_PACKET) { /* We're already there */ goto set_fields; } while (true) { status = handle_state(notit); - if (status == BT_NOTIF_ITER_STATUS_AGAIN) { - BT_LOGV_STR("Medium returned BT_NOTIF_ITER_STATUS_AGAIN."); + if (status == BT_MSG_ITER_STATUS_AGAIN) { + BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_AGAIN."); goto end; } - if (status != BT_NOTIF_ITER_STATUS_OK) { - if (status == BT_NOTIF_ITER_STATUS_EOF) { - BT_LOGV_STR("Medium returned BT_NOTIF_ITER_STATUS_EOF."); + if (status != BT_MSG_ITER_STATUS_OK) { + if (status == BT_MSG_ITER_STATUS_EOF) { + BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_EOF."); } else { BT_LOGW("Cannot handle state: " "notit-addr=%p, state=%s", @@ -2667,14 +2667,14 @@ enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( } switch (notit->state) { - case STATE_EMIT_NOTIF_NEW_PACKET: + case STATE_EMIT_MSG_NEW_PACKET: /* * Packet header and context fields are * potentially decoded (or they don't exist). */ goto set_fields; case STATE_INIT: - case STATE_EMIT_NOTIF_NEW_STREAM: + case STATE_EMIT_MSG_NEW_STREAM: case STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN: case STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE: case STATE_AFTER_TRACE_PACKET_HEADER: @@ -2686,7 +2686,7 @@ enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( default: /* * We should never get past the - * STATE_EMIT_NOTIF_NEW_PACKET state. + * STATE_EMIT_MSG_NEW_PACKET state. */ BT_LOGF("Unexpected state: notit-addr=%p, state=%s", notit, state_string(notit->state)); @@ -2697,7 +2697,7 @@ enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( set_fields: ret = set_current_packet_content_sizes(notit); if (ret) { - status = BT_NOTIF_ITER_STATUS_ERROR; + status = BT_MSG_ITER_STATUS_ERROR; goto end; } @@ -2714,7 +2714,7 @@ end: } BT_HIDDEN -void bt_notif_iter_set_medops_data(struct bt_notif_iter *notit, +void bt_msg_iter_set_medops_data(struct bt_msg_iter *notit, void *medops_data) { BT_ASSERT(notit); @@ -2722,37 +2722,37 @@ void bt_notif_iter_set_medops_data(struct bt_notif_iter *notit, } BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_seek( - struct bt_notif_iter *notit, off_t offset) +enum bt_msg_iter_status bt_msg_iter_seek( + struct bt_msg_iter *notit, off_t offset) { - enum bt_notif_iter_status ret = BT_NOTIF_ITER_STATUS_OK; - enum bt_notif_iter_medium_status medium_status; + enum bt_msg_iter_status ret = BT_MSG_ITER_STATUS_OK; + enum bt_msg_iter_medium_status medium_status; BT_ASSERT(notit); if (offset < 0) { BT_LOGE("Cannot seek to negative offset: offset=%jd", offset); - ret = BT_NOTIF_ITER_STATUS_INVAL; + ret = BT_MSG_ITER_STATUS_INVAL; goto end; } if (!notit->medium.medops.seek) { - ret = BT_NOTIF_ITER_STATUS_UNSUPPORTED; + ret = BT_MSG_ITER_STATUS_UNSUPPORTED; BT_LOGD("Aborting seek as the iterator's underlying media does not implement seek support."); goto end; } medium_status = notit->medium.medops.seek( - BT_NOTIF_ITER_SEEK_WHENCE_SET, offset, notit->medium.data); - if (medium_status != BT_NOTIF_ITER_MEDIUM_STATUS_OK) { - if (medium_status == BT_NOTIF_ITER_MEDIUM_STATUS_EOF) { - ret = BT_NOTIF_ITER_STATUS_EOF; + BT_MSG_ITER_SEEK_WHENCE_SET, offset, notit->medium.data); + if (medium_status != BT_MSG_ITER_MEDIUM_STATUS_OK) { + if (medium_status == BT_MSG_ITER_MEDIUM_STATUS_EOF) { + ret = BT_MSG_ITER_STATUS_EOF; } else { - ret = BT_NOTIF_ITER_STATUS_ERROR; + ret = BT_MSG_ITER_STATUS_ERROR; goto end; } } - bt_notif_iter_reset(notit); + bt_msg_iter_reset(notit); notit->cur_packet_offset = offset; end: @@ -2760,22 +2760,22 @@ end: } BT_HIDDEN -off_t bt_notif_iter_get_current_packet_offset(struct bt_notif_iter *notit) +off_t bt_msg_iter_get_current_packet_offset(struct bt_msg_iter *notit) { BT_ASSERT(notit); return notit->cur_packet_offset; } BT_HIDDEN -off_t bt_notif_iter_get_current_packet_size( - struct bt_notif_iter *notit) +off_t bt_msg_iter_get_current_packet_size( + struct bt_msg_iter *notit) { BT_ASSERT(notit); return notit->cur_exp_packet_total_size; } BT_HIDDEN -void bt_notif_trace_class_changed(struct bt_notif_iter *notit) +void bt_msg_trace_class_changed(struct bt_msg_iter *notit) { if (notit->meta.tc->stored_value_count > notit->stored_values->len) { g_array_set_size(notit->stored_values, @@ -2784,9 +2784,9 @@ void bt_notif_trace_class_changed(struct bt_notif_iter *notit) } BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_get_packet_properties( - struct bt_notif_iter *notit, - struct bt_notif_iter_packet_properties *props) +enum bt_msg_iter_status bt_msg_iter_get_packet_properties( + struct bt_msg_iter *notit, + struct bt_msg_iter_packet_properties *props) { BT_ASSERT(notit); BT_ASSERT(props); @@ -2802,5 +2802,5 @@ enum bt_notif_iter_status bt_notif_iter_get_packet_properties( props->snapshots.packets = notit->snapshots.packets; props->snapshots.beginning_clock = notit->snapshots.beginning_clock; props->snapshots.end_clock = notit->snapshots.end_clock; - return BT_NOTIF_ITER_STATUS_OK; + return BT_MSG_ITER_STATUS_OK; } diff --git a/plugins/ctf/common/notif-iter/notif-iter.h b/plugins/ctf/common/msg-iter/msg-iter.h similarity index 56% rename from plugins/ctf/common/notif-iter/notif-iter.h rename to plugins/ctf/common/msg-iter/msg-iter.h index c0f187ec..89028bbb 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.h +++ b/plugins/ctf/common/msg-iter/msg-iter.h @@ -1,8 +1,8 @@ -#ifndef CTF_NOTIF_ITER_H -#define CTF_NOTIF_ITER_H +#ifndef CTF_MSG_ITER_H +#define CTF_MSG_ITER_H /* - * Babeltrace - CTF notification iterator + * Babeltrace - CTF message iterator * ¯¯¯¯¯ ¯¯¯¯ * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015-2016 Philippe Proulx @@ -35,98 +35,98 @@ #include "../metadata/ctf-meta.h" /** - * @file ctf-notif-iter.h + * @file ctf-msg-iter.h * - * CTF notification iterator + * CTF message iterator * ¯¯¯¯¯ ¯¯¯¯ * This is a common internal API used by CTF source plugins. It allows - * one to get notifications from a user-provided medium. + * one to get messages from a user-provided medium. */ /** * Medium operations status codes. */ -enum bt_notif_iter_medium_status { +enum bt_msg_iter_medium_status { /** * End of file. * - * The medium function called by the notification iterator + * The medium function called by the message iterator * function reached the end of the file. */ - BT_NOTIF_ITER_MEDIUM_STATUS_EOF = 1, + BT_MSG_ITER_MEDIUM_STATUS_EOF = 1, /** * There is no data available right now, try again later. */ - BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN = 11, + BT_MSG_ITER_MEDIUM_STATUS_AGAIN = 11, /** Unsupported operation. */ - BT_NOTIF_ITER_MEDIUM_STATUS_UNSUPPORTED = -3, + BT_MSG_ITER_MEDIUM_STATUS_UNSUPPORTED = -3, /** Invalid argument. */ - BT_NOTIF_ITER_MEDIUM_STATUS_INVAL = -2, + BT_MSG_ITER_MEDIUM_STATUS_INVAL = -2, /** General error. */ - BT_NOTIF_ITER_MEDIUM_STATUS_ERROR = -1, + BT_MSG_ITER_MEDIUM_STATUS_ERROR = -1, /** Everything okay. */ - BT_NOTIF_ITER_MEDIUM_STATUS_OK = 0, + BT_MSG_ITER_MEDIUM_STATUS_OK = 0, }; /** - * CTF notification iterator API status code. + * CTF message iterator API status code. */ -enum bt_notif_iter_status { +enum bt_msg_iter_status { /** * End of file. * - * The medium function called by the notification iterator + * The medium function called by the message iterator * function reached the end of the file. */ - BT_NOTIF_ITER_STATUS_EOF = BT_NOTIF_ITER_MEDIUM_STATUS_EOF, + BT_MSG_ITER_STATUS_EOF = BT_MSG_ITER_MEDIUM_STATUS_EOF, /** * There is no data available right now, try again later. * * Some condition resulted in the - * bt_notif_iter_medium_ops::request_bytes() user function not + * bt_msg_iter_medium_ops::request_bytes() user function not * having access to any data now. You should retry calling the - * last called notification iterator function once the situation + * last called message iterator function once the situation * is resolved. */ - BT_NOTIF_ITER_STATUS_AGAIN = BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN, + BT_MSG_ITER_STATUS_AGAIN = BT_MSG_ITER_MEDIUM_STATUS_AGAIN, /** Invalid argument. */ - BT_NOTIF_ITER_STATUS_INVAL = BT_NOTIF_ITER_MEDIUM_STATUS_INVAL, + BT_MSG_ITER_STATUS_INVAL = BT_MSG_ITER_MEDIUM_STATUS_INVAL, /** Unsupported operation. */ - BT_NOTIF_ITER_STATUS_UNSUPPORTED = BT_NOTIF_ITER_MEDIUM_STATUS_UNSUPPORTED, + BT_MSG_ITER_STATUS_UNSUPPORTED = BT_MSG_ITER_MEDIUM_STATUS_UNSUPPORTED, /** General error. */ - BT_NOTIF_ITER_STATUS_ERROR = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR, + BT_MSG_ITER_STATUS_ERROR = BT_MSG_ITER_MEDIUM_STATUS_ERROR, /** Everything okay. */ - BT_NOTIF_ITER_STATUS_OK = 0, + BT_MSG_ITER_STATUS_OK = 0, }; /** - * CTF notification iterator seek operation directives. + * CTF message iterator seek operation directives. */ -enum bt_notif_iter_seek_whence { +enum bt_msg_iter_seek_whence { /** * Set the iterator's position to an absolute offset in the underlying * medium. */ - BT_NOTIF_ITER_SEEK_WHENCE_SET, + BT_MSG_ITER_SEEK_WHENCE_SET, }; /** * Medium operations. * - * Those user functions are called by the notification iterator + * Those user functions are called by the message iterator * functions to request medium actions. */ -struct bt_notif_iter_medium_ops { +struct bt_msg_iter_medium_ops { /** * Returns the next byte buffer to be used by the binary file * reader to deserialize binary data. @@ -134,15 +134,15 @@ struct bt_notif_iter_medium_ops { * This function \em must be defined. * * The purpose of this function is to return a buffer of bytes - * to the notification iterator, of a maximum of \p request_sz + * to the message iterator, of a maximum of \p request_sz * bytes. If this function cannot return a buffer of at least * \p request_sz bytes, it may return a smaller buffer. In * either cases, \p buffer_sz must be set to the returned buffer * size (in bytes). * * The returned buffer's ownership remains the medium, in that - * it won't be freed by the notification iterator functions. The - * returned buffer won't be modified by the notification + * it won't be freed by the message iterator functions. The + * returned buffer won't be modified by the message * iterator functions either. * * When this function is called for the first time for a given @@ -154,36 +154,36 @@ struct bt_notif_iter_medium_ops { * * This function must return one of the following statuses: * - * - #BT_NOTIF_ITER_MEDIUM_STATUS_OK: Everything + * - #BT_MSG_ITER_MEDIUM_STATUS_OK: Everything * is okay, i.e. \p buffer_sz is set to a positive value * reflecting the number of available bytes in the buffer * starting at the address written in \p buffer_addr. - * - #BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN: No data is - * available right now. In this case, the notification + * - #BT_MSG_ITER_MEDIUM_STATUS_AGAIN: No data is + * available right now. In this case, the message * iterator function called by the user returns - * #BT_NOTIF_ITER_STATUS_AGAIN, and it is the user's + * #BT_MSG_ITER_STATUS_AGAIN, and it is the user's * responsibility to make sure enough data becomes available - * before calling the \em same notification iterator + * before calling the \em same message iterator * function again to continue the decoding process. - * - #BT_NOTIF_ITER_MEDIUM_STATUS_EOF: The end of + * - #BT_MSG_ITER_MEDIUM_STATUS_EOF: The end of * the file was reached, and no more data will ever be - * available for this file. In this case, the notification + * available for this file. In this case, the message * iterator function called by the user returns - * #BT_NOTIF_ITER_STATUS_EOF. This must \em not be + * #BT_MSG_ITER_STATUS_EOF. This must \em not be * returned when returning at least one byte of data to the * caller, i.e. this must be returned when there's * absolutely nothing left; should the request size be * larger than what's left in the file, this function must * return what's left, setting \p buffer_sz to the number of * remaining bytes, and return - * #BT_NOTIF_ITER_MEDIUM_STATUS_EOF on the \em following + * #BT_MSG_ITER_MEDIUM_STATUS_EOF on the \em following * call. - * - #BT_NOTIF_ITER_MEDIUM_STATUS_ERROR: A fatal + * - #BT_MSG_ITER_MEDIUM_STATUS_ERROR: A fatal * error occured during this operation. In this case, the - * notification iterator function called by the user returns - * #BT_NOTIF_ITER_STATUS_ERROR. + * message iterator function called by the user returns + * #BT_MSG_ITER_STATUS_ERROR. * - * If #BT_NOTIF_ITER_MEDIUM_STATUS_OK is not returned, the + * If #BT_MSG_ITER_MEDIUM_STATUS_OK is not returned, the * values of \p buffer_sz and \p buffer_addr are \em ignored by * the caller. * @@ -193,7 +193,7 @@ struct bt_notif_iter_medium_ops { * @param data User data * @returns Status code (see description above) */ - enum bt_notif_iter_medium_status (* request_bytes)( + enum bt_msg_iter_medium_status (* request_bytes)( size_t request_sz, uint8_t **buffer_addr, size_t *buffer_sz, void *data); @@ -204,13 +204,13 @@ struct bt_notif_iter_medium_ops { * to a given absolute or relative position, as indicated by * the whence directive. * - * @param whence One of #bt_notif_iter_seek_whence values + * @param whence One of #bt_msg_iter_seek_whence values * @param offset Offset to use for the given directive * @param data User data - * @returns One of #bt_notif_iter_medium_status values + * @returns One of #bt_msg_iter_medium_status values */ - enum bt_notif_iter_medium_status (* seek)( - enum bt_notif_iter_seek_whence whence, + enum bt_msg_iter_medium_status (* seek)( + enum bt_msg_iter_seek_whence whence, off_t offset, void *data); /** @@ -218,7 +218,7 @@ struct bt_notif_iter_medium_ops { * stream class. * * This is called after a packet header is read, and the - * corresponding stream class is found by the notification + * corresponding stream class is found by the message * iterator. * * @param stream_class Stream class of the stream to get @@ -233,11 +233,11 @@ struct bt_notif_iter_medium_ops { int64_t stream_id, void *data); }; -/** CTF notification iterator. */ -struct bt_notif_iter; +/** CTF message iterator. */ +struct bt_msg_iter; /** - * Creates a CTF notification iterator. + * Creates a CTF message iterator. * * Upon successful completion, the reference count of \p trace is * incremented. @@ -245,70 +245,70 @@ struct bt_notif_iter; * @param trace Trace to read * @param max_request_sz Maximum buffer size, in bytes, to * request to - * bt_notif_iter_medium_ops::request_bytes() + * bt_msg_iter_medium_ops::request_bytes() * at a time * @param medops Medium operations * @param medops_data User data (passed to medium operations) - * @returns New CTF notification iterator on + * @returns New CTF message iterator on * success, or \c NULL on error */ BT_HIDDEN -struct bt_notif_iter *bt_notif_iter_create(struct ctf_trace_class *tc, - size_t max_request_sz, struct bt_notif_iter_medium_ops medops, +struct bt_msg_iter *bt_msg_iter_create(struct ctf_trace_class *tc, + size_t max_request_sz, struct bt_msg_iter_medium_ops medops, void *medops_data); /** - * Destroys a CTF notification iterator, freeing all internal resources. + * Destroys a CTF message iterator, freeing all internal resources. * * The registered trace's reference count is decremented. * - * @param notif_iter CTF notification iterator + * @param msg_iter CTF message iterator */ BT_HIDDEN -void bt_notif_iter_destroy(struct bt_notif_iter *notif_iter); +void bt_msg_iter_destroy(struct bt_msg_iter *msg_iter); /** - * Returns the next notification from a CTF notification iterator. + * Returns the next message from a CTF message iterator. * - * Upon successful completion, #BT_NOTIF_ITER_STATUS_OK is - * returned, and the next notification is written to \p notif. + * Upon successful completion, #BT_MSG_ITER_STATUS_OK is + * returned, and the next message is written to \p msg. * In this case, the caller is responsible for calling - * bt_notification_put() on the returned notification. + * bt_message_put() on the returned message. * - * If this function returns #BT_NOTIF_ITER_STATUS_AGAIN, the caller + * If this function returns #BT_MSG_ITER_STATUS_AGAIN, the caller * should make sure that data becomes available to its medium, and * call this function again, until another status is returned. * - * @param notif_iter CTF notification iterator - * @param notification Returned notification if the function's - * return value is #BT_NOTIF_ITER_STATUS_OK - * @returns One of #bt_notif_iter_status values + * @param msg_iter CTF message iterator + * @param message Returned message if the function's + * return value is #BT_MSG_ITER_STATUS_OK + * @returns One of #bt_msg_iter_status values */ BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_get_next_notification( - struct bt_notif_iter *notit, - bt_self_notification_iterator *notif_iter, - bt_notification **notification); +enum bt_msg_iter_status bt_msg_iter_get_next_message( + struct bt_msg_iter *notit, + bt_self_message_iterator *msg_iter, + bt_message **message); /** * Returns the first packet header and context fields. This function * never needs to call the `borrow_stream()` medium operation because * it does not create packet or event objects. * - * @param notif_iter CTF notification iterator + * @param msg_iter CTF message iterator * @param packet_header_field Packet header field (\c NULL if there's * no packet header field) * @param packet_context_field Packet context field (\c NULL if there's * no packet context field) - * @returns One of #bt_notif_iter_status values + * @returns One of #bt_msg_iter_status values */ BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_borrow_packet_header_context_fields( - struct bt_notif_iter *notit, +enum bt_msg_iter_status bt_msg_iter_borrow_packet_header_context_fields( + struct bt_msg_iter *notit, bt_field **packet_header_field, bt_field **packet_context_field); -struct bt_notif_iter_packet_properties { +struct bt_msg_iter_packet_properties { uint64_t exp_packet_total_size; uint64_t exp_packet_content_size; uint64_t stream_class_id; @@ -323,85 +323,85 @@ struct bt_notif_iter_packet_properties { }; BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_get_packet_properties( - struct bt_notif_iter *notit, - struct bt_notif_iter_packet_properties *props); +enum bt_msg_iter_status bt_msg_iter_get_packet_properties( + struct bt_msg_iter *notit, + struct bt_msg_iter_packet_properties *props); BT_HIDDEN -void bt_notif_iter_set_medops_data(struct bt_notif_iter *notit, +void bt_msg_iter_set_medops_data(struct bt_msg_iter *notit, void *medops_data); BT_HIDDEN -enum bt_notif_iter_status bt_notif_iter_seek( - struct bt_notif_iter *notit, off_t offset); +enum bt_msg_iter_status bt_msg_iter_seek( + struct bt_msg_iter *notit, off_t offset); /* * Get the current packet's offset in bytes relative to the media's initial * position. */ BT_HIDDEN -off_t bt_notif_iter_get_current_packet_offset( - struct bt_notif_iter *notit); +off_t bt_msg_iter_get_current_packet_offset( + struct bt_msg_iter *notit); /* Get the current packet's size (in bits). */ BT_HIDDEN -off_t bt_notif_iter_get_current_packet_size( - struct bt_notif_iter *notit); +off_t bt_msg_iter_get_current_packet_size( + struct bt_msg_iter *notit); /* * Resets the iterator so that the next requested medium bytes are - * assumed to be the first bytes of a new stream. The first notification - * which this iterator emits after calling bt_notif_iter_reset() is a - * BT_NOTIFICATION_TYPE_STREAM_BEGINNING one. + * assumed to be the first bytes of a new stream. The first message + * which this iterator emits after calling bt_msg_iter_reset() is a + * BT_MESSAGE_TYPE_STREAM_BEGINNING one. */ BT_HIDDEN -void bt_notif_iter_reset(struct bt_notif_iter *notit); +void bt_msg_iter_reset(struct bt_msg_iter *notit); /* * Notify the iterator that the trace class changed somehow (new * stream/event classes). */ BT_HIDDEN -void bt_notif_trace_class_changed(struct bt_notif_iter *notit); +void bt_msg_trace_class_changed(struct bt_msg_iter *notit); static inline -const char *bt_notif_iter_medium_status_string( - enum bt_notif_iter_medium_status status) +const char *bt_msg_iter_medium_status_string( + enum bt_msg_iter_medium_status status) { switch (status) { - case BT_NOTIF_ITER_MEDIUM_STATUS_EOF: - return "BT_NOTIF_ITER_MEDIUM_STATUS_EOF"; - case BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN: - return "BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN"; - case BT_NOTIF_ITER_MEDIUM_STATUS_INVAL: - return "BT_NOTIF_ITER_MEDIUM_STATUS_INVAL"; - case BT_NOTIF_ITER_MEDIUM_STATUS_ERROR: - return "BT_NOTIF_ITER_MEDIUM_STATUS_ERROR"; - case BT_NOTIF_ITER_MEDIUM_STATUS_OK: - return "BT_NOTIF_ITER_MEDIUM_STATUS_OK"; + case BT_MSG_ITER_MEDIUM_STATUS_EOF: + return "BT_MSG_ITER_MEDIUM_STATUS_EOF"; + case BT_MSG_ITER_MEDIUM_STATUS_AGAIN: + return "BT_MSG_ITER_MEDIUM_STATUS_AGAIN"; + case BT_MSG_ITER_MEDIUM_STATUS_INVAL: + return "BT_MSG_ITER_MEDIUM_STATUS_INVAL"; + case BT_MSG_ITER_MEDIUM_STATUS_ERROR: + return "BT_MSG_ITER_MEDIUM_STATUS_ERROR"; + case BT_MSG_ITER_MEDIUM_STATUS_OK: + return "BT_MSG_ITER_MEDIUM_STATUS_OK"; default: return "(unknown)"; } } static inline -const char *bt_notif_iter_status_string( - enum bt_notif_iter_status status) +const char *bt_msg_iter_status_string( + enum bt_msg_iter_status status) { switch (status) { - case BT_NOTIF_ITER_STATUS_EOF: - return "BT_NOTIF_ITER_STATUS_EOF"; - case BT_NOTIF_ITER_STATUS_AGAIN: - return "BT_NOTIF_ITER_STATUS_AGAIN"; - case BT_NOTIF_ITER_STATUS_INVAL: - return "BT_NOTIF_ITER_STATUS_INVAL"; - case BT_NOTIF_ITER_STATUS_ERROR: - return "BT_NOTIF_ITER_STATUS_ERROR"; - case BT_NOTIF_ITER_STATUS_OK: - return "BT_NOTIF_ITER_STATUS_OK"; + case BT_MSG_ITER_STATUS_EOF: + return "BT_MSG_ITER_STATUS_EOF"; + case BT_MSG_ITER_STATUS_AGAIN: + return "BT_MSG_ITER_STATUS_AGAIN"; + case BT_MSG_ITER_STATUS_INVAL: + return "BT_MSG_ITER_STATUS_INVAL"; + case BT_MSG_ITER_STATUS_ERROR: + return "BT_MSG_ITER_STATUS_ERROR"; + case BT_MSG_ITER_STATUS_OK: + return "BT_MSG_ITER_STATUS_OK"; default: return "(unknown)"; } } -#endif /* CTF_NOTIF_ITER_H */ +#endif /* CTF_MSG_ITER_H */ diff --git a/plugins/ctf/common/notif-iter/Makefile.am b/plugins/ctf/common/notif-iter/Makefile.am deleted file mode 100644 index e29d92af..00000000 --- a/plugins/ctf/common/notif-iter/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -noinst_LTLIBRARIES = libctf-notif-iter.la - -libctf_notif_iter_la_SOURCES = \ - notif-iter.c \ - notif-iter.h \ - logging.c \ - logging.h diff --git a/plugins/ctf/fs-sink/writer.c b/plugins/ctf/fs-sink/writer.c index ff603513..38db9a5e 100644 --- a/plugins/ctf/fs-sink/writer.c +++ b/plugins/ctf/fs-sink/writer.c @@ -109,9 +109,9 @@ end: } static -enum bt_component_status handle_notification( +enum bt_component_status handle_message( struct writer_component *writer_component, - const bt_notification *notification) + const bt_message *message) { enum bt_component_status ret = BT_COMPONENT_STATUS_OK; @@ -120,11 +120,11 @@ enum bt_component_status handle_notification( goto end; } - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_PACKET_BEGINNING: { const bt_packet *packet = - bt_notification_packet_beginning_get_packet(notification); + bt_message_packet_beginning_get_packet(message); if (!packet) { ret = BT_COMPONENT_STATUS_ERROR; @@ -135,10 +135,10 @@ enum bt_component_status handle_notification( bt_packet_put_ref(packet); break; } - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_PACKET_END: { const bt_packet *packet = - bt_notification_packet_end_get_packet(notification); + bt_message_packet_end_get_packet(message); if (!packet) { ret = BT_COMPONENT_STATUS_ERROR; @@ -148,10 +148,10 @@ enum bt_component_status handle_notification( bt_packet_put_ref(packet); break; } - case BT_NOTIFICATION_TYPE_EVENT: + case BT_MESSAGE_TYPE_EVENT: { - const bt_event *event = bt_notification_event_get_event( - notification); + const bt_event *event = bt_message_event_get_event( + message); if (!event) { ret = BT_COMPONENT_STATUS_ERROR; @@ -164,10 +164,10 @@ enum bt_component_status handle_notification( } break; } - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_BEGINNING: { const bt_stream *stream = - bt_notification_stream_beginning_get_stream(notification); + bt_message_stream_beginning_get_stream(message); if (!stream) { ret = BT_COMPONENT_STATUS_ERROR; @@ -177,10 +177,10 @@ enum bt_component_status handle_notification( bt_stream_put_ref(stream); break; } - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_END: { const bt_stream *stream = - bt_notification_stream_end_get_stream(notification); + bt_message_stream_end_get_stream(message); if (!stream) { ret = BT_COMPONENT_STATUS_ERROR; @@ -212,7 +212,7 @@ void writer_component_port_connected( BT_ASSERT(!writer->input_iterator); connection = bt_private_port_get_connection(self_port); BT_ASSERT(connection); - conn_status = bt_private_connection_create_notification_iterator( + conn_status = bt_private_connection_create_message_iterator( connection, &writer->input_iterator); if (conn_status != BT_CONNECTION_STATUS_OK) { writer->error = true; @@ -225,11 +225,11 @@ BT_HIDDEN enum bt_component_status writer_run(bt_self_component *component) { enum bt_component_status ret; - const bt_notification *notification = NULL; - bt_notification_iterator *it; + const bt_message *message = NULL; + bt_message_iterator *it; struct writer_component *writer_component = bt_self_component_get_user_data(component); - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status it_ret; if (unlikely(writer_component->error)) { ret = BT_COMPONENT_STATUS_ERROR; @@ -238,28 +238,28 @@ enum bt_component_status writer_run(bt_self_component *component) it = writer_component->input_iterator; BT_ASSERT(it); - it_ret = bt_notification_iterator_next(it); + it_ret = bt_message_iterator_next(it); switch (it_ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: ret = BT_COMPONENT_STATUS_END; BT_OBJECT_PUT_REF_AND_RESET(writer_component->input_iterator); goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: ret = BT_COMPONENT_STATUS_AGAIN; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_STATUS_OK: break; default: ret = BT_COMPONENT_STATUS_ERROR; goto end; } - notification = bt_notification_iterator_get_notification(it); - BT_ASSERT(notification); - ret = handle_notification(writer_component, notification); + message = bt_message_iterator_get_message(it); + BT_ASSERT(message); + ret = handle_message(writer_component, message); end: - bt_object_put_ref(notification); + bt_object_put_ref(message); return ret; } diff --git a/plugins/ctf/fs-sink/writer.h b/plugins/ctf/fs-sink/writer.h index 5a098104..965f3d2c 100644 --- a/plugins/ctf/fs-sink/writer.h +++ b/plugins/ctf/fs-sink/writer.h @@ -39,7 +39,7 @@ struct writer_component { /* Map between bt_trace and struct fs_writer. */ GHashTable *trace_map; FILE *err; - bt_notification_iterator *input_iterator; + bt_message_iterator *input_iterator; bool error; bool single_trace; unsigned int nr_traces; @@ -48,7 +48,7 @@ struct writer_component { enum fs_writer_stream_state { /* * We know the stream exists but we have never received a - * stream_begin notification for it. + * stream_begin message for it. */ FS_WRITER_UNKNOWN_STREAM, /* We know this stream is active (between stream_begin and _end). */ diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index dca33e2e..da4d1fa5 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -35,7 +35,7 @@ #include #include "file.h" #include "metadata.h" -#include "../common/notif-iter/notif-iter.h" +#include "../common/msg-iter/msg-iter.h" #include #include "data-stream-file.h" #include @@ -75,11 +75,11 @@ end: } static -enum bt_notif_iter_medium_status ds_file_mmap_next( +enum bt_msg_iter_medium_status ds_file_mmap_next( struct ctf_fs_ds_file *ds_file) { - enum bt_notif_iter_medium_status ret = - BT_NOTIF_ITER_MEDIUM_STATUS_OK; + enum bt_msg_iter_medium_status ret = + BT_MSG_ITER_MEDIUM_STATUS_OK; /* Unmap old region */ if (ds_file->mmap_addr) { @@ -99,7 +99,7 @@ enum bt_notif_iter_medium_status ds_file_mmap_next( ds_file->mmap_len = MIN(ds_file->file->size - ds_file->mmap_offset, ds_file->mmap_max_len); if (ds_file->mmap_len == 0) { - ret = BT_NOTIF_ITER_MEDIUM_STATUS_EOF; + ret = BT_MSG_ITER_MEDIUM_STATUS_EOF; goto end; } /* Map new region */ @@ -118,18 +118,18 @@ enum bt_notif_iter_medium_status ds_file_mmap_next( goto end; error: ds_file_munmap(ds_file); - ret = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR; + ret = BT_MSG_ITER_MEDIUM_STATUS_ERROR; end: return ret; } static -enum bt_notif_iter_medium_status medop_request_bytes( +enum bt_msg_iter_medium_status medop_request_bytes( size_t request_sz, uint8_t **buffer_addr, size_t *buffer_sz, void *data) { - enum bt_notif_iter_medium_status status = - BT_NOTIF_ITER_MEDIUM_STATUS_OK; + enum bt_msg_iter_medium_status status = + BT_MSG_ITER_MEDIUM_STATUS_OK; struct ctf_fs_ds_file *ds_file = data; if (request_sz == 0) { @@ -142,15 +142,15 @@ enum bt_notif_iter_medium_status medop_request_bytes( if (ds_file->mmap_offset >= ds_file->file->size) { BT_LOGD("Reached end of file \"%s\" (%p)", ds_file->file->path->str, ds_file->file->fp); - status = BT_NOTIF_ITER_MEDIUM_STATUS_EOF; + status = BT_MSG_ITER_MEDIUM_STATUS_EOF; goto end; } status = ds_file_mmap_next(ds_file); switch (status) { - case BT_NOTIF_ITER_MEDIUM_STATUS_OK: + case BT_MSG_ITER_MEDIUM_STATUS_OK: break; - case BT_NOTIF_ITER_MEDIUM_STATUS_EOF: + case BT_MSG_ITER_MEDIUM_STATUS_EOF: goto end; default: BT_LOGE("Cannot memory-map next region of file \"%s\" (%p)", @@ -166,7 +166,7 @@ enum bt_notif_iter_medium_status medop_request_bytes( goto end; error: - status = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR; + status = BT_MSG_ITER_MEDIUM_STATUS_ERROR; end: return status; @@ -199,21 +199,21 @@ end: } static -enum bt_notif_iter_medium_status medop_seek( - enum bt_notif_iter_seek_whence whence, off_t offset, +enum bt_msg_iter_medium_status medop_seek( + enum bt_msg_iter_seek_whence whence, off_t offset, void *data) { - enum bt_notif_iter_medium_status ret = - BT_NOTIF_ITER_MEDIUM_STATUS_OK; + enum bt_msg_iter_medium_status ret = + BT_MSG_ITER_MEDIUM_STATUS_OK; struct ctf_fs_ds_file *ds_file = data; off_t file_size = ds_file->file->size; - if (whence != BT_NOTIF_ITER_SEEK_WHENCE_SET || + if (whence != BT_MSG_ITER_SEEK_WHENCE_SET || offset < 0 || offset > file_size) { BT_LOGE("Invalid medium seek request: whence=%d, offset=%jd, " "file-size=%jd", (int) whence, offset, file_size); - ret = BT_NOTIF_ITER_MEDIUM_STATUS_INVAL; + ret = BT_MSG_ITER_MEDIUM_STATUS_INVAL; goto end; } @@ -232,14 +232,14 @@ enum bt_notif_iter_medium_status medop_seek( ds_file->mmap_len); unmap_ret = ds_file_munmap(ds_file); if (unmap_ret) { - ret = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR; + ret = BT_MSG_ITER_MEDIUM_STATUS_ERROR; goto end; } ds_file->mmap_offset = offset - offset_in_mapping; ds_file->request_offset = offset_in_mapping; ret = ds_file_mmap_next(ds_file); - if (ret != BT_NOTIF_ITER_MEDIUM_STATUS_OK) { + if (ret != BT_MSG_ITER_MEDIUM_STATUS_OK) { goto end; } } else { @@ -252,7 +252,7 @@ end: } BT_HIDDEN -struct bt_notif_iter_medium_ops ctf_fs_ds_file_medops = { +struct bt_msg_iter_medium_ops ctf_fs_ds_file_medops = { .request_bytes = medop_request_bytes, .borrow_stream = medop_borrow_stream, .seek = medop_seek, @@ -320,20 +320,20 @@ struct ctf_fs_ds_index *build_index_from_idx_file( size_t file_entry_count; size_t i; struct ctf_stream_class *sc; - struct bt_notif_iter_packet_properties props; + struct bt_msg_iter_packet_properties props; BT_LOGD("Building index from .idx file of stream file %s", ds_file->file->path->str); - ret = bt_notif_iter_borrow_packet_header_context_fields( - ds_file->notif_iter, NULL, NULL); + ret = bt_msg_iter_borrow_packet_header_context_fields( + ds_file->msg_iter, NULL, NULL); if (ret) { BT_LOGD_STR("Cannot borrow first packet's header and context " "fields."); goto error; } - ret = bt_notif_iter_get_packet_properties(ds_file->notif_iter, &props); + ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter, &props); BT_ASSERT(ret == 0); sc = ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id); @@ -493,7 +493,7 @@ error: static int init_index_entry(struct ctf_fs_ds_index_entry *entry, struct ctf_fs_ds_file *ds_file, - struct bt_notif_iter_packet_properties *props, + struct bt_msg_iter_packet_properties *props, off_t packet_size, off_t packet_offset) { int ret; @@ -534,7 +534,7 @@ struct ctf_fs_ds_index *build_index_from_stream_file( { int ret; struct ctf_fs_ds_index *index = NULL; - enum bt_notif_iter_status iter_status; + enum bt_msg_iter_status iter_status; BT_LOGD("Indexing stream file %s", ds_file->file->path->str); @@ -548,24 +548,24 @@ struct ctf_fs_ds_index *build_index_from_stream_file( off_t next_packet_offset; off_t current_packet_size_bytes; struct ctf_fs_ds_index_entry *entry; - struct bt_notif_iter_packet_properties props; + struct bt_msg_iter_packet_properties props; - iter_status = bt_notif_iter_borrow_packet_header_context_fields( - ds_file->notif_iter, NULL, NULL); - if (iter_status != BT_NOTIF_ITER_STATUS_OK) { - if (iter_status == BT_NOTIF_ITER_STATUS_EOF) { + iter_status = bt_msg_iter_borrow_packet_header_context_fields( + ds_file->msg_iter, NULL, NULL); + if (iter_status != BT_MSG_ITER_STATUS_OK) { + if (iter_status == BT_MSG_ITER_STATUS_EOF) { break; } goto error; } - ret = bt_notif_iter_get_packet_properties(ds_file->notif_iter, + ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter, &props); BT_ASSERT(ret == 0); current_packet_offset = - bt_notif_iter_get_current_packet_offset( - ds_file->notif_iter); + bt_msg_iter_get_current_packet_offset( + ds_file->msg_iter); if (current_packet_offset < 0) { BT_LOGE_STR("Cannot get the current packet's offset."); goto error; @@ -604,11 +604,11 @@ struct ctf_fs_ds_index *build_index_from_stream_file( goto error; } - iter_status = bt_notif_iter_seek(ds_file->notif_iter, + iter_status = bt_msg_iter_seek(ds_file->msg_iter, next_packet_offset); - } while (iter_status == BT_NOTIF_ITER_STATUS_OK); + } while (iter_status == BT_MSG_ITER_STATUS_OK); - if (iter_status != BT_NOTIF_ITER_STATUS_EOF) { + if (iter_status != BT_MSG_ITER_STATUS_EOF) { goto error; } @@ -624,8 +624,8 @@ error: BT_HIDDEN struct ctf_fs_ds_file *ctf_fs_ds_file_create( struct ctf_fs_trace *ctf_fs_trace, - bt_self_notification_iterator *pc_notif_iter, - struct bt_notif_iter *notif_iter, + bt_self_message_iterator *pc_msg_iter, + struct bt_msg_iter *msg_iter, bt_stream *stream, const char *path) { int ret; @@ -636,7 +636,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( goto error; } - ds_file->pc_notif_iter = pc_notif_iter; + ds_file->pc_msg_iter = pc_msg_iter; ds_file->file = ctf_fs_file_create(); if (!ds_file->file) { goto error; @@ -651,9 +651,9 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( goto error; } - ds_file->notif_iter = notif_iter; - bt_notif_iter_set_medops_data(ds_file->notif_iter, ds_file); - if (!ds_file->notif_iter) { + ds_file->msg_iter = msg_iter; + bt_msg_iter_set_medops_data(ds_file->msg_iter, ds_file); + if (!ds_file->msg_iter) { goto error; } @@ -706,34 +706,34 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) } BT_HIDDEN -enum bt_notification_iterator_status ctf_fs_ds_file_next( +enum bt_message_iterator_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, - bt_notification **notif) + bt_message **msg) { - enum bt_notif_iter_status notif_iter_status; - enum bt_notification_iterator_status status; + enum bt_msg_iter_status msg_iter_status; + enum bt_message_iterator_status status; - notif_iter_status = bt_notif_iter_get_next_notification( - ds_file->notif_iter, ds_file->pc_notif_iter, notif); + msg_iter_status = bt_msg_iter_get_next_message( + ds_file->msg_iter, ds_file->pc_msg_iter, msg); - switch (notif_iter_status) { - case BT_NOTIF_ITER_STATUS_EOF: - status = BT_NOTIFICATION_ITERATOR_STATUS_END; + switch (msg_iter_status) { + case BT_MSG_ITER_STATUS_EOF: + status = BT_MESSAGE_ITERATOR_STATUS_END; break; - case BT_NOTIF_ITER_STATUS_OK: - status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + case BT_MSG_ITER_STATUS_OK: + status = BT_MESSAGE_ITERATOR_STATUS_OK; break; - case BT_NOTIF_ITER_STATUS_AGAIN: + case BT_MSG_ITER_STATUS_AGAIN: /* * Should not make it this far as this is * medium-specific; there is nothing for the user to do * and it should have been handled upstream. */ abort(); - case BT_NOTIF_ITER_STATUS_INVAL: - case BT_NOTIF_ITER_STATUS_ERROR: + case BT_MSG_ITER_STATUS_INVAL: + case BT_MSG_ITER_STATUS_ERROR: default: - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; break; } return status; @@ -745,20 +745,20 @@ int ctf_fs_ds_file_borrow_packet_header_context_fields( bt_field **packet_header_field, bt_field **packet_context_field) { - enum bt_notif_iter_status notif_iter_status; + enum bt_msg_iter_status msg_iter_status; int ret = 0; BT_ASSERT(ds_file); - notif_iter_status = bt_notif_iter_borrow_packet_header_context_fields( - ds_file->notif_iter, packet_header_field, packet_context_field); - switch (notif_iter_status) { - case BT_NOTIF_ITER_STATUS_EOF: - case BT_NOTIF_ITER_STATUS_OK: + msg_iter_status = bt_msg_iter_borrow_packet_header_context_fields( + ds_file->msg_iter, packet_header_field, packet_context_field); + switch (msg_iter_status) { + case BT_MSG_ITER_STATUS_EOF: + case BT_MSG_ITER_STATUS_OK: break; - case BT_NOTIF_ITER_STATUS_AGAIN: + case BT_MSG_ITER_STATUS_AGAIN: abort(); - case BT_NOTIF_ITER_STATUS_INVAL: - case BT_NOTIF_ITER_STATUS_ERROR: + case BT_MSG_ITER_STATUS_INVAL: + case BT_MSG_ITER_STATUS_ERROR: default: goto error; break; diff --git a/plugins/ctf/fs-src/data-stream-file.h b/plugins/ctf/fs-src/data-stream-file.h index d8e6ff99..544e3559 100644 --- a/plugins/ctf/fs-src/data-stream-file.h +++ b/plugins/ctf/fs-src/data-stream-file.h @@ -29,7 +29,7 @@ #include #include -#include "../common/notif-iter/notif-iter.h" +#include "../common/msg-iter/msg-iter.h" #include "lttng-index.h" struct ctf_fs_component; @@ -91,7 +91,7 @@ struct ctf_fs_ds_file { struct ctf_fs_metadata *metadata; /* Weak */ - bt_self_notification_iterator *pc_notif_iter; + bt_self_message_iterator *pc_msg_iter; /* Owned by this */ struct ctf_fs_file *file; @@ -100,7 +100,7 @@ struct ctf_fs_ds_file { bt_stream *stream; /* Weak */ - struct bt_notif_iter *notif_iter; + struct bt_msg_iter *msg_iter; void *mmap_addr; @@ -128,8 +128,8 @@ struct ctf_fs_ds_file { BT_HIDDEN struct ctf_fs_ds_file *ctf_fs_ds_file_create( struct ctf_fs_trace *ctf_fs_trace, - bt_self_notification_iterator *pc_notif_iter, - struct bt_notif_iter *notif_iter, + bt_self_message_iterator *pc_msg_iter, + struct bt_msg_iter *msg_iter, bt_stream *stream, const char *path); BT_HIDDEN @@ -142,9 +142,9 @@ BT_HIDDEN void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); BT_HIDDEN -enum bt_notification_iterator_status ctf_fs_ds_file_next( +enum bt_message_iterator_status ctf_fs_ds_file_next( struct ctf_fs_ds_file *ds_file, - bt_notification **notif); + bt_message **msg); BT_HIDDEN struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( @@ -153,6 +153,6 @@ struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( BT_HIDDEN void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index); -extern struct bt_notif_iter_medium_ops ctf_fs_ds_file_medops; +extern struct bt_msg_iter_medium_ops ctf_fs_ds_file_medops; #endif /* CTF_FS_DS_FILE_H */ diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index b612d2c6..5b15ffa2 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -37,7 +37,7 @@ #include "data-stream-file.h" #include "file.h" #include "../common/metadata/decoder.h" -#include "../common/notif-iter/notif-iter.h" +#include "../common/msg-iter/msg-iter.h" #include "../common/utils/utils.h" #include "query.h" @@ -45,25 +45,25 @@ #include "logging.h" static -int notif_iter_data_set_current_ds_file(struct ctf_fs_notif_iter_data *notif_iter_data) +int msg_iter_data_set_current_ds_file(struct ctf_fs_msg_iter_data *msg_iter_data) { struct ctf_fs_ds_file_info *ds_file_info; int ret = 0; - BT_ASSERT(notif_iter_data->ds_file_info_index < - notif_iter_data->ds_file_group->ds_file_infos->len); + BT_ASSERT(msg_iter_data->ds_file_info_index < + msg_iter_data->ds_file_group->ds_file_infos->len); ds_file_info = g_ptr_array_index( - notif_iter_data->ds_file_group->ds_file_infos, - notif_iter_data->ds_file_info_index); - - ctf_fs_ds_file_destroy(notif_iter_data->ds_file); - notif_iter_data->ds_file = ctf_fs_ds_file_create( - notif_iter_data->ds_file_group->ctf_fs_trace, - notif_iter_data->pc_notif_iter, - notif_iter_data->notif_iter, - notif_iter_data->ds_file_group->stream, + msg_iter_data->ds_file_group->ds_file_infos, + msg_iter_data->ds_file_info_index); + + ctf_fs_ds_file_destroy(msg_iter_data->ds_file); + msg_iter_data->ds_file = ctf_fs_ds_file_create( + msg_iter_data->ds_file_group->ctf_fs_trace, + msg_iter_data->pc_msg_iter, + msg_iter_data->msg_iter, + msg_iter_data->ds_file_group->stream, ds_file_info->path->str); - if (!notif_iter_data->ds_file) { + if (!msg_iter_data->ds_file) { ret = -1; } @@ -71,121 +71,121 @@ int notif_iter_data_set_current_ds_file(struct ctf_fs_notif_iter_data *notif_ite } static -void ctf_fs_notif_iter_data_destroy( - struct ctf_fs_notif_iter_data *notif_iter_data) +void ctf_fs_msg_iter_data_destroy( + struct ctf_fs_msg_iter_data *msg_iter_data) { - if (!notif_iter_data) { + if (!msg_iter_data) { return; } - ctf_fs_ds_file_destroy(notif_iter_data->ds_file); + ctf_fs_ds_file_destroy(msg_iter_data->ds_file); - if (notif_iter_data->notif_iter) { - bt_notif_iter_destroy(notif_iter_data->notif_iter); + if (msg_iter_data->msg_iter) { + bt_msg_iter_destroy(msg_iter_data->msg_iter); } - g_free(notif_iter_data); + g_free(msg_iter_data); } static -enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( - struct ctf_fs_notif_iter_data *notif_iter_data, - const bt_notification **notif) +enum bt_self_message_iterator_status ctf_fs_iterator_next_one( + struct ctf_fs_msg_iter_data *msg_iter_data, + const bt_message **msg) { - enum bt_self_notification_iterator_status status; - bt_notification *priv_notif; + enum bt_self_message_iterator_status status; + bt_message *priv_msg; int ret; - BT_ASSERT(notif_iter_data->ds_file); - status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); - *notif = priv_notif; + BT_ASSERT(msg_iter_data->ds_file); + status = ctf_fs_ds_file_next(msg_iter_data->ds_file, &priv_msg); + *msg = priv_msg; - if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK && - bt_notification_get_type(*notif) == - BT_NOTIFICATION_TYPE_STREAM_BEGINNING) { - if (notif_iter_data->skip_stream_begin_notifs) { + if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK && + bt_message_get_type(*msg) == + BT_MESSAGE_TYPE_STREAM_BEGINNING) { + if (msg_iter_data->skip_stream_begin_msgs) { /* * We already emitted a - * BT_NOTIFICATION_TYPE_STREAM_BEGINNING - * notification: skip this one, get a new one. + * BT_MESSAGE_TYPE_STREAM_BEGINNING + * message: skip this one, get a new one. */ - BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); - status = ctf_fs_ds_file_next(notif_iter_data->ds_file, - &priv_notif); - *notif = priv_notif; - BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END); + BT_MESSAGE_PUT_REF_AND_RESET(*msg); + status = ctf_fs_ds_file_next(msg_iter_data->ds_file, + &priv_msg); + *msg = priv_msg; + BT_ASSERT(status != BT_SELF_MESSAGE_ITERATOR_STATUS_END); goto end; } else { /* - * First BT_NOTIFICATION_TYPE_STREAM_BEGINNING - * notification: skip all following. + * First BT_MESSAGE_TYPE_STREAM_BEGINNING + * message: skip all following. */ - notif_iter_data->skip_stream_begin_notifs = true; + msg_iter_data->skip_stream_begin_msgs = true; goto end; } } - if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK && - bt_notification_get_type(*notif) == - BT_NOTIFICATION_TYPE_STREAM_END) { - notif_iter_data->ds_file_info_index++; + if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK && + bt_message_get_type(*msg) == + BT_MESSAGE_TYPE_STREAM_END) { + msg_iter_data->ds_file_info_index++; - if (notif_iter_data->ds_file_info_index == - notif_iter_data->ds_file_group->ds_file_infos->len) { + if (msg_iter_data->ds_file_info_index == + msg_iter_data->ds_file_group->ds_file_infos->len) { /* * No more stream files to read: we reached the * real end. Emit this - * BT_NOTIFICATION_TYPE_STREAM_END notification. + * BT_MESSAGE_TYPE_STREAM_END message. * The next time ctf_fs_iterator_next() is - * called for this notification iterator, + * called for this message iterator, * ctf_fs_ds_file_next() will return - * BT_SELF_NOTIFICATION_ITERATOR_STATUS_END(). + * BT_SELF_MESSAGE_ITERATOR_STATUS_END(). */ goto end; } - BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); - bt_notif_iter_reset(notif_iter_data->notif_iter); + BT_MESSAGE_PUT_REF_AND_RESET(*msg); + bt_msg_iter_reset(msg_iter_data->msg_iter); /* * Open and start reading the next stream file within * our stream file group. */ - ret = notif_iter_data_set_current_ds_file(notif_iter_data); + ret = msg_iter_data_set_current_ds_file(msg_iter_data); if (ret) { - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); - *notif = priv_notif; + status = ctf_fs_ds_file_next(msg_iter_data->ds_file, &priv_msg); + *msg = priv_msg; /* - * If we get a notification, we expect to get a - * BT_NOTIFICATION_TYPE_STREAM_BEGINNING notification + * If we get a message, we expect to get a + * BT_MESSAGE_TYPE_STREAM_BEGINNING message * because the iterator's state machine emits one before * even requesting the first block of data from the - * medium. Skip this notification because we're not + * medium. Skip this message because we're not * really starting a new stream here, and try getting a - * new notification (which, if it works, is a - * BT_NOTIFICATION_TYPE_PACKET_BEGINNING one). We're sure to + * new message (which, if it works, is a + * BT_MESSAGE_TYPE_PACKET_BEGINNING one). We're sure to * get at least one pair of - * BT_NOTIFICATION_TYPE_PACKET_BEGINNING and - * BT_NOTIFICATION_TYPE_PACKET_END notifications in the + * BT_MESSAGE_TYPE_PACKET_BEGINNING and + * BT_MESSAGE_TYPE_PACKET_END messages in the * case of a single, empty packet. We know there's at * least one packet because the stream file group does * not contain empty stream files. */ - BT_ASSERT(notif_iter_data->skip_stream_begin_notifs); - - if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { - BT_ASSERT(bt_notification_get_type(*notif) == - BT_NOTIFICATION_TYPE_STREAM_BEGINNING); - BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); - status = ctf_fs_ds_file_next(notif_iter_data->ds_file, - &priv_notif); - *notif = priv_notif; - BT_ASSERT(status != BT_SELF_NOTIFICATION_ITERATOR_STATUS_END); + BT_ASSERT(msg_iter_data->skip_stream_begin_msgs); + + if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + BT_ASSERT(bt_message_get_type(*msg) == + BT_MESSAGE_TYPE_STREAM_BEGINNING); + BT_MESSAGE_PUT_REF_AND_RESET(*msg); + status = ctf_fs_ds_file_next(msg_iter_data->ds_file, + &priv_msg); + *msg = priv_msg; + BT_ASSERT(status != BT_SELF_MESSAGE_ITERATOR_STATUS_END); } } @@ -194,20 +194,20 @@ end: } BT_HIDDEN -enum bt_self_notification_iterator_status ctf_fs_iterator_next( - bt_self_notification_iterator *iterator, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status ctf_fs_iterator_next( + bt_self_message_iterator *iterator, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - enum bt_self_notification_iterator_status status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; - struct ctf_fs_notif_iter_data *notif_iter_data = - bt_self_notification_iterator_get_data(iterator); + enum bt_self_message_iterator_status status = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + struct ctf_fs_msg_iter_data *msg_iter_data = + bt_self_message_iterator_get_data(iterator); uint64_t i = 0; - while (i < capacity && status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { - status = ctf_fs_iterator_next_one(notif_iter_data, ¬ifs[i]); - if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { + while (i < capacity && status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + status = ctf_fs_iterator_next_one(msg_iter_data, &msgs[i]); + if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { i++; } } @@ -215,81 +215,81 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next( if (i > 0) { /* * Even if ctf_fs_iterator_next_one() returned something - * else than BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK, we - * accumulated notification objects in the output - * notification array, so we need to return - * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK so that they are + * else than BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we + * accumulated message objects in the output + * message array, so we need to return + * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they are * transfered to downstream. This other status occurs - * again the next time muxer_notif_iter_do_next() is + * again the next time muxer_msg_iter_do_next() is * called, possibly without any accumulated - * notification, in which case we'll return it. + * message, in which case we'll return it. */ *count = i; - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; } return status; } -void ctf_fs_iterator_finalize(bt_self_notification_iterator *it) +void ctf_fs_iterator_finalize(bt_self_message_iterator *it) { - ctf_fs_notif_iter_data_destroy( - bt_self_notification_iterator_get_data(it)); + ctf_fs_msg_iter_data_destroy( + bt_self_message_iterator_get_data(it)); } -enum bt_self_notification_iterator_status ctf_fs_iterator_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status ctf_fs_iterator_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) { struct ctf_fs_port_data *port_data; - struct ctf_fs_notif_iter_data *notif_iter_data = NULL; - enum bt_self_notification_iterator_status ret = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + struct ctf_fs_msg_iter_data *msg_iter_data = NULL; + enum bt_self_message_iterator_status ret = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; int iret; port_data = bt_self_component_port_get_data( bt_self_component_port_output_as_self_component_port( self_port)); BT_ASSERT(port_data); - notif_iter_data = g_new0(struct ctf_fs_notif_iter_data, 1); - if (!notif_iter_data) { - ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM; + msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1); + if (!msg_iter_data) { + ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; goto error; } - notif_iter_data->pc_notif_iter = self_notif_iter; - notif_iter_data->notif_iter = bt_notif_iter_create( + msg_iter_data->pc_msg_iter = self_msg_iter; + msg_iter_data->msg_iter = bt_msg_iter_create( port_data->ds_file_group->ctf_fs_trace->metadata->tc, bt_common_get_page_size() * 8, ctf_fs_ds_file_medops, NULL); - if (!notif_iter_data->notif_iter) { - BT_LOGE_STR("Cannot create a CTF notification iterator."); - ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM; + if (!msg_iter_data->msg_iter) { + BT_LOGE_STR("Cannot create a CTF message iterator."); + ret = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; goto error; } - notif_iter_data->ds_file_group = port_data->ds_file_group; - iret = notif_iter_data_set_current_ds_file(notif_iter_data); + msg_iter_data->ds_file_group = port_data->ds_file_group; + iret = msg_iter_data_set_current_ds_file(msg_iter_data); if (iret) { - ret = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto error; } - bt_self_notification_iterator_set_data(self_notif_iter, - notif_iter_data); - if (ret != BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { + bt_self_message_iterator_set_data(self_msg_iter, + msg_iter_data); + if (ret != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { goto error; } - notif_iter_data = NULL; + msg_iter_data = NULL; goto end; error: - bt_self_notification_iterator_set_data(self_notif_iter, NULL); + bt_self_message_iterator_set_data(self_msg_iter, NULL); end: - ctf_fs_notif_iter_data_destroy(notif_iter_data); + ctf_fs_msg_iter_data_destroy(msg_iter_data); return ret; } @@ -341,7 +341,7 @@ void ctf_fs_trace_destroy(struct ctf_fs_trace *ctf_fs_trace) } static -void ctf_fs_trace_destroy_notifier(void *data) +void ctf_fs_trace_destroy_msgier(void *data) { struct ctf_fs_trace *trace = data; ctf_fs_trace_destroy(trace); @@ -623,18 +623,18 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, size_t i; struct ctf_fs_ds_file *ds_file = NULL; struct ctf_fs_ds_index *index = NULL; - struct bt_notif_iter *notif_iter = NULL; + struct bt_msg_iter *msg_iter = NULL; struct ctf_stream_class *sc = NULL; - struct bt_notif_iter_packet_properties props; + struct bt_msg_iter_packet_properties props; - notif_iter = bt_notif_iter_create(ctf_fs_trace->metadata->tc, + msg_iter = bt_msg_iter_create(ctf_fs_trace->metadata->tc, bt_common_get_page_size() * 8, ctf_fs_ds_file_medops, NULL); - if (!notif_iter) { - BT_LOGE_STR("Cannot create a CTF notification iterator."); + if (!msg_iter) { + BT_LOGE_STR("Cannot create a CTF message iterator."); goto error; } - ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, notif_iter, + ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, msg_iter, NULL, path); if (!ds_file) { goto error; @@ -648,7 +648,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, goto error; } - ret = bt_notif_iter_get_packet_properties(ds_file->notif_iter, &props); + ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter, &props); BT_ASSERT(ret == 0); sc = ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id); @@ -757,8 +757,8 @@ end: ctf_fs_ds_file_destroy(ds_file); - if (notif_iter) { - bt_notif_iter_destroy(notif_iter); + if (msg_iter) { + bt_msg_iter_destroy(msg_iter); } ctf_fs_ds_index_destroy(index); @@ -1361,7 +1361,7 @@ struct ctf_fs_component *ctf_fs_create( } ctf_fs->traces = g_ptr_array_new_with_free_func( - ctf_fs_trace_destroy_notifier); + ctf_fs_trace_destroy_msgier); if (!ctf_fs->traces) { goto error; } diff --git a/plugins/ctf/fs-src/fs.h b/plugins/ctf/fs-src/fs.h index 16601693..bbcf48ee 100644 --- a/plugins/ctf/fs-src/fs.h +++ b/plugins/ctf/fs-src/fs.h @@ -134,9 +134,9 @@ struct ctf_fs_port_data { struct ctf_fs_component *ctf_fs; }; -struct ctf_fs_notif_iter_data { +struct ctf_fs_msg_iter_data { /* Weak */ - bt_self_notification_iterator *pc_notif_iter; + bt_self_message_iterator *pc_msg_iter; /* Weak, belongs to ctf_fs_trace */ struct ctf_fs_ds_file_group *ds_file_group; @@ -148,10 +148,10 @@ struct ctf_fs_notif_iter_data { size_t ds_file_info_index; /* Owned by this */ - struct bt_notif_iter *notif_iter; + struct bt_msg_iter *msg_iter; - /* True to skip BT_NOTIFICATION_TYPE_STREAM_BEGINNING notifications */ - bool skip_stream_begin_notifs; + /* True to skip BT_MESSAGE_TYPE_STREAM_BEGINNING messages */ + bool skip_stream_begin_msgs; }; BT_HIDDEN @@ -183,18 +183,18 @@ BT_HIDDEN GList *ctf_fs_create_trace_names(GList *trace_paths, const char *base_path); BT_HIDDEN -enum bt_self_notification_iterator_status ctf_fs_iterator_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status ctf_fs_iterator_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN -void ctf_fs_iterator_finalize(bt_self_notification_iterator *it); +void ctf_fs_iterator_finalize(bt_self_message_iterator *it); BT_HIDDEN -enum bt_self_notification_iterator_status ctf_fs_iterator_next( - bt_self_notification_iterator *iterator, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status ctf_fs_iterator_next( + bt_self_message_iterator *iterator, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count); #endif /* BABELTRACE_PLUGIN_CTF_FS_H */ diff --git a/plugins/ctf/lttng-live/data-stream.c b/plugins/ctf/lttng-live/data-stream.c index c0233e11..54eb9dfc 100644 --- a/plugins/ctf/lttng-live/data-stream.c +++ b/plugins/ctf/lttng-live/data-stream.c @@ -33,18 +33,18 @@ #include #include #include -#include "../common/notif-iter/notif-iter.h" +#include "../common/msg-iter/msg-iter.h" #include #include "data-stream.h" static -enum bt_notif_iter_medium_status medop_request_bytes( +enum bt_msg_iter_medium_status medop_request_bytes( size_t request_sz, uint8_t **buffer_addr, size_t *buffer_sz, void *data) { - enum bt_notif_iter_medium_status status = - BT_NOTIF_ITER_MEDIUM_STATUS_OK; + enum bt_msg_iter_medium_status status = + BT_MSG_ITER_MEDIUM_STATUS_OK; struct lttng_live_stream_iterator *stream = data; struct lttng_live_trace *trace = stream->trace; struct lttng_live_session *session = trace->session; @@ -57,7 +57,7 @@ enum bt_notif_iter_medium_status medop_request_bytes( len_left = stream->base_offset + stream->len - stream->offset; if (!len_left) { stream->state = LTTNG_LIVE_STREAM_ACTIVE_NO_DATA; - status = BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN; + status = BT_MSG_ITER_MEDIUM_STATUS_AGAIN; return status; } read_len = MIN(request_sz, stream->buflen); @@ -105,19 +105,19 @@ const bt_stream *medop_get_stream( return lttng_live_stream->stream; } -static struct bt_notif_iter_medium_ops medops = { +static struct bt_msg_iter_medium_ops medops = { .request_bytes = medop_request_bytes, .get_stream = medop_get_stream, }; BT_HIDDEN -enum bt_lttng_live_iterator_status lttng_live_lazy_notif_init( +enum bt_lttng_live_iterator_status lttng_live_lazy_msg_init( struct lttng_live_session *session) { struct lttng_live_component *lttng_live = session->lttng_live; struct lttng_live_trace *trace; - if (!session->lazy_stream_notif_init) { + if (!session->lazy_stream_msg_init) { return BT_LTTNG_LIVE_ITERATOR_STATUS_OK; } @@ -125,19 +125,19 @@ enum bt_lttng_live_iterator_status lttng_live_lazy_notif_init( struct lttng_live_stream_iterator *stream; bt_list_for_each_entry(stream, &trace->streams, node) { - if (stream->notif_iter) { + if (stream->msg_iter) { continue; } - stream->notif_iter = bt_notif_iter_create(trace->trace, + stream->msg_iter = bt_msg_iter_create(trace->trace, lttng_live->max_query_size, medops, stream); - if (!stream->notif_iter) { + if (!stream->msg_iter) { goto error; } } } - session->lazy_stream_notif_init = false; + session->lazy_stream_msg_init = false; return BT_LTTNG_LIVE_ITERATOR_STATUS_OK; @@ -170,10 +170,10 @@ struct lttng_live_stream_iterator *lttng_live_stream_iterator_create( stream->last_returned_inactivity_timestamp = INT64_MIN; if (trace->trace) { - stream->notif_iter = bt_notif_iter_create(trace->trace, + stream->msg_iter = bt_msg_iter_create(trace->trace, lttng_live->max_query_size, medops, stream); - if (!stream->notif_iter) { + if (!stream->msg_iter) { goto error; } } @@ -212,11 +212,11 @@ void lttng_live_stream_iterator_destroy(struct lttng_live_stream_iterator *strea BT_OBJECT_PUT_REF_AND_RESET(stream->stream); } - if (stream->notif_iter) { - bt_notif_iter_destroy(stream->notif_iter); + if (stream->msg_iter) { + bt_msg_iter_destroy(stream->msg_iter); } g_free(stream->buf); - BT_OBJECT_PUT_REF_AND_RESET(stream->packet_end_notif_queue); + BT_OBJECT_PUT_REF_AND_RESET(stream->packet_end_msg_queue); bt_list_del(&stream->node); /* * Ensure we poke the trace metadata in the future, which is diff --git a/plugins/ctf/lttng-live/data-stream.h b/plugins/ctf/lttng-live/data-stream.h index f36e787c..3812315e 100644 --- a/plugins/ctf/lttng-live/data-stream.h +++ b/plugins/ctf/lttng-live/data-stream.h @@ -29,9 +29,9 @@ #include #include "lttng-live-internal.h" -#include "../common/notif-iter/notif-iter.h" +#include "../common/msg-iter/msg-iter.h" -enum bt_lttng_live_iterator_status lttng_live_lazy_notif_init( +enum bt_lttng_live_iterator_status lttng_live_lazy_msg_init( struct lttng_live_session *session); struct lttng_live_stream_iterator *lttng_live_stream_iterator_create( diff --git a/plugins/ctf/lttng-live/lttng-live-internal.h b/plugins/ctf/lttng-live/lttng-live-internal.h index d9c328d3..f8923a74 100644 --- a/plugins/ctf/lttng-live/lttng-live-internal.h +++ b/plugins/ctf/lttng-live/lttng-live-internal.h @@ -78,9 +78,9 @@ struct lttng_live_stream_iterator { /* * Since only a single iterator per viewer connection, we have - * only a single notification iterator per stream. + * only a single message iterator per stream. */ - struct bt_notif_iter *notif_iter; + struct bt_msg_iter *msg_iter; uint64_t viewer_stream_id; @@ -95,7 +95,7 @@ struct lttng_live_stream_iterator { enum lttng_live_stream_state state; uint64_t current_packet_end_timestamp; - const bt_notification *packet_end_notif_queue; + const bt_message *packet_end_msg_queue; uint8_t *buf; size_t buflen; @@ -165,7 +165,7 @@ struct lttng_live_session { bool attached; bool new_streams_needed; - bool lazy_stream_notif_init; + bool lazy_stream_msg_init; bool closed; }; @@ -193,7 +193,7 @@ struct lttng_live_component { enum bt_lttng_live_iterator_status { /** Iterator state has progressed. Continue iteration immediately. */ BT_LTTNG_LIVE_ITERATOR_STATUS_CONTINUE = 3, - /** No notification available for now. Try again later. */ + /** No message available for now. Try again later. */ BT_LTTNG_LIVE_ITERATOR_STATUS_AGAIN = 2, /** No more CTF_LTTNG_LIVEs to be delivered. */ BT_LTTNG_LIVE_ITERATOR_STATUS_END = 1, @@ -219,19 +219,19 @@ bt_component_class_query_method_return lttng_live_query( void lttng_live_component_finalize(bt_self_component *component); -bt_notification_iterator_next_method_return lttng_live_iterator_next( - bt_self_notification_iterator *iterator); +bt_message_iterator_next_method_return lttng_live_iterator_next( + bt_self_message_iterator *iterator); enum bt_component_status lttng_live_accept_port_connection( bt_self_component *private_component, struct bt_private_port *self_private_port, const bt_port *other_port); -enum bt_notification_iterator_status lttng_live_iterator_init( - bt_self_notification_iterator *it, +enum bt_message_iterator_status lttng_live_iterator_init( + bt_self_message_iterator *it, struct bt_private_port *port); -void lttng_live_iterator_finalize(bt_self_notification_iterator *it); +void lttng_live_iterator_finalize(bt_self_message_iterator *it); int lttng_live_create_viewer_session(struct lttng_live_component *lttng_live); int lttng_live_attach_session(struct lttng_live_session *session); @@ -250,7 +250,7 @@ enum bt_lttng_live_iterator_status lttng_live_get_next_index( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *stream, struct packet_index *index); -enum bt_notif_iter_medium_status lttng_live_get_stream_bytes( +enum bt_msg_iter_medium_status lttng_live_get_stream_bytes( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *stream, uint8_t *buf, uint64_t offset, uint64_t req_len, uint64_t *recv_len); diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index ff646bb2..1bc5dc60 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -339,10 +339,10 @@ void lttng_live_destroy_session(struct lttng_live_session *session) } BT_HIDDEN -void lttng_live_iterator_finalize(bt_self_notification_iterator *it) +void lttng_live_iterator_finalize(bt_self_message_iterator *it) { struct lttng_live_stream_iterator_generic *s = - bt_self_notification_iterator_get_user_data(it); + bt_self_message_iterator_get_user_data(it); switch (s->type) { case LIVE_STREAM_TYPE_NO_STREAM: @@ -442,11 +442,11 @@ end: } /* - * Creation of the notification requires the ctf trace to be created + * Creation of the message requires the ctf trace to be created * beforehand, but the live protocol gives us all streams (including * metadata) at once. So we split it in three steps: getting streams, * getting metadata (which creates the ctf trace), and then creating the - * per-stream notifications. + * per-stream messages. */ static enum bt_lttng_live_iterator_status lttng_live_get_session( @@ -475,7 +475,7 @@ enum bt_lttng_live_iterator_status lttng_live_get_session( return status; } } - return lttng_live_lazy_notif_init(session); + return lttng_live_lazy_msg_init(session); } BT_HIDDEN @@ -553,10 +553,10 @@ end: } static -enum bt_lttng_live_iterator_status emit_inactivity_notification( +enum bt_lttng_live_iterator_status emit_inactivity_message( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - const bt_notification **notification, + const bt_message **message, uint64_t timestamp) { enum bt_lttng_live_iterator_status ret = @@ -564,7 +564,7 @@ enum bt_lttng_live_iterator_status emit_inactivity_notification( struct lttng_live_trace *trace; const bt_clock_class *clock_class = NULL; bt_clock_value *clock_value = NULL; - const bt_notification *notif = NULL; + const bt_message *msg = NULL; int retval; trace = lttng_live_stream->trace; @@ -579,15 +579,15 @@ enum bt_lttng_live_iterator_status emit_inactivity_notification( if (!clock_value) { goto error; } - notif = bt_notification_inactivity_create(trace->cc_prio_map); - if (!notif) { + msg = bt_message_inactivity_create(trace->cc_prio_map); + if (!msg) { goto error; } - retval = bt_notification_inactivity_set_clock_value(notif, clock_value); + retval = bt_message_inactivity_set_clock_value(msg, clock_value); if (retval) { goto error; } - *notification = notif; + *message = msg; end: bt_object_put_ref(clock_value); bt_clock_class_put_ref(clock_class); @@ -595,7 +595,7 @@ end: error: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR; - bt_notification_put_ref(notif); + bt_message_put_ref(msg); goto end; } @@ -603,7 +603,7 @@ static enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent_stream( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - const bt_notification **notification) + const bt_message **message) { enum bt_lttng_live_iterator_status ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; @@ -621,7 +621,7 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent goto end; } - ret = emit_inactivity_notification(lttng_live, lttng_live_stream, notification, + ret = emit_inactivity_message(lttng_live, lttng_live_stream, message, (uint64_t) lttng_live_stream->current_inactivity_timestamp); lttng_live_stream->last_returned_inactivity_timestamp = @@ -636,11 +636,11 @@ static enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_stream( struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *lttng_live_stream, - const bt_notification **notification) + const bt_message **message) { enum bt_lttng_live_iterator_status ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; - enum bt_notif_iter_status status; + enum bt_msg_iter_status status; struct lttng_live_session *session; bt_list_for_each_entry(session, <tng_live->sessions, node) { @@ -659,36 +659,36 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_da if (lttng_live_stream->state != LTTNG_LIVE_STREAM_ACTIVE_DATA) { return BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR; } - if (lttng_live_stream->packet_end_notif_queue) { - *notification = lttng_live_stream->packet_end_notif_queue; - lttng_live_stream->packet_end_notif_queue = NULL; - status = BT_NOTIF_ITER_STATUS_OK; + if (lttng_live_stream->packet_end_msg_queue) { + *message = lttng_live_stream->packet_end_msg_queue; + lttng_live_stream->packet_end_msg_queue = NULL; + status = BT_MSG_ITER_STATUS_OK; } else { - status = bt_notif_iter_get_next_notification( - lttng_live_stream->notif_iter, + status = bt_msg_iter_get_next_message( + lttng_live_stream->msg_iter, lttng_live_stream->trace->cc_prio_map, - notification); - if (status == BT_NOTIF_ITER_STATUS_OK) { + message); + if (status == BT_MSG_ITER_STATUS_OK) { /* * Consider empty packets as inactivity. */ - if (bt_notification_get_type(*notification) == BT_NOTIFICATION_TYPE_PACKET_END) { - lttng_live_stream->packet_end_notif_queue = *notification; - *notification = NULL; - return emit_inactivity_notification(lttng_live, - lttng_live_stream, notification, + if (bt_message_get_type(*message) == BT_MESSAGE_TYPE_PACKET_END) { + lttng_live_stream->packet_end_msg_queue = *message; + *message = NULL; + return emit_inactivity_message(lttng_live, + lttng_live_stream, message, lttng_live_stream->current_packet_end_timestamp); } } } switch (status) { - case BT_NOTIF_ITER_STATUS_EOF: + case BT_MSG_ITER_STATUS_EOF: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_END; break; - case BT_NOTIF_ITER_STATUS_OK: + case BT_MSG_ITER_STATUS_OK: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_OK; break; - case BT_NOTIF_ITER_STATUS_AGAIN: + case BT_MSG_ITER_STATUS_AGAIN: /* * Continue immediately (end of packet). The next * get_index may return AGAIN to delay the following @@ -696,9 +696,9 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_da */ ret = BT_LTTNG_LIVE_ITERATOR_STATUS_CONTINUE; break; - case BT_NOTIF_ITER_STATUS_INVAL: + case BT_MSG_ITER_STATUS_INVAL: /* No argument provided by the user, so don't return INVAL. */ - case BT_NOTIF_ITER_STATUS_ERROR: + case BT_MSG_ITER_STATUS_ERROR: default: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR; break; @@ -741,7 +741,7 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_da * handle_active_data_streams() * - if at least one stream is ACTIVE_DATA: * - get stream event with lowest timestamp from heap - * - make that stream event the current notification. + * - make that stream event the current message. * - move this stream heap position to its next event * - if we need to fetch data from relayd, move * stream to ACTIVE_NO_DATA. @@ -755,18 +755,18 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_da * When disconnected from relayd: try to re-connect endlessly. */ static -bt_notification_iterator_next_method_return lttng_live_iterator_next_stream( - bt_self_notification_iterator *iterator, +bt_message_iterator_next_method_return lttng_live_iterator_next_stream( + bt_self_message_iterator *iterator, struct lttng_live_stream_iterator *stream_iter) { enum bt_lttng_live_iterator_status status; - bt_notification_iterator_next_method_return next_return; + bt_message_iterator_next_method_return next_return; struct lttng_live_component *lttng_live; lttng_live = stream_iter->trace->session->lttng_live; retry: print_stream_state(stream_iter); - next_return.notification = NULL; + next_return.message = NULL; status = lttng_live_iterator_next_handle_new_streams_and_metadata(lttng_live); if (status != BT_LTTNG_LIVE_ITERATOR_STATUS_OK) { goto end; @@ -777,18 +777,18 @@ retry: goto end; } status = lttng_live_iterator_next_handle_one_quiescent_stream( - lttng_live, stream_iter, &next_return.notification); + lttng_live, stream_iter, &next_return.message); if (status != BT_LTTNG_LIVE_ITERATOR_STATUS_OK) { - BT_ASSERT(next_return.notification == NULL); + BT_ASSERT(next_return.message == NULL); goto end; } - if (next_return.notification) { + if (next_return.message) { goto end; } status = lttng_live_iterator_next_handle_one_active_data_stream(lttng_live, - stream_iter, &next_return.notification); + stream_iter, &next_return.message); if (status != BT_LTTNG_LIVE_ITERATOR_STATUS_OK) { - BT_ASSERT(next_return.notification == NULL); + BT_ASSERT(next_return.message == NULL); } end: @@ -797,47 +797,47 @@ end: print_dbg("continue"); goto retry; case BT_LTTNG_LIVE_ITERATOR_STATUS_AGAIN: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_AGAIN; print_dbg("again"); break; case BT_LTTNG_LIVE_ITERATOR_STATUS_END: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_END; print_dbg("end"); break; case BT_LTTNG_LIVE_ITERATOR_STATUS_OK: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_OK; print_dbg("ok"); break; case BT_LTTNG_LIVE_ITERATOR_STATUS_INVAL: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_INVALID; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_NOMEM: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_UNSUPPORTED; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR: default: /* fall-through */ - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_ERROR; break; } return next_return; } static -bt_notification_iterator_next_method_return lttng_live_iterator_next_no_stream( - bt_self_notification_iterator *iterator, +bt_message_iterator_next_method_return lttng_live_iterator_next_no_stream( + bt_self_message_iterator *iterator, struct lttng_live_no_stream_iterator *no_stream_iter) { enum bt_lttng_live_iterator_status status; - bt_notification_iterator_next_method_return next_return; + bt_message_iterator_next_method_return next_return; struct lttng_live_component *lttng_live; lttng_live = no_stream_iter->lttng_live; retry: lttng_live_force_new_streams_and_metadata(lttng_live); - next_return.notification = NULL; + next_return.message = NULL; status = lttng_live_iterator_next_handle_new_streams_and_metadata(lttng_live); if (status != BT_LTTNG_LIVE_ITERATOR_STATUS_OK) { goto end; @@ -852,35 +852,35 @@ end: case BT_LTTNG_LIVE_ITERATOR_STATUS_CONTINUE: goto retry; case BT_LTTNG_LIVE_ITERATOR_STATUS_AGAIN: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_AGAIN; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_END: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_END; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_INVAL: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_INVALID; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_NOMEM: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_NOMEM; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_UNSUPPORTED; break; case BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR: default: /* fall-through */ - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_ERROR; break; } return next_return; } BT_HIDDEN -bt_notification_iterator_next_method_return lttng_live_iterator_next( - bt_self_notification_iterator *iterator) +bt_message_iterator_next_method_return lttng_live_iterator_next( + bt_self_message_iterator *iterator) { struct lttng_live_stream_iterator_generic *s = - bt_self_notification_iterator_get_user_data(iterator); - bt_notification_iterator_next_method_return next_return; + bt_self_message_iterator_get_user_data(iterator); + bt_message_iterator_next_method_return next_return; switch (s->type) { case LIVE_STREAM_TYPE_NO_STREAM: @@ -892,19 +892,19 @@ bt_notification_iterator_next_method_return lttng_live_iterator_next( container_of(s, struct lttng_live_stream_iterator, p)); break; default: - next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + next_return.status = BT_MESSAGE_ITERATOR_STATUS_ERROR; break; } return next_return; } BT_HIDDEN -enum bt_notification_iterator_status lttng_live_iterator_init( - bt_self_notification_iterator *it, +enum bt_message_iterator_status lttng_live_iterator_init( + bt_self_message_iterator *it, struct bt_private_port *port) { - enum bt_notification_iterator_status ret = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_message_iterator_status ret = + BT_MESSAGE_ITERATOR_STATUS_OK; struct lttng_live_stream_iterator_generic *s; BT_ASSERT(it); @@ -916,7 +916,7 @@ enum bt_notification_iterator_status lttng_live_iterator_init( { struct lttng_live_no_stream_iterator *no_stream_iter = container_of(s, struct lttng_live_no_stream_iterator, p); - ret = bt_self_notification_iterator_set_user_data(it, no_stream_iter); + ret = bt_self_message_iterator_set_user_data(it, no_stream_iter); if (ret) { goto error; } @@ -926,22 +926,22 @@ enum bt_notification_iterator_status lttng_live_iterator_init( { struct lttng_live_stream_iterator *stream_iter = container_of(s, struct lttng_live_stream_iterator, p); - ret = bt_self_notification_iterator_set_user_data(it, stream_iter); + ret = bt_self_message_iterator_set_user_data(it, stream_iter); if (ret) { goto error; } break; } default: - ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } end: return ret; error: - if (bt_self_notification_iterator_set_user_data(it, NULL) - != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + if (bt_self_message_iterator_set_user_data(it, NULL) + != BT_MESSAGE_ITERATOR_STATUS_OK) { BT_LOGE("Error setting private data to NULL"); } goto end; diff --git a/plugins/ctf/lttng-live/lttng-viewer-abi.h b/plugins/ctf/lttng-live/lttng-viewer-abi.h index 71047f8c..79b05695 100644 --- a/plugins/ctf/lttng-live/lttng-viewer-abi.h +++ b/plugins/ctf/lttng-live/lttng-viewer-abi.h @@ -90,7 +90,7 @@ enum lttng_viewer_get_metadata_return_code { enum lttng_viewer_connection_type { LTTNG_VIEWER_CLIENT_COMMAND = 1, - LTTNG_VIEWER_CLIENT_NOTIFICATION = 2, + LTTNG_VIEWER_CLIENT_MESSAGE = 2, }; enum lttng_viewer_seek { diff --git a/plugins/ctf/lttng-live/viewer-connection.c b/plugins/ctf/lttng-live/viewer-connection.c index 25498750..b4028978 100644 --- a/plugins/ctf/lttng-live/viewer-connection.c +++ b/plugins/ctf/lttng-live/viewer-connection.c @@ -770,7 +770,7 @@ int receive_streams(struct lttng_live_session *session, goto error; } - session->lazy_stream_notif_init = true; + session->lazy_stream_msg_init = true; } else { BT_LOGD(" stream %" PRIu64 " : %s/%s", stream_id, stream.path_name, @@ -1212,11 +1212,11 @@ error: } BT_HIDDEN -enum bt_notif_iter_medium_status lttng_live_get_stream_bytes(struct lttng_live_component *lttng_live, +enum bt_msg_iter_medium_status lttng_live_get_stream_bytes(struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *stream, uint8_t *buf, uint64_t offset, uint64_t req_len, uint64_t *recv_len) { - enum bt_notif_iter_medium_status retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_OK; + enum bt_msg_iter_medium_status retstatus = BT_MSG_ITER_MEDIUM_STATUS_OK; struct lttng_viewer_cmd cmd; struct lttng_viewer_get_packet rq; struct lttng_viewer_trace_packet rp; @@ -1280,7 +1280,7 @@ enum bt_notif_iter_medium_status lttng_live_get_stream_bytes(struct lttng_live_c case LTTNG_VIEWER_GET_PACKET_RETRY: /* Unimplemented by relay daemon */ BT_LOGD("get_data_packet: retry"); - retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN; + retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN; goto end; case LTTNG_VIEWER_GET_PACKET_ERR: if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) { @@ -1293,13 +1293,13 @@ enum bt_notif_iter_medium_status lttng_live_get_stream_bytes(struct lttng_live_c } if (flags & (LTTNG_VIEWER_FLAG_NEW_METADATA | LTTNG_VIEWER_FLAG_NEW_STREAM)) { - retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN; + retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN; goto end; } BT_LOGE("get_data_packet: error"); goto error; case LTTNG_VIEWER_GET_PACKET_EOF: - retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_EOF; + retstatus = BT_MSG_ITER_MEDIUM_STATUS_EOF; goto end; default: BT_LOGE("get_data_packet: unknown"); @@ -1326,9 +1326,9 @@ end: error: if (lttng_live_is_canceled(lttng_live)) { - retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_AGAIN; + retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN; } else { - retstatus = BT_NOTIF_ITER_MEDIUM_STATUS_ERROR; + retstatus = BT_MSG_ITER_MEDIUM_STATUS_ERROR; } return retstatus; } diff --git a/plugins/ctf/plugin.c b/plugins/ctf/plugin.c index 06a715b4..e87f83fe 100644 --- a/plugins/ctf/plugin.c +++ b/plugins/ctf/plugin.c @@ -46,9 +46,9 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(fs, ctf_fs_init); BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(fs, ctf_fs_query); BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(fs, ctf_fs_finalize); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(fs, +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(fs, ctf_fs_iterator_init); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(fs, +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(fs, ctf_fs_iterator_finalize); #if 0 @@ -73,8 +73,8 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, lttng_live, lttng_live_component_finalize); BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(auto, lttng_live, lttng_live_accept_port_connection); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID( +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID( auto, lttng_live, lttng_live_iterator_init); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID( +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID( auto, lttng_live, lttng_live_iterator_finalize); #endif diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 71ce63c1..00ec45b7 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -1413,7 +1413,7 @@ const bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it, goto error; } /* - * Take the ref on the stream and keep it until the notification + * Take the ref on the stream and keep it until the message * is created. */ bt_stream_get_ref(writer_stream); diff --git a/plugins/lttng-utils/debug-info.h b/plugins/lttng-utils/debug-info.h index 58cb5728..4b765d16 100644 --- a/plugins/lttng-utils/debug-info.h +++ b/plugins/lttng-utils/debug-info.h @@ -45,7 +45,7 @@ enum debug_info_stream_state { /* * We know the stream exists but we have never received a - * stream_begin notification for it. + * stream_begin message for it. */ DEBUG_INFO_UNKNOWN_STREAM, /* We know this stream is active (between stream_begin and _end). */ @@ -68,8 +68,8 @@ struct debug_info_iterator { GHashTable *trace_map; /* Input iterators associated with this output iterator. */ GPtrArray *input_iterator_group; - const bt_notification *current_notification; - bt_notification_iterator *input_iterator; + const bt_message *current_message; + bt_message_iterator *input_iterator; FILE *err; }; diff --git a/plugins/lttng-utils/plugin.c b/plugins/lttng-utils/plugin.c index 09740c67..6654e76d 100644 --- a/plugins/lttng-utils/plugin.c +++ b/plugins/lttng-utils/plugin.c @@ -83,11 +83,11 @@ void unref_trace(struct debug_info_trace *di_trace) } static -void debug_info_iterator_destroy(bt_self_notification_iterator *it) +void debug_info_iterator_destroy(bt_self_message_iterator *it) { struct debug_info_iterator *it_data; - it_data = bt_self_notification_iterator_get_user_data(it); + it_data = bt_self_message_iterator_get_user_data(it); BT_ASSERT(it_data); if (it_data->input_iterator_group) { @@ -98,24 +98,24 @@ void debug_info_iterator_destroy(bt_self_notification_iterator *it) empty_trace_map, it_data); g_hash_table_destroy(it_data->trace_map); - bt_notification_put_ref(it_data->current_notification); + bt_message_put_ref(it_data->current_message); bt_object_put_ref(it_data->input_iterator); g_free(it_data); } static -const bt_notification *handle_notification(FILE *err, +const bt_message *handle_message(FILE *err, struct debug_info_iterator *debug_it, - const bt_notification *notification) + const bt_message *message) { - const bt_notification *new_notification = NULL; + const bt_message *new_message = NULL; - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_PACKET_BEGINNING: { const bt_packet *packet = - bt_notification_packet_beginning_get_packet(notification); + bt_message_packet_beginning_get_packet(message); const bt_packet *writer_packet; if (!packet) { @@ -124,17 +124,17 @@ const bt_notification *handle_notification(FILE *err, writer_packet = debug_info_new_packet(debug_it, packet); BT_ASSERT(writer_packet); - new_notification = bt_notification_packet_beginning_create( + new_message = bt_message_packet_beginning_create( writer_packet); - BT_ASSERT(new_notification); + BT_ASSERT(new_message); bt_packet_put_ref(packet); bt_packet_put_ref(writer_packet); break; } - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_PACKET_END: { const bt_packet *packet = - bt_notification_packet_end_get_packet(notification); + bt_message_packet_end_get_packet(message); const bt_packet *writer_packet; if (!packet) { @@ -143,39 +143,39 @@ const bt_notification *handle_notification(FILE *err, writer_packet = debug_info_close_packet(debug_it, packet); BT_ASSERT(writer_packet); - new_notification = bt_notification_packet_end_create( + new_message = bt_message_packet_end_create( writer_packet); - BT_ASSERT(new_notification); + BT_ASSERT(new_message); bt_packet_put_ref(packet); bt_packet_put_ref(writer_packet); break; } - case BT_NOTIFICATION_TYPE_EVENT: + case BT_MESSAGE_TYPE_EVENT: { - const bt_event *event = bt_notification_event_get_event( - notification); + const bt_event *event = bt_message_event_get_event( + message); const bt_event *writer_event; bt_clock_class_priority_map *cc_prio_map = - bt_notification_event_get_clock_class_priority_map( - notification); + bt_message_event_get_clock_class_priority_map( + message); if (!event) { goto end; } writer_event = debug_info_output_event(debug_it, event); BT_ASSERT(writer_event); - new_notification = bt_notification_event_create(writer_event, + new_message = bt_message_event_create(writer_event, cc_prio_map); bt_object_put_ref(cc_prio_map); - BT_ASSERT(new_notification); + BT_ASSERT(new_message); bt_object_put_ref(event); bt_object_put_ref(writer_event); break; } - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_BEGINNING: { const bt_stream *stream = - bt_notification_stream_beginning_get_stream(notification); + bt_message_stream_beginning_get_stream(message); const bt_stream *writer_stream; if (!stream) { @@ -184,17 +184,17 @@ const bt_notification *handle_notification(FILE *err, writer_stream = debug_info_stream_begin(debug_it, stream); BT_ASSERT(writer_stream); - new_notification = bt_notification_stream_beginning_create( + new_message = bt_message_stream_beginning_create( writer_stream); - BT_ASSERT(new_notification); + BT_ASSERT(new_message); bt_stream_put_ref(stream); bt_stream_put_ref(writer_stream); break; } - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_END: { const bt_stream *stream = - bt_notification_stream_end_get_stream(notification); + bt_message_stream_end_get_stream(message); const bt_stream *writer_stream; if (!stream) { @@ -203,62 +203,62 @@ const bt_notification *handle_notification(FILE *err, writer_stream = debug_info_stream_end(debug_it, stream); BT_ASSERT(writer_stream); - new_notification = bt_notification_stream_end_create( + new_message = bt_message_stream_end_create( writer_stream); - BT_ASSERT(new_notification); + BT_ASSERT(new_message); bt_stream_put_ref(stream); bt_stream_put_ref(writer_stream); break; } default: - new_notification = bt_notification_get_ref(notification); + new_message = bt_message_get_ref(message); break; } end: - return new_notification; + return new_message; } static -bt_notification_iterator_next_method_return debug_info_iterator_next( - bt_self_notification_iterator *iterator) +bt_message_iterator_next_method_return debug_info_iterator_next( + bt_self_message_iterator *iterator) { struct debug_info_iterator *debug_it = NULL; bt_self_component *component = NULL; struct debug_info_component *debug_info = NULL; - bt_notification_iterator *source_it = NULL; - const bt_notification *notification; - bt_notification_iterator_next_method_return ret = { - .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, - .notification = NULL, + bt_message_iterator *source_it = NULL; + const bt_message *message; + bt_message_iterator_next_method_return ret = { + .status = BT_MESSAGE_ITERATOR_STATUS_OK, + .message = NULL, }; - debug_it = bt_self_notification_iterator_get_user_data(iterator); + debug_it = bt_self_message_iterator_get_user_data(iterator); BT_ASSERT(debug_it); - component = bt_self_notification_iterator_get_private_component(iterator); + component = bt_self_message_iterator_get_private_component(iterator); BT_ASSERT(component); debug_info = bt_self_component_get_user_data(component); BT_ASSERT(debug_info); source_it = debug_it->input_iterator; - ret.status = bt_notification_iterator_next(source_it); - if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + ret.status = bt_message_iterator_next(source_it); + if (ret.status != BT_MESSAGE_ITERATOR_STATUS_OK) { goto end; } - notification = bt_notification_iterator_get_notification( + message = bt_message_iterator_get_message( source_it); - if (!notification) { - ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + if (!message) { + ret.status = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - ret.notification = handle_notification(debug_info->err, debug_it, - notification); - BT_ASSERT(ret.notification); - bt_notification_put_ref(notification); + ret.message = handle_message(debug_info->err, debug_it, + message); + BT_ASSERT(ret.message); + bt_message_put_ref(message); end: bt_object_put_ref(component); @@ -266,43 +266,43 @@ end: } static -enum bt_notification_iterator_status debug_info_iterator_init( - bt_self_notification_iterator *iterator, +enum bt_message_iterator_status debug_info_iterator_init( + bt_self_message_iterator *iterator, struct bt_private_port *port) { - enum bt_notification_iterator_status ret = - BT_NOTIFICATION_ITERATOR_STATUS_OK; - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status ret = + BT_MESSAGE_ITERATOR_STATUS_OK; + enum bt_message_iterator_status it_ret; enum bt_connection_status conn_status; struct bt_private_connection *connection = NULL; bt_self_component *component = - bt_self_notification_iterator_get_private_component(iterator); + bt_self_message_iterator_get_private_component(iterator); struct debug_info_iterator *it_data = g_new0(struct debug_info_iterator, 1); struct bt_private_port *input_port; if (!it_data) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM; + ret = BT_MESSAGE_ITERATOR_STATUS_NOMEM; goto end; } input_port = bt_self_component_filter_get_input_port_by_name( component, "in"); if (!input_port) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } connection = bt_private_port_get_connection(input_port); bt_object_put_ref(input_port); if (!connection) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - conn_status = bt_private_connection_create_notification_iterator( + conn_status = bt_private_connection_create_message_iterator( connection, &it_data->input_iterator); if (conn_status != BT_CONNECTION_STATUS_OK) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } @@ -312,7 +312,7 @@ enum bt_notification_iterator_status debug_info_iterator_init( it_data->trace_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) unref_trace); - it_ret = bt_self_notification_iterator_set_user_data(iterator, it_data); + it_ret = bt_self_message_iterator_set_user_data(iterator, it_data); if (it_ret) { goto end; } @@ -451,7 +451,7 @@ BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(lttng_utils, debug_info, debug_info_component_init); BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(lttng_utils, debug_info, destroy_debug_info_component); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID( +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID( lttng_utils, debug_info, debug_info_iterator_init); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID( +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID( lttng_utils, debug_info, debug_info_iterator_destroy); diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index 1d721ab1..c85eb16a 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -43,13 +43,13 @@ struct dmesg_component; -struct dmesg_notif_iter { +struct dmesg_msg_iter { struct dmesg_component *dmesg_comp; - bt_self_notification_iterator *pc_notif_iter; /* Weak */ + bt_self_message_iterator *pc_msg_iter; /* Weak */ char *linebuf; size_t linebuf_len; FILE *fp; - bt_notification *tmp_event_notif; + bt_message *tmp_event_msg; enum { STATE_EMIT_STREAM_BEGINNING, @@ -432,18 +432,18 @@ void dmesg_finalize(bt_self_component_source *self_comp) } static -bt_notification *create_init_event_notif_from_line( - struct dmesg_notif_iter *notif_iter, +bt_message *create_init_event_msg_from_line( + struct dmesg_msg_iter *msg_iter, const char *line, const char **new_start) { bt_event *event; - bt_notification *notif = NULL; + bt_message *msg = NULL; bool has_timestamp = false; unsigned long sec, usec, msec; unsigned int year, mon, mday, hour, min; uint64_t ts = 0; int ret = 0; - struct dmesg_component *dmesg_comp = notif_iter->dmesg_comp; + struct dmesg_component *dmesg_comp = msg_iter->dmesg_comp; *new_start = line; @@ -507,14 +507,14 @@ skip_ts: goto error; } - notif = bt_notification_event_create(notif_iter->pc_notif_iter, + msg = bt_message_event_create(msg_iter->pc_msg_iter, dmesg_comp->event_class, dmesg_comp->packet); - if (!notif) { - BT_LOGE_STR("Cannot create event notification."); + if (!msg) { + BT_LOGE_STR("Cannot create event message."); goto error; } - event = bt_notification_event_borrow_event(notif); + event = bt_message_event_borrow_event(msg); BT_ASSERT(event); if (dmesg_comp->clock_class) { @@ -524,10 +524,10 @@ skip_ts: goto end; error: - BT_NOTIFICATION_PUT_REF_AND_RESET(notif); + BT_MESSAGE_PUT_REF_AND_RESET(msg); end: - return notif; + return msg; } static @@ -577,22 +577,22 @@ end: } static -bt_notification *create_notif_from_line( - struct dmesg_notif_iter *dmesg_notif_iter, const char *line) +bt_message *create_msg_from_line( + struct dmesg_msg_iter *dmesg_msg_iter, const char *line) { bt_event *event = NULL; - bt_notification *notif = NULL; + bt_message *msg = NULL; const char *new_start; int ret; - notif = create_init_event_notif_from_line(dmesg_notif_iter, + msg = create_init_event_msg_from_line(dmesg_msg_iter, line, &new_start); - if (!notif) { - BT_LOGE_STR("Cannot create and initialize event notification from line."); + if (!msg) { + BT_LOGE_STR("Cannot create and initialize event message from line."); goto error; } - event = bt_notification_event_borrow_event(notif); + event = bt_message_event_borrow_event(msg); BT_ASSERT(event); ret = fill_event_payload_from_line(new_start, event); if (ret) { @@ -604,73 +604,73 @@ bt_notification *create_notif_from_line( goto end; error: - BT_NOTIFICATION_PUT_REF_AND_RESET(notif); + BT_MESSAGE_PUT_REF_AND_RESET(msg); end: - return notif; + return msg; } static -void destroy_dmesg_notif_iter(struct dmesg_notif_iter *dmesg_notif_iter) +void destroy_dmesg_msg_iter(struct dmesg_msg_iter *dmesg_msg_iter) { - if (!dmesg_notif_iter) { + if (!dmesg_msg_iter) { return; } - if (dmesg_notif_iter->fp && dmesg_notif_iter->fp != stdin) { - if (fclose(dmesg_notif_iter->fp)) { + if (dmesg_msg_iter->fp && dmesg_msg_iter->fp != stdin) { + if (fclose(dmesg_msg_iter->fp)) { BT_LOGE_ERRNO("Cannot close input file", "."); } } - bt_notification_put_ref(dmesg_notif_iter->tmp_event_notif); - free(dmesg_notif_iter->linebuf); - g_free(dmesg_notif_iter); + bt_message_put_ref(dmesg_msg_iter->tmp_event_msg); + free(dmesg_msg_iter->linebuf); + g_free(dmesg_msg_iter); } BT_HIDDEN -enum bt_self_notification_iterator_status dmesg_notif_iter_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status dmesg_msg_iter_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) { struct dmesg_component *dmesg_comp; - struct dmesg_notif_iter *dmesg_notif_iter = - g_new0(struct dmesg_notif_iter, 1); - enum bt_self_notification_iterator_status status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + struct dmesg_msg_iter *dmesg_msg_iter = + g_new0(struct dmesg_msg_iter, 1); + enum bt_self_message_iterator_status status = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; - if (!dmesg_notif_iter) { - BT_LOGE_STR("Failed to allocate on dmesg notification iterator structure."); + if (!dmesg_msg_iter) { + BT_LOGE_STR("Failed to allocate on dmesg message iterator structure."); goto error; } dmesg_comp = bt_self_component_get_data( bt_self_component_source_as_self_component(self_comp)); BT_ASSERT(dmesg_comp); - dmesg_notif_iter->dmesg_comp = dmesg_comp; - dmesg_notif_iter->pc_notif_iter = self_notif_iter; + dmesg_msg_iter->dmesg_comp = dmesg_comp; + dmesg_msg_iter->pc_msg_iter = self_msg_iter; if (dmesg_comp->params.read_from_stdin) { - dmesg_notif_iter->fp = stdin; + dmesg_msg_iter->fp = stdin; } else { - dmesg_notif_iter->fp = fopen(dmesg_comp->params.path->str, "r"); - if (!dmesg_notif_iter->fp) { + dmesg_msg_iter->fp = fopen(dmesg_comp->params.path->str, "r"); + if (!dmesg_msg_iter->fp) { BT_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"", dmesg_comp->params.path->str); goto error; } } - bt_self_notification_iterator_set_data(self_notif_iter, - dmesg_notif_iter); + bt_self_message_iterator_set_data(self_msg_iter, + dmesg_msg_iter); goto end; error: - destroy_dmesg_notif_iter(dmesg_notif_iter); - bt_self_notification_iterator_set_data(self_notif_iter, NULL); + destroy_dmesg_msg_iter(dmesg_msg_iter); + bt_self_message_iterator_set_data(self_msg_iter, NULL); if (status >= 0) { - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; } end: @@ -678,35 +678,35 @@ end: } BT_HIDDEN -void dmesg_notif_iter_finalize( - bt_self_notification_iterator *priv_notif_iter) +void dmesg_msg_iter_finalize( + bt_self_message_iterator *priv_msg_iter) { - destroy_dmesg_notif_iter(bt_self_notification_iterator_get_data( - priv_notif_iter)); + destroy_dmesg_msg_iter(bt_self_message_iterator_get_data( + priv_msg_iter)); } static -enum bt_self_notification_iterator_status dmesg_notif_iter_next_one( - struct dmesg_notif_iter *dmesg_notif_iter, - bt_notification **notif) +enum bt_self_message_iterator_status dmesg_msg_iter_next_one( + struct dmesg_msg_iter *dmesg_msg_iter, + bt_message **msg) { ssize_t len; struct dmesg_component *dmesg_comp; - enum bt_self_notification_iterator_status status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_self_message_iterator_status status = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; - BT_ASSERT(dmesg_notif_iter); - dmesg_comp = dmesg_notif_iter->dmesg_comp; + BT_ASSERT(dmesg_msg_iter); + dmesg_comp = dmesg_msg_iter->dmesg_comp; BT_ASSERT(dmesg_comp); - if (dmesg_notif_iter->state == STATE_DONE) { - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END; + if (dmesg_msg_iter->state == STATE_DONE) { + status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; goto end; } - if (dmesg_notif_iter->tmp_event_notif || - dmesg_notif_iter->state == STATE_EMIT_PACKET_END || - dmesg_notif_iter->state == STATE_EMIT_STREAM_END) { + if (dmesg_msg_iter->tmp_event_msg || + dmesg_msg_iter->state == STATE_EMIT_PACKET_END || + dmesg_msg_iter->state == STATE_EMIT_STREAM_END) { goto handle_state; } @@ -714,22 +714,22 @@ enum bt_self_notification_iterator_status dmesg_notif_iter_next_one( const char *ch; bool only_spaces = true; - len = bt_getline(&dmesg_notif_iter->linebuf, - &dmesg_notif_iter->linebuf_len, dmesg_notif_iter->fp); + len = bt_getline(&dmesg_msg_iter->linebuf, + &dmesg_msg_iter->linebuf_len, dmesg_msg_iter->fp); if (len < 0) { if (errno == EINVAL) { - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; } else if (errno == ENOMEM) { status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_NOMEM; + BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; } else { - if (dmesg_notif_iter->state == STATE_EMIT_STREAM_BEGINNING) { + if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) { /* Stream did not even begin */ - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; goto end; } else { /* End current packet now */ - dmesg_notif_iter->state = + dmesg_msg_iter->state = STATE_EMIT_PACKET_END; goto handle_state; } @@ -738,10 +738,10 @@ enum bt_self_notification_iterator_status dmesg_notif_iter_next_one( goto end; } - BT_ASSERT(dmesg_notif_iter->linebuf); + BT_ASSERT(dmesg_msg_iter->linebuf); /* Ignore empty lines, once trimmed */ - for (ch = dmesg_notif_iter->linebuf; *ch != '\0'; ch++) { + for (ch = dmesg_msg_iter->linebuf; *ch != '\0'; ch++) { if (!isspace(*ch)) { only_spaces = false; break; @@ -753,54 +753,54 @@ enum bt_self_notification_iterator_status dmesg_notif_iter_next_one( } } - dmesg_notif_iter->tmp_event_notif = create_notif_from_line( - dmesg_notif_iter, dmesg_notif_iter->linebuf); - if (!dmesg_notif_iter->tmp_event_notif) { - BT_LOGE("Cannot create event notification from line: " + dmesg_msg_iter->tmp_event_msg = create_msg_from_line( + dmesg_msg_iter, dmesg_msg_iter->linebuf); + if (!dmesg_msg_iter->tmp_event_msg) { + BT_LOGE("Cannot create event message from line: " "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp, - dmesg_notif_iter->linebuf); + dmesg_msg_iter->linebuf); goto end; } handle_state: BT_ASSERT(dmesg_comp->trace); - switch (dmesg_notif_iter->state) { + switch (dmesg_msg_iter->state) { case STATE_EMIT_STREAM_BEGINNING: - BT_ASSERT(dmesg_notif_iter->tmp_event_notif); - *notif = bt_notification_stream_beginning_create( - dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); - dmesg_notif_iter->state = STATE_EMIT_PACKET_BEGINNING; + BT_ASSERT(dmesg_msg_iter->tmp_event_msg); + *msg = bt_message_stream_beginning_create( + dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); + dmesg_msg_iter->state = STATE_EMIT_PACKET_BEGINNING; break; case STATE_EMIT_PACKET_BEGINNING: - BT_ASSERT(dmesg_notif_iter->tmp_event_notif); - *notif = bt_notification_packet_beginning_create( - dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); - dmesg_notif_iter->state = STATE_EMIT_EVENT; + BT_ASSERT(dmesg_msg_iter->tmp_event_msg); + *msg = bt_message_packet_beginning_create( + dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet); + dmesg_msg_iter->state = STATE_EMIT_EVENT; break; case STATE_EMIT_EVENT: - BT_ASSERT(dmesg_notif_iter->tmp_event_notif); - *notif = dmesg_notif_iter->tmp_event_notif; - dmesg_notif_iter->tmp_event_notif = NULL; + BT_ASSERT(dmesg_msg_iter->tmp_event_msg); + *msg = dmesg_msg_iter->tmp_event_msg; + dmesg_msg_iter->tmp_event_msg = NULL; break; case STATE_EMIT_PACKET_END: - *notif = bt_notification_packet_end_create( - dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); - dmesg_notif_iter->state = STATE_EMIT_STREAM_END; + *msg = bt_message_packet_end_create( + dmesg_msg_iter->pc_msg_iter, dmesg_comp->packet); + dmesg_msg_iter->state = STATE_EMIT_STREAM_END; break; case STATE_EMIT_STREAM_END: - *notif = bt_notification_stream_end_create( - dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); - dmesg_notif_iter->state = STATE_DONE; + *msg = bt_message_stream_end_create( + dmesg_msg_iter->pc_msg_iter, dmesg_comp->stream); + dmesg_msg_iter->state = STATE_DONE; break; default: break; } - if (!*notif) { - BT_LOGE("Cannot create notification: dmesg-comp-addr=%p", + if (!*msg) { + BT_LOGE("Cannot create message: dmesg-comp-addr=%p", dmesg_comp); - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; } end: @@ -808,45 +808,45 @@ end: } BT_HIDDEN -enum bt_self_notification_iterator_status dmesg_notif_iter_next( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status dmesg_msg_iter_next( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - struct dmesg_notif_iter *dmesg_notif_iter = - bt_self_notification_iterator_get_data( - self_notif_iter); - enum bt_self_notification_iterator_status status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + struct dmesg_msg_iter *dmesg_msg_iter = + bt_self_message_iterator_get_data( + self_msg_iter); + enum bt_self_message_iterator_status status = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; uint64_t i = 0; while (i < capacity && - status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { - bt_notification *priv_notif = NULL; + status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { + bt_message *priv_msg = NULL; - status = dmesg_notif_iter_next_one(dmesg_notif_iter, - &priv_notif); - notifs[i] = priv_notif; - if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { + status = dmesg_msg_iter_next_one(dmesg_msg_iter, + &priv_msg); + msgs[i] = priv_msg; + if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { i++; } } if (i > 0) { /* - * Even if dmesg_notif_iter_next_one() returned + * Even if dmesg_msg_iter_next_one() returned * something else than - * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK, we - * accumulated notification objects in the output - * notification array, so we need to return - * BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK so that they + * BT_SELF_MESSAGE_ITERATOR_STATUS_OK, we + * accumulated message objects in the output + * message array, so we need to return + * BT_SELF_MESSAGE_ITERATOR_STATUS_OK so that they * are transfered to downstream. This other status - * occurs again the next time muxer_notif_iter_do_next() + * occurs again the next time muxer_msg_iter_do_next() * is called, possibly without any accumulated - * notification, in which case we'll return it. + * message, in which case we'll return it. */ *count = i; - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; } return status; diff --git a/plugins/text/dmesg/dmesg.h b/plugins/text/dmesg/dmesg.h index 7fbaf4cc..75603381 100644 --- a/plugins/text/dmesg/dmesg.h +++ b/plugins/text/dmesg/dmesg.h @@ -36,19 +36,19 @@ BT_HIDDEN void dmesg_finalize(bt_self_component_source *self_comp); BT_HIDDEN -enum bt_self_notification_iterator_status dmesg_notif_iter_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status dmesg_msg_iter_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN -void dmesg_notif_iter_finalize( - bt_self_notification_iterator *self_notif_iter); +void dmesg_msg_iter_finalize( + bt_self_message_iterator *self_msg_iter); BT_HIDDEN -enum bt_self_notification_iterator_status dmesg_notif_iter_next( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status dmesg_msg_iter_next( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count); #endif /* BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H */ diff --git a/plugins/text/plugin.c b/plugins/text/plugin.c index 2b09b77b..41da4395 100644 --- a/plugins/text/plugin.c +++ b/plugins/text/plugin.c @@ -40,15 +40,15 @@ BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(pretty, pretty_finalize); BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(pretty, pretty_port_connected); BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(pretty, - "Pretty-print notifications (`text` format of Babeltrace 1)."); + "Pretty-print messages (`text` format of Babeltrace 1)."); /* dmesg source */ -BT_PLUGIN_SOURCE_COMPONENT_CLASS(dmesg, dmesg_notif_iter_next); +BT_PLUGIN_SOURCE_COMPONENT_CLASS(dmesg, dmesg_msg_iter_next); BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(dmesg, "Read a dmesg output from a file or from standard input."); BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(dmesg, dmesg_init); BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(dmesg, dmesg_finalize); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(dmesg, - dmesg_notif_iter_init); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(dmesg, - dmesg_notif_iter_finalize); +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(dmesg, + dmesg_msg_iter_init); +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(dmesg, + dmesg_msg_iter_finalize); diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index d9f1888b..abf14ecc 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -65,7 +65,7 @@ const char *plugin_options[] = { static void destroy_pretty_data(struct pretty_component *pretty) { - bt_self_component_port_input_notification_iterator_put_ref(pretty->iterator); + bt_self_component_port_input_message_iterator_put_ref(pretty->iterator); if (pretty->string) { (void) g_string_free(pretty->string, TRUE); @@ -121,27 +121,27 @@ void pretty_finalize(bt_self_component_sink *comp) } static -enum bt_self_component_status handle_notification( +enum bt_self_component_status handle_message( struct pretty_component *pretty, - const bt_notification *notification) + const bt_message *message) { enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; BT_ASSERT(pretty); - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - if (pretty_print_packet(pretty, notification)) { + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + if (pretty_print_packet(pretty, message)) { ret = BT_SELF_COMPONENT_STATUS_ERROR; } break; - case BT_NOTIFICATION_TYPE_EVENT: - if (pretty_print_event(pretty, notification)) { + case BT_MESSAGE_TYPE_EVENT: + if (pretty_print_event(pretty, message)) { ret = BT_SELF_COMPONENT_STATUS_ERROR; } break; - case BT_NOTIFICATION_TYPE_INACTIVITY: - fprintf(stderr, "Inactivity notification\n"); + case BT_MESSAGE_TYPE_INACTIVITY: + fprintf(stderr, "Inactivity message\n"); break; default: break; @@ -163,7 +163,7 @@ enum bt_self_component_status pretty_port_connected( bt_self_component_sink_as_self_component(comp)); BT_ASSERT(pretty); BT_ASSERT(!pretty->iterator); - pretty->iterator = bt_self_component_port_input_notification_iterator_create( + pretty->iterator = bt_self_component_port_input_message_iterator_create( self_port); if (!pretty->iterator) { status = BT_SELF_COMPONENT_STATUS_NOMEM; @@ -177,30 +177,30 @@ enum bt_self_component_status pretty_consume( bt_self_component_sink *comp) { enum bt_self_component_status ret; - bt_notification_array_const notifs; - bt_self_component_port_input_notification_iterator *it; + bt_message_array_const msgs; + bt_self_component_port_input_message_iterator *it; struct pretty_component *pretty = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status it_ret; uint64_t count = 0; uint64_t i = 0; it = pretty->iterator; - it_ret = bt_self_component_port_input_notification_iterator_next(it, - ¬ifs, &count); + it_ret = bt_self_component_port_input_message_iterator_next(it, + &msgs, &count); switch (it_ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_STATUS_OK: break; - case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM: + case BT_MESSAGE_ITERATOR_STATUS_NOMEM: ret = BT_SELF_COMPONENT_STATUS_NOMEM; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: ret = BT_SELF_COMPONENT_STATUS_AGAIN; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: ret = BT_SELF_COMPONENT_STATUS_END; - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( pretty->iterator); goto end; default: @@ -208,20 +208,20 @@ enum bt_self_component_status pretty_consume( goto end; } - BT_ASSERT(it_ret == BT_NOTIFICATION_ITERATOR_STATUS_OK); + BT_ASSERT(it_ret == BT_MESSAGE_ITERATOR_STATUS_OK); for (i = 0; i < count; i++) { - ret = handle_notification(pretty, notifs[i]); + ret = handle_message(pretty, msgs[i]); if (ret) { goto end; } - bt_notification_put_ref(notifs[i]); + bt_message_put_ref(msgs[i]); } end: for (; i < count; i++) { - bt_notification_put_ref(notifs[i]); + bt_message_put_ref(msgs[i]); } return ret; diff --git a/plugins/text/pretty/pretty.h b/plugins/text/pretty/pretty.h index e8dcbc65..86c27853 100644 --- a/plugins/text/pretty/pretty.h +++ b/plugins/text/pretty/pretty.h @@ -72,7 +72,7 @@ struct pretty_options { struct pretty_component { struct pretty_options options; - bt_self_component_port_input_notification_iterator *iterator; + bt_self_component_port_input_message_iterator *iterator; FILE *out, *err; int depth; /* nesting, used for tabulation alignment. */ bool start_line; @@ -124,10 +124,10 @@ void pretty_finalize(bt_self_component_sink *component); BT_HIDDEN int pretty_print_event(struct pretty_component *pretty, - const bt_notification *event_notif); + const bt_message *event_msg); BT_HIDDEN int pretty_print_packet(struct pretty_component *pretty, - const bt_notification *packet_beginning_notif); + const bt_message *packet_beginning_msg); #endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */ diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index 3c398882..d0639817 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -1196,11 +1196,11 @@ end: BT_HIDDEN int pretty_print_event(struct pretty_component *pretty, - const bt_notification *event_notif) + const bt_message *event_msg) { int ret; const bt_event *event = - bt_notification_event_borrow_event_const(event_notif); + bt_message_event_borrow_event_const(event_msg); BT_ASSERT(event); pretty->start_line = true; @@ -1370,11 +1370,11 @@ int print_discarded_elements_msg( BT_HIDDEN int pretty_print_packet(struct pretty_component *pretty, - const bt_notification *packet_beginning_notif) + const bt_message *packet_beginning_msg) { #if 0 - const bt_packet *packet = bt_notification_packet_beginning_borrow_packet_const( - packet_beginning_notif); + const bt_packet *packet = bt_message_packet_beginning_borrow_packet_const( + packet_beginning_msg); uint64_t count; int status = 0; diff --git a/plugins/utils/counter/counter.c b/plugins/utils/counter/counter.c index 5506e580..e667e252 100644 --- a/plugins/utils/counter/counter.c +++ b/plugins/utils/counter/counter.c @@ -64,25 +64,25 @@ void print_count(struct counter *counter) PRINTF_COUNT("inactivity", "inactivities", inactivity); if (counter->count.other > 0) { - PRINTF_COUNT(" other (unknown) notification", - " other (unknown) notifications", other); + PRINTF_COUNT(" other (unknown) message", + " other (unknown) messages", other); } - printf("%s%15" PRIu64 " notification%s (TOTAL)%s\n", + printf("%s%15" PRIu64 " message%s (TOTAL)%s\n", bt_common_color_bold(), total, total == 1 ? "" : "s", bt_common_color_reset()); counter->last_printed_total = total; } static -void try_print_count(struct counter *counter, uint64_t notif_count) +void try_print_count(struct counter *counter, uint64_t msg_count) { if (counter->step == 0) { /* No update */ return; } - counter->at += notif_count; + counter->at += msg_count; if (counter->at >= counter->step) { counter->at = 0; @@ -103,7 +103,7 @@ void try_print_last(struct counter *counter) void destroy_private_counter_data(struct counter *counter) { - bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter); + bt_self_component_port_input_message_iterator_put_ref(counter->msg_iter); g_free(counter); } @@ -117,7 +117,7 @@ void counter_finalize(bt_self_component_sink *comp) bt_self_component_sink_as_self_component(comp)); BT_ASSERT(counter); try_print_last(counter); - bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter); + bt_self_component_port_input_message_iterator_put_ref(counter->msg_iter); g_free(counter); } @@ -183,20 +183,20 @@ enum bt_self_component_status counter_port_connected( { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct counter *counter; - bt_self_component_port_input_notification_iterator *iterator; + bt_self_component_port_input_message_iterator *iterator; counter = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); BT_ASSERT(counter); - iterator = bt_self_component_port_input_notification_iterator_create( + iterator = bt_self_component_port_input_message_iterator_create( self_port); if (!iterator) { status = BT_SELF_COMPONENT_STATUS_NOMEM; goto end; } - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF( - counter->notif_iter, iterator); + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF( + counter->msg_iter, iterator); end: return status; @@ -208,81 +208,81 @@ enum bt_self_component_status counter_consume( { enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; struct counter *counter; - enum bt_notification_iterator_status it_ret; - uint64_t notif_count; - bt_notification_array_const notifs; + enum bt_message_iterator_status it_ret; + uint64_t msg_count; + bt_message_array_const msgs; counter = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); BT_ASSERT(counter); - if (unlikely(!counter->notif_iter)) { + if (unlikely(!counter->msg_iter)) { try_print_last(counter); ret = BT_SELF_COMPONENT_STATUS_END; goto end; } - /* Consume notifications */ - it_ret = bt_self_component_port_input_notification_iterator_next( - counter->notif_iter, ¬ifs, ¬if_count); + /* Consume messages */ + it_ret = bt_self_component_port_input_message_iterator_next( + counter->msg_iter, &msgs, &msg_count); if (it_ret < 0) { ret = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } switch (it_ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_STATUS_OK: { uint64_t i; - for (i = 0; i < notif_count; i++) { - const bt_notification *notif = notifs[i]; + for (i = 0; i < msg_count; i++) { + const bt_message *msg = msgs[i]; - BT_ASSERT(notif); - switch (bt_notification_get_type(notif)) { - case BT_NOTIFICATION_TYPE_EVENT: + BT_ASSERT(msg); + switch (bt_message_get_type(msg)) { + case BT_MESSAGE_TYPE_EVENT: counter->count.event++; break; - case BT_NOTIFICATION_TYPE_INACTIVITY: + case BT_MESSAGE_TYPE_INACTIVITY: counter->count.inactivity++; break; - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_BEGINNING: counter->count.stream_begin++; break; - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_END: counter->count.stream_end++; break; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + case BT_MESSAGE_TYPE_PACKET_BEGINNING: counter->count.packet_begin++; break; - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_PACKET_END: counter->count.packet_end++; break; default: counter->count.other++; } - bt_notification_put_ref(notif); + bt_message_put_ref(msg); } ret = BT_SELF_COMPONENT_STATUS_OK; break; } - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: ret = BT_SELF_COMPONENT_STATUS_AGAIN; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: try_print_last(counter); ret = BT_SELF_COMPONENT_STATUS_END; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM: + case BT_MESSAGE_ITERATOR_STATUS_NOMEM: ret = BT_SELF_COMPONENT_STATUS_NOMEM; goto end; default: break; } - try_print_count(counter, notif_count); + try_print_count(counter, msg_count); end: return ret; diff --git a/plugins/utils/counter/counter.h b/plugins/utils/counter/counter.h index beed7ddc..eb8a37bb 100644 --- a/plugins/utils/counter/counter.h +++ b/plugins/utils/counter/counter.h @@ -29,7 +29,7 @@ #include struct counter { - bt_self_component_port_input_notification_iterator *notif_iter; + bt_self_component_port_input_message_iterator *msg_iter; struct { uint64_t event; uint64_t stream_begin; diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index a2bab430..5d513cf2 100644 --- a/plugins/utils/dummy/dummy.c +++ b/plugins/utils/dummy/dummy.c @@ -28,7 +28,7 @@ void destroy_private_dummy_data(struct dummy *dummy) { - bt_self_component_port_input_notification_iterator_put_ref(dummy->notif_iter); + bt_self_component_port_input_message_iterator_put_ref(dummy->msg_iter); g_free(dummy); } @@ -84,20 +84,20 @@ enum bt_self_component_status dummy_port_connected( { enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; struct dummy *dummy; - bt_self_component_port_input_notification_iterator *iterator; + bt_self_component_port_input_message_iterator *iterator; dummy = bt_self_component_get_data( bt_self_component_sink_as_self_component(comp)); BT_ASSERT(dummy); - iterator = bt_self_component_port_input_notification_iterator_create( + iterator = bt_self_component_port_input_message_iterator_create( self_port); if (!iterator) { status = BT_SELF_COMPONENT_STATUS_NOMEM; goto end; } - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF( - dummy->notif_iter, iterator); + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF( + dummy->msg_iter, iterator); end: return status; @@ -108,43 +108,43 @@ enum bt_self_component_status dummy_consume( bt_self_component_sink *component) { enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK; - bt_notification_array_const notifs; + bt_message_array_const msgs; uint64_t count; struct dummy *dummy; - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status it_ret; uint64_t i; dummy = bt_self_component_get_data( bt_self_component_sink_as_self_component(component)); BT_ASSERT(dummy); - if (unlikely(!dummy->notif_iter)) { + if (unlikely(!dummy->msg_iter)) { ret = BT_SELF_COMPONENT_STATUS_END; goto end; } - /* Consume one notification */ - it_ret = bt_self_component_port_input_notification_iterator_next( - dummy->notif_iter, ¬ifs, &count); + /* Consume one message */ + it_ret = bt_self_component_port_input_message_iterator_next( + dummy->msg_iter, &msgs, &count); switch (it_ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_STATUS_OK: ret = BT_SELF_COMPONENT_STATUS_OK; for (i = 0; i < count; i++) { - bt_notification_put_ref(notifs[i]); + bt_message_put_ref(msgs[i]); } break; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: ret = BT_SELF_COMPONENT_STATUS_AGAIN; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: ret = BT_SELF_COMPONENT_STATUS_END; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_ERROR: + case BT_MESSAGE_ITERATOR_STATUS_ERROR: ret = BT_SELF_COMPONENT_STATUS_ERROR; goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM: + case BT_MESSAGE_ITERATOR_STATUS_NOMEM: ret = BT_SELF_COMPONENT_STATUS_NOMEM; goto end; default: diff --git a/plugins/utils/dummy/dummy.h b/plugins/utils/dummy/dummy.h index 833df41e..c87969d1 100644 --- a/plugins/utils/dummy/dummy.h +++ b/plugins/utils/dummy/dummy.h @@ -29,7 +29,7 @@ #include struct dummy { - bt_self_component_port_input_notification_iterator *notif_iter; + bt_self_component_port_input_message_iterator *msg_iter; }; BT_HIDDEN diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index 9aa69223..bb786ed9 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,130 +44,130 @@ struct muxer_comp { /* * Array of struct - * bt_self_notification_iterator * + * bt_self_message_iterator * * (weak refs) */ - GPtrArray *muxer_notif_iters; + GPtrArray *muxer_msg_iters; /* Weak ref */ bt_self_component_filter *self_comp; unsigned int next_port_num; size_t available_input_ports; - bool initializing_muxer_notif_iter; + bool initializing_muxer_msg_iter; bool assume_absolute_clock_classes; }; -struct muxer_upstream_notif_iter { +struct muxer_upstream_msg_iter { /* Owned by this, NULL if ended */ - bt_self_component_port_input_notification_iterator *notif_iter; + bt_self_component_port_input_message_iterator *msg_iter; - /* Contains `const bt_notification *`, owned by this */ - GQueue *notifs; + /* Contains `const bt_message *`, owned by this */ + GQueue *msgs; }; -enum muxer_notif_iter_clock_class_expectation { - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ANY = 0, - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE, - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID, - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID, +enum muxer_msg_iter_clock_class_expectation { + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY = 0, + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE, + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID, + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID, }; -struct muxer_notif_iter { +struct muxer_msg_iter { /* - * Array of struct muxer_upstream_notif_iter * (owned by this). + * Array of struct muxer_upstream_msg_iter * (owned by this). * * NOTE: This array is searched in linearly to find the youngest - * current notification. Keep this until benchmarks confirm that + * current message. Keep this until benchmarks confirm that * another data structure is faster than this for our typical * use cases. */ - GPtrArray *muxer_upstream_notif_iters; + GPtrArray *muxer_upstream_msg_iters; /* * List of "recently" connected input ports (weak) to - * handle by this muxer notification iterator. + * handle by this muxer message iterator. * muxer_port_connected() adds entries to this list, and the - * entries are removed when a notification iterator is created + * entries are removed when a message iterator is created * on the port's connection and put into - * muxer_upstream_notif_iters above by - * muxer_notif_iter_handle_newly_connected_ports(). + * muxer_upstream_msg_iters above by + * muxer_msg_iter_handle_newly_connected_ports(). */ GList *newly_connected_self_ports; - /* Last time returned in a notification */ + /* Last time returned in a message */ int64_t last_returned_ts_ns; /* Clock class expectation state */ - enum muxer_notif_iter_clock_class_expectation clock_class_expectation; + enum muxer_msg_iter_clock_class_expectation clock_class_expectation; /* * Expected clock class UUID, only valid when * clock_class_expectation is - * MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID. + * MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID. */ unsigned char expected_clock_class_uuid[BABELTRACE_UUID_LEN]; }; static -void destroy_muxer_upstream_notif_iter( - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter) +void destroy_muxer_upstream_msg_iter( + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter) { - if (!muxer_upstream_notif_iter) { + if (!muxer_upstream_msg_iter) { return; } - BT_LOGD("Destroying muxer's upstream notification iterator wrapper: " - "addr=%p, notif-iter-addr=%p, queue-len=%u", - muxer_upstream_notif_iter, - muxer_upstream_notif_iter->notif_iter, - muxer_upstream_notif_iter->notifs->length); - bt_self_component_port_input_notification_iterator_put_ref(muxer_upstream_notif_iter->notif_iter); + BT_LOGD("Destroying muxer's upstream message iterator wrapper: " + "addr=%p, msg-iter-addr=%p, queue-len=%u", + muxer_upstream_msg_iter, + muxer_upstream_msg_iter->msg_iter, + muxer_upstream_msg_iter->msgs->length); + bt_self_component_port_input_message_iterator_put_ref(muxer_upstream_msg_iter->msg_iter); - if (muxer_upstream_notif_iter->notifs) { - const bt_notification *notif; + if (muxer_upstream_msg_iter->msgs) { + const bt_message *msg; - while ((notif = g_queue_pop_head( - muxer_upstream_notif_iter->notifs))) { - bt_notification_put_ref(notif); + while ((msg = g_queue_pop_head( + muxer_upstream_msg_iter->msgs))) { + bt_message_put_ref(msg); } - g_queue_free(muxer_upstream_notif_iter->notifs); + g_queue_free(muxer_upstream_msg_iter->msgs); } - g_free(muxer_upstream_notif_iter); + g_free(muxer_upstream_msg_iter); } static -struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter( - struct muxer_notif_iter *muxer_notif_iter, - bt_self_component_port_input_notification_iterator *self_notif_iter) +struct muxer_upstream_msg_iter *muxer_msg_iter_add_upstream_msg_iter( + struct muxer_msg_iter *muxer_msg_iter, + bt_self_component_port_input_message_iterator *self_msg_iter) { - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter = - g_new0(struct muxer_upstream_notif_iter, 1); + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = + g_new0(struct muxer_upstream_msg_iter, 1); - if (!muxer_upstream_notif_iter) { - BT_LOGE_STR("Failed to allocate one muxer's upstream notification iterator wrapper."); + if (!muxer_upstream_msg_iter) { + BT_LOGE_STR("Failed to allocate one muxer's upstream message iterator wrapper."); goto end; } - muxer_upstream_notif_iter->notif_iter = self_notif_iter; - bt_self_component_port_input_notification_iterator_get_ref(muxer_upstream_notif_iter->notif_iter); - muxer_upstream_notif_iter->notifs = g_queue_new(); - if (!muxer_upstream_notif_iter->notifs) { + muxer_upstream_msg_iter->msg_iter = self_msg_iter; + bt_self_component_port_input_message_iterator_get_ref(muxer_upstream_msg_iter->msg_iter); + muxer_upstream_msg_iter->msgs = g_queue_new(); + if (!muxer_upstream_msg_iter->msgs) { BT_LOGE_STR("Failed to allocate a GQueue."); goto end; } - g_ptr_array_add(muxer_notif_iter->muxer_upstream_notif_iters, - muxer_upstream_notif_iter); - BT_LOGD("Added muxer's upstream notification iterator wrapper: " - "addr=%p, muxer-notif-iter-addr=%p, notif-iter-addr=%p", - muxer_upstream_notif_iter, muxer_notif_iter, - self_notif_iter); + g_ptr_array_add(muxer_msg_iter->muxer_upstream_msg_iters, + muxer_upstream_msg_iter); + BT_LOGD("Added muxer's upstream message iterator wrapper: " + "addr=%p, muxer-msg-iter-addr=%p, msg-iter-addr=%p", + muxer_upstream_msg_iter, muxer_msg_iter, + self_msg_iter); end: - return muxer_upstream_notif_iter; + return muxer_upstream_msg_iter; } static @@ -232,12 +232,12 @@ void destroy_muxer_comp(struct muxer_comp *muxer_comp) } BT_LOGD("Destroying muxer component: muxer-comp-addr=%p, " - "muxer-notif-iter-count=%u", muxer_comp, - muxer_comp->muxer_notif_iters ? - muxer_comp->muxer_notif_iters->len : 0); + "muxer-msg-iter-count=%u", muxer_comp, + muxer_comp->muxer_msg_iters ? + muxer_comp->muxer_msg_iters->len : 0); - if (muxer_comp->muxer_notif_iters) { - g_ptr_array_free(muxer_comp->muxer_notif_iters, TRUE); + if (muxer_comp->muxer_msg_iters) { + g_ptr_array_free(muxer_comp->muxer_msg_iters, TRUE); } g_free(muxer_comp); @@ -350,8 +350,8 @@ enum bt_self_component_status muxer_init( goto error; } - muxer_comp->muxer_notif_iters = g_ptr_array_new(); - if (!muxer_comp->muxer_notif_iters) { + muxer_comp->muxer_msg_iters = g_ptr_array_new(); + if (!muxer_comp->muxer_msg_iters) { BT_LOGE_STR("Failed to allocate a GPtrArray."); goto error; } @@ -410,14 +410,14 @@ void muxer_finalize(bt_self_component_filter *self_comp) } static -bt_self_component_port_input_notification_iterator * -create_notif_iter_on_input_port( +bt_self_component_port_input_message_iterator * +create_msg_iter_on_input_port( bt_self_component_port_input *self_port, int *ret) { const bt_port *port = bt_self_component_port_as_port( bt_self_component_port_input_as_self_component_port( self_port)); - bt_self_component_port_input_notification_iterator *notif_iter = + bt_self_component_port_input_message_iterator *msg_iter = NULL; BT_ASSERT(ret); @@ -426,86 +426,86 @@ create_notif_iter_on_input_port( BT_ASSERT(bt_port_is_connected(port)); // TODO: Advance the iterator to >= the time of the latest - // returned notification by the muxer notification + // returned message by the muxer message // iterator which creates it. - notif_iter = bt_self_component_port_input_notification_iterator_create( + msg_iter = bt_self_component_port_input_message_iterator_create( self_port); - if (!notif_iter) { - BT_LOGE("Cannot create upstream notification iterator on input port: " + if (!msg_iter) { + BT_LOGE("Cannot create upstream message iterator on input port: " "port-addr=%p, port-name=\"%s\"", port, bt_port_get_name(port)); *ret = -1; goto end; } - BT_LOGD("Created upstream notification iterator on input port: " - "port-addr=%p, port-name=\"%s\", notif-iter-addr=%p", - port, bt_port_get_name(port), notif_iter); + BT_LOGD("Created upstream message iterator on input port: " + "port-addr=%p, port-name=\"%s\", msg-iter-addr=%p", + port, bt_port_get_name(port), msg_iter); end: - return notif_iter; + return msg_iter; } static -enum bt_notification_iterator_status muxer_upstream_notif_iter_next( - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter) +enum bt_message_iterator_status muxer_upstream_msg_iter_next( + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter) { - enum bt_notification_iterator_status status; - bt_notification_array_const notifs; + enum bt_message_iterator_status status; + bt_message_array_const msgs; uint64_t i; uint64_t count; - BT_LOGV("Calling upstream notification iterator's \"next\" method: " - "muxer-upstream-notif-iter-wrap-addr=%p, notif-iter-addr=%p", - muxer_upstream_notif_iter, - muxer_upstream_notif_iter->notif_iter); - status = bt_self_component_port_input_notification_iterator_next( - muxer_upstream_notif_iter->notif_iter, ¬ifs, &count); - BT_LOGV("Upstream notification iterator's \"next\" method returned: " - "status=%s", bt_notification_iterator_status_string(status)); + BT_LOGV("Calling upstream message iterator's \"next\" method: " + "muxer-upstream-msg-iter-wrap-addr=%p, msg-iter-addr=%p", + muxer_upstream_msg_iter, + muxer_upstream_msg_iter->msg_iter); + status = bt_self_component_port_input_message_iterator_next( + muxer_upstream_msg_iter->msg_iter, &msgs, &count); + BT_LOGV("Upstream message iterator's \"next\" method returned: " + "status=%s", bt_message_iterator_status_string(status)); switch (status) { - case BT_NOTIFICATION_ITERATOR_STATUS_OK: + case BT_MESSAGE_ITERATOR_STATUS_OK: /* - * Notification iterator's current notification is + * Message iterator's current message is * valid: it must be considered for muxing operations. */ - BT_LOGV_STR("Validated upstream notification iterator wrapper."); + BT_LOGV_STR("Validated upstream message iterator wrapper."); BT_ASSERT(count > 0); - /* Move notifications to our queue */ + /* Move messages to our queue */ for (i = 0; i < count; i++) { /* * Push to tail in order; other side - * (muxer_notif_iter_do_next_one()) consumes + * (muxer_msg_iter_do_next_one()) consumes * from the head first. */ - g_queue_push_tail(muxer_upstream_notif_iter->notifs, - (void *) notifs[i]); + g_queue_push_tail(muxer_upstream_msg_iter->msgs, + (void *) msgs[i]); } break; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: /* - * Notification iterator's current notification is not + * Message iterator's current message is not * valid anymore. Return - * BT_NOTIFICATION_ITERATOR_STATUS_AGAIN immediately. + * BT_MESSAGE_ITERATOR_STATUS_AGAIN immediately. */ break; - case BT_NOTIFICATION_ITERATOR_STATUS_END: /* Fall-through. */ - case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED: + case BT_MESSAGE_ITERATOR_STATUS_END: /* Fall-through. */ + case BT_MESSAGE_ITERATOR_STATUS_CANCELED: /* - * Notification iterator reached the end: release it. It + * Message iterator reached the end: release it. It * won't be considered again to find the youngest - * notification. + * message. */ - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter); - status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(muxer_upstream_msg_iter->msg_iter); + status = BT_MESSAGE_ITERATOR_STATUS_OK; break; default: /* Error or unsupported status code */ BT_LOGE("Error or unsupported status code: " "status-code=%d", status); - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; break; } @@ -513,29 +513,29 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next( } static -int muxer_notif_iter_handle_newly_connected_ports( - struct muxer_notif_iter *muxer_notif_iter) +int muxer_msg_iter_handle_newly_connected_ports( + struct muxer_msg_iter *muxer_msg_iter) { int ret = 0; BT_LOGV("Handling newly connected ports: " - "muxer-notif-iter-addr=%p", muxer_notif_iter); + "muxer-msg-iter-addr=%p", muxer_msg_iter); /* - * Here we create one upstream notification iterator for each + * Here we create one upstream message iterator for each * newly connected port. We do NOT perform an initial "next" on - * those new upstream notification iterators: they are + * those new upstream message iterators: they are * invalidated, to be validated later. The list of newly * connected ports to handle here is updated by * muxer_port_connected(). */ while (true) { - GList *node = muxer_notif_iter->newly_connected_self_ports; + GList *node = muxer_msg_iter->newly_connected_self_ports; bt_self_component_port_input *self_port; const bt_port *port; - bt_self_component_port_input_notification_iterator * - upstream_notif_iter = NULL; - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter; + bt_self_component_port_input_message_iterator * + upstream_msg_iter = NULL; + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter; if (!node) { break; @@ -551,37 +551,37 @@ int muxer_notif_iter_handle_newly_connected_ports( /* * Looks like this port is not connected * anymore: we can't create an upstream - * notification iterator on its (non-existing) + * message iterator on its (non-existing) * connection in this case. */ goto remove_node; } - upstream_notif_iter = create_notif_iter_on_input_port( + upstream_msg_iter = create_msg_iter_on_input_port( self_port, &ret); if (ret) { - /* create_notif_iter_on_input_port() logs errors */ - BT_ASSERT(!upstream_notif_iter); + /* create_msg_iter_on_input_port() logs errors */ + BT_ASSERT(!upstream_msg_iter); goto error; } - muxer_upstream_notif_iter = - muxer_notif_iter_add_upstream_notif_iter( - muxer_notif_iter, upstream_notif_iter); - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(upstream_notif_iter); - if (!muxer_upstream_notif_iter) { + muxer_upstream_msg_iter = + muxer_msg_iter_add_upstream_msg_iter( + muxer_msg_iter, upstream_msg_iter); + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(upstream_msg_iter); + if (!muxer_upstream_msg_iter) { /* - * muxer_notif_iter_add_upstream_notif_iter() + * muxer_msg_iter_add_upstream_msg_iter() * logs errors. */ goto error; } remove_node: - bt_self_component_port_input_notification_iterator_put_ref(upstream_notif_iter); - muxer_notif_iter->newly_connected_self_ports = + bt_self_component_port_input_message_iterator_put_ref(upstream_msg_iter); + muxer_msg_iter->newly_connected_self_ports = g_list_delete_link( - muxer_notif_iter->newly_connected_self_ports, + muxer_msg_iter->newly_connected_self_ports, node); } @@ -597,9 +597,9 @@ end: } static -int get_notif_ts_ns(struct muxer_comp *muxer_comp, - struct muxer_notif_iter *muxer_notif_iter, - const bt_notification *notif, int64_t last_returned_ts_ns, +int get_msg_ts_ns(struct muxer_comp *muxer_comp, + struct muxer_msg_iter *muxer_msg_iter, + const bt_message *msg, int64_t last_returned_ts_ns, int64_t *ts_ns) { const bt_clock_class *clock_class = NULL; @@ -610,30 +610,30 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, const char *cc_name; enum bt_clock_value_status cv_status = BT_CLOCK_VALUE_STATUS_KNOWN; - BT_ASSERT(notif); + BT_ASSERT(msg); BT_ASSERT(ts_ns); - BT_LOGV("Getting notification's timestamp: " - "muxer-notif-iter-addr=%p, notif-addr=%p, " + BT_LOGV("Getting message's timestamp: " + "muxer-msg-iter-addr=%p, msg-addr=%p, " "last-returned-ts=%" PRId64, - muxer_notif_iter, notif, last_returned_ts_ns); + muxer_msg_iter, msg, last_returned_ts_ns); - switch (bt_notification_get_type(notif)) { - case BT_NOTIFICATION_TYPE_EVENT: - event = bt_notification_event_borrow_event_const(notif); + switch (bt_message_get_type(msg)) { + case BT_MESSAGE_TYPE_EVENT: + event = bt_message_event_borrow_event_const(msg); BT_ASSERT(event); cv_status = bt_event_borrow_default_clock_value_const(event, &clock_value); break; - case BT_NOTIFICATION_TYPE_INACTIVITY: + case BT_MESSAGE_TYPE_INACTIVITY: clock_value = - bt_notification_inactivity_borrow_default_clock_value_const( - notif); + bt_message_inactivity_borrow_default_clock_value_const( + msg); break; default: - /* All the other notifications have a higher priority */ - BT_LOGV_STR("Notification has no timestamp: using the last returned timestamp."); + /* All the other messages have a higher priority */ + BT_LOGV_STR("Message has no timestamp: using the last returned timestamp."); *ts_ns = last_returned_ts_ns; goto end; } @@ -646,11 +646,11 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, /* * If the clock value is missing, then we consider that this - * notification has no time. In this case it's always the + * message has no time. In this case it's always the * youngest. */ if (!clock_value) { - BT_LOGV_STR("Notification's default clock value is missing: " + BT_LOGV_STR("Message's default clock value is missing: " "using the last returned timestamp."); *ts_ns = last_returned_ts_ns; goto end; @@ -661,43 +661,43 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, cc_uuid = bt_clock_class_get_uuid(clock_class); cc_name = bt_clock_class_get_name(clock_class); - if (muxer_notif_iter->clock_class_expectation == - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ANY) { + if (muxer_msg_iter->clock_class_expectation == + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY) { /* * This is the first clock class that this muxer - * notification iterator encounters. Its properties + * message iterator encounters. Its properties * determine what to expect for the whole lifetime of * the iterator without a true * `assume-absolute-clock-classes` parameter. */ if (bt_clock_class_is_absolute(clock_class)) { /* Expect absolute clock classes */ - muxer_notif_iter->clock_class_expectation = - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE; + muxer_msg_iter->clock_class_expectation = + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE; } else { if (cc_uuid) { /* * Expect non-absolute clock classes * with a specific UUID. */ - muxer_notif_iter->clock_class_expectation = - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID; - memcpy(muxer_notif_iter->expected_clock_class_uuid, + muxer_msg_iter->clock_class_expectation = + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID; + memcpy(muxer_msg_iter->expected_clock_class_uuid, cc_uuid, BABELTRACE_UUID_LEN); } else { /* * Expect non-absolute clock classes * with no UUID. */ - muxer_notif_iter->clock_class_expectation = - MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID; + muxer_msg_iter->clock_class_expectation = + MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID; } } } if (!muxer_comp->assume_absolute_clock_classes) { - switch (muxer_notif_iter->clock_class_expectation) { - case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE: + switch (muxer_msg_iter->clock_class_expectation) { + case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE: if (!bt_clock_class_is_absolute(clock_class)) { BT_LOGE("Expecting an absolute clock class, " "but got a non-absolute one: " @@ -706,7 +706,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, goto error; } break; - case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID: + case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID: if (bt_clock_class_is_absolute(clock_class)) { BT_LOGE("Expecting a non-absolute clock class with no UUID, " "but got an absolute one: " @@ -740,7 +740,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, goto error; } break; - case MUXER_NOTIF_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID: + case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID: if (bt_clock_class_is_absolute(clock_class)) { BT_LOGE("Expecting a non-absolute clock class with a specific UUID, " "but got an absolute one: " @@ -757,7 +757,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, goto error; } - if (memcmp(muxer_notif_iter->expected_clock_class_uuid, + if (memcmp(muxer_msg_iter->expected_clock_class_uuid, cc_uuid, BABELTRACE_UUID_LEN) != 0) { BT_LOGE("Expecting a non-absolute clock class with a specific UUID, " "but got one with different UUID: " @@ -765,22 +765,22 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", clock_class, cc_name, - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[0], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[1], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[2], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[3], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[4], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[5], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[6], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[7], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[8], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[9], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[10], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[11], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[12], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[13], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[14], - (unsigned int) muxer_notif_iter->expected_clock_class_uuid[15], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[0], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[1], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[2], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[3], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[4], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[5], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[6], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[7], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[8], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[9], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[10], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[11], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[12], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[13], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[14], + (unsigned int) muxer_msg_iter->expected_clock_class_uuid[15], (unsigned int) cc_uuid[0], (unsigned int) cc_uuid[1], (unsigned int) cc_uuid[2], @@ -804,7 +804,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp, /* Unexpected */ BT_LOGF("Unexpected clock class expectation: " "expectation-code=%d", - muxer_notif_iter->clock_class_expectation); + muxer_msg_iter->clock_class_expectation); abort(); } } @@ -823,10 +823,10 @@ error: end: if (ret == 0) { - BT_LOGV("Found notification's timestamp: " - "muxer-notif-iter-addr=%p, notif-addr=%p, " + BT_LOGV("Found message's timestamp: " + "muxer-msg-iter-addr=%p, msg-addr=%p, " "last-returned-ts=%" PRId64 ", ts=%" PRId64, - muxer_notif_iter, notif, last_returned_ts_ns, + muxer_msg_iter, msg, last_returned_ts_ns, *ts_ns); } @@ -834,77 +834,77 @@ end: } /* - * This function finds the youngest available notification amongst the - * non-ended upstream notification iterators and returns the upstream - * notification iterator which has it, or - * BT_NOTIFICATION_ITERATOR_STATUS_END if there's no available - * notification. + * This function finds the youngest available message amongst the + * non-ended upstream message iterators and returns the upstream + * message iterator which has it, or + * BT_MESSAGE_ITERATOR_STATUS_END if there's no available + * message. * * This function does NOT: * - * * Update any upstream notification iterator. + * * Update any upstream message iterator. * * Check for newly connected ports. - * * Check the upstream notification iterators to retry. + * * Check the upstream message iterators to retry. * - * On sucess, this function sets *muxer_upstream_notif_iter to the - * upstream notification iterator of which the current notification is + * On sucess, this function sets *muxer_upstream_msg_iter to the + * upstream message iterator of which the current message is * the youngest, and sets *ts_ns to its time. */ static -enum bt_notification_iterator_status -muxer_notif_iter_youngest_upstream_notif_iter( +enum bt_message_iterator_status +muxer_msg_iter_youngest_upstream_msg_iter( struct muxer_comp *muxer_comp, - struct muxer_notif_iter *muxer_notif_iter, - struct muxer_upstream_notif_iter **muxer_upstream_notif_iter, + struct muxer_msg_iter *muxer_msg_iter, + struct muxer_upstream_msg_iter **muxer_upstream_msg_iter, int64_t *ts_ns) { size_t i; int ret; int64_t youngest_ts_ns = INT64_MAX; - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; BT_ASSERT(muxer_comp); - BT_ASSERT(muxer_notif_iter); - BT_ASSERT(muxer_upstream_notif_iter); - *muxer_upstream_notif_iter = NULL; - - for (i = 0; i < muxer_notif_iter->muxer_upstream_notif_iters->len; i++) { - const bt_notification *notif; - struct muxer_upstream_notif_iter *cur_muxer_upstream_notif_iter = - g_ptr_array_index(muxer_notif_iter->muxer_upstream_notif_iters, i); - int64_t notif_ts_ns; - - if (!cur_muxer_upstream_notif_iter->notif_iter) { - /* This upstream notification iterator is ended */ - BT_LOGV("Skipping ended upstream notification iterator: " - "muxer-upstream-notif-iter-wrap-addr=%p", - cur_muxer_upstream_notif_iter); + BT_ASSERT(muxer_msg_iter); + BT_ASSERT(muxer_upstream_msg_iter); + *muxer_upstream_msg_iter = NULL; + + for (i = 0; i < muxer_msg_iter->muxer_upstream_msg_iters->len; i++) { + const bt_message *msg; + struct muxer_upstream_msg_iter *cur_muxer_upstream_msg_iter = + g_ptr_array_index(muxer_msg_iter->muxer_upstream_msg_iters, i); + int64_t msg_ts_ns; + + if (!cur_muxer_upstream_msg_iter->msg_iter) { + /* This upstream message iterator is ended */ + BT_LOGV("Skipping ended upstream message iterator: " + "muxer-upstream-msg-iter-wrap-addr=%p", + cur_muxer_upstream_msg_iter); continue; } - BT_ASSERT(cur_muxer_upstream_notif_iter->notifs->length > 0); - notif = g_queue_peek_head(cur_muxer_upstream_notif_iter->notifs); - BT_ASSERT(notif); - ret = get_notif_ts_ns(muxer_comp, muxer_notif_iter, notif, - muxer_notif_iter->last_returned_ts_ns, ¬if_ts_ns); + BT_ASSERT(cur_muxer_upstream_msg_iter->msgs->length > 0); + msg = g_queue_peek_head(cur_muxer_upstream_msg_iter->msgs); + BT_ASSERT(msg); + ret = get_msg_ts_ns(muxer_comp, muxer_msg_iter, msg, + muxer_msg_iter->last_returned_ts_ns, &msg_ts_ns); if (ret) { - /* get_notif_ts_ns() logs errors */ - *muxer_upstream_notif_iter = NULL; - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + /* get_msg_ts_ns() logs errors */ + *muxer_upstream_msg_iter = NULL; + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - if (notif_ts_ns <= youngest_ts_ns) { - *muxer_upstream_notif_iter = - cur_muxer_upstream_notif_iter; - youngest_ts_ns = notif_ts_ns; + if (msg_ts_ns <= youngest_ts_ns) { + *muxer_upstream_msg_iter = + cur_muxer_upstream_msg_iter; + youngest_ts_ns = msg_ts_ns; *ts_ns = youngest_ts_ns; } } - if (!*muxer_upstream_notif_iter) { - status = BT_NOTIFICATION_ITERATOR_STATUS_END; + if (!*muxer_upstream_msg_iter) { + status = BT_MESSAGE_ITERATOR_STATUS_END; *ts_ns = INT64_MIN; } @@ -913,84 +913,84 @@ end: } static -enum bt_notification_iterator_status validate_muxer_upstream_notif_iter( - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter) +enum bt_message_iterator_status validate_muxer_upstream_msg_iter( + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter) { - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; - BT_LOGV("Validating muxer's upstream notification iterator wrapper: " - "muxer-upstream-notif-iter-wrap-addr=%p", - muxer_upstream_notif_iter); + BT_LOGV("Validating muxer's upstream message iterator wrapper: " + "muxer-upstream-msg-iter-wrap-addr=%p", + muxer_upstream_msg_iter); - if (muxer_upstream_notif_iter->notifs->length > 0 || - !muxer_upstream_notif_iter->notif_iter) { + if (muxer_upstream_msg_iter->msgs->length > 0 || + !muxer_upstream_msg_iter->msg_iter) { BT_LOGV("Already valid or not considered: " - "queue-len=%u, upstream-notif-iter-addr=%p", - muxer_upstream_notif_iter->notifs->length, - muxer_upstream_notif_iter->notif_iter); + "queue-len=%u, upstream-msg-iter-addr=%p", + muxer_upstream_msg_iter->msgs->length, + muxer_upstream_msg_iter->msg_iter); goto end; } - /* muxer_upstream_notif_iter_next() logs details/errors */ - status = muxer_upstream_notif_iter_next(muxer_upstream_notif_iter); + /* muxer_upstream_msg_iter_next() logs details/errors */ + status = muxer_upstream_msg_iter_next(muxer_upstream_msg_iter); end: return status; } static -enum bt_notification_iterator_status validate_muxer_upstream_notif_iters( - struct muxer_notif_iter *muxer_notif_iter) +enum bt_message_iterator_status validate_muxer_upstream_msg_iters( + struct muxer_msg_iter *muxer_msg_iter) { - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; size_t i; - BT_LOGV("Validating muxer's upstream notification iterator wrappers: " - "muxer-notif-iter-addr=%p", muxer_notif_iter); + BT_LOGV("Validating muxer's upstream message iterator wrappers: " + "muxer-msg-iter-addr=%p", muxer_msg_iter); - for (i = 0; i < muxer_notif_iter->muxer_upstream_notif_iters->len; i++) { - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter = + for (i = 0; i < muxer_msg_iter->muxer_upstream_msg_iters->len; i++) { + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = g_ptr_array_index( - muxer_notif_iter->muxer_upstream_notif_iters, + muxer_msg_iter->muxer_upstream_msg_iters, i); - status = validate_muxer_upstream_notif_iter( - muxer_upstream_notif_iter); - if (status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + status = validate_muxer_upstream_msg_iter( + muxer_upstream_msg_iter); + if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { if (status < 0) { - BT_LOGE("Cannot validate muxer's upstream notification iterator wrapper: " - "muxer-notif-iter-addr=%p, " - "muxer-upstream-notif-iter-wrap-addr=%p", - muxer_notif_iter, - muxer_upstream_notif_iter); + BT_LOGE("Cannot validate muxer's upstream message iterator wrapper: " + "muxer-msg-iter-addr=%p, " + "muxer-upstream-msg-iter-wrap-addr=%p", + muxer_msg_iter, + muxer_upstream_msg_iter); } else { - BT_LOGV("Cannot validate muxer's upstream notification iterator wrapper: " - "muxer-notif-iter-addr=%p, " - "muxer-upstream-notif-iter-wrap-addr=%p", - muxer_notif_iter, - muxer_upstream_notif_iter); + BT_LOGV("Cannot validate muxer's upstream message iterator wrapper: " + "muxer-msg-iter-addr=%p, " + "muxer-upstream-msg-iter-wrap-addr=%p", + muxer_msg_iter, + muxer_upstream_msg_iter); } goto end; } /* - * Remove this muxer upstream notification iterator + * Remove this muxer upstream message iterator * if it's ended or canceled. */ - if (!muxer_upstream_notif_iter->notif_iter) { + if (!muxer_upstream_msg_iter->msg_iter) { /* * Use g_ptr_array_remove_fast() because the * order of those elements is not important. */ - BT_LOGV("Removing muxer's upstream notification iterator wrapper: ended or canceled: " - "muxer-notif-iter-addr=%p, " - "muxer-upstream-notif-iter-wrap-addr=%p", - muxer_notif_iter, muxer_upstream_notif_iter); + BT_LOGV("Removing muxer's upstream message iterator wrapper: ended or canceled: " + "muxer-msg-iter-addr=%p, " + "muxer-upstream-msg-iter-wrap-addr=%p", + muxer_msg_iter, muxer_upstream_msg_iter); g_ptr_array_remove_index_fast( - muxer_notif_iter->muxer_upstream_notif_iters, + muxer_msg_iter->muxer_upstream_msg_iters, i); i--; } @@ -1001,185 +1001,185 @@ end: } static inline -enum bt_notification_iterator_status muxer_notif_iter_do_next_one( +enum bt_message_iterator_status muxer_msg_iter_do_next_one( struct muxer_comp *muxer_comp, - struct muxer_notif_iter *muxer_notif_iter, - const bt_notification **notif) + struct muxer_msg_iter *muxer_msg_iter, + const bt_message **msg) { - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; - struct muxer_upstream_notif_iter *muxer_upstream_notif_iter = NULL; + enum bt_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; + struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = NULL; int64_t next_return_ts; while (true) { - int ret = muxer_notif_iter_handle_newly_connected_ports( - muxer_notif_iter); + int ret = muxer_msg_iter_handle_newly_connected_ports( + muxer_msg_iter); if (ret) { - BT_LOGE("Cannot handle newly connected input ports for muxer's notification iterator: " - "muxer-comp-addr=%p, muxer-notif-iter-addr=%p, " + BT_LOGE("Cannot handle newly connected input ports for muxer's message iterator: " + "muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " "ret=%d", - muxer_comp, muxer_notif_iter, ret); - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + muxer_comp, muxer_msg_iter, ret); + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - status = validate_muxer_upstream_notif_iters(muxer_notif_iter); - if (status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { - /* validate_muxer_upstream_notif_iters() logs details */ + status = validate_muxer_upstream_msg_iters(muxer_msg_iter); + if (status != BT_MESSAGE_ITERATOR_STATUS_OK) { + /* validate_muxer_upstream_msg_iters() logs details */ goto end; } /* * At this point, we know that all the existing upstream - * notification iterators are valid. However the + * message iterators are valid. However the * operations to validate them (during - * validate_muxer_upstream_notif_iters()) may have + * validate_muxer_upstream_msg_iters()) may have * connected new ports. If no ports were connected * during this operation, exit the loop. */ - if (!muxer_notif_iter->newly_connected_self_ports) { - BT_LOGV("Not breaking this loop: muxer's notification iterator still has newly connected input ports to handle: " + if (!muxer_msg_iter->newly_connected_self_ports) { + BT_LOGV("Not breaking this loop: muxer's message iterator still has newly connected input ports to handle: " "muxer-comp-addr=%p", muxer_comp); break; } } - BT_ASSERT(!muxer_notif_iter->newly_connected_self_ports); + BT_ASSERT(!muxer_msg_iter->newly_connected_self_ports); /* * At this point we know that all the existing upstream - * notification iterators are valid. We can find the one, - * amongst those, of which the current notification is the + * message iterators are valid. We can find the one, + * amongst those, of which the current message is the * youngest. */ - status = muxer_notif_iter_youngest_upstream_notif_iter(muxer_comp, - muxer_notif_iter, &muxer_upstream_notif_iter, + status = muxer_msg_iter_youngest_upstream_msg_iter(muxer_comp, + muxer_msg_iter, &muxer_upstream_msg_iter, &next_return_ts); - if (status < 0 || status == BT_NOTIFICATION_ITERATOR_STATUS_END || - status == BT_NOTIFICATION_ITERATOR_STATUS_CANCELED) { + if (status < 0 || status == BT_MESSAGE_ITERATOR_STATUS_END || + status == BT_MESSAGE_ITERATOR_STATUS_CANCELED) { if (status < 0) { - BT_LOGE("Cannot find the youngest upstream notification iterator wrapper: " + BT_LOGE("Cannot find the youngest upstream message iterator wrapper: " "status=%s", - bt_notification_iterator_status_string(status)); + bt_message_iterator_status_string(status)); } else { - BT_LOGV("Cannot find the youngest upstream notification iterator wrapper: " + BT_LOGV("Cannot find the youngest upstream message iterator wrapper: " "status=%s", - bt_notification_iterator_status_string(status)); + bt_message_iterator_status_string(status)); } goto end; } - if (next_return_ts < muxer_notif_iter->last_returned_ts_ns) { - BT_LOGE("Youngest upstream notification iterator wrapper's timestamp is less than muxer's notification iterator's last returned timestamp: " - "muxer-notif-iter-addr=%p, ts=%" PRId64 ", " + if (next_return_ts < muxer_msg_iter->last_returned_ts_ns) { + BT_LOGE("Youngest upstream message iterator wrapper's timestamp is less than muxer's message iterator's last returned timestamp: " + "muxer-msg-iter-addr=%p, ts=%" PRId64 ", " "last-returned-ts=%" PRId64, - muxer_notif_iter, next_return_ts, - muxer_notif_iter->last_returned_ts_ns); - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + muxer_msg_iter, next_return_ts, + muxer_msg_iter->last_returned_ts_ns); + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - BT_LOGV("Found youngest upstream notification iterator wrapper: " - "muxer-notif-iter-addr=%p, " - "muxer-upstream-notif-iter-wrap-addr=%p, " + BT_LOGV("Found youngest upstream message iterator wrapper: " + "muxer-msg-iter-addr=%p, " + "muxer-upstream-msg-iter-wrap-addr=%p, " "ts=%" PRId64, - muxer_notif_iter, muxer_upstream_notif_iter, next_return_ts); - BT_ASSERT(status == BT_NOTIFICATION_ITERATOR_STATUS_OK); - BT_ASSERT(muxer_upstream_notif_iter); + muxer_msg_iter, muxer_upstream_msg_iter, next_return_ts); + BT_ASSERT(status == BT_MESSAGE_ITERATOR_STATUS_OK); + BT_ASSERT(muxer_upstream_msg_iter); /* * Consume from the queue's head: other side - * (muxer_upstream_notif_iter_next()) writes to the tail. + * (muxer_upstream_msg_iter_next()) writes to the tail. */ - *notif = g_queue_pop_head(muxer_upstream_notif_iter->notifs); - BT_ASSERT(*notif); - muxer_notif_iter->last_returned_ts_ns = next_return_ts; + *msg = g_queue_pop_head(muxer_upstream_msg_iter->msgs); + BT_ASSERT(*msg); + muxer_msg_iter->last_returned_ts_ns = next_return_ts; end: return status; } static -enum bt_notification_iterator_status muxer_notif_iter_do_next( +enum bt_message_iterator_status muxer_msg_iter_do_next( struct muxer_comp *muxer_comp, - struct muxer_notif_iter *muxer_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, + struct muxer_msg_iter *muxer_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; uint64_t i = 0; - while (i < capacity && status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { - status = muxer_notif_iter_do_next_one(muxer_comp, - muxer_notif_iter, ¬ifs[i]); - if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { + while (i < capacity && status == BT_MESSAGE_ITERATOR_STATUS_OK) { + status = muxer_msg_iter_do_next_one(muxer_comp, + muxer_msg_iter, &msgs[i]); + if (status == BT_MESSAGE_ITERATOR_STATUS_OK) { i++; } } if (i > 0) { /* - * Even if muxer_notif_iter_do_next_one() returned + * Even if muxer_msg_iter_do_next_one() returned * something else than - * BT_NOTIFICATION_ITERATOR_STATUS_OK, we accumulated - * notification objects in the output notification + * BT_MESSAGE_ITERATOR_STATUS_OK, we accumulated + * message objects in the output message * array, so we need to return - * BT_NOTIFICATION_ITERATOR_STATUS_OK so that they are + * BT_MESSAGE_ITERATOR_STATUS_OK so that they are * transfered to downstream. This other status occurs - * again the next time muxer_notif_iter_do_next() is + * again the next time muxer_msg_iter_do_next() is * called, possibly without any accumulated - * notification, in which case we'll return it. + * message, in which case we'll return it. */ *count = i; - status = BT_NOTIFICATION_ITERATOR_STATUS_OK; + status = BT_MESSAGE_ITERATOR_STATUS_OK; } return status; } static -void destroy_muxer_notif_iter(struct muxer_notif_iter *muxer_notif_iter) +void destroy_muxer_msg_iter(struct muxer_msg_iter *muxer_msg_iter) { - if (!muxer_notif_iter) { + if (!muxer_msg_iter) { return; } - BT_LOGD("Destroying muxer component's notification iterator: " - "muxer-notif-iter-addr=%p", muxer_notif_iter); + BT_LOGD("Destroying muxer component's message iterator: " + "muxer-msg-iter-addr=%p", muxer_msg_iter); - if (muxer_notif_iter->muxer_upstream_notif_iters) { - BT_LOGD_STR("Destroying muxer's upstream notification iterator wrappers."); + if (muxer_msg_iter->muxer_upstream_msg_iters) { + BT_LOGD_STR("Destroying muxer's upstream message iterator wrappers."); g_ptr_array_free( - muxer_notif_iter->muxer_upstream_notif_iters, TRUE); + muxer_msg_iter->muxer_upstream_msg_iters, TRUE); } - g_list_free(muxer_notif_iter->newly_connected_self_ports); - g_free(muxer_notif_iter); + g_list_free(muxer_msg_iter->newly_connected_self_ports); + g_free(muxer_msg_iter); } static -int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, - struct muxer_notif_iter *muxer_notif_iter) +int muxer_msg_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, + struct muxer_msg_iter *muxer_msg_iter) { int64_t count; int64_t i; int ret = 0; /* - * Add the connected input ports to this muxer notification + * Add the connected input ports to this muxer message * iterator's list of newly connected ports. They will be - * handled by muxer_notif_iter_handle_newly_connected_ports(). + * handled by muxer_msg_iter_handle_newly_connected_ports(). */ count = bt_component_filter_get_input_port_count( bt_self_component_filter_as_component_filter( muxer_comp->self_comp)); if (count < 0) { - BT_LOGD("No input port to initialize for muxer component's notification iterator: " - "muxer-comp-addr=%p, muxer-notif-iter-addr=%p", - muxer_comp, muxer_notif_iter); + BT_LOGD("No input port to initialize for muxer component's message iterator: " + "muxer-comp-addr=%p, muxer-msg-iter-addr=%p", + muxer_comp, muxer_msg_iter); goto end; } @@ -1202,23 +1202,23 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, continue; } - muxer_notif_iter->newly_connected_self_ports = + muxer_msg_iter->newly_connected_self_ports = g_list_append( - muxer_notif_iter->newly_connected_self_ports, + muxer_msg_iter->newly_connected_self_ports, self_port); - if (!muxer_notif_iter->newly_connected_self_ports) { - BT_LOGE("Cannot append port to muxer's notification iterator list of newly connected input ports: " + if (!muxer_msg_iter->newly_connected_self_ports) { + BT_LOGE("Cannot append port to muxer's message iterator list of newly connected input ports: " "port-addr=%p, port-name=\"%s\", " - "muxer-notif-iter-addr=%p", port, - bt_port_get_name(port), muxer_notif_iter); + "muxer-msg-iter-addr=%p", port, + bt_port_get_name(port), muxer_msg_iter); ret = -1; goto end; } - BT_LOGD("Appended port to muxer's notification iterator list of newly connected input ports: " + BT_LOGD("Appended port to muxer's message iterator list of newly connected input ports: " "port-addr=%p, port-name=\"%s\", " - "muxer-notif-iter-addr=%p", port, - bt_port_get_name(port), muxer_notif_iter); + "muxer-msg-iter-addr=%p", port, + bt_port_get_name(port), muxer_msg_iter); } end: @@ -1226,157 +1226,157 @@ end: } BT_HIDDEN -enum bt_self_notification_iterator_status muxer_notif_iter_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status muxer_msg_iter_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *port) { struct muxer_comp *muxer_comp = NULL; - struct muxer_notif_iter *muxer_notif_iter = NULL; - enum bt_self_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + struct muxer_msg_iter *muxer_msg_iter = NULL; + enum bt_self_message_iterator_status status = + BT_MESSAGE_ITERATOR_STATUS_OK; int ret; muxer_comp = bt_self_component_get_data( bt_self_component_filter_as_self_component(self_comp)); BT_ASSERT(muxer_comp); - BT_LOGD("Initializing muxer component's notification iterator: " - "comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p", - self_comp, muxer_comp, self_notif_iter); + BT_LOGD("Initializing muxer component's message iterator: " + "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p", + self_comp, muxer_comp, self_msg_iter); - if (muxer_comp->initializing_muxer_notif_iter) { + if (muxer_comp->initializing_muxer_msg_iter) { /* * Weird, unhandled situation detected: downstream - * creates a muxer notification iterator while creating - * another muxer notification iterator (same component). + * creates a muxer message iterator while creating + * another muxer message iterator (same component). */ - BT_LOGE("Recursive initialization of muxer component's notification iterator: " - "comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p", - self_comp, muxer_comp, self_notif_iter); + BT_LOGE("Recursive initialization of muxer component's message iterator: " + "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p", + self_comp, muxer_comp, self_msg_iter); goto error; } - muxer_comp->initializing_muxer_notif_iter = true; - muxer_notif_iter = g_new0(struct muxer_notif_iter, 1); - if (!muxer_notif_iter) { - BT_LOGE_STR("Failed to allocate one muxer component's notification iterator."); + muxer_comp->initializing_muxer_msg_iter = true; + muxer_msg_iter = g_new0(struct muxer_msg_iter, 1); + if (!muxer_msg_iter) { + BT_LOGE_STR("Failed to allocate one muxer component's message iterator."); goto error; } - muxer_notif_iter->last_returned_ts_ns = INT64_MIN; - muxer_notif_iter->muxer_upstream_notif_iters = + muxer_msg_iter->last_returned_ts_ns = INT64_MIN; + muxer_msg_iter->muxer_upstream_msg_iters = g_ptr_array_new_with_free_func( - (GDestroyNotify) destroy_muxer_upstream_notif_iter); - if (!muxer_notif_iter->muxer_upstream_notif_iters) { + (GDestroyNotify) destroy_muxer_upstream_msg_iter); + if (!muxer_msg_iter->muxer_upstream_msg_iters) { BT_LOGE_STR("Failed to allocate a GPtrArray."); goto error; } /* - * Add the muxer notification iterator to the component's array - * of muxer notification iterators here because - * muxer_notif_iter_init_newly_connected_ports() can cause + * Add the muxer message iterator to the component's array + * of muxer message iterators here because + * muxer_msg_iter_init_newly_connected_ports() can cause * muxer_port_connected() to be called, which adds the newly - * connected port to each muxer notification iterator's list of + * connected port to each muxer message iterator's list of * newly connected ports. */ - g_ptr_array_add(muxer_comp->muxer_notif_iters, muxer_notif_iter); - ret = muxer_notif_iter_init_newly_connected_ports(muxer_comp, - muxer_notif_iter); + g_ptr_array_add(muxer_comp->muxer_msg_iters, muxer_msg_iter); + ret = muxer_msg_iter_init_newly_connected_ports(muxer_comp, + muxer_msg_iter); if (ret) { - BT_LOGE("Cannot initialize newly connected input ports for muxer component's notification iterator: " + BT_LOGE("Cannot initialize newly connected input ports for muxer component's message iterator: " "comp-addr=%p, muxer-comp-addr=%p, " - "muxer-notif-iter-addr=%p, notif-iter-addr=%p, ret=%d", - self_comp, muxer_comp, muxer_notif_iter, - self_notif_iter, ret); + "muxer-msg-iter-addr=%p, msg-iter-addr=%p, ret=%d", + self_comp, muxer_comp, muxer_msg_iter, + self_msg_iter, ret); goto error; } - bt_self_notification_iterator_set_data(self_notif_iter, - muxer_notif_iter); - BT_LOGD("Initialized muxer component's notification iterator: " - "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, " - "notif-iter-addr=%p", - self_comp, muxer_comp, muxer_notif_iter, self_notif_iter); + bt_self_message_iterator_set_data(self_msg_iter, + muxer_msg_iter); + BT_LOGD("Initialized muxer component's message iterator: " + "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " + "msg-iter-addr=%p", + self_comp, muxer_comp, muxer_msg_iter, self_msg_iter); goto end; error: - if (g_ptr_array_index(muxer_comp->muxer_notif_iters, - muxer_comp->muxer_notif_iters->len - 1) == muxer_notif_iter) { - g_ptr_array_remove_index(muxer_comp->muxer_notif_iters, - muxer_comp->muxer_notif_iters->len - 1); + if (g_ptr_array_index(muxer_comp->muxer_msg_iters, + muxer_comp->muxer_msg_iters->len - 1) == muxer_msg_iter) { + g_ptr_array_remove_index(muxer_comp->muxer_msg_iters, + muxer_comp->muxer_msg_iters->len - 1); } - destroy_muxer_notif_iter(muxer_notif_iter); - bt_self_notification_iterator_set_data(self_notif_iter, + destroy_muxer_msg_iter(muxer_msg_iter); + bt_self_message_iterator_set_data(self_msg_iter, NULL); - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_STATUS_ERROR; end: - muxer_comp->initializing_muxer_notif_iter = false; + muxer_comp->initializing_muxer_msg_iter = false; return status; } BT_HIDDEN -void muxer_notif_iter_finalize( - bt_self_notification_iterator *self_notif_iter) +void muxer_msg_iter_finalize( + bt_self_message_iterator *self_msg_iter) { - struct muxer_notif_iter *muxer_notif_iter = - bt_self_notification_iterator_get_data(self_notif_iter); + struct muxer_msg_iter *muxer_msg_iter = + bt_self_message_iterator_get_data(self_msg_iter); bt_self_component *self_comp = NULL; struct muxer_comp *muxer_comp = NULL; - self_comp = bt_self_notification_iterator_borrow_component( - self_notif_iter); + self_comp = bt_self_message_iterator_borrow_component( + self_msg_iter); BT_ASSERT(self_comp); muxer_comp = bt_self_component_get_data(self_comp); - BT_LOGD("Finalizing muxer component's notification iterator: " - "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, " - "notif-iter-addr=%p", - self_comp, muxer_comp, muxer_notif_iter, self_notif_iter); + BT_LOGD("Finalizing muxer component's message iterator: " + "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " + "msg-iter-addr=%p", + self_comp, muxer_comp, muxer_msg_iter, self_msg_iter); if (muxer_comp) { - (void) g_ptr_array_remove_fast(muxer_comp->muxer_notif_iters, - muxer_notif_iter); - destroy_muxer_notif_iter(muxer_notif_iter); + (void) g_ptr_array_remove_fast(muxer_comp->muxer_msg_iters, + muxer_msg_iter); + destroy_muxer_msg_iter(muxer_msg_iter); } } BT_HIDDEN -enum bt_notification_iterator_status muxer_notif_iter_next( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_message_iterator_status muxer_msg_iter_next( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - enum bt_notification_iterator_status status; - struct muxer_notif_iter *muxer_notif_iter = - bt_self_notification_iterator_get_data(self_notif_iter); + enum bt_message_iterator_status status; + struct muxer_msg_iter *muxer_msg_iter = + bt_self_message_iterator_get_data(self_msg_iter); bt_self_component *self_comp = NULL; struct muxer_comp *muxer_comp = NULL; - BT_ASSERT(muxer_notif_iter); - self_comp = bt_self_notification_iterator_borrow_component( - self_notif_iter); + BT_ASSERT(muxer_msg_iter); + self_comp = bt_self_message_iterator_borrow_component( + self_msg_iter); BT_ASSERT(self_comp); muxer_comp = bt_self_component_get_data(self_comp); BT_ASSERT(muxer_comp); - BT_LOGV("Muxer component's notification iterator's \"next\" method called: " - "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, " - "notif-iter-addr=%p", - self_comp, muxer_comp, muxer_notif_iter, self_notif_iter); + BT_LOGV("Muxer component's message iterator's \"next\" method called: " + "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " + "msg-iter-addr=%p", + self_comp, muxer_comp, muxer_msg_iter, self_msg_iter); - status = muxer_notif_iter_do_next(muxer_comp, muxer_notif_iter, - notifs, capacity, count); + status = muxer_msg_iter_do_next(muxer_comp, muxer_msg_iter, + msgs, capacity, count); if (status < 0) { - BT_LOGE("Cannot get next notification: " - "comp-addr=%p, muxer-comp-addr=%p, muxer-notif-iter-addr=%p, " - "notif-iter-addr=%p, status=%s", - self_comp, muxer_comp, muxer_notif_iter, self_notif_iter, - bt_notification_iterator_status_string(status)); + BT_LOGE("Cannot get next message: " + "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, " + "msg-iter-addr=%p, status=%s", + self_comp, muxer_comp, muxer_msg_iter, self_msg_iter, + bt_message_iterator_status_string(status)); } else { - BT_LOGV("Returning from muxer component's notification iterator's \"next\" method: " + BT_LOGV("Returning from muxer component's message iterator's \"next\" method: " "status=%s", - bt_notification_iterator_status_string(status)); + bt_message_iterator_status_string(status)); } return status; @@ -1409,34 +1409,34 @@ enum bt_self_component_status muxer_input_port_connected( other_port, bt_port_get_name(bt_port_output_as_port_const(other_port))); - for (i = 0; i < muxer_comp->muxer_notif_iters->len; i++) { - struct muxer_notif_iter *muxer_notif_iter = - g_ptr_array_index(muxer_comp->muxer_notif_iters, i); + for (i = 0; i < muxer_comp->muxer_msg_iters->len; i++) { + struct muxer_msg_iter *muxer_msg_iter = + g_ptr_array_index(muxer_comp->muxer_msg_iters, i); /* * Add this port to the list of newly connected ports - * for this muxer notification iterator. We append at + * for this muxer message iterator. We append at * the end of this list while - * muxer_notif_iter_handle_newly_connected_ports() + * muxer_msg_iter_handle_newly_connected_ports() * removes the nodes from the beginning. */ - muxer_notif_iter->newly_connected_self_ports = + muxer_msg_iter->newly_connected_self_ports = g_list_append( - muxer_notif_iter->newly_connected_self_ports, + muxer_msg_iter->newly_connected_self_ports, self_port); - if (!muxer_notif_iter->newly_connected_self_ports) { - BT_LOGE("Cannot append port to muxer's notification iterator list of newly connected input ports: " + if (!muxer_msg_iter->newly_connected_self_ports) { + BT_LOGE("Cannot append port to muxer's message iterator list of newly connected input ports: " "port-addr=%p, port-name=\"%s\", " - "muxer-notif-iter-addr=%p", self_port, - bt_port_get_name(port), muxer_notif_iter); + "muxer-msg-iter-addr=%p", self_port, + bt_port_get_name(port), muxer_msg_iter); status = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } - BT_LOGD("Appended port to muxer's notification iterator list of newly connected input ports: " + BT_LOGD("Appended port to muxer's message iterator list of newly connected input ports: " "port-addr=%p, port-name=\"%s\", " - "muxer-notif-iter-addr=%p", self_port, - bt_port_get_name(port), muxer_notif_iter); + "muxer-msg-iter-addr=%p", self_port, + bt_port_get_name(port), muxer_msg_iter); } /* One less available input port */ diff --git a/plugins/utils/muxer/muxer.h b/plugins/utils/muxer/muxer.h index b2036e05..c5b123f3 100644 --- a/plugins/utils/muxer/muxer.h +++ b/plugins/utils/muxer/muxer.h @@ -37,19 +37,19 @@ BT_HIDDEN void muxer_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -enum bt_self_notification_iterator_status muxer_notif_iter_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status muxer_msg_iter_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN -void muxer_notif_iter_finalize( - bt_self_notification_iterator *self_notif_iter); +void muxer_msg_iter_finalize( + bt_self_message_iterator *self_msg_iter); BT_HIDDEN -enum bt_self_notification_iterator_status muxer_notif_iter_next( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status muxer_msg_iter_next( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN diff --git a/plugins/utils/plugin.c b/plugins/utils/plugin.c index 9c1d79dc..bec501d9 100644 --- a/plugins/utils/plugin.c +++ b/plugins/utils/plugin.c @@ -41,7 +41,7 @@ BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dummy, dummy_finalize); BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(dummy, dummy_port_connected); BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(dummy, - "Consume notifications and discard them."); + "Consume messages and discard them."); /* sink.utils.counter */ BT_PLUGIN_SINK_COMPONENT_CLASS(counter, counter_consume); @@ -50,32 +50,32 @@ BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(counter, counter_finalize); BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(counter, counter_port_connected); BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(counter, - "Count notifications and print the results."); + "Count messages and print the results."); #if 0 /* flt.utils.trimmer */ BT_PLUGIN_FILTER_COMPONENT_CLASS(trimmer, trimmer_iterator_next); BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(trimmer, - "Keep notifications that occur within a specific time range."); + "Keep messages that occur within a specific time range."); BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(trimmer, trimmer_component_init); BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(trimmer, finalize_trimmer); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(trimmer, +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(trimmer, trimmer_iterator_init); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(trimmer, +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(trimmer, trimmer_iterator_finalize); #endif /* flt.utils.muxer */ -BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_notif_iter_next); +BT_PLUGIN_FILTER_COMPONENT_CLASS(muxer, muxer_msg_iter_next); BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(muxer, - "Sort notifications from multiple input ports to a single output port by time."); + "Sort messages from multiple input ports to a single output port by time."); BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(muxer, muxer_init); BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(muxer, muxer_finalize); BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_DISCONNECTED_METHOD(muxer, muxer_input_port_disconnected); BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(muxer, muxer_input_port_connected); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(muxer, - muxer_notif_iter_init); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(muxer, - muxer_notif_iter_finalize); +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(muxer, + muxer_msg_iter_init); +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(muxer, + muxer_msg_iter_finalize); diff --git a/plugins/utils/trimmer/copy.c b/plugins/utils/trimmer/copy.c index 33583c20..5fab0d6a 100644 --- a/plugins/utils/trimmer/copy.c +++ b/plugins/utils/trimmer/copy.c @@ -257,7 +257,7 @@ const bt_event *trimmer_output_event( goto error; } - /* We keep the reference on the writer_event to create a notification. */ + /* We keep the reference on the writer_event to create a message. */ goto end; error: diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index b7e958ac..0e015119 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -49,11 +49,11 @@ gboolean close_packets(gpointer key, gpointer value, gpointer user_data) } BT_HIDDEN -void trimmer_iterator_finalize(bt_self_notification_iterator *it) +void trimmer_iterator_finalize(bt_self_message_iterator *it) { struct trimmer_iterator *trim_it; - trim_it = bt_self_notification_iterator_get_user_data(it); + trim_it = bt_self_message_iterator_get_user_data(it); BT_ASSERT(trim_it); bt_object_put_ref(trim_it->input_iterator); @@ -64,22 +64,22 @@ void trimmer_iterator_finalize(bt_self_notification_iterator *it) } BT_HIDDEN -enum bt_notification_iterator_status trimmer_iterator_init( - bt_self_notification_iterator *iterator, +enum bt_message_iterator_status trimmer_iterator_init( + bt_self_message_iterator *iterator, struct bt_private_port *port) { - enum bt_notification_iterator_status ret = - BT_NOTIFICATION_ITERATOR_STATUS_OK; - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status ret = + BT_MESSAGE_ITERATOR_STATUS_OK; + enum bt_message_iterator_status it_ret; enum bt_connection_status conn_status; struct bt_private_port *input_port = NULL; struct bt_private_connection *connection = NULL; bt_self_component *component = - bt_self_notification_iterator_get_private_component(iterator); + bt_self_message_iterator_get_private_component(iterator); struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1); if (!it_data) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM; + ret = BT_MESSAGE_ITERATOR_STATUS_NOMEM; goto end; } @@ -90,10 +90,10 @@ enum bt_notification_iterator_status trimmer_iterator_init( connection = bt_private_port_get_connection(input_port); BT_ASSERT(connection); - conn_status = bt_private_connection_create_notification_iterator(connection, + conn_status = bt_private_connection_create_message_iterator(connection, &it_data->input_iterator); if (conn_status != BT_CONNECTION_STATUS_OK) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } @@ -101,7 +101,7 @@ enum bt_notification_iterator_status trimmer_iterator_init( it_data->packet_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); - it_ret = bt_self_notification_iterator_set_user_data(iterator, + it_ret = bt_self_message_iterator_set_user_data(iterator, it_data); if (it_ret) { goto end; @@ -174,8 +174,8 @@ error: } static -const bt_notification *evaluate_event_notification( - const bt_notification *notification, +const bt_message *evaluate_event_message( + const bt_message *message, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_event_in_range, bool *finished) @@ -190,18 +190,18 @@ const bt_notification *evaluate_event_notification( const bt_stream_class *stream_class = NULL; bt_clock_value *clock_value = NULL; bool lazy_update = false; - const bt_notification *new_notification = NULL; + const bt_message *new_message = NULL; bt_clock_class_priority_map *cc_prio_map; - event = bt_notification_event_get_event(notification); + event = bt_message_event_get_event(message); BT_ASSERT(event); - cc_prio_map = bt_notification_event_get_clock_class_priority_map( - notification); + cc_prio_map = bt_message_event_get_clock_class_priority_map( + message); BT_ASSERT(cc_prio_map); writer_event = trimmer_output_event(trim_it, event); BT_ASSERT(writer_event); - new_notification = bt_notification_event_create(writer_event, cc_prio_map); - BT_ASSERT(new_notification); + new_message = bt_message_event_create(writer_event, cc_prio_map); + BT_ASSERT(new_message); bt_object_put_ref(cc_prio_map); stream = bt_event_get_stream(event); @@ -254,7 +254,7 @@ const bt_notification *evaluate_event_notification( goto end; error: - BT_NOTIFICATION_PUT_REF_AND_RESET(new_notification); + BT_MESSAGE_PUT_REF_AND_RESET(new_message); end: bt_object_put_ref(event); bt_object_put_ref(writer_event); @@ -264,7 +264,7 @@ end: bt_stream_class_put_ref(stream_class); bt_object_put_ref(clock_value); *_event_in_range = in_range; - return new_notification; + return new_message; } static @@ -375,8 +375,8 @@ int64_t get_raw_timestamp(const bt_packet *writer_packet, } static -const bt_notification *evaluate_packet_notification( - const bt_notification *notification, +const bt_message *evaluate_packet_message( + const bt_message *message, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_packet_in_range, bool *finished) @@ -387,19 +387,19 @@ const bt_notification *evaluate_packet_notification( const bt_field *packet_context = NULL, *timestamp_begin = NULL, *timestamp_end = NULL; - const bt_notification *new_notification = NULL; + const bt_message *new_message = NULL; enum bt_component_status ret; bool lazy_update = false; - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - packet = bt_notification_packet_beginning_get_packet(notification); + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + packet = bt_message_packet_beginning_get_packet(message); BT_ASSERT(packet); writer_packet = trimmer_new_packet(trim_it, packet); BT_ASSERT(writer_packet); break; - case BT_NOTIFICATION_TYPE_PACKET_END: - packet = bt_notification_packet_end_get_packet(notification); + case BT_MESSAGE_TYPE_PACKET_END: + packet = bt_message_packet_end_get_packet(message); BT_ASSERT(packet); writer_packet = trimmer_close_packet(trim_it, packet); BT_ASSERT(writer_packet); @@ -410,41 +410,41 @@ const bt_notification *evaluate_packet_notification( packet_context = bt_packet_get_context(writer_packet); if (!packet_context) { - goto end_no_notif; + goto end_no_msg; } if (!bt_field_is_structure(packet_context)) { - goto end_no_notif; + goto end_no_msg; } timestamp_begin = bt_field_structure_get_field_by_name( packet_context, "timestamp_begin"); if (!timestamp_begin || !bt_field_is_integer(timestamp_begin)) { - goto end_no_notif; + goto end_no_msg; } timestamp_end = bt_field_structure_get_field_by_name( packet_context, "timestamp_end"); if (!timestamp_end || !bt_field_is_integer(timestamp_end)) { - goto end_no_notif; + goto end_no_msg; } if (ns_from_integer_field(timestamp_begin, &pkt_begin_ns)) { - goto end_no_notif; + goto end_no_msg; } if (ns_from_integer_field(timestamp_end, &pkt_end_ns)) { - goto end_no_notif; + goto end_no_msg; } if (update_lazy_bound(begin, "begin", pkt_begin_ns, &lazy_update)) { - goto end_no_notif; + goto end_no_msg; } if (update_lazy_bound(end, "end", pkt_end_ns, &lazy_update)) { - goto end_no_notif; + goto end_no_msg; } if (lazy_update && begin->set && end->set) { if (begin->value > end->value) { BT_LOGE_STR("Unexpected: time range begin value is above end value."); - goto end_no_notif; + goto end_no_msg; } } @@ -457,7 +457,7 @@ const bt_notification *evaluate_packet_notification( */ in_range = (pkt_end_ns >= begin_ns) && (pkt_begin_ns <= end_ns); if (!in_range) { - goto end_no_notif; + goto end_no_msg; } if (pkt_begin_ns > end_ns) { *finished = true; @@ -478,101 +478,101 @@ const bt_notification *evaluate_packet_notification( } end: - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - new_notification = bt_notification_packet_beginning_create(writer_packet); - BT_ASSERT(new_notification); + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + new_message = bt_message_packet_beginning_create(writer_packet); + BT_ASSERT(new_message); break; - case BT_NOTIFICATION_TYPE_PACKET_END: - new_notification = bt_notification_packet_end_create(writer_packet); - BT_ASSERT(new_notification); + case BT_MESSAGE_TYPE_PACKET_END: + new_message = bt_message_packet_end_create(writer_packet); + BT_ASSERT(new_message); break; default: break; } -end_no_notif: +end_no_msg: *_packet_in_range = in_range; bt_packet_put_ref(packet); bt_packet_put_ref(writer_packet); bt_object_put_ref(packet_context); bt_object_put_ref(timestamp_begin); bt_object_put_ref(timestamp_end); - return new_notification; + return new_message; } static -const bt_notification *evaluate_stream_notification( - const bt_notification *notification, +const bt_message *evaluate_stream_message( + const bt_message *message, struct trimmer_iterator *trim_it) { const bt_stream *stream; - stream = bt_notification_stream_end_get_stream(notification); + stream = bt_message_stream_end_get_stream(message); BT_ASSERT(stream); /* FIXME: useless copy */ - return bt_notification_stream_end_create(stream); + return bt_message_stream_end_create(stream); } -/* Return true if the notification should be forwarded. */ +/* Return true if the message should be forwarded. */ static -enum bt_notification_iterator_status evaluate_notification( - const bt_notification **notification, +enum bt_message_iterator_status evaluate_message( + const bt_message **message, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *in_range) { - enum bt_notification_type type; - const bt_notification *new_notification = NULL; + enum bt_message_type type; + const bt_message *new_message = NULL; bool finished = false; *in_range = true; - type = bt_notification_get_type(*notification); + type = bt_message_get_type(*message); switch (type) { - case BT_NOTIFICATION_TYPE_EVENT: - new_notification = evaluate_event_notification(*notification, + case BT_MESSAGE_TYPE_EVENT: + new_message = evaluate_event_message(*message, trim_it, begin, end, in_range, &finished); break; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - case BT_NOTIFICATION_TYPE_PACKET_END: - new_notification = evaluate_packet_notification(*notification, + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + case BT_MESSAGE_TYPE_PACKET_END: + new_message = evaluate_packet_message(*message, trim_it, begin, end, in_range, &finished); break; - case BT_NOTIFICATION_TYPE_STREAM_END: - new_notification = evaluate_stream_notification(*notification, + case BT_MESSAGE_TYPE_STREAM_END: + new_message = evaluate_stream_message(*message, trim_it); break; default: break; } - BT_NOTIFICATION_PUT_REF_AND_RESET(*notification); - *notification = new_notification; + BT_MESSAGE_PUT_REF_AND_RESET(*message); + *message = new_message; if (finished) { - return BT_NOTIFICATION_ITERATOR_STATUS_END; + return BT_MESSAGE_ITERATOR_STATUS_END; } - return BT_NOTIFICATION_ITERATOR_STATUS_OK; + return BT_MESSAGE_ITERATOR_STATUS_OK; } BT_HIDDEN -bt_notification_iterator_next_method_return trimmer_iterator_next( - bt_self_notification_iterator *iterator) +bt_message_iterator_next_method_return trimmer_iterator_next( + bt_self_message_iterator *iterator) { struct trimmer_iterator *trim_it = NULL; bt_self_component *component = NULL; struct trimmer *trimmer = NULL; - bt_notification_iterator *source_it = NULL; - bt_notification_iterator_next_method_return ret = { - .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, - .notification = NULL, + bt_message_iterator *source_it = NULL; + bt_message_iterator_next_method_return ret = { + .status = BT_MESSAGE_ITERATOR_STATUS_OK, + .message = NULL, }; - bool notification_in_range = false; + bool message_in_range = false; - trim_it = bt_self_notification_iterator_get_user_data(iterator); + trim_it = bt_self_message_iterator_get_user_data(iterator); BT_ASSERT(trim_it); - component = bt_self_notification_iterator_get_private_component( + component = bt_self_message_iterator_get_private_component( iterator); BT_ASSERT(component); trimmer = bt_self_component_get_user_data(component); @@ -581,27 +581,27 @@ bt_notification_iterator_next_method_return trimmer_iterator_next( source_it = trim_it->input_iterator; BT_ASSERT(source_it); - while (!notification_in_range) { - ret.status = bt_notification_iterator_next(source_it); - if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + while (!message_in_range) { + ret.status = bt_message_iterator_next(source_it); + if (ret.status != BT_MESSAGE_ITERATOR_STATUS_OK) { goto end; } - ret.notification = bt_notification_iterator_get_notification( + ret.message = bt_message_iterator_get_message( source_it); - if (!ret.notification) { - ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + if (!ret.message) { + ret.status = BT_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - ret.status = evaluate_notification(&ret.notification, trim_it, + ret.status = evaluate_message(&ret.message, trim_it, &trimmer->begin, &trimmer->end, - ¬ification_in_range); - if (!notification_in_range) { - BT_OBJECT_PUT_REF_AND_RESET(ret.notification); + &message_in_range); + if (!message_in_range) { + BT_OBJECT_PUT_REF_AND_RESET(ret.message); } - if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { + if (ret.status != BT_MESSAGE_ITERATOR_STATUS_OK) { break; } } diff --git a/plugins/utils/trimmer/iterator.h b/plugins/utils/trimmer/iterator.h index e3f663dd..bcfc416f 100644 --- a/plugins/utils/trimmer/iterator.h +++ b/plugins/utils/trimmer/iterator.h @@ -32,23 +32,23 @@ struct trimmer_iterator { /* Input iterator associated with this output iterator. */ - bt_notification_iterator *input_iterator; - const bt_notification *current_notification; + bt_message_iterator *input_iterator; + const bt_message *current_message; FILE *err; /* Map between reader and writer packets. */ GHashTable *packet_map; }; BT_HIDDEN -enum bt_notification_iterator_status trimmer_iterator_init( - bt_self_notification_iterator *iterator, +enum bt_message_iterator_status trimmer_iterator_init( + bt_self_message_iterator *iterator, struct bt_private_port *port); BT_HIDDEN -void trimmer_iterator_finalize(bt_self_notification_iterator *it); +void trimmer_iterator_finalize(bt_self_message_iterator *it); BT_HIDDEN -bt_notification_iterator_next_method_return trimmer_iterator_next( - bt_self_notification_iterator *iterator); +bt_message_iterator_next_method_return trimmer_iterator_next( + bt_self_message_iterator *iterator); #endif /* BABELTRACE_PLUGIN_TRIMMER_ITERATOR_H */ diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 39ad76e0..a1fa8729 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -23,17 +23,17 @@ test_trace_ir_ref_LDADD = $(COMMON_TEST_LDADD) test_graph_topo_LDADD = $(COMMON_TEST_LDADD) -test_bt_notification_iterator_LDADD = $(COMMON_TEST_LDADD) +test_bt_message_iterator_LDADD = $(COMMON_TEST_LDADD) noinst_PROGRAMS = test_bitfield test_ctf_writer test_bt_values \ - test_trace_ir_ref test_graph_topo test_bt_notification_iterator + test_trace_ir_ref test_graph_topo test_bt_message_iterator test_bitfield_SOURCES = test_bitfield.c test_ctf_writer_SOURCES = test_ctf_writer.c test_bt_values_SOURCES = test_bt_values.c test_trace_ir_ref_SOURCES = test_trace_ir_ref.c test_graph_topo_SOURCES = test_graph_topo.c -test_bt_notification_iterator_SOURCES = test_bt_notification_iterator.c +test_bt_message_iterator_SOURCES = test_bt_message_iterator.c check_SCRIPTS = test_ctf_writer_complete diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index 77e6a656..b5487504 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -24,33 +24,33 @@ static enum bt_self_component_status sink_consume( return BT_SELF_COMPONENT_STATUS_OK; } -static enum bt_self_notification_iterator_status src_dummy_iterator_init_method( - bt_self_notification_iterator *self_notif_iter, +static enum bt_self_message_iterator_status src_dummy_iterator_init_method( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) { - return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; } -static enum bt_self_notification_iterator_status flt_dummy_iterator_init_method( - bt_self_notification_iterator *self_notif_iter, +static enum bt_self_message_iterator_status flt_dummy_iterator_init_method( + bt_self_message_iterator *self_msg_iter, bt_self_component_filter *self_comp, bt_self_component_port_output *self_port) { - return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; } static void dummy_iterator_finalize_method( - bt_self_notification_iterator *self_notif_iter) + bt_self_message_iterator *self_msg_iter) { } -static enum bt_self_notification_iterator_status dummy_iterator_next_method( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +static enum bt_self_message_iterator_status dummy_iterator_next_method( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; } static enum bt_query_status flt_query_method( @@ -84,9 +84,9 @@ BT_PLUGIN_VERSION(1, 2, 3, "yes"); BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method); BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source."); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source, +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(source, src_dummy_iterator_init_method); -BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source, +BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(source, dummy_iterator_finalize_method); BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume); @@ -100,8 +100,8 @@ BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink, BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method); BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter."); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter, +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(filter, flt_dummy_iterator_init_method); -BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter, +BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(filter, dummy_iterator_finalize_method); BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method); diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_message_iterator.c similarity index 63% rename from tests/lib/test_bt_notification_iterator.c rename to tests/lib/test_bt_message_iterator.c index 387eaa81..5a1ef540 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_message_iterator.c @@ -30,17 +30,17 @@ #define NR_TESTS 5 enum test { - TEST_NO_AUTO_NOTIFS, - TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR, + TEST_NO_AUTO_MSGS, + TEST_OUTPUT_PORT_MESSAGE_ITERATOR, }; enum test_event_type { - TEST_EV_TYPE_NOTIF_UNEXPECTED, - TEST_EV_TYPE_NOTIF_EVENT, - TEST_EV_TYPE_NOTIF_STREAM_BEGIN, - TEST_EV_TYPE_NOTIF_PACKET_BEGIN, - TEST_EV_TYPE_NOTIF_PACKET_END, - TEST_EV_TYPE_NOTIF_STREAM_END, + TEST_EV_TYPE_MSG_UNEXPECTED, + TEST_EV_TYPE_MSG_EVENT, + TEST_EV_TYPE_MSG_STREAM_BEGIN, + TEST_EV_TYPE_MSG_PACKET_BEGIN, + TEST_EV_TYPE_MSG_PACKET_END, + TEST_EV_TYPE_MSG_STREAM_END, TEST_EV_TYPE_END, TEST_EV_TYPE_SENTINEL, }; @@ -90,14 +90,14 @@ struct src_iter_user_data { }; struct sink_user_data { - bt_self_component_port_input_notification_iterator *notif_iter; + bt_self_component_port_input_message_iterator *msg_iter; }; /* - * No automatic notifications generated in this block. - * Stream 2 notifications are more indented. + * No automatic messages generated in this block. + * Stream 2 messages are more indented. */ -static int64_t seq_no_auto_notifs[] = { +static int64_t seq_no_auto_msgs[] = { SEQ_STREAM1_BEGIN, SEQ_STREAM1_PACKET1_BEGIN, SEQ_EVENT_STREAM1_PACKET1, @@ -129,23 +129,23 @@ void print_test_event(FILE *fp, const struct test_event *event) fprintf(fp, "{ type = "); switch (event->type) { - case TEST_EV_TYPE_NOTIF_UNEXPECTED: - fprintf(fp, "TEST_EV_TYPE_NOTIF_UNEXPECTED"); + case TEST_EV_TYPE_MSG_UNEXPECTED: + fprintf(fp, "TEST_EV_TYPE_MSG_UNEXPECTED"); break; - case TEST_EV_TYPE_NOTIF_EVENT: - fprintf(fp, "TEST_EV_TYPE_NOTIF_EVENT"); + case TEST_EV_TYPE_MSG_EVENT: + fprintf(fp, "TEST_EV_TYPE_MSG_EVENT"); break; - case TEST_EV_TYPE_NOTIF_STREAM_BEGIN: - fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_BEGIN"); + case TEST_EV_TYPE_MSG_STREAM_BEGIN: + fprintf(fp, "TEST_EV_TYPE_MSG_STREAM_BEGIN"); break; - case TEST_EV_TYPE_NOTIF_STREAM_END: - fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_END"); + case TEST_EV_TYPE_MSG_STREAM_END: + fprintf(fp, "TEST_EV_TYPE_MSG_STREAM_END"); break; - case TEST_EV_TYPE_NOTIF_PACKET_BEGIN: - fprintf(fp, "TEST_EV_TYPE_NOTIF_PACKET_BEGIN"); + case TEST_EV_TYPE_MSG_PACKET_BEGIN: + fprintf(fp, "TEST_EV_TYPE_MSG_PACKET_BEGIN"); break; - case TEST_EV_TYPE_NOTIF_PACKET_END: - fprintf(fp, "TEST_EV_TYPE_NOTIF_PACKET_END"); + case TEST_EV_TYPE_MSG_PACKET_END: + fprintf(fp, "TEST_EV_TYPE_MSG_PACKET_END"); break; case TEST_EV_TYPE_END: fprintf(fp, "TEST_EV_TYPE_END"); @@ -301,11 +301,11 @@ void fini_static_data(void) } static -void src_iter_finalize(bt_self_notification_iterator *self_notif_iter) +void src_iter_finalize(bt_self_message_iterator *self_msg_iter) { struct src_iter_user_data *user_data = - bt_self_notification_iterator_get_data( - self_notif_iter); + bt_self_message_iterator_get_data( + self_msg_iter); if (user_data) { g_free(user_data); @@ -313,8 +313,8 @@ void src_iter_finalize(bt_self_notification_iterator *self_notif_iter) } static -enum bt_self_notification_iterator_status src_iter_init( - bt_self_notification_iterator *self_notif_iter, +enum bt_self_message_iterator_status src_iter_init( + bt_self_message_iterator *self_msg_iter, bt_self_component_source *self_comp, bt_self_component_port_output *self_port) { @@ -322,74 +322,74 @@ enum bt_self_notification_iterator_status src_iter_init( g_new0(struct src_iter_user_data, 1); BT_ASSERT(user_data); - bt_self_notification_iterator_set_data(self_notif_iter, user_data); + bt_self_message_iterator_set_data(self_msg_iter, user_data); switch (current_test) { - case TEST_NO_AUTO_NOTIFS: - case TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR: - user_data->seq = seq_no_auto_notifs; + case TEST_NO_AUTO_MSGS: + case TEST_OUTPUT_PORT_MESSAGE_ITERATOR: + user_data->seq = seq_no_auto_msgs; break; default: abort(); } - return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + return BT_SELF_MESSAGE_ITERATOR_STATUS_OK; } static -void src_iter_next_seq_one(bt_self_notification_iterator* notif_iter, +void src_iter_next_seq_one(bt_self_message_iterator* msg_iter, struct src_iter_user_data *user_data, - const bt_notification **notif) + const bt_message **msg) { bt_packet *event_packet = NULL; switch (user_data->seq[user_data->at]) { case SEQ_STREAM1_BEGIN: - *notif = bt_notification_stream_beginning_create(notif_iter, + *msg = bt_message_stream_beginning_create(msg_iter, src_stream1); break; case SEQ_STREAM2_BEGIN: - *notif = bt_notification_stream_beginning_create(notif_iter, + *msg = bt_message_stream_beginning_create(msg_iter, src_stream2); break; case SEQ_STREAM1_END: - *notif = bt_notification_stream_end_create(notif_iter, + *msg = bt_message_stream_end_create(msg_iter, src_stream1); break; case SEQ_STREAM2_END: - *notif = bt_notification_stream_end_create(notif_iter, + *msg = bt_message_stream_end_create(msg_iter, src_stream2); break; case SEQ_STREAM1_PACKET1_BEGIN: - *notif = bt_notification_packet_beginning_create(notif_iter, + *msg = bt_message_packet_beginning_create(msg_iter, src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_BEGIN: - *notif = bt_notification_packet_beginning_create(notif_iter, + *msg = bt_message_packet_beginning_create(msg_iter, src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_BEGIN: - *notif = bt_notification_packet_beginning_create(notif_iter, + *msg = bt_message_packet_beginning_create(msg_iter, src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_BEGIN: - *notif = bt_notification_packet_beginning_create(notif_iter, + *msg = bt_message_packet_beginning_create(msg_iter, src_stream2_packet2); break; case SEQ_STREAM1_PACKET1_END: - *notif = bt_notification_packet_end_create(notif_iter, + *msg = bt_message_packet_end_create(msg_iter, src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_END: - *notif = bt_notification_packet_end_create(notif_iter, + *msg = bt_message_packet_end_create(msg_iter, src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_END: - *notif = bt_notification_packet_end_create(notif_iter, + *msg = bt_message_packet_end_create(msg_iter, src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_END: - *notif = bt_notification_packet_end_create(notif_iter, + *msg = bt_message_packet_end_create(msg_iter, src_stream2_packet2); break; case SEQ_EVENT_STREAM1_PACKET1: @@ -409,35 +409,35 @@ void src_iter_next_seq_one(bt_self_notification_iterator* notif_iter, } if (event_packet) { - *notif = bt_notification_event_create(notif_iter, + *msg = bt_message_event_create(msg_iter, src_event_class, event_packet); } - BT_ASSERT(*notif); + BT_ASSERT(*msg); user_data->at++; } static -enum bt_self_notification_iterator_status src_iter_next_seq( - bt_self_notification_iterator *notif_iter, +enum bt_self_message_iterator_status src_iter_next_seq( + bt_self_message_iterator *msg_iter, struct src_iter_user_data *user_data, - bt_notification_array_const notifs, uint64_t capacity, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - enum bt_self_notification_iterator_status status = - BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; + enum bt_self_message_iterator_status status = + BT_SELF_MESSAGE_ITERATOR_STATUS_OK; uint64_t i = 0; BT_ASSERT(user_data->seq); if (user_data->seq[user_data->at] == SEQ_END) { - status = BT_SELF_NOTIFICATION_ITERATOR_STATUS_END; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_END; goto end; } while (i < capacity && user_data->seq[user_data->at] != SEQ_END) { - src_iter_next_seq_one(notif_iter, user_data, ¬ifs[i]); + src_iter_next_seq_one(msg_iter, user_data, &msgs[i]); i++; } @@ -449,16 +449,16 @@ end: } static -enum bt_self_notification_iterator_status src_iter_next( - bt_self_notification_iterator *self_notif_iter, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status src_iter_next( + bt_self_message_iterator *self_msg_iter, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { struct src_iter_user_data *user_data = - bt_self_notification_iterator_get_data(self_notif_iter); + bt_self_message_iterator_get_data(self_msg_iter); BT_ASSERT(user_data); - return src_iter_next_seq(self_notif_iter, user_data, notifs, + return src_iter_next_seq(self_msg_iter, user_data, msgs, capacity, count); } @@ -481,48 +481,48 @@ void src_finalize(bt_self_component_source *self_comp) } static -void append_test_events_from_notification(const bt_notification *notification) +void append_test_events_from_message(const bt_message *message) { struct test_event test_event = { 0 }; - switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_EVENT: + switch (bt_message_get_type(message)) { + case BT_MESSAGE_TYPE_EVENT: { const bt_event *event; - test_event.type = TEST_EV_TYPE_NOTIF_EVENT; - event = bt_notification_event_borrow_event_const(notification); + test_event.type = TEST_EV_TYPE_MSG_EVENT; + event = bt_message_event_borrow_event_const(message); BT_ASSERT(event); test_event.packet = bt_event_borrow_packet_const(event); BT_ASSERT(test_event.packet); break; } - case BT_NOTIFICATION_TYPE_STREAM_BEGINNING: - test_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN; + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + test_event.type = TEST_EV_TYPE_MSG_STREAM_BEGIN; test_event.stream = - bt_notification_stream_beginning_borrow_stream_const(notification); + bt_message_stream_beginning_borrow_stream_const(message); BT_ASSERT(test_event.stream); break; - case BT_NOTIFICATION_TYPE_STREAM_END: - test_event.type = TEST_EV_TYPE_NOTIF_STREAM_END; + case BT_MESSAGE_TYPE_STREAM_END: + test_event.type = TEST_EV_TYPE_MSG_STREAM_END; test_event.stream = - bt_notification_stream_end_borrow_stream_const(notification); + bt_message_stream_end_borrow_stream_const(message); BT_ASSERT(test_event.stream); break; - case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: - test_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN; + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + test_event.type = TEST_EV_TYPE_MSG_PACKET_BEGIN; test_event.packet = - bt_notification_packet_beginning_borrow_packet_const(notification); + bt_message_packet_beginning_borrow_packet_const(message); BT_ASSERT(test_event.packet); break; - case BT_NOTIFICATION_TYPE_PACKET_END: - test_event.type = TEST_EV_TYPE_NOTIF_PACKET_END; + case BT_MESSAGE_TYPE_PACKET_END: + test_event.type = TEST_EV_TYPE_MSG_PACKET_END; test_event.packet = - bt_notification_packet_end_borrow_packet_const(notification); + bt_message_packet_end_borrow_packet_const(message); BT_ASSERT(test_event.packet); break; default: - test_event.type = TEST_EV_TYPE_NOTIF_UNEXPECTED; + test_event.type = TEST_EV_TYPE_MSG_UNEXPECTED; break; } @@ -536,23 +536,23 @@ void append_test_events_from_notification(const bt_notification *notification) } static -enum bt_notification_iterator_status common_consume( - void *notif_iter, bool is_output_port_notif_iter) +enum bt_message_iterator_status common_consume( + void *msg_iter, bool is_output_port_msg_iter) { - enum bt_notification_iterator_status ret; - bt_notification_array_const notifications = NULL; + enum bt_message_iterator_status ret; + bt_message_array_const messages = NULL; uint64_t count = 0; struct test_event test_event = { 0 }; uint64_t i; - BT_ASSERT(notif_iter); + BT_ASSERT(msg_iter); - if (is_output_port_notif_iter) { - ret = bt_port_output_notification_iterator_next(notif_iter, - ¬ifications, &count); + if (is_output_port_msg_iter) { + ret = bt_port_output_message_iterator_next(msg_iter, + &messages, &count); } else { - ret = bt_self_component_port_input_notification_iterator_next( - notif_iter, ¬ifications, &count); + ret = bt_self_component_port_input_message_iterator_next( + msg_iter, &messages, &count); } if (ret < 0) { @@ -560,22 +560,22 @@ enum bt_notification_iterator_status common_consume( } switch (ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: test_event.type = TEST_EV_TYPE_END; append_test_event(&test_event); goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: abort(); default: break; } - BT_ASSERT(notifications); + BT_ASSERT(messages); BT_ASSERT(count > 0); for (i = 0; i < count; i++) { - append_test_events_from_notification(notifications[i]); - bt_notification_put_ref(notifications[i]); + append_test_events_from_message(messages[i]); + bt_message_put_ref(messages[i]); } end: @@ -591,10 +591,10 @@ enum bt_self_component_status sink_consume( bt_self_component_get_data( bt_self_component_sink_as_self_component( self_comp)); - enum bt_notification_iterator_status it_ret; + enum bt_message_iterator_status it_ret; - BT_ASSERT(user_data && user_data->notif_iter); - it_ret = common_consume(user_data->notif_iter, false); + BT_ASSERT(user_data && user_data->msg_iter); + it_ret = common_consume(user_data->msg_iter, false); if (it_ret < 0) { ret = BT_SELF_COMPONENT_STATUS_ERROR; @@ -602,12 +602,12 @@ enum bt_self_component_status sink_consume( } switch (it_ret) { - case BT_NOTIFICATION_ITERATOR_STATUS_END: + case BT_MESSAGE_ITERATOR_STATUS_END: ret = BT_SELF_COMPONENT_STATUS_END; - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( - user_data->notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( + user_data->msg_iter); goto end; - case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: + case BT_MESSAGE_ITERATOR_STATUS_AGAIN: abort(); default: break; @@ -629,8 +629,8 @@ enum bt_self_component_status sink_port_connected( self_comp)); BT_ASSERT(user_data); - user_data->notif_iter = - bt_self_component_port_input_notification_iterator_create( + user_data->msg_iter = + bt_self_component_port_input_message_iterator_create( self_port); return BT_SELF_COMPONENT_STATUS_OK; } @@ -662,8 +662,8 @@ void sink_finalize(bt_self_component_sink *self_comp) self_comp)); if (user_data) { - BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( - user_data->notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET( + user_data->msg_iter); g_free(user_data); } } @@ -688,10 +688,10 @@ void create_source_sink(bt_graph *graph, ret = bt_component_class_source_set_finalize_method( src_comp_class, src_finalize); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_notification_iterator_init_method( + ret = bt_component_class_source_set_message_iterator_init_method( src_comp_class, src_iter_init); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_notification_iterator_finalize_method( + ret = bt_component_class_source_set_message_iterator_finalize_method( src_comp_class, src_iter_finalize); BT_ASSERT(ret == 0); ret = bt_graph_add_source_component(graph, @@ -771,84 +771,84 @@ void do_std_test(enum test test, const char *name, } static -void test_no_auto_notifs(void) +void test_no_auto_msgs(void) { const struct test_event expected_test_events[] = { - { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream2, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_STREAM_END, .stream = src_stream2, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_STREAM_END, .stream = src_stream1, .packet = NULL, }, { .type = TEST_EV_TYPE_END, }, { .type = TEST_EV_TYPE_SENTINEL, }, }; - do_std_test(TEST_NO_AUTO_NOTIFS, "no automatic notifications", + do_std_test(TEST_NO_AUTO_MSGS, "no automatic messages", expected_test_events); } static -void test_output_port_notification_iterator(void) +void test_output_port_message_iterator(void) { const struct test_event expected_test_events[] = { - { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream2, .packet = NULL, }, - { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, }, - { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_STREAM_BEGIN, .stream = src_stream2, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream2, .packet = src_stream2_packet2, }, + { .type = TEST_EV_TYPE_MSG_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_STREAM_END, .stream = src_stream2, .packet = NULL, }, + { .type = TEST_EV_TYPE_MSG_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, }, + { .type = TEST_EV_TYPE_MSG_STREAM_END, .stream = src_stream1, .packet = NULL, }, { .type = TEST_EV_TYPE_END, }, { .type = TEST_EV_TYPE_SENTINEL, }, }; const bt_component_source *src_comp; - bt_port_output_notification_iterator *notif_iter; - enum bt_notification_iterator_status iter_status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + bt_port_output_message_iterator *msg_iter; + enum bt_message_iterator_status iter_status = + BT_MESSAGE_ITERATOR_STATUS_OK; const bt_port_output *upstream_port; clear_test_events(); - current_test = TEST_OUTPUT_PORT_NOTIFICATION_ITERATOR; - diag("test: output port notification iterator"); + current_test = TEST_OUTPUT_PORT_MESSAGE_ITERATOR; + diag("test: output port message iterator"); BT_ASSERT(!graph); graph = bt_graph_create(); BT_ASSERT(graph); create_source_sink(graph, &src_comp, NULL); - /* Create notification iterator on source's output port */ + /* Create message iterator on source's output port */ upstream_port = bt_component_source_borrow_output_port_by_name_const(src_comp, "out"); - notif_iter = bt_port_output_notification_iterator_create(graph, + msg_iter = bt_port_output_message_iterator_create(graph, upstream_port); - ok(notif_iter, "bt_private_output_port_notification_iterator_create() succeeds"); + ok(msg_iter, "bt_private_output_port_message_iterator_create() succeeds"); - /* Consume the notification iterator */ - while (iter_status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { - iter_status = common_consume(notif_iter, true); + /* Consume the message iterator */ + while (iter_status == BT_MESSAGE_ITERATOR_STATUS_OK) { + iter_status = common_consume(msg_iter, true); } - ok(iter_status == BT_NOTIFICATION_ITERATOR_STATUS_END, - "output port notification iterator finishes without any error"); + ok(iter_status == BT_MESSAGE_ITERATOR_STATUS_END, + "output port message iterator finishes without any error"); /* Compare the resulting test events */ ok(compare_test_events(expected_test_events), @@ -856,10 +856,10 @@ void test_output_port_notification_iterator(void) bt_component_source_put_ref(src_comp); BT_GRAPH_PUT_REF_AND_RESET(graph); - bt_port_output_notification_iterator_put_ref(notif_iter); + bt_port_output_message_iterator_put_ref(msg_iter); } -#define DEBUG_ENV_VAR "TEST_BT_NOTIFICATION_ITERATOR_DEBUG" +#define DEBUG_ENV_VAR "TEST_BT_MESSAGE_ITERATOR_DEBUG" int main(int argc, char **argv) { @@ -869,8 +869,8 @@ int main(int argc, char **argv) plan_tests(NR_TESTS); init_static_data(); - test_no_auto_notifs(); - test_output_port_notification_iterator(); + test_no_auto_msgs(); + test_output_port_message_iterator(); fini_static_data(); return exit_status(); } diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index 43c236e4..7cf87083 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -364,12 +364,12 @@ size_t event_pos(struct event *event) } static -enum bt_self_notification_iterator_status src_iter_next( - bt_self_notification_iterator *self_iterator, - bt_notification_array_const notifs, uint64_t capacity, +enum bt_self_message_iterator_status src_iter_next( + bt_self_message_iterator *self_iterator, + bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; + return BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; } static -- 2.34.1