Rename the include dir to be co-installable with bt1.
Change-Id: Icb9a048988544eaca7054648b9c7a9e76d70b9db
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1405
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
The logging API headers are:
-`<babeltrace/logging.h>`::
+`<babeltrace2/logging.h>`::
Public header which a library user can use to control and read
libbabeltrace2's current log level.
-`<babeltrace/logging-internal.h>`::
+`<babeltrace2/logging-internal.h>`::
Internal, generic logging API which you can use in any Babeltrace
subproject. This is the translation of `zf_log.h`.
-`<babeltrace/lib-logging-internal.h>`::
+`<babeltrace2/lib-logging-internal.h>`::
Specific internal header to use within the library. This header
defines `BT_LOG_OUTPUT_LEVEL` to a custom, library-wide hidden
symbol which is the library's current log level before including
- `<babeltrace/logging-internal.h>`.
+ `<babeltrace2/logging-internal.h>`.
-Do not include `<babeltrace/logging-internal.h>` or
-`<babeltrace/lib-logging-internal.h>` in a header which contains logging
+Do not include `<babeltrace2/logging-internal.h>` or
+`<babeltrace2/lib-logging-internal.h>` in a header which contains logging
statements: this header could be included in source files which define a
different <<choose-a-tag,tag>>, for example. See
<<logging-instrument-header, Instrument a C header file>>.
`_bt_log_global_output_lvl` symbol. In practice, we never use this
symbol, and always make sure that `BT_LOG_OUTPUT_LEVEL` is defined to a
module-wise or subproject-wise hidden symbol before including
-`<babeltrace/logging-internal.h>`. In the library,
-`<babeltrace/lib-logging-internal.h>` does this job: just include this
+`<babeltrace2/logging-internal.h>`. In the library,
+`<babeltrace2/lib-logging-internal.h>` does this job: just include this
header which defines `BT_LOG_OUTPUT_LEVEL` to the appropriate symbol
-before it includes `<babeltrace/logging-internal.h>`. In plugins, for
+before it includes `<babeltrace2/logging-internal.h>`. In plugins, for
example, there is one log level per component class, which makes log
filtering easier during execution.
+
*/
#define BT_LOG_OUTPUT_LEVEL my_module_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(my_module_log_level, "BABELTRACE_MY_MODULE_LOG_LEVEL");
----
*/
#define BT_LOG_OUTPUT_LEVEL my_module_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(my_module_log_level);
*/
#define BT_LOG_OUTPUT_LEVEL bt_python_bindings_bt2_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_python_bindings_bt2_log_level,
"BABELTRACE_PYTHON_BT2_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_python_bindings_bt2_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_python_bindings_bt2_log_level);
#define BT_LOG_TAG "PY-NATIVE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/property.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/property.h>
+#include <babeltrace2/assert-internal.h>
typedef const uint8_t *bt_uuid;
%}
*/
%{
-#include <babeltrace/logging.h>
+#include <babeltrace2/logging.h>
%}
/* Log levels */
*/
#include <stdlib.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include "babeltrace2-cfg.h"
#include "babeltrace2-cfg-cli-args-connect.h"
#include <stdlib.h>
#include <stdint.h>
-#include <babeltrace/value.h>
+#include <babeltrace2/value.h>
#include <glib.h>
#include "babeltrace2-cfg.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "babeltrace2-cfg.h"
#include "babeltrace2-cfg-cli-args.h"
#include "babeltrace2-cfg-cli-args-default.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <stdio.h>
#include <stdbool.h>
#include <inttypes.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include <popt.h>
#include <glib.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdint.h>
-#include <babeltrace/value.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/component-class.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/graph/component-class.h>
#include <glib.h>
#include "babeltrace2-cfg.h"
* SOFTWARE.
*/
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace.h>
#include <glib.h>
#include "babeltrace2-cfg.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
-#include <babeltrace/value.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/component-class.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/graph/component-class.h>
#include <glib.h>
enum bt_config_command {
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
#include <popt.h>
#include <glib.h>
#define BT_LOG_TAG "CLI"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include <unistd.h>
#include <stdlib.h>
#include <popt.h>
*/
#define BT_LOG_OUTPUT_LEVEL bt_cli_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_cli_log_level, "BABELTRACE_CLI_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_cli_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_cli_log_level);
* SOFTWARE.
*/
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
void bt_common_assert_failed(const char *file, int line, const char *func,
const char *assertion)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <stdarg.h>
#include <ctype.h>
#include <glib.h>
#include <stdio.h>
#include <wchar.h>
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/compat/unistd-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/compat/unistd-internal.h>
#ifndef __MINGW32__
#include <pwd.h>
*/
#define BT_LOG_OUTPUT_LEVEL bt_common_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_common_log_level, "BABELTRACE_COMMON_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_common_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_common_log_level);
#include <pthread.h>
#include <stdlib.h>
#include <windows.h>
-#include <babeltrace/compat/mman-internal.h>
+#include <babeltrace2/compat/mman-internal.h>
struct mmap_mapping {
/* The duplicated handle. */
#include <rpc.h>
#include <stdlib.h>
-#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
/* MinGW does not provide byteswap - implement our own version. */
static
*/
#define BT_LOG_OUTPUT_LEVEL bt_compat_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_compat_log_level, "BABELTRACE_COMPAT_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_compat_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_compat_log_level);
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <stdarg.h>
#include <ctype.h>
#include <glib.h>
#include <stdio.h>
#include <wchar.h>
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/ctfser-internal.h>
-#include <babeltrace/compat/unistd-internal.h>
-#include <babeltrace/compat/fcntl-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/ctfser-internal.h>
+#include <babeltrace2/compat/unistd-internal.h>
+#include <babeltrace2/compat/fcntl-internal.h>
static inline
uint64_t get_packet_size_increment_bytes(void)
*/
#define BT_LOG_OUTPUT_LEVEL bt_ctfser_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_ctfser_log_level, "BABELTRACE_CTFSER_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_ctfser_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_ctfser_log_level);
@code{.c}
#include <assert.h>
-#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/field-types.h>
struct bt_field_type *create_int_field_type(void)
{
@code{.c}
#include <assert.h>
-#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/field-types.h>
struct bt_field_type *create_int_field_type(void)
{
@code{.c}
#include <assert.h>
-#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/field-types.h>
struct bt_field_type *create_int_field_type(
struct bt_clock_class *clock_class)
@code{.c}
#include <assert.h>
-#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/field-types.h>
struct bt_field_type *create_float_field_type(void)
{
@code{.c}
#include <assert.h>
-#include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/field-types.h>
struct bt_field_type *create_float_field_type(void)
{
but which necessarily makes the compilation slower:
@code
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
@endcode
@section howtobuild How to build
cur_title = m.group(1)
continue
- m = re.match(r'^\s+(babeltrace/.+\.h).*$', line)
+ m = re.match(r'^\s+(babeltrace2/.+\.h).*$', line)
if m:
- if m.group(1) != 'babeltrace/babeltrace.h':
+ if m.group(1) != 'babeltrace2/babeltrace.h':
cur_filenames.append(m.group(1))
continue
#include <unistd.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/fd-cache-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/fd-cache-internal.h>
struct file_key {
uint64_t dev;
*/
#define BT_LOG_OUTPUT_LEVEL bt_fd_cache_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_fd_cache_log_level, "BABELTRACE_FD_CACHE_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_fd_cache_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_fd_cache_log_level);
DISTCLEANFILES = version.i
# Core API
-babeltraceincludedir = "$(includedir)/babeltrace"
-babeltraceinclude_HEADERS = \
- babeltrace/babeltrace.h \
- babeltrace/logging.h \
- babeltrace/property.h \
- babeltrace/types.h \
- babeltrace/util.h \
- babeltrace/value-const.h \
- babeltrace/value.h \
- babeltrace/version.h
+babeltrace2includedir = "$(includedir)/babeltrace2"
+babeltrace2include_HEADERS = \
+ babeltrace2/babeltrace.h \
+ babeltrace2/logging.h \
+ babeltrace2/property.h \
+ babeltrace2/types.h \
+ babeltrace2/util.h \
+ babeltrace2/value-const.h \
+ babeltrace2/value.h \
+ babeltrace2/version.h
# Legacy API (for CTF writer)
-babeltracectfincludedir = "$(includedir)/babeltrace/ctf"
-babeltracectfinclude_HEADERS = \
- babeltrace/ctf/events.h
+babeltrace2ctfincludedir = "$(includedir)/babeltrace2/ctf"
+babeltrace2ctfinclude_HEADERS = \
+ babeltrace2/ctf/events.h
# CTF writer API
-babeltracectfwriterincludedir = "$(includedir)/babeltrace/ctf-writer"
-babeltracectfwriterinclude_HEADERS = \
- babeltrace/ctf-writer/clock-class.h \
- babeltrace/ctf-writer/clock.h \
- babeltrace/ctf-writer/event-fields.h \
- babeltrace/ctf-writer/event-types.h \
- babeltrace/ctf-writer/event.h \
- babeltrace/ctf-writer/field-types.h \
- babeltrace/ctf-writer/fields.h \
- babeltrace/ctf-writer/object.h \
- babeltrace/ctf-writer/stream-class.h \
- babeltrace/ctf-writer/stream.h \
- babeltrace/ctf-writer/trace.h \
- babeltrace/ctf-writer/utils.h \
- babeltrace/ctf-writer/visitor.h \
- babeltrace/ctf-writer/writer.h
+babeltrace2ctfwriterincludedir = "$(includedir)/babeltrace2/ctf-writer"
+babeltrace2ctfwriterinclude_HEADERS = \
+ babeltrace2/ctf-writer/clock-class.h \
+ babeltrace2/ctf-writer/clock.h \
+ babeltrace2/ctf-writer/event-fields.h \
+ babeltrace2/ctf-writer/event-types.h \
+ babeltrace2/ctf-writer/event.h \
+ babeltrace2/ctf-writer/field-types.h \
+ babeltrace2/ctf-writer/fields.h \
+ babeltrace2/ctf-writer/object.h \
+ babeltrace2/ctf-writer/stream-class.h \
+ babeltrace2/ctf-writer/stream.h \
+ babeltrace2/ctf-writer/trace.h \
+ babeltrace2/ctf-writer/utils.h \
+ babeltrace2/ctf-writer/visitor.h \
+ babeltrace2/ctf-writer/writer.h
# Legacy API (for CTF writer)
-babeltracectfirincludedir = "$(includedir)/babeltrace/ctf-ir"
-babeltracectfirinclude_HEADERS = \
- babeltrace/ctf-ir/clock.h \
- babeltrace/ctf-ir/event-fields.h \
- babeltrace/ctf-ir/event-types.h \
- babeltrace/ctf-ir/event.h \
- babeltrace/ctf-ir/field-types.h \
- babeltrace/ctf-ir/fields.h \
- babeltrace/ctf-ir/stream-class.h \
- babeltrace/ctf-ir/stream.h \
- babeltrace/ctf-ir/trace.h \
- babeltrace/ctf-ir/utils.h
+babeltrace2ctfirincludedir = "$(includedir)/babeltrace2/ctf-ir"
+babeltrace2ctfirinclude_HEADERS = \
+ babeltrace2/ctf-ir/clock.h \
+ babeltrace2/ctf-ir/event-fields.h \
+ babeltrace2/ctf-ir/event-types.h \
+ babeltrace2/ctf-ir/event.h \
+ babeltrace2/ctf-ir/field-types.h \
+ babeltrace2/ctf-ir/fields.h \
+ babeltrace2/ctf-ir/stream-class.h \
+ babeltrace2/ctf-ir/stream.h \
+ babeltrace2/ctf-ir/trace.h \
+ babeltrace2/ctf-ir/utils.h
# Trace IR API
-babeltracetraceirincludedir = "$(includedir)/babeltrace/trace-ir"
-babeltracetraceirinclude_HEADERS = \
- babeltrace/trace-ir/clock-class-const.h \
- babeltrace/trace-ir/clock-class.h \
- babeltrace/trace-ir/clock-snapshot-const.h \
- babeltrace/trace-ir/event-class-const.h \
- babeltrace/trace-ir/event-class.h \
- babeltrace/trace-ir/event-const.h \
- babeltrace/trace-ir/event.h \
- babeltrace/trace-ir/field-class-const.h \
- babeltrace/trace-ir/field-class.h \
- babeltrace/trace-ir/field-path-const.h \
- babeltrace/trace-ir/field-const.h \
- babeltrace/trace-ir/field.h \
- babeltrace/trace-ir/packet-const.h \
- babeltrace/trace-ir/packet-context-field.h \
- babeltrace/trace-ir/packet.h \
- babeltrace/trace-ir/stream-class-const.h \
- babeltrace/trace-ir/stream-class.h \
- babeltrace/trace-ir/stream-const.h \
- babeltrace/trace-ir/stream.h \
- babeltrace/trace-ir/trace-class-const.h \
- babeltrace/trace-ir/trace-class.h \
- babeltrace/trace-ir/trace-const.h \
- babeltrace/trace-ir/trace.h
+babeltrace2traceirincludedir = "$(includedir)/babeltrace2/trace-ir"
+babeltrace2traceirinclude_HEADERS = \
+ babeltrace2/trace-ir/clock-class-const.h \
+ babeltrace2/trace-ir/clock-class.h \
+ babeltrace2/trace-ir/clock-snapshot-const.h \
+ babeltrace2/trace-ir/event-class-const.h \
+ babeltrace2/trace-ir/event-class.h \
+ babeltrace2/trace-ir/event-const.h \
+ babeltrace2/trace-ir/event.h \
+ babeltrace2/trace-ir/field-class-const.h \
+ babeltrace2/trace-ir/field-class.h \
+ babeltrace2/trace-ir/field-path-const.h \
+ babeltrace2/trace-ir/field-const.h \
+ babeltrace2/trace-ir/field.h \
+ babeltrace2/trace-ir/packet-const.h \
+ babeltrace2/trace-ir/packet-context-field.h \
+ babeltrace2/trace-ir/packet.h \
+ babeltrace2/trace-ir/stream-class-const.h \
+ babeltrace2/trace-ir/stream-class.h \
+ babeltrace2/trace-ir/stream-const.h \
+ babeltrace2/trace-ir/stream.h \
+ babeltrace2/trace-ir/trace-class-const.h \
+ babeltrace2/trace-ir/trace-class.h \
+ babeltrace2/trace-ir/trace-const.h \
+ babeltrace2/trace-ir/trace.h
# Plugin and plugin development API
-babeltracepluginincludedir = "$(includedir)/babeltrace/plugin"
-babeltraceplugininclude_HEADERS = \
- babeltrace/plugin/plugin-dev.h \
- babeltrace/plugin/plugin-const.h \
- babeltrace/plugin/plugin-set-const.h
+babeltrace2pluginincludedir = "$(includedir)/babeltrace2/plugin"
+babeltrace2plugininclude_HEADERS = \
+ babeltrace2/plugin/plugin-dev.h \
+ babeltrace2/plugin/plugin-const.h \
+ babeltrace2/plugin/plugin-set-const.h
# Graph, component, and message API
-babeltracegraphincludedir = "$(includedir)/babeltrace/graph"
-babeltracegraphinclude_HEADERS = \
- babeltrace/graph/component-class-const.h \
- babeltrace/graph/component-class-filter-const.h \
- babeltrace/graph/component-class-filter.h \
- babeltrace/graph/component-class-sink-const.h \
- babeltrace/graph/component-class-sink.h \
- babeltrace/graph/component-class-source-const.h \
- babeltrace/graph/component-class-source.h \
- babeltrace/graph/component-class.h \
- babeltrace/graph/component-const.h \
- babeltrace/graph/component-filter-const.h \
- babeltrace/graph/component-sink-const.h \
- babeltrace/graph/component-source-const.h \
- babeltrace/graph/connection-const.h \
- babeltrace/graph/graph-const.h \
- babeltrace/graph/graph.h \
- babeltrace/graph/message-const.h \
- babeltrace/graph/message-discarded-events-const.h \
- babeltrace/graph/message-discarded-events.h \
- babeltrace/graph/message-discarded-packets-const.h \
- babeltrace/graph/message-discarded-packets.h \
- babeltrace/graph/message-event-const.h \
- babeltrace/graph/message-event.h \
- babeltrace/graph/message-message-iterator-inactivity-const.h \
- babeltrace/graph/message-message-iterator-inactivity.h \
- babeltrace/graph/message-iterator-const.h \
- babeltrace/graph/message-packet-beginning-const.h \
- babeltrace/graph/message-packet-beginning.h \
- babeltrace/graph/message-packet-end-const.h \
- babeltrace/graph/message-packet-end.h \
- babeltrace/graph/message-stream-activity-beginning-const.h \
- babeltrace/graph/message-stream-activity-beginning.h \
- babeltrace/graph/message-stream-activity-const.h \
- babeltrace/graph/message-stream-activity-end-const.h \
- babeltrace/graph/message-stream-activity-end.h \
- babeltrace/graph/message-stream-beginning-const.h \
- babeltrace/graph/message-stream-beginning.h \
- babeltrace/graph/message-stream-end-const.h \
- babeltrace/graph/message-stream-end.h \
- babeltrace/graph/port-const.h \
- babeltrace/graph/port-input-const.h \
- babeltrace/graph/port-output-const.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-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-message-iterator.h
+babeltrace2graphincludedir = "$(includedir)/babeltrace2/graph"
+babeltrace2graphinclude_HEADERS = \
+ babeltrace2/graph/component-class-const.h \
+ babeltrace2/graph/component-class-filter-const.h \
+ babeltrace2/graph/component-class-filter.h \
+ babeltrace2/graph/component-class-sink-const.h \
+ babeltrace2/graph/component-class-sink.h \
+ babeltrace2/graph/component-class-source-const.h \
+ babeltrace2/graph/component-class-source.h \
+ babeltrace2/graph/component-class.h \
+ babeltrace2/graph/component-const.h \
+ babeltrace2/graph/component-filter-const.h \
+ babeltrace2/graph/component-sink-const.h \
+ babeltrace2/graph/component-source-const.h \
+ babeltrace2/graph/connection-const.h \
+ babeltrace2/graph/graph-const.h \
+ babeltrace2/graph/graph.h \
+ babeltrace2/graph/message-const.h \
+ babeltrace2/graph/message-discarded-events-const.h \
+ babeltrace2/graph/message-discarded-events.h \
+ babeltrace2/graph/message-discarded-packets-const.h \
+ babeltrace2/graph/message-discarded-packets.h \
+ babeltrace2/graph/message-event-const.h \
+ babeltrace2/graph/message-event.h \
+ babeltrace2/graph/message-message-iterator-inactivity-const.h \
+ babeltrace2/graph/message-message-iterator-inactivity.h \
+ babeltrace2/graph/message-iterator-const.h \
+ babeltrace2/graph/message-packet-beginning-const.h \
+ babeltrace2/graph/message-packet-beginning.h \
+ babeltrace2/graph/message-packet-end-const.h \
+ babeltrace2/graph/message-packet-end.h \
+ babeltrace2/graph/message-stream-activity-beginning-const.h \
+ babeltrace2/graph/message-stream-activity-beginning.h \
+ babeltrace2/graph/message-stream-activity-const.h \
+ babeltrace2/graph/message-stream-activity-end-const.h \
+ babeltrace2/graph/message-stream-activity-end.h \
+ babeltrace2/graph/message-stream-beginning-const.h \
+ babeltrace2/graph/message-stream-beginning.h \
+ babeltrace2/graph/message-stream-end-const.h \
+ babeltrace2/graph/message-stream-end.h \
+ babeltrace2/graph/port-const.h \
+ babeltrace2/graph/port-input-const.h \
+ babeltrace2/graph/port-output-const.h \
+ babeltrace2/graph/port-output-message-iterator.h \
+ babeltrace2/graph/query-executor-const.h \
+ babeltrace2/graph/query-executor.h \
+ babeltrace2/graph/self-component-class-filter.h \
+ babeltrace2/graph/self-component-class-sink.h \
+ babeltrace2/graph/self-component-class-source.h \
+ babeltrace2/graph/self-component-filter.h \
+ babeltrace2/graph/self-component-port-input-message-iterator.h \
+ babeltrace2/graph/self-component-port-input.h \
+ babeltrace2/graph/self-component-port-output.h \
+ babeltrace2/graph/self-component-port.h \
+ babeltrace2/graph/self-component-sink.h \
+ babeltrace2/graph/self-component-source.h \
+ babeltrace2/graph/self-component.h \
+ babeltrace2/graph/self-message-iterator.h
noinst_HEADERS = \
- babeltrace/compat/stdlib-internal.h \
- babeltrace/compat/fcntl-internal.h \
- babeltrace/compat/glib-internal.h \
- babeltrace/compat/uuid-internal.h \
- babeltrace/compat/unistd-internal.h \
- babeltrace/compat/stdio-internal.h \
- babeltrace/compat/time-internal.h \
- babeltrace/compat/utc-internal.h \
- babeltrace/compat/memstream-internal.h \
- babeltrace/compat/string-internal.h \
- babeltrace/compat/limits-internal.h \
- babeltrace/compat/mman-internal.h \
- babeltrace/compat/socket-internal.h \
- babeltrace/common-internal.h \
- babeltrace/ctfser-internal.h \
- babeltrace/bitfield-internal.h \
- babeltrace/object-internal.h \
- babeltrace/object-pool-internal.h \
- babeltrace/plugin/plugin-internal.h \
- babeltrace/plugin/plugin-so-internal.h \
- babeltrace/plugin/python-plugin-provider-internal.h \
- babeltrace/assert-internal.h \
- babeltrace/value-internal.h \
- babeltrace/ctf-writer/attributes-internal.h \
- babeltrace/ctf-writer/clock-class-internal.h \
- babeltrace/ctf-writer/clock-internal.h \
- babeltrace/ctf-writer/event-class-internal.h \
- babeltrace/ctf-writer/event-internal.h \
- babeltrace/ctf-writer/field-path-internal.h \
- babeltrace/ctf-writer/fields-internal.h \
- babeltrace/ctf-writer/field-types-internal.h \
- babeltrace/ctf-writer/field-wrapper-internal.h \
- babeltrace/ctf-writer/functor-internal.h \
- babeltrace/ctf-writer/object-internal.h \
- babeltrace/ctf-writer/object-pool-internal.h \
- babeltrace/ctf-writer/resolve-internal.h \
- babeltrace/ctf-writer/stream-class-internal.h \
- babeltrace/ctf-writer/stream-internal.h \
- babeltrace/ctf-writer/trace-internal.h \
- babeltrace/ctf-writer/utils-internal.h \
- babeltrace/ctf-writer/validation-internal.h \
- babeltrace/ctf-writer/values-internal.h \
- babeltrace/ctf-writer/visitor-internal.h \
- babeltrace/ctf-writer/writer-internal.h \
- babeltrace/mmap-align-internal.h \
- babeltrace/align-internal.h \
- babeltrace/logging-internal.h \
- babeltrace/endian-internal.h \
- babeltrace/trace-ir/attributes-internal.h \
- babeltrace/trace-ir/clock-class-internal.h \
- babeltrace/trace-ir/clock-snapshot-internal.h \
- babeltrace/trace-ir/clock-snapshot-set-internal.h \
- babeltrace/trace-ir/event-class-internal.h \
- babeltrace/trace-ir/event-internal.h \
- babeltrace/trace-ir/field-class-internal.h \
- babeltrace/trace-ir/field-path-internal.h \
- babeltrace/trace-ir/field-internal.h \
- babeltrace/trace-ir/field-wrapper-internal.h \
- babeltrace/trace-ir/packet-internal.h \
- babeltrace/trace-ir/resolve-field-path-internal.h \
- babeltrace/trace-ir/stream-class-internal.h \
- babeltrace/trace-ir/stream-internal.h \
- babeltrace/trace-ir/trace-class-internal.h \
- babeltrace/trace-ir/trace-internal.h \
- babeltrace/trace-ir/utils-internal.h \
- babeltrace/prio-heap-internal.h \
- babeltrace/lib-logging-internal.h \
- babeltrace/compiler-internal.h \
- babeltrace/babeltrace-internal.h \
- babeltrace/assert-pre-internal.h \
- babeltrace/graph/component-class-internal.h \
- babeltrace/graph/component-class-sink-colander-internal.h \
- babeltrace/graph/component-filter-internal.h \
- babeltrace/graph/component-internal.h \
- babeltrace/graph/component-sink-internal.h \
- babeltrace/graph/component-source-internal.h \
- babeltrace/graph/connection-internal.h \
- babeltrace/graph/graph-internal.h \
- babeltrace/graph/message-discarded-items-internal.h \
- babeltrace/graph/message-event-internal.h \
- babeltrace/graph/message-message-iterator-inactivity-internal.h \
- babeltrace/graph/message-internal.h \
- babeltrace/graph/message-iterator-internal.h \
- babeltrace/graph/message-packet-internal.h \
- babeltrace/graph/message-stream-activity-internal.h \
- babeltrace/graph/message-stream-internal.h \
- babeltrace/graph/port-internal.h \
- babeltrace/graph/query-executor-internal.h \
- babeltrace/list-internal.h \
- babeltrace/fd-cache-internal.h \
- babeltrace/property-internal.h \
+ babeltrace2/compat/stdlib-internal.h \
+ babeltrace2/compat/fcntl-internal.h \
+ babeltrace2/compat/glib-internal.h \
+ babeltrace2/compat/uuid-internal.h \
+ babeltrace2/compat/unistd-internal.h \
+ babeltrace2/compat/stdio-internal.h \
+ babeltrace2/compat/time-internal.h \
+ babeltrace2/compat/utc-internal.h \
+ babeltrace2/compat/memstream-internal.h \
+ babeltrace2/compat/string-internal.h \
+ babeltrace2/compat/limits-internal.h \
+ babeltrace2/compat/mman-internal.h \
+ babeltrace2/compat/socket-internal.h \
+ babeltrace2/common-internal.h \
+ babeltrace2/ctfser-internal.h \
+ babeltrace2/bitfield-internal.h \
+ babeltrace2/object-internal.h \
+ babeltrace2/object-pool-internal.h \
+ babeltrace2/plugin/plugin-internal.h \
+ babeltrace2/plugin/plugin-so-internal.h \
+ babeltrace2/plugin/python-plugin-provider-internal.h \
+ babeltrace2/assert-internal.h \
+ babeltrace2/value-internal.h \
+ babeltrace2/ctf-writer/attributes-internal.h \
+ babeltrace2/ctf-writer/clock-class-internal.h \
+ babeltrace2/ctf-writer/clock-internal.h \
+ babeltrace2/ctf-writer/event-class-internal.h \
+ babeltrace2/ctf-writer/event-internal.h \
+ babeltrace2/ctf-writer/field-path-internal.h \
+ babeltrace2/ctf-writer/fields-internal.h \
+ babeltrace2/ctf-writer/field-types-internal.h \
+ babeltrace2/ctf-writer/field-wrapper-internal.h \
+ babeltrace2/ctf-writer/functor-internal.h \
+ babeltrace2/ctf-writer/object-internal.h \
+ babeltrace2/ctf-writer/object-pool-internal.h \
+ babeltrace2/ctf-writer/resolve-internal.h \
+ babeltrace2/ctf-writer/stream-class-internal.h \
+ babeltrace2/ctf-writer/stream-internal.h \
+ babeltrace2/ctf-writer/trace-internal.h \
+ babeltrace2/ctf-writer/utils-internal.h \
+ babeltrace2/ctf-writer/validation-internal.h \
+ babeltrace2/ctf-writer/values-internal.h \
+ babeltrace2/ctf-writer/visitor-internal.h \
+ babeltrace2/ctf-writer/writer-internal.h \
+ babeltrace2/mmap-align-internal.h \
+ babeltrace2/align-internal.h \
+ babeltrace2/logging-internal.h \
+ babeltrace2/endian-internal.h \
+ babeltrace2/trace-ir/attributes-internal.h \
+ babeltrace2/trace-ir/clock-class-internal.h \
+ babeltrace2/trace-ir/clock-snapshot-internal.h \
+ babeltrace2/trace-ir/clock-snapshot-set-internal.h \
+ babeltrace2/trace-ir/event-class-internal.h \
+ babeltrace2/trace-ir/event-internal.h \
+ babeltrace2/trace-ir/field-class-internal.h \
+ babeltrace2/trace-ir/field-path-internal.h \
+ babeltrace2/trace-ir/field-internal.h \
+ babeltrace2/trace-ir/field-wrapper-internal.h \
+ babeltrace2/trace-ir/packet-internal.h \
+ babeltrace2/trace-ir/resolve-field-path-internal.h \
+ babeltrace2/trace-ir/stream-class-internal.h \
+ babeltrace2/trace-ir/stream-internal.h \
+ babeltrace2/trace-ir/trace-class-internal.h \
+ babeltrace2/trace-ir/trace-internal.h \
+ babeltrace2/trace-ir/utils-internal.h \
+ babeltrace2/prio-heap-internal.h \
+ babeltrace2/lib-logging-internal.h \
+ babeltrace2/compiler-internal.h \
+ babeltrace2/babeltrace-internal.h \
+ babeltrace2/assert-pre-internal.h \
+ babeltrace2/graph/component-class-internal.h \
+ babeltrace2/graph/component-class-sink-colander-internal.h \
+ babeltrace2/graph/component-filter-internal.h \
+ babeltrace2/graph/component-internal.h \
+ babeltrace2/graph/component-sink-internal.h \
+ babeltrace2/graph/component-source-internal.h \
+ babeltrace2/graph/connection-internal.h \
+ babeltrace2/graph/graph-internal.h \
+ babeltrace2/graph/message-discarded-items-internal.h \
+ babeltrace2/graph/message-event-internal.h \
+ babeltrace2/graph/message-message-iterator-inactivity-internal.h \
+ babeltrace2/graph/message-internal.h \
+ babeltrace2/graph/message-iterator-internal.h \
+ babeltrace2/graph/message-packet-internal.h \
+ babeltrace2/graph/message-stream-activity-internal.h \
+ babeltrace2/graph/message-stream-internal.h \
+ babeltrace2/graph/port-internal.h \
+ babeltrace2/graph/query-executor-internal.h \
+ babeltrace2/list-internal.h \
+ babeltrace2/fd-cache-internal.h \
+ babeltrace2/property-internal.h \
version.h \
version.i
+++ /dev/null
-#ifndef _BABELTRACE_ALIGN_H
-#define _BABELTRACE_ALIGN_H
-
-/*
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <babeltrace/compiler-internal.h>
-#include <babeltrace/compat/limits-internal.h>
-
-#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
-#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
-#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a))
-#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
-#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask))
-#define PTR_ALIGN_FLOOR(p, a) \
- ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
-#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0)
-
-/*
- * Align pointer on natural object alignment.
- */
-#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
-#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
-
-/**
- * offset_align - Calculate the offset needed to align an object on its natural
- * alignment towards higher addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be added to align towards higher
- * addresses.
- */
-#define offset_align(align_drift, alignment) \
- ({ \
- MAYBE_BUILD_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((alignment) - (align_drift)) & ((alignment) - 1)); \
- })
-
-/**
- * offset_align_floor - Calculate the offset needed to align an object
- * on its natural alignment towards lower addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be substracted to align towards lower addresses.
- */
-#define offset_align_floor(align_drift, alignment) \
- ({ \
- MAYBE_BUILD_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((align_drift) - (alignment)) & ((alignment) - 1)); \
- })
-
-#endif /* _BABELTRACE_ALIGN_H */
+++ /dev/null
-#ifndef BABELTRACE_ASSERT_INTERNAL_H
-#define BABELTRACE_ASSERT_INTERNAL_H
-
-/*
- * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <assert.h>
-#include <babeltrace/babeltrace-internal.h>
-
-#ifdef BT_DEBUG_MODE
-
-extern void bt_common_assert_failed(const char *file, int line,
- const char *func, const char *assertion) __attribute__((noreturn));
-
-/*
- * Internal assertion (to detect logic errors on which the library user
- * has no influence). Use BT_ASSERT_PRE() to check a precondition which
- * must be directly or indirectly satisfied by the library user.
- */
-#define BT_ASSERT(_cond) \
- do { \
- if (!(_cond)) { \
- bt_common_assert_failed(__FILE__, __LINE__, __func__, \
- TOSTRING(_cond)); \
- } \
- } while (0)
-
-/*
- * Marks a function as being only used within a BT_ASSERT() context.
- */
-# define BT_ASSERT_FUNC
-#else
-/*
- * When BT_DEBUG_MODE is not defined, define BT_ASSERT() macro to the following
- * to trick the compiler into thinking that the variable passed as condition to
- * the assertion is used. This is to prevent set-but-not-used warnings from the
- * compiler when assertions are disabled. The `sizeof` operator also makes sure
- * that the `_cond` expression is not evaluated, thus preventing unwanted side
- * effects.
- *
- * In-depth explanation: https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551
- */
-# define BT_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
-# define BT_ASSERT_FUNC BT_UNUSED
-#endif /* BT_DEBUG_MODE */
-
-#endif /* BABELTRACE_ASSERT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_ASSERT_PRE_INTERNAL_H
-#define BABELTRACE_ASSERT_PRE_INTERNAL_H
-
-/*
- * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-/*
- * The macros in this header use macros defined in
- * <babeltrace/lib-logging-internal.h>. We don't want this header to
- * automatically include <babeltrace/lib-logging-internal.h> because you
- * need to manually define BT_LOG_TAG before including
- * <babeltrace/lib-logging-internal.h> and it is unexpected that you
- * also need to define it before including this header.
- *
- * This is a reminder that in order to use
- * <babeltrace/assert-pre-internal.h>, you also need to use logging
- * explicitly.
- */
-
-#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
-# error Include <babeltrace/lib-logging-internal.h> before this header.
-#endif
-
-#include <stdlib.h>
-#include <inttypes.h>
-#include <babeltrace/babeltrace-internal.h>
-
-#ifdef BT_DEV_MODE
-/*
- * Asserts that the library precondition _cond is satisfied.
- *
- * If _cond is false, log a fatal statement using _fmt and the optional
- * arguments using BT_LIB_LOGF(), and abort.
- *
- * To assert that a postcondition is satisfied or that some internal
- * object/context/value is in the expected state, use BT_ASSERT().
- */
-# define BT_ASSERT_PRE(_cond, _fmt, ...) \
- do { \
- if (!(_cond)) { \
- BT_LOGF_STR("Library precondition not satisfied; error is:"); \
- BT_LIB_LOGF((_fmt), ##__VA_ARGS__); \
- BT_LOGF_STR("Aborting..."); \
- abort(); \
- } \
- } while (0)
-
-/*
- * Marks a function as being only used within a BT_ASSERT_PRE() context.
- */
-# define BT_ASSERT_PRE_FUNC
-
-/*
- * Prints the details of an unsatisfied precondition without immediately
- * aborting. You should use this within a function which checks
- * preconditions, but which is called from a BT_ASSERT_PRE() context, so
- * that the function can still return its result for BT_ASSERT_PRE() to
- * evaluate it.
- *
- * Example:
- *
- * BT_ASSERT_PRE_FUNC
- * static inline bool check_complex_precond(...)
- * {
- * ...
- *
- * if (...) {
- * BT_ASSERT_PRE_MSG("Invalid object: ...", ...);
- * return false;
- * }
- *
- * ...
- * }
- *
- * ...
- *
- * BT_ASSERT_PRE(check_complex_precond(...),
- * "Precondition is not satisfied: ...", ...);
- */
-# define BT_ASSERT_PRE_MSG BT_LIB_LOGF
-#else
-# define BT_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0))
-# define BT_ASSERT_PRE_FUNC BT_UNUSED
-# define BT_ASSERT_PRE_MSG(_fmt, ...)
-#endif /* BT_DEV_MODE */
-
-/*
- * Developer mode: asserts that a given variable is not NULL.
- */
-#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \
- BT_ASSERT_PRE((_obj) != NULL, "%s is NULL: ", _obj_name)
-
-/*
- * Developer mode: asserts that a given object is NOT frozen. This macro
- * checks the `frozen` field of _obj.
- */
-#define BT_ASSERT_PRE_HOT(_obj, _obj_name, _fmt, ...) \
- BT_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name, \
- ##__VA_ARGS__)
-
-/*
- * Developer mode: asserts that a given index is less than a given size.
- */
-#define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
- BT_ASSERT_PRE((_index) < (_length), \
- "Index is out of bounds: index=%" PRIu64 ", " \
- "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
-
-#endif /* BABELTRACE_ASSERT_PRE_INTERNAL_H */
+++ /dev/null
-#ifndef _BABELTRACE_INTERNAL_H
-#define _BABELTRACE_INTERNAL_H
-
-/*
- * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <stdio.h>
-#include <glib.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <babeltrace/compat/string-internal.h>
-#include <babeltrace/types.h>
-
-#define PERROR_BUFLEN 200
-
-#ifndef likely
-# ifdef __GNUC__
-# define likely(x) __builtin_expect(!!(x), 1)
-# else
-# define likely(x) (!!(x))
-# endif
-#endif
-
-#ifndef unlikely
-# ifdef __GNUC__
-# define unlikely(x) __builtin_expect(!!(x), 0)
-# else
-# define unlikely(x) (!!(x))
-# endif
-#endif
-
-#ifndef min
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef max
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef max_t
-#define max_t(type, a, b) \
- ((type) (a) > (type) (b) ? (type) (a) : (type) (b))
-#endif
-
-static inline
-bool bt_safe_to_mul_int64(int64_t a, int64_t b)
-{
- if (a == 0 || b == 0) {
- return true;
- }
-
- return a < INT64_MAX / b;
-}
-
-static inline
-bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b)
-{
- if (a == 0 || b == 0) {
- return true;
- }
-
- return a < UINT64_MAX / b;
-}
-
-static inline
-bool bt_safe_to_add_int64(int64_t a, int64_t b)
-{
- return a <= INT64_MAX - b;
-}
-
-static inline
-bool bt_safe_to_add_uint64(uint64_t a, uint64_t b)
-{
- return a <= UINT64_MAX - b;
-}
-
-/*
- * Memory allocation zeroed
- */
-#define zmalloc(x) calloc(1, x)
-
-/*
- * BT_HIDDEN: set the hidden attribute for internal functions
- * On Windows, symbols are local unless explicitly exported,
- * see https://gcc.gnu.org/wiki/Visibility
- */
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define BT_HIDDEN
-#else
-#define BT_HIDDEN __attribute__((visibility("hidden")))
-#endif
-
-#ifndef __STRINGIFY
-#define __STRINGIFY(x) #x
-#endif
-
-#define TOSTRING(x) __STRINGIFY(x)
-
-#define BT_UNUSED __attribute__((unused))
-
-#endif
+++ /dev/null
-#ifndef BABELTRACE_BABELTRACE_H
-#define BABELTRACE_BABELTRACE_H
-
-/*
- * Babeltrace API
- *
- * Copyright 2010-2018 EfficiOS Inc. <http://www.efficios.com/>
- *
- * 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.
- */
-
-/* Core API */
-#include <babeltrace/logging.h>
-#include <babeltrace/property.h>
-#include <babeltrace/types.h>
-#include <babeltrace/util.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value.h>
-#include <babeltrace/version.h>
-
-/* Legacy API (for CTF writer) */
-#include <babeltrace/ctf/events.h>
-
-/* CTF writer API */
-#include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/visitor.h>
-#include <babeltrace/ctf-writer/writer.h>
-
-/* Legacy API (for CTF writer) */
-#include <babeltrace/ctf-ir/clock.h>
-#include <babeltrace/ctf-ir/event-fields.h>
-#include <babeltrace/ctf-ir/event-types.h>
-#include <babeltrace/ctf-ir/event.h>
-#include <babeltrace/ctf-ir/field-types.h>
-#include <babeltrace/ctf-ir/fields.h>
-#include <babeltrace/ctf-ir/stream-class.h>
-#include <babeltrace/ctf-ir/stream.h>
-#include <babeltrace/ctf-ir/trace.h>
-#include <babeltrace/ctf-ir/utils.h>
-
-/* Trace IR API */
-#include <babeltrace/trace-ir/clock-class-const.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-snapshot-const.h>
-#include <babeltrace/trace-ir/event-class-const.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event-const.h>
-#include <babeltrace/trace-ir/event.h>
-#include <babeltrace/trace-ir/field-class-const.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field-const.h>
-#include <babeltrace/trace-ir/field-path-const.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/packet-const.h>
-#include <babeltrace/trace-ir/packet-context-field.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/stream-class-const.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream-const.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/trace-class-const.h>
-#include <babeltrace/trace-ir/trace-class.h>
-#include <babeltrace/trace-ir/trace-const.h>
-#include <babeltrace/trace-ir/trace.h>
-
-/* Plugin and plugin development API */
-#include <babeltrace/plugin/plugin-const.h>
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/plugin/plugin-set-const.h>
-
-/* Graph, component, and message API */
-#include <babeltrace/graph/component-class-const.h>
-#include <babeltrace/graph/component-class-filter-const.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink-const.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/component-class-source-const.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-const.h>
-#include <babeltrace/graph/component-filter-const.h>
-#include <babeltrace/graph/component-sink-const.h>
-#include <babeltrace/graph/component-source-const.h>
-#include <babeltrace/graph/connection-const.h>
-#include <babeltrace/graph/graph-const.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/message-discarded-events-const.h>
-#include <babeltrace/graph/message-discarded-events.h>
-#include <babeltrace/graph/message-discarded-packets-const.h>
-#include <babeltrace/graph/message-discarded-packets.h>
-#include <babeltrace/graph/message-event-const.h>
-#include <babeltrace/graph/message-event.h>
-#include <babeltrace/graph/message-iterator-const.h>
-#include <babeltrace/graph/message-message-iterator-inactivity-const.h>
-#include <babeltrace/graph/message-message-iterator-inactivity.h>
-#include <babeltrace/graph/message-packet-beginning-const.h>
-#include <babeltrace/graph/message-packet-beginning.h>
-#include <babeltrace/graph/message-packet-end-const.h>
-#include <babeltrace/graph/message-packet-end.h>
-#include <babeltrace/graph/message-stream-activity-beginning-const.h>
-#include <babeltrace/graph/message-stream-activity-beginning.h>
-#include <babeltrace/graph/message-stream-activity-const.h>
-#include <babeltrace/graph/message-stream-activity-end-const.h>
-#include <babeltrace/graph/message-stream-activity-end.h>
-#include <babeltrace/graph/message-stream-beginning-const.h>
-#include <babeltrace/graph/message-stream-beginning.h>
-#include <babeltrace/graph/message-stream-end-const.h>
-#include <babeltrace/graph/message-stream-end.h>
-#include <babeltrace/graph/port-const.h>
-#include <babeltrace/graph/port-input-const.h>
-#include <babeltrace/graph/port-output-const.h>
-#include <babeltrace/graph/port-output-message-iterator.h>
-#include <babeltrace/graph/query-executor-const.h>
-#include <babeltrace/graph/query-executor.h>
-#include <babeltrace/graph/self-component-class-filter.h>
-#include <babeltrace/graph/self-component-class-sink.h>
-#include <babeltrace/graph/self-component-class-source.h>
-#include <babeltrace/graph/self-component-filter.h>
-#include <babeltrace/graph/self-component-port-input-message-iterator.h>
-#include <babeltrace/graph/self-component-port-input.h>
-#include <babeltrace/graph/self-component-port-output.h>
-#include <babeltrace/graph/self-component-port.h>
-#include <babeltrace/graph/self-component-sink.h>
-#include <babeltrace/graph/self-component-source.h>
-#include <babeltrace/graph/self-component.h>
-#include <babeltrace/graph/self-message-iterator.h>
-
-#endif /* BABELTRACE_BABELTRACE_H */
+++ /dev/null
-#ifndef _BABELTRACE_BITFIELD_H
-#define _BABELTRACE_BITFIELD_H
-
-/*
- * Copyright 2010-2019 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <stdint.h> /* C99 5.2.4.2 Numerical limits */
-#include <stdbool.h> /* C99 7.16 bool type */
-#include <babeltrace/compat/limits-internal.h> /* C99 5.2.4.2 Numerical limits */
-#include <babeltrace/endian-internal.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
-
-/*
- * This header strictly follows the C99 standard, except for use of the
- * compiler-specific __typeof__.
- */
-
-/*
- * This bitfield header requires the compiler representation of signed
- * integers to be two's complement.
- */
-#if (-1 != ~0)
-#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
-#endif
-
-/*
- * _bt_is_signed_type() willingly generates comparison of unsigned
- * expression < 0, which is always false. Silence compiler warnings.
- */
-#ifdef __GNUC__
-# define _BT_DIAG_PUSH _Pragma("GCC diagnostic push")
-# define _BT_DIAG_POP _Pragma("GCC diagnostic pop")
-
-# define _BT_DIAG_STRINGIFY_1(x) #x
-# define _BT_DIAG_STRINGIFY(x) _BT_DIAG_STRINGIFY_1(x)
-
-# define _BT_DIAG_IGNORE(option) \
- _Pragma(_BT_DIAG_STRINGIFY(GCC diagnostic ignored option))
-# define _BT_DIAG_IGNORE_TYPE_LIMITS _BT_DIAG_IGNORE("-Wtype-limits")
-#else
-# define _BT_DIAG_PUSH
-# define _BT_DIAG_POP
-# define _BT_DIAG_IGNORE
-#endif
-
-#define _bt_is_signed_type(type) ((type) -1 < (type) 0)
-
-/*
- * Produce a build-time error if the condition `cond` is non-zero.
- * Evaluates as a size_t expression.
- */
-#define _BT_BUILD_ASSERT(cond) \
- sizeof(struct { int f:(2 * !!(cond) - 1); })
-
-/*
- * Cast value `v` to an unsigned integer of the same size as `v`.
- */
-#define _bt_cast_value_to_unsigned(v) \
- (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) : \
- sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) : \
- sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) : \
- sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) : \
- _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * Cast value `v` to an unsigned integer type of the size of type `type`
- * *without* sign-extension.
- *
- * The unsigned cast ensures that we're not shifting a negative value,
- * which is undefined in C. However, this limits the maximum type size
- * of `type` to 64-bit. Generate a compile-time error if the size of
- * `type` is larger than 64-bit.
- */
-#define _bt_cast_value_to_unsigned_type(type, v) \
- (sizeof(type) == sizeof(uint8_t) ? \
- (uint8_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint16_t) ? \
- (uint16_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint32_t) ? \
- (uint32_t) _bt_cast_value_to_unsigned(v) : \
- sizeof(type) == sizeof(uint64_t) ? \
- (uint64_t) _bt_cast_value_to_unsigned(v) : \
- _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
-
-/*
- * _bt_fill_mask evaluates to a "type" integer with all bits set.
- */
-#define _bt_fill_mask(type) ((type) ~(type) 0)
-
-/*
- * Left shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, left shift of a left hand-side signed
- * type is undefined if it has a negative value or if the result cannot
- * be represented in the result type. This bitfield header discards the
- * bits that are left-shifted beyond the result type representation,
- * which is the behavior of an unsigned type left shift operation.
- * Therefore, always perform left shift on an unsigned type.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_lshift`.
- */
-#define _bt_lshift(v, shift) \
- ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * cleared, and the most significant bits set.
- */
-#define _bt_make_mask_complement(type, length) \
- _bt_lshift(_bt_fill_mask(type), length)
-
-/*
- * Generate a mask of type `type` with the `length` least significant bits
- * set, and the most significant bits cleared.
- */
-#define _bt_make_mask(type, length) \
- ((type) ~_bt_make_mask_complement(type, length))
-
-/*
- * Right shift a value `v` of `shift` bits.
- *
- * The type of `v` can be signed or unsigned integer.
- * The value of `shift` must be less than the size of `v` (in bits),
- * otherwise the behavior is undefined.
- * Evaluates to the result of the shift operation.
- *
- * According to the C99 standard, right shift of a left hand-side signed
- * type which has a negative value is implementation defined. This
- * bitfield header relies on the right shift implementation carrying the
- * sign bit. If the compiler implementation has a different behavior,
- * emulate carrying the sign bit.
- *
- * This macro should not be used if `shift` can be greater or equal than
- * the bitwidth of `v`. See `_bt_safe_rshift`.
- */
-#if ((-1 >> 1) == -1)
-#define _bt_rshift(v, shift) ((v) >> (shift))
-#else
-#define _bt_rshift(v, shift) \
- ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) | \
- ((v) < 0 ? _bt_make_mask_complement(__typeof__(v), \
- sizeof(v) * CHAR_BIT - (shift)) : 0)))
-#endif
-
-/*
- * Right shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_rshift(v, shift) \
-do { \
- unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
- unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
- \
- for (; _nr_partial_shifts; _nr_partial_shifts--) \
- (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1); \
- (v) = _bt_rshift(v, _leftover_bits); \
-} while (0)
-
-/*
- * Left shift a signed or unsigned integer with `shift` value being an
- * arbitrary number of bits. `v` is modified by this macro. The shift
- * is transformed into a sequence of `_nr_partial_shifts` consecutive
- * shift operations, each of a number of bits smaller than the bitwidth
- * of `v`, ending with a shift of the number of left over bits.
- */
-#define _bt_safe_lshift(v, shift) \
-do { \
- unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
- unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
- \
- for (; _nr_partial_shifts; _nr_partial_shifts--) \
- (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1); \
- (v) = _bt_lshift(v, _leftover_bits); \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- *
- * Save integer to the bitfield, which starts at the "start" bit, has "len"
- * bits.
- * The inside of a bitfield is from high bits to low bits.
- * Uses native endianness.
- * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
- * For signed "v", sign-extend v if bitfield is larger than v.
- *
- * On little endian, bytes are placed from the less significant to the most
- * significant. Also, consecutive bitfields are placed from lower bits to higher
- * bits.
- *
- * On big endian, bytes are places from most significant to less significant.
- * Also, consecutive bitfields are placed from higher to lower bits.
- */
-
-#define _bt_bitfield_write_le(ptr, type, start, length, v) \
-do { \
- __typeof__(v) _v = (v); \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) \
- break; \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- /* Trim v high bits */ \
- if (_length < sizeof(_v) * CHAR_BIT) \
- _v &= _bt_make_mask(__typeof__(_v), _length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- _this_unit = _start_unit; \
- if (_start_unit == _end_unit - 1) { \
- _mask = _bt_make_mask(type, _start % _ts); \
- if (_end % _ts) \
- _mask |= _bt_make_mask_complement(type, _end % _ts); \
- _cmask = _bt_lshift((type) (_v), _start % _ts); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- break; \
- } \
- if (_start % _ts) { \
- _cshift = _start % _ts; \
- _mask = _bt_make_mask(type, _cshift); \
- _cmask = _bt_lshift((type) (_v), _cshift); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- _bt_safe_rshift(_v, _ts - _cshift); \
- _start += _ts - _cshift; \
- _this_unit++; \
- } \
- for (; _this_unit < _end_unit - 1; _this_unit++) { \
- _ptr[_this_unit] = (type) _v; \
- _bt_safe_rshift(_v, _ts); \
- _start += _ts; \
- } \
- if (_end % _ts) { \
- _mask = _bt_make_mask_complement(type, _end % _ts); \
- _cmask = (type) _v; \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- } else \
- _ptr[_this_unit] = (type) _v; \
-} while (0)
-
-#define _bt_bitfield_write_be(ptr, type, start, length, v) \
-do { \
- __typeof__(v) _v = (v); \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- \
- if (!_length) \
- break; \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- /* Trim v high bits */ \
- if (_length < sizeof(_v) * CHAR_BIT) \
- _v &= _bt_make_mask(__typeof__(_v), _length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- _this_unit = _end_unit - 1; \
- if (_start_unit == _end_unit - 1) { \
- _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
- if (_start % _ts) \
- _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
- _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- break; \
- } \
- if (_end % _ts) { \
- _cshift = _end % _ts; \
- _mask = _bt_make_mask(type, _ts - _cshift); \
- _cmask = _bt_lshift((type) (_v), _ts - _cshift); \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- _bt_safe_rshift(_v, _cshift); \
- _end -= _cshift; \
- _this_unit--; \
- } \
- for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
- _ptr[_this_unit] = (type) _v; \
- _bt_safe_rshift(_v, _ts); \
- _end -= _ts; \
- } \
- if (_start % _ts) { \
- _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
- _cmask = (type) _v; \
- _cmask &= ~_mask; \
- _ptr[_this_unit] &= _mask; \
- _ptr[_this_unit] |= _cmask; \
- } else \
- _ptr[_this_unit] = (type) _v; \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- * bt_bitfield_write_le - write integer to a bitfield in little endian
- * bt_bitfield_write_be - write integer to a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, type, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#define bt_bitfield_write_le(ptr, type, start, length, v) \
- _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
-
-#define bt_bitfield_write_be(ptr, type, start, length, v) \
- _bt_bitfield_write_be(ptr, type, start, length, v)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#define _bt_bitfield_read_le(ptr, type, start, length, vptr) \
-do { \
- __typeof__(*(vptr)) *_vptr = (vptr); \
- __typeof__(*_vptr) _v; \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- bool _is_signed_type; \
- \
- if (!_length) { \
- *_vptr = 0; \
- break; \
- } \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- _this_unit = _end_unit - 1; \
- _BT_DIAG_PUSH \
- _BT_DIAG_IGNORE_TYPE_LIMITS \
- _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \
- _BT_DIAG_POP \
- if (_is_signed_type \
- && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
- _v = ~(__typeof__(_v)) 0; \
- else \
- _v = 0; \
- if (_start_unit == _end_unit - 1) { \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _start % _ts); \
- if ((_end - _start) % _ts) { \
- _mask = _bt_make_mask(type, _end - _start); \
- _cmask &= _mask; \
- } \
- _bt_safe_lshift(_v, _end - _start); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- *_vptr = _v; \
- break; \
- } \
- if (_end % _ts) { \
- _cshift = _end % _ts; \
- _mask = _bt_make_mask(type, _cshift); \
- _cmask = _ptr[_this_unit]; \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _cshift); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- _end -= _cshift; \
- _this_unit--; \
- } \
- for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- _end -= _ts; \
- } \
- if (_start % _ts) { \
- _mask = _bt_make_mask(type, _ts - (_start % _ts)); \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _start % _ts); \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _ts - (_start % _ts)); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- } else { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- } \
- *_vptr = _v; \
-} while (0)
-
-#define _bt_bitfield_read_be(ptr, type, start, length, vptr) \
-do { \
- __typeof__(*(vptr)) *_vptr = (vptr); \
- __typeof__(*_vptr) _v; \
- type *_ptr = (void *) (ptr); \
- unsigned long _start = (start), _length = (length); \
- type _mask, _cmask; \
- unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long _start_unit, _end_unit, _this_unit; \
- unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
- bool _is_signed_type; \
- \
- if (!_length) { \
- *_vptr = 0; \
- break; \
- } \
- \
- _end = _start + _length; \
- _start_unit = _start / _ts; \
- _end_unit = (_end + (_ts - 1)) / _ts; \
- \
- _this_unit = _start_unit; \
- _BT_DIAG_PUSH \
- _BT_DIAG_IGNORE_TYPE_LIMITS \
- _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \
- _BT_DIAG_POP \
- if (_is_signed_type \
- && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
- _v = ~(__typeof__(_v)) 0; \
- else \
- _v = 0; \
- if (_start_unit == _end_unit - 1) { \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
- if ((_end - _start) % _ts) { \
- _mask = _bt_make_mask(type, _end - _start); \
- _cmask &= _mask; \
- } \
- _bt_safe_lshift(_v, _end - _start); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- *_vptr = _v; \
- break; \
- } \
- if (_start % _ts) { \
- _cshift = _start % _ts; \
- _mask = _bt_make_mask(type, _ts - _cshift); \
- _cmask = _ptr[_this_unit]; \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _ts - _cshift); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- _start += _ts - _cshift; \
- _this_unit++; \
- } \
- for (; _this_unit < _end_unit - 1; _this_unit++) { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- _start += _ts; \
- } \
- if (_end % _ts) { \
- _mask = _bt_make_mask(type, _end % _ts); \
- _cmask = _ptr[_this_unit]; \
- _cmask = _bt_rshift(_cmask, _ts - (_end % _ts)); \
- _cmask &= _mask; \
- _bt_safe_lshift(_v, _end % _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
- } else { \
- _bt_safe_lshift(_v, _ts); \
- _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
- } \
- *_vptr = _v; \
-} while (0)
-
-/*
- * bt_bitfield_read - read integer from a bitfield in native endianness
- * bt_bitfield_read_le - read integer from a bitfield in little endian
- * bt_bitfield_read_be - read integer from a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_read(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
- _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
-
-#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
- _bt_bitfield_read_be(ptr, type, start, length, vptr)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#endif /* _BABELTRACE_BITFIELD_H */
+++ /dev/null
-#ifndef BABELTRACE_COMMON_INTERNAL_H
-#define BABELTRACE_COMMON_INTERNAL_H
-
-/*
- * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdbool.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/trace-ir/field-class-const.h>
-#include <babeltrace/trace-ir/field-path-const.h>
-#include <babeltrace/trace-ir/event-class-const.h>
-#include <babeltrace/graph/self-message-iterator.h>
-#include <babeltrace/value.h>
-#include <inttypes.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <glib.h>
-
-#define BT_COMMON_COLOR_RESET "\033[0m"
-#define BT_COMMON_COLOR_BOLD "\033[1m"
-#define BT_COMMON_COLOR_FG_DEFAULT "\033[39m"
-#define BT_COMMON_COLOR_FG_RED "\033[31m"
-#define BT_COMMON_COLOR_FG_GREEN "\033[32m"
-#define BT_COMMON_COLOR_FG_YELLOW "\033[33m"
-#define BT_COMMON_COLOR_FG_BLUE "\033[34m"
-#define BT_COMMON_COLOR_FG_MAGENTA "\033[35m"
-#define BT_COMMON_COLOR_FG_CYAN "\033[36m"
-#define BT_COMMON_COLOR_FG_LIGHT_GRAY "\033[37m"
-#define BT_COMMON_COLOR_BG_DEFAULT "\033[49m"
-#define BT_COMMON_COLOR_BG_RED "\033[41m"
-#define BT_COMMON_COLOR_BG_GREEN "\033[42m"
-#define BT_COMMON_COLOR_BG_YELLOW "\033[43m"
-#define BT_COMMON_COLOR_BG_BLUE "\033[44m"
-#define BT_COMMON_COLOR_BG_MAGENTA "\033[45m"
-#define BT_COMMON_COLOR_BG_CYAN "\033[46m"
-#define BT_COMMON_COLOR_BG_LIGHT_GRAY "\033[47m"
-
-struct bt_common_lttng_live_url_parts {
- GString *proto;
- GString *hostname;
- GString *target_hostname;
- GString *session_name;
-
- /* -1 means default port */
- int port;
-};
-
-/*
- * Checks if the current process has setuid or setgid access rights.
- * Returns `true` if so.
- */
-BT_HIDDEN
-bool bt_common_is_setuid_setgid(void);
-
-/*
- * Returns the system-wide plugin path, e.g.
- * `/usr/lib/babeltrace/plugins`. Do not free the return value.
- */
-BT_HIDDEN
-const char *bt_common_get_system_plugin_path(void);
-
-/*
- * Returns the user plugin path, e.g.
- * `/home/user/.local/lib/babeltrace/plugins`. You need to free the
- * return value.
- */
-BT_HIDDEN
-char *bt_common_get_home_plugin_path(void);
-
-/*
- * Appends the list of directories in `paths` to the array `dirs`.
- * `paths` is a list of directories separated by `:`. Returns 0 on
- * success.
- */
-BT_HIDDEN
-int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs);
-
-/*
- * Returns `true` if terminal color codes are supported for this
- * process.
- */
-BT_HIDDEN
-bool bt_common_colors_supported(void);
-
-BT_HIDDEN
-const char *bt_common_color_reset(void);
-
-BT_HIDDEN
-const char *bt_common_color_bold(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_default(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_red(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_green(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_yellow(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_blue(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_magenta(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_cyan(void);
-
-BT_HIDDEN
-const char *bt_common_color_fg_light_gray(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_default(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_red(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_green(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_yellow(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_blue(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_magenta(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_cyan(void);
-
-BT_HIDDEN
-const char *bt_common_color_bg_light_gray(void);
-
-/*
- * Returns the substring from `input` to the first character found
- * in the list of characters `end_chars`, unescaping any character
- * found in `escapable_chars`, and sets `*end_pos` to the position of
- * the end (from `input`). The caller owns the returned GString.
- */
-BT_HIDDEN
-GString *bt_common_string_until(const char *input, const char *escapable_chars,
- const char *end_chars, size_t *end_pos);
-
-/*
- * Returns the quoted version of `input` for a shell. If
- * `with_single_quotes` is `true`, prepends and appends the `'` prefix
- * and suffix to the returned string; otherwise the caller should
- * prepend and append them manually, although they are not always
- * required. The caller owns the returned GString.
- */
-BT_HIDDEN
-GString *bt_common_shell_quote(const char *input, bool with_single_quotes);
-
-/*
- * Returns `true` if `input` is a string made only of printable
- * characters.
- */
-BT_HIDDEN
-bool bt_common_string_is_printable(const char *input);
-
-/*
- * Destroys the parts of an LTTng live URL as returned by
- * bt_common_parse_lttng_live_url().
- */
-BT_HIDDEN
-void bt_common_destroy_lttng_live_url_parts(
- struct bt_common_lttng_live_url_parts *parts);
-
-/*
- * Parses the LTTng live URL `url` and returns its different parts.
- * If there's an error, writes the error message into `*error_buf`
- * up to `error_buf_size` bytes. You must destroy the returned value
- * with bt_common_destroy_lttng_live_url_parts().
- */
-BT_HIDDEN
-struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url(
- const char *url, char *error_buf, size_t error_buf_size);
-
-/*
- * Normalizes (in place) a star globbing pattern to be used with
- * bt_common_star_glob_match(). This function always succeeds.
- */
-BT_HIDDEN
-void bt_common_normalize_star_glob_pattern(char *pattern);
-
-/*
- * Returns `true` if `candidate` (of size `candidate_len`) matches
- * the star globbing pattern `pattern` (of size `pattern_len`).
- */
-BT_HIDDEN
-bool bt_common_star_glob_match(const char *pattern, size_t pattern_len,
- const char *candidate, size_t candidate_len);
-
-/*
- * Normalizes the path `path`:
- *
- * * If it's a relative path, converts it to an absolute path using
- * `wd` as the working directory (or the current working directory
- * if `wd` is NULL).
- * * Removes consecutive and trailing slashes.
- * * Resolves `..` and `.` in the path (both in `path` and in `wd`).
- * * Does NOT resolve symbolic links.
- *
- * The caller owns the returned GString.
- */
-BT_HIDDEN
-GString *bt_common_normalize_path(const char *path, const char *wd);
-
-typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data,
- char **buf, size_t avail_size, const char **fmt, va_list *args);
-
-/*
- * This is a custom vsnprintf() which handles the standard conversion
- * specifier as well as custom ones.
- *
- * `fmt` is a typical printf()-style format string, with the following
- * limitations:
- *
- * * The `*` width specifier is not accepted.
- * * The `*` precision specifier is not accepted.
- * * The `j` and `t` length modifiers are not accepted.
- * * The `n` format specifier is not accepted.
- * * The format specifiers defined in <inttypes.h> are not accepted
- * except for `PRId64`, `PRIu64`, `PRIx64`, `PRIX64`, `PRIo64`, and
- * `PRIi64`.
- *
- * `intro` specifies which special character immediately following an
- * introductory `%` character in `fmt` is used to indicate a custom
- * conversion specifier. For example, if `intro` is '@', then any `%@`
- * sequence in `fmt` is the beginning of a custom conversion specifier.
- *
- * When a custom conversion specifier is encountered in `fmt`,
- * the function calls `handle_specifier`. This callback receives:
- *
- * `priv_data`:
- * Custom, private data.
- *
- * `buf`:
- * Address of the current buffer pointer. `*buf` is the position to
- * append new data. The callback must update `*buf` when appending
- * new data. The callback must ensure not to write passed the whole
- * buffer passed to bt_common_custom_vsnprintf().
- *
- * `avail_size`:
- * Number of bytes left in whole buffer from the `*buf` point.
- *
- * `fmt`:
- * Address of the current format string pointer. `*fmt` points to
- * the introductory `%` character, which is followed by the
- * character `intro`. The callback must update `*fmt` so that it
- * points after the whole custom conversion specifier.
- *
- * `args`:
- * Variable argument list. Use va_arg() to get new arguments from
- * this list and update it at the same time.
- *
- * Because this is an internal utility, this function and its callback
- * do not return error codes: they abort when there's any error (bad
- * format string, for example).
- */
-BT_HIDDEN
-void bt_common_custom_vsnprintf(char *buf, size_t buf_size,
- char intro,
- bt_common_handle_custom_specifier_func handle_specifier,
- void *priv_data, const char *fmt, va_list *args);
-
-/*
- * Variadic form of bt_common_custom_vsnprintf().
- */
-BT_HIDDEN
-void bt_common_custom_snprintf(char *buf, size_t buf_size,
- char intro,
- bt_common_handle_custom_specifier_func handle_specifier,
- void *priv_data, const char *fmt, ...);
-
-/*
- * Returns the system page size.
- */
-BT_HIDDEN
-size_t bt_common_get_page_size(void);
-
-/*
- * Wraps read() function to handle EINTR and partial reads.
- * On success, it returns `count` received as parameter. On error, it returns a
- * value smaller than the requested `count`.
- */
-static inline
-ssize_t bt_common_read(int fd, void *buf, size_t count)
-{
- size_t i = 0;
- ssize_t ret;
-
- BT_ASSERT(buf);
-
- /* Never return an overflow value. */
- BT_ASSERT(count <= SSIZE_MAX);
-
- do {
- ret = read(fd, buf + i, count - i);
- if (ret < 0) {
- if (errno == EINTR) {
-#ifdef BT_LOGD_STR
- BT_LOGD_STR("read() call interrupted. Retrying...");
-#endif
- /* retry operation */
- continue;
- } else {
-#ifdef BT_LOGE_ERRNO
- BT_LOGE_ERRNO("Error while reading", ": fd=%d",
- fd);
-#endif
- goto end;
- }
- }
- i += ret;
- BT_ASSERT(i <= count);
- } while (count - i > 0 && ret > 0);
-
-end:
- if (ret >= 0) {
- if (i == 0) {
- ret = -1;
- } else {
- ret = i;
- }
- }
-
- return ret;
-}
-
-static inline
-const char *bt_common_field_class_type_string(enum bt_field_class_type class_type)
-{
- switch (class_type) {
- case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
- return "BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER";
- case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
- return "BT_FIELD_CLASS_TYPE_SIGNED_INTEGER";
- case BT_FIELD_CLASS_TYPE_REAL:
- return "BT_FIELD_CLASS_TYPE_REAL";
- case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
- return "BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION";
- case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
- return "BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION";
- case BT_FIELD_CLASS_TYPE_STRING:
- return "BT_FIELD_CLASS_TYPE_STRING";
- case BT_FIELD_CLASS_TYPE_STRUCTURE:
- return "BT_FIELD_CLASS_TYPE_STRUCTURE";
- case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- return "BT_FIELD_CLASS_TYPE_STATIC_ARRAY";
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
- return "BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY";
- case BT_FIELD_CLASS_TYPE_VARIANT:
- return "BT_FIELD_CLASS_TYPE_VARIANT";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_common_field_class_integer_preferred_display_base_string(enum bt_field_class_integer_preferred_display_base base)
-{
- switch (base) {
- case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
- return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY";
- case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
- return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL";
- case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
- return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL";
- case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
- return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_common_scope_string(enum bt_scope scope)
-{
- switch (scope) {
- case BT_SCOPE_PACKET_CONTEXT:
- return "BT_SCOPE_PACKET_CONTEXT";
- case BT_SCOPE_EVENT_COMMON_CONTEXT:
- return "BT_SCOPE_EVENT_COMMON_CONTEXT";
- case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
- return "BT_SCOPE_EVENT_SPECIFIC_CONTEXT";
- case BT_SCOPE_EVENT_PAYLOAD:
- return "BT_SCOPE_EVENT_PAYLOAD";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_common_event_class_log_level_string(
- enum bt_event_class_log_level level)
-{
- switch (level) {
- case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
- return "BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY";
- case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
- return "BT_EVENT_CLASS_LOG_LEVEL_ALERT";
- case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
- return "BT_EVENT_CLASS_LOG_LEVEL_CRITICAL";
- case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
- return "BT_EVENT_CLASS_LOG_LEVEL_ERROR";
- case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
- return "BT_EVENT_CLASS_LOG_LEVEL_WARNING";
- case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
- return "BT_EVENT_CLASS_LOG_LEVEL_NOTICE";
- case BT_EVENT_CLASS_LOG_LEVEL_INFO:
- return "BT_EVENT_CLASS_LOG_LEVEL_INFO";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE";
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
- return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_common_value_type_string(enum bt_value_type type)
-{
- switch (type) {
- case BT_VALUE_TYPE_NULL:
- return "BT_VALUE_TYPE_NULL";
- case BT_VALUE_TYPE_BOOL:
- return "BT_VALUE_TYPE_BOOL";
- case BT_VALUE_TYPE_UNSIGNED_INTEGER:
- return "BT_VALUE_TYPE_UNSIGNED_INTEGER";
- case BT_VALUE_TYPE_SIGNED_INTEGER:
- return "BT_VALUE_TYPE_SIGNED_INTEGER";
- case BT_VALUE_TYPE_REAL:
- return "BT_VALUE_TYPE_REAL";
- case BT_VALUE_TYPE_STRING:
- return "BT_VALUE_TYPE_STRING";
- case BT_VALUE_TYPE_ARRAY:
- return "BT_VALUE_TYPE_ARRAY";
- case BT_VALUE_TYPE_MAP:
- return "BT_VALUE_TYPE_MAP";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-GString *bt_common_field_path_string(struct bt_field_path *path)
-{
- GString *str = g_string_new(NULL);
- uint64_t i;
-
- BT_ASSERT(path);
-
- if (!str) {
- goto end;
- }
-
- g_string_append_printf(str, "[%s", bt_common_scope_string(
- bt_field_path_get_root_scope(path)));
-
- for (i = 0; i < bt_field_path_get_item_count(path); i++) {
- const struct bt_field_path_item *fp_item =
- bt_field_path_borrow_item_by_index_const(path, i);
-
- switch (bt_field_path_item_get_type(fp_item)) {
- case BT_FIELD_PATH_ITEM_TYPE_INDEX:
- g_string_append_printf(str, ", %" PRIu64,
- bt_field_path_item_index_get_index(fp_item));
- break;
- case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
- g_string_append(str, ", <CUR>");
- break;
- default:
- abort();
- }
- }
-
- g_string_append(str, "]");
-
-end:
- return str;
-}
-
-static inline
-const char *bt_common_self_message_iterator_status_string(
- enum bt_self_message_iterator_status status)
-{
- switch (status) {
- case BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN:
- return "BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN";
- case BT_SELF_MESSAGE_ITERATOR_STATUS_END:
- return "BT_SELF_MESSAGE_ITERATOR_STATUS_END";
- case BT_SELF_MESSAGE_ITERATOR_STATUS_OK:
- return "BT_SELF_MESSAGE_ITERATOR_STATUS_OK";
- case BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR:
- return "BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR";
- case BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM:
- return "BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-};
-
-#define NS_PER_S_I INT64_C(1000000000)
-#define NS_PER_S_U UINT64_C(1000000000)
-
-static inline
-int bt_common_clock_value_from_ns_from_origin(
- int64_t cc_offset_seconds, uint64_t cc_offset_cycles,
- uint64_t cc_freq, int64_t ns_from_origin,
- uint64_t *raw_value)
-{
- int ret = 0;
- int64_t offset_in_ns;
- uint64_t value_in_ns;
- uint64_t rem_value_in_ns;
- uint64_t value_periods;
- uint64_t value_period_cycles;
- int64_t ns_to_add;
-
- BT_ASSERT(raw_value);
-
- /* Compute offset part of requested value, in nanoseconds */
- if (!bt_safe_to_mul_int64(cc_offset_seconds, NS_PER_S_I)) {
- ret = -1;
- goto end;
- }
-
- offset_in_ns = cc_offset_seconds * NS_PER_S_I;
-
- if (cc_freq == NS_PER_S_U) {
- ns_to_add = (int64_t) cc_offset_cycles;
- } else {
- if (!bt_safe_to_mul_int64((int64_t) cc_offset_cycles,
- NS_PER_S_I)) {
- ret = -1;
- goto end;
- }
-
- ns_to_add = ((int64_t) cc_offset_cycles * NS_PER_S_I) /
- (int64_t) cc_freq;
- }
-
- if (!bt_safe_to_add_int64(offset_in_ns, ns_to_add)) {
- ret = -1;
- goto end;
- }
-
- offset_in_ns += ns_to_add;
-
- /* Value part in nanoseconds */
- if (ns_from_origin < offset_in_ns) {
- ret = -1;
- goto end;
- }
-
- value_in_ns = (uint64_t) (ns_from_origin - offset_in_ns);
-
- /* Number of whole clock periods in `value_in_ns` */
- value_periods = value_in_ns / NS_PER_S_U;
-
- /* Remaining nanoseconds in cycles + whole clock periods in cycles */
- rem_value_in_ns = value_in_ns - value_periods * NS_PER_S_U;
-
- if (value_periods > UINT64_MAX / cc_freq) {
- ret = -1;
- goto end;
- }
-
- if (!bt_safe_to_mul_uint64(value_periods, cc_freq)) {
- ret = -1;
- goto end;
- }
-
- value_period_cycles = value_periods * cc_freq;
-
- if (!bt_safe_to_mul_uint64(cc_freq, rem_value_in_ns)) {
- ret = -1;
- goto end;
- }
-
- if (!bt_safe_to_add_uint64(cc_freq * rem_value_in_ns / NS_PER_S_U,
- value_period_cycles)) {
- ret = -1;
- goto end;
- }
-
- *raw_value = cc_freq * rem_value_in_ns / NS_PER_S_U +
- value_period_cycles;
-
-end:
- return ret;
-}
-
-static inline
-enum bt_self_message_iterator_status bt_common_message_iterator_status_to_self(
- enum bt_message_iterator_status status)
-{
- return (int) status;
-}
-#endif /* BABELTRACE_COMMON_INTERNAL_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_FCNTL_H
-#define _BABELTRACE_COMPAT_FCNTL_H
-
-/*
- * Copyright 2015 (c) - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * fcntl compatibility layer.
- *
- * 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.
- */
-
-#ifdef BABELTRACE_HAVE_POSIX_FALLOCATE
-
-#include <fcntl.h>
-
-static inline
-int bt_posix_fallocate(int fd, off_t offset, off_t len)
-{
- return posix_fallocate(fd, offset, len);
-}
-
-#elif defined(__MINGW32__) /* #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
-
-#include <stdlib.h>
-#include <windows.h>
-#include <fcntl.h>
-
-static inline
-int bt_posix_fallocate(int fd, off_t offset, off_t len)
-{
- HANDLE handle;
- LARGE_INTEGER pos, file_pos, orig_end_offset, range_end;
- int ret = 0;
- char zero = 0;
- DWORD byteswritten;
-
- if (offset < 0 || len <= 0) {
- ret = EINVAL;
- goto end;
- }
-
- range_end.QuadPart = (__int64) offset + (__int64) len;
-
- /* Get a handle from the fd */
- handle = (HANDLE) _get_osfhandle(fd);
- if (handle == INVALID_HANDLE_VALUE) {
- ret = EBADF;
- goto end;
- }
-
- /* Get the file original end offset */
- ret = GetFileSizeEx(handle, &orig_end_offset);
- if (ret == 0) {
- ret = EBADF;
- goto end;
- }
-
- /* Make sure we don't truncate the file */
- if (orig_end_offset.QuadPart >= range_end.QuadPart) {
- ret = 0;
- goto end;
- }
-
- /* Get the current file pointer position */
- pos.QuadPart = 0;
- ret = SetFilePointerEx(handle, pos, &file_pos, FILE_CURRENT);
- if (ret == 0) {
- ret = EBADF;
- goto end;
- }
-
- /* Move the file pointer to the new end offset */
- ret = SetFilePointerEx(handle, range_end, NULL, FILE_BEGIN);
- if (ret == 0) {
- ret = EBADF;
- goto end;
- }
-
- /* Sets the physical file size to the current position */
- ret = SetEndOfFile(handle);
- if (ret == 0) {
- ret = EINVAL;
- goto restore;
- }
-
- /*
- * Move the file pointer back 1 byte, and write a single 0 at the
- * last byte of the new end offset, the operating system will zero
- * fill the file.
- */
- pos.QuadPart = -1;
- ret = SetFilePointerEx(handle, pos, NULL, FILE_END);
- if (ret == 0) {
- ret = EBADF;
- goto end;
- }
-
- ret = WriteFile(handle, &zero, 1, &byteswritten, NULL);
- if (ret == 0 || byteswritten != 1) {
- ret = ENOSPC;
- } else {
- ret = 0;
- }
-
-restore:
- /* Restore the original file pointer position */
- if (!SetFilePointerEx(handle, file_pos, NULL, FILE_BEGIN)) {
- /* We moved the file pointer but failed to restore it. */
- abort();
- }
-
-end:
- return ret;
-}
-
-#else
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-
-#define BABELTRACE_FALLOCATE_BUFLEN 256
-
-#ifndef min_t
-#define min_t(type, a, b) \
- ((type) (a) < (type) (b) ? (type) (a) : (type) (b))
-#endif
-
-static inline
-int bt_posix_fallocate(int fd, off_t offset, off_t len)
-{
- int ret = 0;
- ssize_t copy_len;
- char buf[BABELTRACE_FALLOCATE_BUFLEN];
- off_t i, file_pos, orig_end_offset, range_end;
-
- if (offset < 0 || len < 0) {
- ret = EINVAL;
- goto end;
- }
-
- range_end = offset + len;
- if (range_end < 0) {
- ret = EFBIG;
- goto end;
- }
-
- file_pos = lseek(fd, 0, SEEK_CUR);
- if (file_pos < 0) {
- ret = errno;
- goto end;
- }
-
- orig_end_offset = lseek(fd, 0, SEEK_END);
- if (orig_end_offset < 0) {
- ret = errno;
- goto end;
- }
-
- /* Seek back to original position. */
- ret = lseek(fd, file_pos, SEEK_SET);
- if (ret) {
- ret = errno;
- goto end;
- }
-
- /*
- * The file may not need to grow, but we want to ensure the
- * space has actually been reserved by the file system. First, copy
- * the "existing" region of the file, then grow the file if needed.
- */
- for (i = file_pos; i < min_t(off_t, range_end, orig_end_offset);
- i += copy_len) {
- ssize_t copy_ret;
-
- copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
- min_t(off_t, range_end - i,
- orig_end_offset - i));
- copy_ret = pread(fd, &buf, copy_len, i);
- if (copy_ret < copy_len) {
- /*
- * The caller must handle any EINTR.
- * POSIX_FALLOCATE(3) does not mention EINTR.
- * However, glibc does forward to fallocate()
- * directly on Linux, which may be interrupted.
- */
- ret = errno;
- goto end;
- }
-
- copy_ret = pwrite(fd, &buf, copy_len, i);
- if (copy_ret < copy_len) {
- /* Same caveat as noted at pread() */
- ret = errno;
- goto end;
- }
- }
-
- /* Grow file, as necessary. */
- memset(&buf, 0, BABELTRACE_FALLOCATE_BUFLEN);
- for (i = orig_end_offset; i < range_end; i += copy_len) {
- ssize_t write_ret;
-
- copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
- range_end - i);
- write_ret = pwrite(fd, &buf, copy_len, i);
- if (write_ret < copy_len) {
- ret = errno;
- goto end;
- }
- }
-end:
- return ret;
-}
-#endif /* #else #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
-
-#endif /* _BABELTRACE_COMPAT_FCNTL_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_GLIB_H
-#define _BABELTRACE_COMPAT_GLIB_H
-
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * 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 <glib.h>
-
-#if GLIB_CHECK_VERSION(2,31,8)
-
-static inline gboolean
-bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
-{
- return g_hash_table_contains(hash_table, key);
-}
-
-#else
-
-static inline gboolean
-bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
-{
- gpointer orig_key;
- gpointer value;
-
- return g_hash_table_lookup_extended(hash_table, key, &orig_key,
- &value);
-}
-
-#endif
-
-
-#if GLIB_CHECK_VERSION(2,29,16)
-
-static inline GPtrArray *
-bt_g_ptr_array_new_full(guint reserved_size,
- GDestroyNotify element_free_func)
-{
- return g_ptr_array_new_full(reserved_size, element_free_func);
-}
-
-#else
-
-static inline GPtrArray *
-bt_g_ptr_array_new_full(guint reserved_size,
- GDestroyNotify element_free_func)
-{
- GPtrArray *array;
-
- array = g_ptr_array_sized_new(reserved_size);
- if (!array) {
- goto end;
- }
- g_ptr_array_set_free_func(array, element_free_func);
-end:
- return array;
-}
-#endif
-
-#endif /* _BABELTRACE_COMPAT_GLIB_H */
+++ /dev/null
-#ifndef _BABELTRACE_LIMITS_H
-#define _BABELTRACE_LIMITS_H
-
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <limits.h>
-
-#ifdef __linux__
-
-#define BABELTRACE_HOST_NAME_MAX HOST_NAME_MAX
-
-#elif defined(__FreeBSD__)
-
-#define BABELTRACE_HOST_NAME_MAX MAXHOSTNAMELEN
-
-#elif defined(_POSIX_HOST_NAME_MAX)
-
-#define BABELTRACE_HOST_NAME_MAX _POSIX_HOST_NAME_MAX
-
-#else
-
-#define BABELTRACE_HOST_NAME_MAX 256
-
-#endif /* __linux__, __FreeBSD__, _POSIX_HOST_NAME_MAX */
-
-#endif /* _BABELTRACE_LIMITS_H */
+++ /dev/null
-#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-
-/*
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * memstream compatibility layer.
- *
- * 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.
- */
-
-#ifdef BABELTRACE_HAVE_FMEMOPEN
-#include <stdio.h>
-
-static inline
-FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
-{
- return fmemopen(buf, size, mode);
-}
-
-#else /* BABELTRACE_HAVE_FMEMOPEN */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <babeltrace/endian-internal.h>
-
-#ifdef __MINGW32__
-
-#include <io.h>
-#include <glib.h>
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
-{
- char *tmpname;
- size_t len;
- FILE *fp;
- int ret;
-
- /*
- * Support reading only.
- */
- if (strcmp(mode, "rb") != 0) {
- return NULL;
- }
-
- /* Build a temporary filename */
- tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
- if (_mktemp(tmpname) == NULL) {
- goto error_free;
- }
-
- /*
- * Open as a read/write binary temporary deleted on close file.
- * Will be deleted when the last file pointer is closed.
- */
- fp = fopen(tmpname, "w+bTD");
- if (!fp) {
- goto error_free;
- }
-
- /* Copy the entire buffer to the file */
- len = fwrite(buf, sizeof(char), size, fp);
- if (len != size) {
- goto error_close;
- }
-
- /* Set the file pointer to the start of file */
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- perror("fseek");
- goto error_close;
- }
-
- g_free(tmpname);
- return fp;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- perror("close");
- }
-error_free:
- g_free(tmpname);
- return NULL;
-}
-
-#else /* __MINGW32__ */
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
-{
- char *tmpname;
- size_t len;
- FILE *fp;
- int ret;
-
- /*
- * Support reading only.
- */
- if (strcmp(mode, "rb") != 0) {
- return NULL;
- }
-
- tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
- ret = mkstemp(tmpname);
- if (ret < 0) {
- g_free(tmpname);
- return NULL;
- }
- /*
- * We need to write to the file.
- */
- fp = fdopen(ret, "wb+");
- if (!fp) {
- goto error_unlink;
- }
- /* Copy the entire buffer to the file */
- len = fwrite(buf, sizeof(char), size, fp);
- if (len != size) {
- goto error_close;
- }
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- perror("fseek");
- goto error_close;
- }
- /* We keep the handle open, but can unlink the file on the VFS. */
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- g_free(tmpname);
- return fp;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- perror("close");
- }
-error_unlink:
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- g_free(tmpname);
- return NULL;
-}
-
-#endif /* __MINGW32__ */
-
-#endif /* BABELTRACE_HAVE_FMEMOPEN */
-
-
-#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
-
-#include <stdio.h>
-
-static inline
-FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
-{
- return open_memstream(ptr, sizeloc);
-}
-
-static inline
-int bt_close_memstream(char **buf, size_t *size, FILE *fp)
-{
- return fclose(fp);
-}
-
-#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-
-#ifdef __MINGW32__
-
-/*
- * Fallback for systems which don't have open_memstream. Create FILE *
- * with bt_open_memstream, but require call to
- * bt_close_memstream to flush all data written to the FILE *
- * into the buffer (which we allocate).
- */
-static inline
-FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
-{
- char *tmpname;
- FILE *fp;
-
- tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
-
- if (_mktemp(tmpname) == NULL) {
- goto error_free;
- }
-
- /*
- * Open as a read/write binary temporary deleted on close file.
- * Will be deleted when the last file pointer is closed.
- */
- fp = fopen(tmpname, "w+bTD");
- if (!fp) {
- goto error_free;
- }
-
- g_free(tmpname);
- return fp;
-
-error_free:
- g_free(tmpname);
- return NULL;
-}
-
-#else /* __MINGW32__ */
-
-/*
- * Fallback for systems which don't have open_memstream. Create FILE *
- * with bt_open_memstream, but require call to
- * bt_close_memstream to flush all data written to the FILE *
- * into the buffer (which we allocate).
- */
-static inline
-FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
-{
- char *tmpname;
- int ret;
- FILE *fp;
-
- tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
-
- ret = mkstemp(tmpname);
- if (ret < 0) {
- perror("mkstemp");
- g_free(tmpname);
- return NULL;
- }
- fp = fdopen(ret, "wb+");
- if (!fp) {
- goto error_unlink;
- }
- /*
- * babeltrace_flush_memstream will update the buffer content
- * with read from fp. No need to keep the file around, just the
- * handle.
- */
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- g_free(tmpname);
- return fp;
-
-error_unlink:
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- g_free(tmpname);
- return NULL;
-}
-
-#endif /* __MINGW32__ */
-
-/* Get file size, allocate buffer, copy. */
-static inline
-int bt_close_memstream(char **buf, size_t *size, FILE *fp)
-{
- size_t len, n;
- long pos;
- int ret;
-
- ret = fflush(fp);
- if (ret < 0) {
- perror("fflush");
- return ret;
- }
- ret = fseek(fp, 0L, SEEK_END);
- if (ret < 0) {
- perror("fseek");
- return ret;
- }
- pos = ftell(fp);
- if (ret < 0) {
- perror("ftell");
- return ret;
- }
- *size = pos;
- /* add final \0 */
- *buf = calloc(pos + 1, sizeof(char));
- if (!*buf) {
- return -ENOMEM;
- }
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- perror("fseek");
- goto error_free;
- }
- /* Copy the entire file into the buffer */
- n = 0;
- clearerr(fp);
- while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
- len = fread(*buf, sizeof(char), *size - n, fp);
- n += len;
- }
- if (n != *size) {
- ret = -1;
- goto error_close;
- }
- ret = fclose(fp);
- if (ret < 0) {
- perror("fclose");
- return ret;
- }
- return 0;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- perror("fclose");
- }
-error_free:
- free(*buf);
- *buf = NULL;
- return ret;
-}
-
-#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_MMAN_H
-#define _BABELTRACE_COMPAT_MMAN_H
-
-/*
- * Copyright (C) 2015-2016 Michael Jeanson <mjeanson@efficios.com>
- *
- * 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.
- */
-
-#ifdef __MINGW32__
-
-#include <sys/types.h>
-
-#define PROT_NONE 0x0
-#define PROT_READ 0x1
-#define PROT_WRITE 0x2
-#define PROT_EXEC 0x4
-
-#define MAP_FILE 0
-#define MAP_SHARED 1
-#define MAP_PRIVATE 2
-#define MAP_TYPE 0xF
-#define MAP_FIXED 0x10
-#define MAP_ANONYMOUS 0x20
-#define MAP_ANON MAP_ANONYMOUS
-#define MAP_FAILED ((void *) -1)
-
-/*
- * Note that some platforms (e.g. Windows) do not allow read-only
- * mappings to exceed the file's size (even within a page).
- */
-void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
- off_t offset);
-
-int bt_munmap(void *addr, size_t length);
-
-#else /* __MINGW32__ */
-
-#include <sys/mman.h>
-
-static inline
-void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
- off_t offset)
-{
- return (void *) mmap(addr, length, prot, flags, fd, offset);
-}
-
-static inline
-int bt_munmap(void *addr, size_t length)
-{
- return munmap(addr, length);
-}
-#endif /* __MINGW32__ */
-
-#ifndef MAP_ANONYMOUS
-# ifdef MAP_ANON
-# define MAP_ANONYMOUS MAP_ANON
-# endif
-#endif
-
-#endif /* _BABELTRACE_COMPAT_MMAN_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_SOCKET_H
-#define _BABELTRACE_COMPAT_SOCKET_H
-
-/*
- * Copyright (C) 2015-2017 Michael Jeanson <mjeanson@efficios.com>
- * 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- */
-
-#ifdef __MINGW32__
-
-#include <winsock2.h>
-
-#define BT_INVALID_SOCKET INVALID_SOCKET
-#define BT_SOCKET_ERROR SOCKET_ERROR
-#define BT_SOCKET SOCKET
-
-static inline
-int bt_socket_init(void)
-{
- WORD verreq;
- WSADATA wsa;
- int ret;
-
- /* Request winsock 2.2 support */
- verreq = MAKEWORD(2, 2);
-
- ret = WSAStartup(verreq, &wsa);
- if (ret != 0) {
-#ifdef BT_LOGE
- BT_LOGE("Winsock init failed with error: %d", ret);
-#endif
- goto end;
- }
-
- if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wVersion) != 2) {
-#ifdef BT_LOGE_STR
- BT_LOGE_STR("Could not init winsock 2.2 support");
-#endif
- WSACleanup();
- ret = -1;
- }
-
-end:
- return ret;
-}
-
-static inline
-int bt_socket_fini(void)
-{
- return WSACleanup();
-}
-
-static inline
-int bt_socket_send(int sockfd, const void *buf, size_t len, int flags)
-{
- return send(sockfd, buf, len, flags);
-}
-
-static inline
-int bt_socket_recv(int sockfd, void *buf, size_t len, int flags)
-{
- return recv(sockfd, buf, len, flags);
-}
-
-static inline
-int bt_socket_close(int fd)
-{
- return closesocket(fd);
-}
-
-static inline
-bool bt_socket_interrupted(void)
-{
- /* There is no equivalent to EINTR in winsock 2.2 */
- return false;
-}
-
-static inline
-const char *bt_socket_errormsg(void)
-{
- const char *errstr;
- int error = WSAGetLastError();
-
- switch (error) {
- case WSAEINTR:
- errstr = "Call interrupted";
- break;
- case WSAEBADF:
- errstr = "Bad file";
- break;
- case WSAEACCES:
- errstr = "Bad access";
- break;
- case WSAEFAULT:
- errstr = "Bad argument";
- break;
- case WSAEINVAL:
- errstr = "Invalid arguments";
- break;
- case WSAEMFILE:
- errstr = "Out of file descriptors";
- break;
- case WSAEWOULDBLOCK:
- errstr = "Call would block";
- break;
- case WSAEINPROGRESS:
- case WSAEALREADY:
- errstr = "Blocking call in progress";
- break;
- case WSAENOTSOCK:
- errstr = "Descriptor is not a socket";
- break;
- case WSAEDESTADDRREQ:
- errstr = "Need destination address";
- break;
- case WSAEMSGSIZE:
- errstr = "Bad message size";
- break;
- case WSAEPROTOTYPE:
- errstr = "Bad protocol";
- break;
- case WSAENOPROTOOPT:
- errstr = "Protocol option is unsupported";
- break;
- case WSAEPROTONOSUPPORT:
- errstr = "Protocol is unsupported";
- break;
- case WSAESOCKTNOSUPPORT:
- errstr = "Socket is unsupported";
- break;
- case WSAEOPNOTSUPP:
- errstr = "Operation not supported";
- break;
- case WSAEAFNOSUPPORT:
- errstr = "Address family not supported";
- break;
- case WSAEPFNOSUPPORT:
- errstr = "Protocol family not supported";
- break;
- case WSAEADDRINUSE:
- errstr = "Address already in use";
- break;
- case WSAEADDRNOTAVAIL:
- errstr = "Address not available";
- break;
- case WSAENETDOWN:
- errstr = "Network down";
- break;
- case WSAENETUNREACH:
- errstr = "Network unreachable";
- break;
- case WSAENETRESET:
- errstr = "Network has been reset";
- break;
- case WSAECONNABORTED:
- errstr = "Connection was aborted";
- break;
- case WSAECONNRESET:
- errstr = "Connection was reset";
- break;
- case WSAENOBUFS:
- errstr = "No buffer space";
- break;
- case WSAEISCONN:
- errstr = "Socket is already connected";
- break;
- case WSAENOTCONN:
- errstr = "Socket is not connected";
- break;
- case WSAESHUTDOWN:
- errstr = "Socket has been shut down";
- break;
- case WSAETOOMANYREFS:
- errstr = "Too many references";
- break;
- case WSAETIMEDOUT:
- errstr = "Timed out";
- break;
- case WSAECONNREFUSED:
- errstr = "Connection refused";
- break;
- case WSAELOOP:
- errstr = "Loop??";
- break;
- case WSAENAMETOOLONG:
- errstr = "Name too long";
- break;
- case WSAEHOSTDOWN:
- errstr = "Host down";
- break;
- case WSAEHOSTUNREACH:
- errstr = "Host unreachable";
- break;
- case WSAENOTEMPTY:
- errstr = "Not empty";
- break;
- case WSAEPROCLIM:
- errstr = "Process limit reached";
- break;
- case WSAEUSERS:
- errstr = "Too many users";
- break;
- case WSAEDQUOT:
- errstr = "Bad quota";
- break;
- case WSAESTALE:
- errstr = "Something is stale";
- break;
- case WSAEREMOTE:
- errstr = "Remote error";
- break;
- case WSAEDISCON:
- errstr = "Disconnected";
- break;
-
- /* Extended Winsock errors */
- case WSASYSNOTREADY:
- errstr = "Winsock library is not ready";
- break;
- case WSANOTINITIALISED:
- errstr = "Winsock library not initialised";
- break;
- case WSAVERNOTSUPPORTED:
- errstr = "Winsock version not supported";
- break;
-
- /* getXbyY() errors (already handled in herrmsg):
- * Authoritative Answer: Host not found */
- case WSAHOST_NOT_FOUND:
- errstr = "Host not found";
- break;
-
- /* Non-Authoritative: Host not found, or SERVERFAIL */
- case WSATRY_AGAIN:
- errstr = "Host not found, try again";
- break;
-
- /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
- case WSANO_RECOVERY:
- errstr = "Unrecoverable error in call to nameserver";
- break;
-
- /* Valid name, no data record of requested type */
- case WSANO_DATA:
- errstr = "No data record of requested type";
- break;
-
- default:
- errstr = "Unknown error";
- }
-
- return errstr;
-}
-
-#else /* __MINGW32__ */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-
-#define BT_INVALID_SOCKET -1
-#define BT_SOCKET_ERROR -1
-#define BT_SOCKET int
-
-static inline
-int bt_socket_init(void)
-{
- return 0;
-}
-
-static inline
-int bt_socket_fini(void)
-{
- return 0;
-}
-
-static inline
-int bt_socket_send(int sockfd, const void *buf, size_t len, int flags)
-{
- return send(sockfd, buf, len, flags);
-}
-
-static inline
-int bt_socket_recv(int sockfd, void *buf, size_t len, int flags)
-{
- return recv(sockfd, buf, len, flags);
-}
-
-static inline
-int bt_socket_close(int fd)
-{
- return close(fd);
-}
-
-static inline
-bool bt_socket_interrupted(void)
-{
- return (errno == EINTR);
-}
-
-static inline
-const char *bt_socket_errormsg(void)
-{
- return g_strerror(errno);
-}
-#endif
-
-
-/*
- * This wrapper is used on platforms that have no way of ignoring SIGPIPE
- * during a send().
- */
-
-#ifndef MSG_NOSIGNAL
-# ifdef SO_NOSIGPIPE
-# define MSG_NOSIGNAL SO_NOSIGPIPE
-# elif defined(__MINGW32__)
-# define MSG_NOSIGNAL 0
-# endif
-#endif
-
-#if defined(MSG_NOSIGNAL)
-static inline
-ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size)
-{
- return bt_socket_send(fd, buffer, size, MSG_NOSIGNAL);
-}
-#else
-
-#include <signal.h>
-
-static inline
-ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size)
-{
- ssize_t sent;
- int saved_err;
- sigset_t sigpipe_set, pending_set, old_set;
- int sigpipe_was_pending;
-
- /*
- * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
- * that might be already pending. If a bogus SIGPIPE is sent to
- * the entire process concurrently by a malicious user, it may
- * be simply discarded.
- */
- if (sigemptyset(&pending_set)) {
- return -1;
- }
- /*
- * sigpending returns the mask of signals that are _both_
- * blocked for the thread _and_ pending for either the thread or
- * the entire process.
- */
- if (sigpending(&pending_set)) {
- return -1;
- }
- sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
- /*
- * If sigpipe was pending, it means it was already blocked, so
- * no need to block it.
- */
- if (!sigpipe_was_pending) {
- if (sigemptyset(&sigpipe_set)) {
- return -1;
- }
- if (sigaddset(&sigpipe_set, SIGPIPE)) {
- return -1;
- }
- if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
- return -1;
- }
- }
-
- /* Send and save errno. */
- sent = bt_socket_send(fd, buffer, size, 0);
- saved_err = errno;
-
- if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) {
- struct timespec timeout = { 0, 0 };
- int ret;
-
- do {
- ret = sigtimedwait(&sigpipe_set, NULL,
- &timeout);
- } while (ret == -1 && errno == EINTR);
- }
- if (!sigpipe_was_pending) {
- if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
- return -1;
- }
- }
- /* Restore send() errno */
- errno = saved_err;
-
- return sent;
-}
-#endif
-
-
-#endif /* _BABELTRACE_COMPAT_SOCKET_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STDIO_H
-#define _BABELTRACE_COMPAT_STDIO_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <babeltrace/assert-internal.h>
-
-#define BT_GETLINE_MINBUFLEN 64
-
-static inline
-char * _bt_getline_bufalloc(char **lineptr, size_t *n, size_t linelen)
-{
- size_t buflen = *n;
- char *buf = *lineptr;
-
- if (buflen >= linelen && buf != NULL) {
- return buf;
- }
- if (buf == NULL) {
- buflen = BT_GETLINE_MINBUFLEN;
- } else {
- buflen = buflen << 1;
- if (buflen < BT_GETLINE_MINBUFLEN) {
- buflen = BT_GETLINE_MINBUFLEN;
- }
- }
- /* Check below not strictly needed, extra safety. */
- if (buflen < linelen) {
- buflen = linelen;
- }
- buf = realloc(buf, buflen);
- if (!buf) {
- errno = ENOMEM;
- return NULL;
- }
- *n = buflen;
- *lineptr = buf;
- return buf;
-}
-
-/*
- * Returns line length (including possible final \n, excluding final
- * \0). On end of file, returns -1 with nonzero feof(stream) and errno
- * set to 0. On error, returns -1 with errno set.
- *
- * This interface is similar to the getline(3) man page part of the
- * Linux man-pages project, release 3.74. One major difference from the
- * Open Group POSIX specification is that this implementation does not
- * necessarily set the ferror() flag on error (because it is internal to
- * libc).
- */
-static inline
-ssize_t bt_getline(char **lineptr, size_t *n, FILE *stream)
-{
- size_t linelen = 0;
- char *buf;
- int found_eof = 0;
-
- if (lineptr == NULL || n == NULL) {
- errno = EINVAL;
- return -1;
- }
- for (;;) {
- char c;
- int ret;
-
- ret = fgetc(stream);
- if (ret == EOF) {
- if (ferror(stream)) {
- /* ferror() is set, errno set by fgetc(). */
- return -1;
- }
- BT_ASSERT(feof(stream));
- found_eof = 1;
- break;
- }
- c = (char) ret;
- if (linelen == SSIZE_MAX) {
- errno = EOVERFLOW;
- return -1;
- }
- buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
- if (!buf) {
- return -1;
- }
- buf[linelen - 1] = c;
- if (c == '\n') {
- break;
- }
- }
- if (!linelen && found_eof) {
- /* feof() is set. */
- errno = 0;
- return -1;
- }
- buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
- if (!buf) {
- return -1;
- }
- buf[linelen - 1] = '\0';
- return linelen - 1; /* Count don't include final \0. */
-}
-
-#endif /* _BABELTRACE_COMPAT_STDIO_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STDLIB_H
-#define _BABELTRACE_COMPAT_STDLIB_H
-
-/*
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * 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.
- */
-
-/*
- * This compat wrapper can be removed and replaced by g_mkdtemp() when we bump
- * the requirement on glib to version 2.30.
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <glib.h>
-
-#ifdef HAVE_MKDTEMP
-
-static inline
-char *bt_mkdtemp(char *template)
-{
- return mkdtemp(template);
-}
-
-#elif GLIB_CHECK_VERSION(2,30,0)
-
-#include <glib/gstdio.h>
-static inline
-char *bt_mkdtemp(char *template)
-{
- return g_mkdtemp(template);
-}
-
-#else
-
-static inline
-char *bt_mkdtemp(char *template)
-{
- char *ret;
-
- ret = mktemp(template);
- if (!ret) {
- goto end;
- }
-
- if(mkdir(template, 0700)) {
- ret = NULL;
- goto end;
- }
-
- ret = template;
-end:
- return ret;
-}
-
-#endif
-
-#endif /* _BABELTRACE_COMPAT_STDLIB_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STRING_H
-#define _BABELTRACE_COMPAT_STRING_H
-
-/*
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-
-#ifdef HAVE_STRNLEN
-static inline
-size_t bt_strnlen(const char *str, size_t max)
-{
- return strnlen(str, max);
-}
-#else
-static inline
-size_t bt_strnlen(const char *str, size_t max)
-{
- size_t ret;
- const char *end;
-
- end = memchr(str, 0, max);
-
- if (end) {
- ret = (size_t) (end - str);
- } else {
- ret = max;
- }
-
- return ret;
-}
-#endif /* HAVE_STRNLEN */
-
-#ifdef HAVE_STRNDUP
-static inline
-char *bt_strndup(const char *s, size_t n)
-{
- return strndup(s, n);
-}
-#else
-static inline
-char *bt_strndup(const char *s, size_t n)
-{
- char *ret;
- size_t navail;
-
- if (!s) {
- ret = NULL;
- goto end;
- }
-
- /* min() */
- navail = strlen(s) + 1;
- if ((n + 1) < navail) {
- navail = n + 1;
- }
-
- ret = malloc(navail);
- if (!ret) {
- goto end;
- }
-
- memcpy(ret, s, navail);
- ret[navail - 1] = '\0';
-end:
- return ret;
-}
-#endif /* HAVE_STRNDUP */
-
-#endif /* _BABELTRACE_COMPAT_STRING_H */
+++ /dev/null
-#ifndef _BABELTRACE_INCLUDE_COMPAT_TIME_H
-#define _BABELTRACE_INCLUDE_COMPAT_TIME_H
-
-/*
- * Copyright (C) 2013 JP Ikaheimonen <jp_ikaheimonen@mentor.com>
- * 2016 Michael Jeanson <mjeanson@efficios.com>
- *
- * 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 <time.h>
-#include <stdlib.h>
-
-#ifdef __MINGW32__
-
-#include <string.h>
-
-/*
- * The Windows version of the time functions use one common tm structure per
- * thread which makes them thread-safe. Implement the POSIX _r variants by
- * copying this to a user supplied struct.
- */
-
-static inline
-struct tm *bt_gmtime_r(const time_t *timep, struct tm *result)
-{
- struct tm *local_res;
-
- if (!result) {
- goto error;
- }
-
- local_res = gmtime(timep);
- if (!local_res) {
- result = NULL;
- goto error;
- }
-
- memcpy(result, local_res, sizeof(struct tm));
-
-error:
- return result;
-}
-
-static inline
-struct tm *bt_localtime_r(const time_t *timep, struct tm *result)
-{
- struct tm *local_res;
-
- if (!result) {
- goto error;
- }
-
- local_res = localtime(timep);
- if (!local_res) {
- result = NULL;
- goto error;
- }
-
- memcpy(result, local_res, sizeof(struct tm));
-
-error:
- return result;
-}
-
-#else /* __MINGW32__ */
-
-static inline
-struct tm *bt_gmtime_r(const time_t *timep, struct tm *result)
-{
- return gmtime_r(timep, result);
-}
-
-static inline
-struct tm *bt_localtime_r(const time_t *timep, struct tm *result)
-{
- return localtime_r(timep, result);
-}
-
-#endif /* __MINGW32__ */
-#endif /* _BABELTRACE_INCLUDE_COMPAT_TIME_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_UNISTD_H
-#define _BABELTRACE_COMPAT_UNISTD_H
-
-/*
- * (C) Copyright 2016 - Michael Jeanson <mjeanson@efficios.com>
- *
- * 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 <unistd.h>
-
-#ifdef __MINGW32__
-#include <windows.h>
-#include <errno.h>
-
-#define _SC_PAGESIZE 30
-
-static inline
-long bt_sysconf(int name)
-{
- SYSTEM_INFO si;
-
- switch(name) {
- case _SC_PAGESIZE:
- GetNativeSystemInfo(&si);
- return si.dwPageSize;
- default:
- errno = EINVAL;
- return -1;
- }
-}
-
-#else
-
-static inline
-long bt_sysconf(int name)
-{
- return sysconf(name);
-}
-
-#endif
-#endif /* _BABELTRACE_COMPAT_UNISTD_H */
+++ /dev/null
-#ifndef _BABELTRACE_UTC_H
-#define _BABELTRACE_UTC_H
-
-/*
- * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <time.h>
-
-/* If set, use GNU or BSD timegm(3) */
-#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
-
-static inline
-time_t bt_timegm(struct tm *tm)
-{
- return timegm(tm);
-}
-
-#elif defined(__MINGW32__)
-
-static inline
-time_t bt_timegm(struct tm *tm)
-{
- return _mkgmtime(tm);
-}
-
-#else
-
-#include <errno.h>
-
-/*
- * This is a simple implementation of timegm() it just turns the "struct tm" into
- * a GMT time_t. It does not normalize any of the fields of the "struct tm", nor
- * does it set tm_wday or tm_yday.
- */
-
-static inline
-int bt_leapyear(int year)
-{
- return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));
-}
-
-static inline
-time_t bt_timegm(struct tm *tm)
-{
- int year, month, total_days;
-
- int monthlen[2][12] = {
- /* Days per month for a regular year */
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- /* Days per month for a leap year */
- { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- };
-
- if ((tm->tm_mon >= 12) ||
- (tm->tm_mday >= 32) ||
- (tm->tm_hour >= 24) ||
- (tm->tm_min >= 60) ||
- (tm->tm_sec >= 61)) {
- errno = EOVERFLOW;
- return (time_t) -1;
- }
-
- /* Add 365 days for each year since 1970 */
- total_days = 365 * (tm->tm_year - 70);
-
- /* Add one day for each leap year since 1970 */
- for (year = 70; year < tm->tm_year; year++) {
- if (bt_leapyear(1900 + year)) {
- total_days++;
- }
- }
-
- /* Add days for each remaining month */
- for (month = 0; month < tm->tm_mon; month++) {
- total_days += monthlen[bt_leapyear(1900 + year)][month];
- }
-
- /* Add remaining days */
- total_days += tm->tm_mday - 1;
-
- return ((((total_days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);
-}
-
-#endif
-
-#endif /* _BABELTRACE_UTC_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_UUID_H
-#define _BABELTRACE_COMPAT_UUID_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- */
-
-/* Includes final \0. */
-#define BABELTRACE_UUID_STR_LEN 37
-#define BABELTRACE_UUID_LEN 16
-
-#ifdef BABELTRACE_HAVE_LIBUUID
-#include <uuid/uuid.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uuid_generate(uuid_out);
- return 0;
-}
-
-/* Sun's libuuid lacks const qualifiers */
-#if defined(__sun__)
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse((unsigned char *) uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse((char *) str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare((unsigned char *) uuid_a,
- (unsigned char *) uuid_b);
-}
-#else
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse(uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse(str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare(uuid_a, uuid_b);
-}
-#endif
-
-#elif defined(BABELTRACE_HAVE_LIBC_UUID)
-#include <uuid.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_create((uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uint32_t status;
- char *alloc_str;
- int ret;
-
- uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
- if (status == uuid_s_ok) {
- strcpy(str_out, alloc_str);
- ret = 0;
- } else {
- ret = -1;
- }
- free(alloc_str);
- return ret;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- uint32_t status;
-
- uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-#elif defined(__MINGW32__)
-
-int bt_uuid_generate(unsigned char *uuid_out);
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out);
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out);
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b);
-
-#else
-#error "Babeltrace needs to have a UUID generator configured."
-#endif
-
-#endif /* _BABELTRACE_COMPAT_UUID_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPILER_H
-#define _BABELTRACE_COMPILER_H
-
-/*
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <stddef.h> /* for offsetof */
-
-#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
-
-#ifndef container_of
-#define container_of(ptr, type, member) \
- ({ \
- const typeof(((type *)NULL)->member) * __ptr = (ptr); \
- (type *)((char *)__ptr - offsetof(type, member)); \
- })
-#endif
-
-#define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-#endif /* _BABELTRACE_COMPILER_H */
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/clock.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/event-fields.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/event-types.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/event.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/field-types.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/fields.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/stream-class.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/stream.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/trace.h>
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/utils.h>
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_ATTRIBUTES_H
-#define BABELTRACE_CTF_WRITER_ATTRIBUTES_H
-
-/*
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_attributes_create(void);
-
-BT_HIDDEN
-void bt_ctf_attributes_destroy(struct bt_ctf_private_value *attr_obj);
-
-BT_HIDDEN
-int64_t bt_ctf_attributes_get_count(struct bt_ctf_private_value *attr_obj);
-
-BT_HIDDEN
-const char *bt_ctf_attributes_get_field_name(struct bt_ctf_private_value *attr_obj,
- uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value(struct bt_ctf_private_value *attr_obj,
- uint64_t index);
-
-BT_HIDDEN
-int bt_ctf_attributes_set_field_value(struct bt_ctf_private_value *attr_obj,
- const char *name, struct bt_ctf_private_value *value_obj);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value_by_name(
- struct bt_ctf_private_value *attr_obj, const char *name);
-
-BT_HIDDEN
-int bt_ctf_attributes_freeze(struct bt_ctf_private_value *attr_obj);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_ATTRIBUTES_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/types.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <glib.h>
-
-struct bt_ctf_clock_class {
- struct bt_ctf_object base;
- GString *name;
- GString *description;
- uint64_t frequency;
- uint64_t precision;
- int64_t offset_s; /* Offset in seconds */
- int64_t offset; /* Offset in ticks */
- unsigned char uuid[BABELTRACE_UUID_LEN];
- int uuid_set;
- int absolute;
-
- /*
- * A clock's properties can't be modified once it is added to a stream
- * class.
- */
- int frozen;
-};
-
-BT_HIDDEN
-void bt_ctf_clock_class_freeze(struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a,
- struct bt_ctf_clock_class *clock_class_b);
-
-BT_HIDDEN
-struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
- uint64_t freq);
-BT_HIDDEN
-const char *bt_ctf_clock_class_get_name(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class,
- const char *name);
-BT_HIDDEN
-const char *bt_ctf_clock_class_get_description(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_description(
- struct bt_ctf_clock_class *clock_class,
- const char *desc);
-BT_HIDDEN
-uint64_t bt_ctf_clock_class_get_frequency(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_frequency(
- struct bt_ctf_clock_class *clock_class, uint64_t freq);
-BT_HIDDEN
-uint64_t bt_ctf_clock_class_get_precision(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_precision(
- struct bt_ctf_clock_class *clock_class, uint64_t precision);
-BT_HIDDEN
-int bt_ctf_clock_class_get_offset_s(
- struct bt_ctf_clock_class *clock_class, int64_t *seconds);
-BT_HIDDEN
-int bt_ctf_clock_class_set_offset_s(
- struct bt_ctf_clock_class *clock_class, int64_t seconds);
-BT_HIDDEN
-int bt_ctf_clock_class_get_offset_cycles(
- struct bt_ctf_clock_class *clock_class, int64_t *cycles);
-BT_HIDDEN
-int bt_ctf_clock_class_set_offset_cycles(
- struct bt_ctf_clock_class *clock_class, int64_t cycles);
-BT_HIDDEN
-bt_bool bt_ctf_clock_class_is_absolute(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_is_absolute(
- struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
-BT_HIDDEN
-const unsigned char *bt_ctf_clock_class_get_uuid(
- struct bt_ctf_clock_class *clock_class);
-BT_HIDDEN
-int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
- const unsigned char *uuid);
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_CLASS_H
-#define BABELTRACE_CTF_WRITER_CLOCK_CLASS_H
-
-/*
- * BabelTrace - CTF Writer: Clock Class
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_clock_class;
-
-extern struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
- uint64_t freq);
-
-extern const char *bt_ctf_clock_class_get_name(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class,
- const char *name);
-
-extern const char *bt_ctf_clock_class_get_description(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_description(
- struct bt_ctf_clock_class *clock_class,
- const char *desc);
-
-extern uint64_t bt_ctf_clock_class_get_frequency(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_frequency(
- struct bt_ctf_clock_class *clock_class, uint64_t freq);
-
-extern uint64_t bt_ctf_clock_class_get_precision(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_precision(
- struct bt_ctf_clock_class *clock_class, uint64_t precision);
-
-extern int bt_ctf_clock_class_get_offset_s(
- struct bt_ctf_clock_class *clock_class, int64_t *seconds);
-
-extern int bt_ctf_clock_class_set_offset_s(
- struct bt_ctf_clock_class *clock_class, int64_t seconds);
-
-extern int bt_ctf_clock_class_get_offset_cycles(
- struct bt_ctf_clock_class *clock_class, int64_t *cycles);
-
-extern int bt_ctf_clock_class_set_offset_cycles(
- struct bt_ctf_clock_class *clock_class, int64_t cycles);
-
-extern bt_bool bt_ctf_clock_class_is_absolute(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_is_absolute(
- struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
-
-extern const unsigned char *bt_ctf_clock_class_get_uuid(
- struct bt_ctf_clock_class *clock_class);
-
-extern int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
- const unsigned char *uuid);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-#include <babeltrace/compat/uuid-internal.h>
-
-struct bt_ctf_clock {
- struct bt_ctf_object base;
- struct bt_ctf_clock_class *clock_class;
- uint64_t value; /* Current clock value */
-};
-
-struct metadata_context;
-
-BT_HIDDEN
-int bt_ctf_clock_get_value(struct bt_ctf_clock *clock, uint64_t *value);
-
-BT_HIDDEN
-void bt_ctf_clock_class_serialize(struct bt_ctf_clock_class *clock_class,
- struct metadata_context *context);
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_H
-#define BABELTRACE_CTF_WRITER_CLOCK_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_clock;
-struct bt_ctf_clock_class;
-
-/*
- * bt_ctf_clock_create: create a clock.
- *
- * Allocate a new clock setting its reference count to 1.
- *
- * @param name Name of the clock (will be copied); can be set to NULL
- * for nameless clocks.
- *
- * Returns an allocated clock on success, NULL on error.
- */
-extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
-
-/*
- * bt_ctf_clock_get_name: get a clock's name.
- *
- * Get the clock's name.
- *
- * @param clock Clock instance.
- *
- * Returns the clock's name, NULL on error.
- */
-extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_get_description: get a clock's description.
- *
- * Get the clock's description.
- *
- * @param clock Clock instance.
- *
- * Returns the clock's description, NULL if unset.
- */
-extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_set_description: set a clock's description.
- *
- * Set the clock's description. The description appears in the clock's TSDL
- * meta-data.
- *
- * @param clock Clock instance.
- * @param desc Description of the clock.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
- const char *desc);
-
-/*
- * bt_ctf_clock_get_frequency: get a clock's frequency.
- *
- * Get the clock's frequency (Hz).
- *
- * @param clock Clock instance.
- *
- * Returns the clock's frequency, -1ULL on error.
- */
-extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_set_frequency: set a clock's frequency.
- *
- * Set the clock's frequency (Hz).
- *
- * @param clock Clock instance.
- * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
- uint64_t freq);
-
-/*
- * bt_ctf_clock_get_precision: get a clock's precision.
- *
- * Get the clock's precision (in clock ticks).
- *
- * @param clock Clock instance.
- *
- * Returns the clock's precision, -1ULL on error.
- */
-extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_set_precision: set a clock's precision.
- *
- * Set the clock's precision.
- *
- * @param clock Clock instance.
- * @param precision Clock's precision in clock ticks, defaults to 1.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
- uint64_t precision);
-
-/*
- * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
- *
- * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
- *
- * @param clock Clock instance.
- * @param offset_s Pointer to clock offset in seconds (output).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock,
- int64_t *offset_s);
-
-/*
- * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
- *
- * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
- * defaults to 0.
- *
- * @param clock Clock instance.
- * @param offset_s Clock's offset in seconds, defaults to 0.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
- int64_t offset_s);
-
-/*
- * bt_ctf_clock_get_offset: get a clock's offset in ticks.
- *
- * Get the clock's offset in ticks from Epoch + offset_t.
- *
- * @param clock Clock instance.
- * @param offset Clock offset in ticks from Epoch + offset_s (output).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_get_offset(struct bt_ctf_clock *clock,
- int64_t *offset);
-
-/*
- * bt_ctf_clock_set_offset: set a clock's offset in ticks.
- *
- * Set the clock's offset in ticks from Epoch + offset_s.
- *
- * @param clock Clock instance.
- * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
- int64_t offset);
-
-/*
- * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
- *
- * Get the clock's absolute attribute. A clock is absolute if the clock is a
- * global reference across the trace's other clocks.
- *
- * @param clock Clock instance.
- *
- * Returns the clock's absolute attribute, a negative value on error.
- */
-extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
- *
- * Set the clock's absolute attribute. A clock is absolute if the clock is a
- * global reference across the trace's other clocks.
- *
- * @param clock Clock instance.
- * @param is_absolute Clock's absolute attribute, defaults to FALSE.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
- int is_absolute);
-
-/*
- * bt_ctf_clock_get_uuid: get a clock's UUID.
- *
- * Get the clock's UUID.
- *
- * @param clock Clock instance.
- *
- * Returns a pointer to the clock's UUID (16 byte array) on success,
- * NULL on error.
- */
-extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_clock_set_uuid: set a clock's UUID.
- *
- * Set a clock's UUID.
- *
- * @param clock Clock instance.
- * @param uuid A 16-byte array containing a UUID.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock,
- const unsigned char *uuid);
-
-/*
- * bt_ctf_clock_set_time: set a clock's current time value.
- *
- * Set the current time in nanoseconds since the clock's origin (offset and
- * offset_s attributes). Defaults to 0.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock,
- int64_t time);
-
-/*
- * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
- * refcount of the clock
- *
- * You may also use bt_ctf_get() and bt_ctf_put() with clock objects.
- *
- * These functions ensure that the clock won't be destroyed when it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) has to be done to
- * destroy a clock.
- *
- * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
- * the clock is freed.
- *
- * @param clock Clock instance.
- */
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_clock_get(struct bt_ctf_clock *clock)
-{
- bt_ctf_object_get_ref(clock);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_clock_put(struct bt_ctf_clock *clock)
-{
- bt_ctf_object_put_ref(clock);
-}
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <glib.h>
-
-struct bt_ctf_event_class_common {
- struct bt_ctf_object base;
- struct bt_ctf_field_type_common *context_field_type;
- struct bt_ctf_field_type_common *payload_field_type;
- int frozen;
-
- /*
- * This flag indicates if the event class is valid. A valid
- * event class is _always_ frozen. However, an event class
- * may be frozen, but not valid yet. This is okay, as long as
- * no events are created out of this event class.
- */
- int valid;
-
- /* Attributes */
- GString *name;
- int64_t id;
- int log_level;
- GString *emf_uri;
-};
-
-BT_HIDDEN
-void bt_ctf_event_class_common_freeze(struct bt_ctf_event_class_common *event_class);
-
-BT_HIDDEN
-void bt_ctf_event_class_common_set_native_byte_order(
- struct bt_ctf_event_class_common *event_class, int byte_order);
-
-static inline
-struct bt_ctf_stream_class_common *bt_ctf_event_class_common_borrow_stream_class(
- struct bt_ctf_event_class_common *event_class)
-{
- BT_ASSERT(event_class);
- return (void *) bt_ctf_object_borrow_parent(&event_class->base);
-}
-
-typedef struct bt_ctf_field_type_common *(*bt_ctf_field_type_structure_create_func)();
-
-BT_HIDDEN
-int bt_ctf_event_class_common_initialize(struct bt_ctf_event_class_common *event_class,
- const char *name, bt_ctf_object_release_func release_func,
- bt_ctf_field_type_structure_create_func ft_struct_create_func);
-
-BT_HIDDEN
-void bt_ctf_event_class_common_finalize(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-int bt_ctf_event_class_common_validate_single_clock_class(
- struct bt_ctf_event_class_common *event_class,
- struct bt_ctf_clock_class **expected_clock_class);
-
-static inline
-const char *bt_ctf_event_class_common_get_name(
- struct bt_ctf_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- BT_ASSERT(event_class->name);
- return event_class->name->str;
-}
-
-static inline
-int64_t bt_ctf_event_class_common_get_id(
- struct bt_ctf_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->id;
-}
-
-static inline
-int bt_ctf_event_class_common_set_id(
- struct bt_ctf_event_class_common *event_class, uint64_t id_param)
-{
- int ret = 0;
- int64_t id = (int64_t) id_param;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class,
- bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (id < 0) {
- BT_LOGW("Invalid parameter: invalid event class's ID: "
- "addr=%p, name=\"%s\", id=%" PRIu64,
- event_class,
- bt_ctf_event_class_common_get_name(event_class),
- id_param);
- ret = -1;
- goto end;
- }
-
- event_class->id = id;
- BT_LOGV("Set event class's ID: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_ctf_event_class_common_get_name(event_class), id);
-
-end:
- return ret;
-}
-
-static inline
-int bt_ctf_event_class_common_get_log_level(
- struct bt_ctf_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->log_level;
-}
-
-static inline
-int bt_ctf_event_class_common_set_log_level(
- struct bt_ctf_event_class_common *event_class, int log_level)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class,
- bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- switch (log_level) {
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG:
- break;
- default:
- BT_LOGW("Invalid parameter: unknown event class log level: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class), log_level);
- ret = -1;
- goto end;
- }
-
- event_class->log_level = log_level;
- BT_LOGV("Set event class's log level: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class),
- bt_ctf_event_class_log_level_string(log_level));
-
-end:
- return ret;
-}
-
-static inline
-const char *bt_ctf_event_class_common_get_emf_uri(
- struct bt_ctf_event_class_common *event_class)
-{
- const char *emf_uri = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
- if (event_class->emf_uri->len > 0) {
- emf_uri = event_class->emf_uri->str;
- }
-
- return emf_uri;
-}
-
-static inline
-int bt_ctf_event_class_common_set_emf_uri(
- struct bt_ctf_event_class_common *event_class,
- const char *emf_uri)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (emf_uri && strlen(emf_uri) == 0) {
- BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (emf_uri) {
- g_string_assign(event_class->emf_uri, emf_uri);
- BT_LOGV("Set event class's EMF URI: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class), emf_uri);
- } else {
- g_string_assign(event_class->emf_uri, "");
- BT_LOGV("Reset event class's EMF URI: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- }
-
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_context_field_type(
- struct bt_ctf_event_class_common *event_class)
-{
- struct bt_ctf_field_type_common *context_ft = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
- if (!event_class->context_field_type) {
- BT_LOGV("Event class has no context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- goto end;
- }
-
- context_ft = event_class->context_field_type;
-
-end:
- return context_ft;
-}
-
-static inline
-int bt_ctf_event_class_common_set_context_field_type(
- struct bt_ctf_event_class_common *event_class,
- struct bt_ctf_field_type_common *context_ft)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (context_ft && bt_ctf_field_type_common_get_type_id(context_ft) !=
- BT_CTF_FIELD_TYPE_ID_STRUCT) {
- BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "context-ft-id=%s",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class),
- bt_ctf_field_type_id_string(
- bt_ctf_field_type_common_get_type_id(context_ft)));
- ret = -1;
- goto end;
- }
-
- bt_ctf_object_put_ref(event_class->context_field_type);
- event_class->context_field_type = context_ft;
- bt_ctf_object_get_ref(event_class->context_field_type);
- BT_LOGV("Set event class's context field type: "
- "event-class-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", context-ft-addr=%p",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class), context_ft);
-
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_payload_field_type(
- struct bt_ctf_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->payload_field_type;
-}
-
-static inline
-int bt_ctf_event_class_common_set_payload_field_type(
- struct bt_ctf_event_class_common *event_class,
- struct bt_ctf_field_type_common *payload_ft)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (payload_ft && bt_ctf_field_type_common_get_type_id(payload_ft) !=
- BT_CTF_FIELD_TYPE_ID_STRUCT) {
- BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "payload-ft-addr=%p, payload-ft-id=%s",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class), payload_ft,
- bt_ctf_field_type_id_string(
- bt_ctf_field_type_common_get_type_id(payload_ft)));
- ret = -1;
- goto end;
- }
-
- bt_ctf_object_put_ref(event_class->payload_field_type);
- event_class->payload_field_type = payload_ft;
- bt_ctf_object_get_ref(event_class->payload_field_type);
- BT_LOGV("Set event class's payload field type: "
- "event-class-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", payload-ft-addr=%p",
- event_class, bt_ctf_event_class_common_get_name(event_class),
- bt_ctf_event_class_common_get_id(event_class), payload_ft);
-end:
- return ret;
-}
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
-#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
- * field's reference count.
- *
- * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field objects.
- *
- * These functions ensure that the field won't be destroyed when it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) have to be done to
- * destroy a field.
- *
- * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
- * the field is freed.
- *
- * @param field Field instance.
- */
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_field_get(struct bt_ctf_field *field)
-{
- bt_ctf_object_get_ref(field);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_field_put(struct bt_ctf_field *field)
-{
- bt_ctf_object_put_ref(field);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/field-wrapper-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/ctfser-internal.h>
-
-struct bt_ctf_stream_class;
-struct bt_ctf_stream_pos;
-struct metadata_context;
-
-struct bt_ctf_event_common {
- struct bt_ctf_object base;
- struct bt_ctf_event_class_common *class;
- struct bt_ctf_field_wrapper *header_field;
- struct bt_ctf_field_common *stream_event_context_field;
- struct bt_ctf_field_common *context_field;
- struct bt_ctf_field_common *payload_field;
- int frozen;
-};
-
-BT_HIDDEN
-int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event);
-
-BT_HIDDEN
-void _bt_ctf_event_common_set_is_frozen(struct bt_ctf_event_common *event,
- bool is_frozen);
-
-#ifdef BT_DEV_MODE
-# define bt_ctf_event_common_validate _bt_ctf_event_common_validate
-# define bt_ctf_event_common_set_is_frozen _bt_ctf_event_common_set_is_frozen
-#else
-# define bt_ctf_event_common_validate(_event) 0
-# define bt_ctf_event_common_set_is_frozen(_event, _is_frozen)
-#endif
-
-#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \
- BT_ASSERT_PRE_HOT((_event), (_name), ": event-addr=%p", (_event))
-
-static inline
-struct bt_ctf_event_class_common *bt_ctf_event_common_borrow_class(
- struct bt_ctf_event_common *event)
-{
- BT_ASSERT(event);
- return event->class;
-}
-
-typedef void *(*create_field_func)(void *);
-typedef void (*release_field_func)(void *);
-typedef void *(*create_header_field_func)(void *, void *);
-typedef void (*release_header_field_func)(void *, void *);
-
-BT_HIDDEN
-int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event,
- struct bt_ctf_event_class_common *event_class,
- struct bt_ctf_clock_class *init_expected_clock_class,
- bool is_shared_with_parent, bt_ctf_object_release_func release_func,
- bt_ctf_validation_flag_copy_field_type_func field_type_copy_func,
- bool must_be_in_trace,
- int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_field_type_common *packet_context_field_type,
- struct bt_ctf_field_type_common *event_header_field_type),
- create_field_func create_field_func,
- release_field_func release_field_func,
- create_header_field_func create_header_field_func,
- release_header_field_func release_header_field_func);
-
-static inline
-struct bt_ctf_field_common *bt_ctf_event_common_borrow_payload(
- struct bt_ctf_event_common *event)
-{
- struct bt_ctf_field_common *payload = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->payload_field) {
- BT_LOGV("Event has no current payload field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_ctf_event_class_common_get_name(event->class),
- bt_ctf_event_class_common_get_id(event->class));
- goto end;
- }
-
- payload = event->payload_field;
-
-end:
- return payload;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_event_common_borrow_header(
- struct bt_ctf_event_common *event)
-{
- struct bt_ctf_field_common *header = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->header_field) {
- BT_LOGV("Event has no current header field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_ctf_event_class_common_get_name(event->class),
- bt_ctf_event_class_common_get_id(event->class));
- goto end;
- }
-
- header = event->header_field->field;
-
-end:
- return header;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_event_common_borrow_context(
- struct bt_ctf_event_common *event)
-{
- struct bt_ctf_field_common *context = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->context_field) {
- BT_LOGV("Event has no current context field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_ctf_event_class_common_get_name(event->class),
- bt_ctf_event_class_common_get_id(event->class));
- goto end;
- }
-
- context = event->context_field;
-
-end:
- return context;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_event_common_borrow_stream_event_context(
- struct bt_ctf_event_common *event)
-{
- struct bt_ctf_field_common *stream_event_context = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->stream_event_context_field) {
- BT_LOGV("Event has no current stream event context field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_ctf_event_class_common_get_name(event->class),
- bt_ctf_event_class_common_get_id(event->class));
- goto end;
- }
-
- stream_event_context = event->stream_event_context_field;
-
-end:
- return stream_event_context;
-}
-
-static inline
-void bt_ctf_event_common_finalize(struct bt_ctf_object *obj,
- void (*field_release_func)(void *),
- void (*header_field_release_func)(void *, struct bt_ctf_event_common *))
-{
- struct bt_ctf_event_common *event = (void *) obj;
-
- BT_LOGD("Destroying event: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event,
- event->class ? bt_ctf_event_class_common_get_name(event->class) : NULL,
- event->class ? bt_ctf_event_class_common_get_id(event->class) : INT64_C(-1));
-
- if (event->header_field) {
- BT_LOGD_STR("Releasing event's header field.");
- header_field_release_func(event->header_field, event);
- }
-
- if (event->stream_event_context_field) {
- BT_LOGD_STR("Releasing event's stream event context field.");
- field_release_func(event->stream_event_context_field);
- }
-
- if (event->context_field) {
- BT_LOGD_STR("Releasing event's context field.");
- field_release_func(event->context_field);
- }
-
- if (event->payload_field) {
- BT_LOGD_STR("Releasing event's payload field.");
- field_release_func(event->payload_field);
- }
-
- /*
- * Leave this after calling header_field_release_func() because
- * this function receives the event object and could need its
- * class to perform some cleanup.
- */
- if (!event->base.parent) {
- /*
- * Event was keeping a reference to its class since it shared no
- * common ancestor with it to guarantee they would both have the
- * same lifetime.
- */
- bt_ctf_object_put_ref(event->class);
- }
-}
-
-struct bt_ctf_event {
- struct bt_ctf_event_common common;
-};
-
-struct bt_ctf_event_class {
- struct bt_ctf_event_class_common common;
-};
-
-BT_HIDDEN
-int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
- struct metadata_context *context);
-
-BT_HIDDEN
-int bt_ctf_event_serialize(struct bt_ctf_event *event,
- struct bt_ctfser *pos,
- enum bt_ctf_byte_order native_byte_order);
-
-static inline
-struct bt_ctf_stream_class *bt_ctf_event_class_borrow_stream_class(
- struct bt_ctf_event_class *event_class)
-{
- return BT_CTF_FROM_COMMON(bt_ctf_event_class_common_borrow_stream_class(
- BT_CTF_TO_COMMON(event_class)));
-}
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_EVENT_TYPES_H
-#define BABELTRACE_CTF_WRITER_EVENT_TYPES_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/field-types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
- * the field type's reference count.
- *
- * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field type objects.
- *
- * These functions ensure that the field type won't be destroyed while it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) have to be done to
- * destroy a field type.
- *
- * When the field type's reference count is decremented to 0 by a
- * bt_ctf_field_type_put, the field type is freed.
- *
- * @param type Field type.
- */
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
-{
- bt_ctf_object_get_ref(type);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_field_type_put(struct bt_ctf_field_type *type)
-{
- bt_ctf_object_put_ref(type);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_TYPES_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_EVENT_H
-#define BABELTRACE_CTF_WRITER_EVENT_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/ctf-writer/object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event;
-struct bt_ctf_event_class;
-struct bt_ctf_stream;
-struct bt_ctf_field;
-struct bt_ctf_field_type;
-
-enum bt_ctf_event_class_log_level {
- /// Unknown, used for errors.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN = -1,
-
- /// Unspecified log level.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED = 255,
-
- /// System is unusable.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY = 0,
-
- /// Action must be taken immediately.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT = 1,
-
- /// Critical conditions.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL = 2,
-
- /// Error conditions.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR = 3,
-
- /// Warning conditions.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING = 4,
-
- /// Normal, but significant, condition.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE = 5,
-
- /// Informational message.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO = 6,
-
- /// Debug information with system-level scope (set of programs).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM = 7,
-
- /// Debug information with program-level scope (set of processes).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM = 8,
-
- /// Debug information with process-level scope (set of modules).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS = 9,
-
- /// Debug information with module (executable/library) scope (set of units).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE = 10,
-
- /// Debug information with compilation unit scope (set of functions).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT = 11,
-
- /// Debug information with function-level scope.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION = 12,
-
- /// Debug information with line-level scope (default log level).
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE = 13,
-
- /// Debug-level message.
- BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG = 14,
-};
-
-extern struct bt_ctf_event *bt_ctf_event_create(
- struct bt_ctf_event_class *event_class);
-
-extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
- const char *name);
-
-extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
- const char *name, struct bt_ctf_field *field);
-
-extern struct bt_ctf_field *bt_ctf_event_get_payload_field(
- struct bt_ctf_event *event);
-
-extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event,
- struct bt_ctf_field *field);
-
-extern int bt_ctf_event_set_context(struct bt_ctf_event *event,
- struct bt_ctf_field *field);
-
-extern struct bt_ctf_field *bt_ctf_event_get_context(
- struct bt_ctf_event *event);
-
-extern int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event,
- struct bt_ctf_field *field);
-
-extern struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
- struct bt_ctf_event *event);
-
-extern int bt_ctf_event_set_header(struct bt_ctf_event *event,
- struct bt_ctf_field *field);
-
-extern struct bt_ctf_field *bt_ctf_event_get_header(
- struct bt_ctf_event *event);
-
-extern struct bt_ctf_stream *bt_ctf_event_get_stream(
- struct bt_ctf_event *event);
-
-extern struct bt_ctf_event_class *bt_ctf_event_get_class(
- struct bt_ctf_event *event);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_event_get(struct bt_ctf_event *event)
-{
- bt_ctf_object_get_ref(event);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_event_put(struct bt_ctf_event *event)
-{
- bt_ctf_object_put_ref(event);
-}
-
-extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
-
-extern struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class(
- struct bt_ctf_event_class *event_class);
-
-extern const char *bt_ctf_event_class_get_name(
- struct bt_ctf_event_class *event_class);
-
-extern int64_t bt_ctf_event_class_get_id(
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_event_class_set_id(
- struct bt_ctf_event_class *event_class, uint64_t id);
-
-extern enum bt_ctf_event_class_log_level bt_ctf_event_class_get_log_level(
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_event_class_set_log_level(
- struct bt_ctf_event_class *event_class,
- enum bt_ctf_event_class_log_level log_level);
-
-extern const char *bt_ctf_event_class_get_emf_uri(
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_event_class_set_emf_uri(
- struct bt_ctf_event_class *event_class,
- const char *emf_uri);
-
-extern struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type(
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_event_class_set_context_field_type(
- struct bt_ctf_event_class *event_class,
- struct bt_ctf_field_type *context_type);
-
-extern struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type(
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_event_class_set_payload_field_type(
- struct bt_ctf_event_class *event_class,
- struct bt_ctf_field_type *payload_type);
-
-extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class,
- struct bt_ctf_field_type *field_type,
- const char *name);
-
-extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name(
- struct bt_ctf_event_class *event_class, const char *name);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class)
-{
- bt_ctf_object_get_ref(event_class);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class)
-{
- bt_ctf_object_put_ref(event_class);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL
-#define BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL
-
-/*
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/common-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <glib.h>
-
-struct bt_ctf_field_path {
- struct bt_ctf_object base;
- enum bt_ctf_scope root;
-
- /*
- * Array of integers (int) indicating the index in either
- * structures, variants, arrays, or sequences that make up
- * the path to a field type. -1 means the "current element
- * of an array or sequence type".
- */
- GArray *indexes;
-};
-
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_create(void);
-
-BT_HIDDEN
-void bt_ctf_field_path_clear(struct bt_ctf_field_path *field_path);
-
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_copy(
- struct bt_ctf_field_path *path);
-
-BT_HIDDEN enum bt_ctf_scope bt_ctf_field_path_get_root_scope(
- const struct bt_ctf_field_path *field_path);
-
-BT_HIDDEN int64_t bt_ctf_field_path_get_index_count(
- const struct bt_ctf_field_path *field_path);
-
-BT_HIDDEN int bt_ctf_field_path_get_index(
- const struct bt_ctf_field_path *field_path, uint64_t index);
-
-#endif /* BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/types.h>
-
-#define BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(_ft, _type_id, _name) \
- BT_ASSERT_PRE(((struct bt_ctf_field_type_common *) (_ft))->id == (_type_id), \
- _name " has the wrong type ID: expected-type-id=%s, " \
- "ft-addr=%p", bt_ctf_field_type_id_string(_type_id), (_ft))
-
-#define BT_ASSERT_PRE_CTF_FT_HOT(_ft, _name) \
- BT_ASSERT_PRE_HOT((_ft), (_name), ": ft-addr=%p", (_ft))
-
-#define BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_ctf_field_type_common_structure *) (_ft))->fields, \
- struct bt_ctf_field_type_common_structure_field, (_index)))
-
-#define BT_CTF_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_ctf_field_type_common_variant *) (_ft))->choices, \
- struct bt_ctf_field_type_common_variant_choice, (_index)))
-
-struct bt_ctf_field_common;
-struct bt_ctf_field_type_common;
-
-typedef void (*bt_ctf_field_type_common_method_freeze)(
- struct bt_ctf_field_type_common *);
-typedef int (*bt_ctf_field_type_common_method_validate)(
- struct bt_ctf_field_type_common *);
-typedef void (*bt_ctf_field_type_common_method_set_byte_order)(
- struct bt_ctf_field_type_common *, enum bt_ctf_byte_order);
-typedef struct bt_ctf_field_type_common *(*bt_ctf_field_type_common_method_copy)(
- struct bt_ctf_field_type_common *);
-typedef int (*bt_ctf_field_type_common_method_compare)(
- struct bt_ctf_field_type_common *,
- struct bt_ctf_field_type_common *);
-
-struct bt_ctf_field_type_common_methods {
- bt_ctf_field_type_common_method_freeze freeze;
- bt_ctf_field_type_common_method_validate validate;
- bt_ctf_field_type_common_method_set_byte_order set_byte_order;
- bt_ctf_field_type_common_method_copy copy;
- bt_ctf_field_type_common_method_compare compare;
-};
-
-struct bt_ctf_field_type_common {
- struct bt_ctf_object base;
- enum bt_ctf_field_type_id id;
- unsigned int alignment;
-
- /* Virtual table */
- struct bt_ctf_field_type_common_methods *methods;
-
- /*
- * A type can't be modified once it is added to an event or after a
- * a field has been instanciated from it.
- */
- int frozen;
-
- /*
- * This flag indicates if the field type is valid. A valid
- * field type is _always_ frozen. All the nested field types of
- * a valid field type are also valid (and thus frozen).
- */
- int valid;
-
- /*
- * Specialized data for either CTF IR or CTF writer APIs.
- * Having this here ensures that:
- *
- * * The type-specific common data is always found at the same
- * offset when the common API has a `struct
- * bt_ctf_field_type_common *` so that you can cast it to `struct
- * bt_ctf_field_type_common_integer *` for example and access the
- * common integer field type fields.
- *
- * * The specific CTF IR and CTF writer APIs can access their
- * specific field type fields in this union at an offset known
- * at build time. This avoids a pointer to specific data so
- * that all the fields, common or specific, of a CTF IR
- * integer field type or of a CTF writer integer field type,
- * for example, are contained within the same contiguous block
- * of memory.
- */
- union {
- struct {
- } ir;
- struct {
- void *serialize_func;
- } writer;
- } spec;
-};
-
-struct bt_ctf_field_type_common_integer {
- struct bt_ctf_field_type_common common;
-
- /* Owned by this */
- struct bt_ctf_clock_class *mapped_clock_class;
-
- enum bt_ctf_byte_order user_byte_order;
- bt_bool is_signed;
- unsigned int size;
- enum bt_ctf_integer_base base;
- enum bt_ctf_string_encoding encoding;
-};
-
-struct bt_ctf_enumeration_mapping {
- union {
- uint64_t _unsigned;
- int64_t _signed;
- } range_start;
- union {
- uint64_t _unsigned;
- int64_t _signed;
- } range_end;
- GQuark string;
-};
-
-struct bt_ctf_field_type_common_enumeration {
- struct bt_ctf_field_type_common common;
-
- /* Owned by this */
- struct bt_ctf_field_type_common_integer *container_ft;
-
- /* Array of `struct bt_ctf_enumeration_mapping *`, owned by this */
- GPtrArray *entries;
-
- /* Only set during validation */
- bt_bool has_overlapping_ranges;
-};
-
-enum bt_ctf_field_type_enumeration_mapping_iterator_type {
- CTF_ITERATOR_BY_NAME,
- CTF_ITERATOR_BY_SIGNED_VALUE,
- CTF_ITERATOR_BY_UNSIGNED_VALUE,
-};
-
-struct bt_ctf_field_type_enumeration_mapping_iterator {
- struct bt_ctf_object base;
-
- /* Owned by this */
- struct bt_ctf_field_type_common_enumeration *enumeration_ft;
-
- enum bt_ctf_field_type_enumeration_mapping_iterator_type type;
- int index;
- union {
- GQuark name_quark;
- int64_t signed_value;
- uint64_t unsigned_value;
- } u;
-};
-
-struct bt_ctf_field_type_common_floating_point {
- struct bt_ctf_field_type_common common;
- enum bt_ctf_byte_order user_byte_order;
- unsigned int exp_dig;
- unsigned int mant_dig;
-};
-
-struct bt_ctf_field_type_common_structure_field {
- GQuark name;
-
- /* Owned by this */
- struct bt_ctf_field_type_common *type;
-};
-
-struct bt_ctf_field_type_common_structure {
- struct bt_ctf_field_type_common common;
- GHashTable *field_name_to_index;
-
- /*
- * Array of `struct bt_ctf_field_type_common_structure_field`,
- * owned by this
- */
- GArray *fields;
-};
-
-struct bt_ctf_field_type_common_variant_choice_range {
- union {
- int64_t i;
- uint64_t u;
- } lower;
- union {
- int64_t i;
- uint64_t u;
- } upper;
-};
-
-struct bt_ctf_field_type_common_variant_choice {
- GQuark name;
-
- /* Owned by this */
- struct bt_ctf_field_type_common *type;
-
- /* Array of `struct bt_ctf_field_type_common_variant_choice_range` */
- GArray *ranges;
-};
-
-struct bt_ctf_field_type_common_variant {
- struct bt_ctf_field_type_common common;
- GString *tag_name;
- bool choices_up_to_date;
-
- /* Owned by this */
- struct bt_ctf_field_type_common_enumeration *tag_ft;
-
- /* Owned by this */
- struct bt_ctf_field_path *tag_field_path;
-
- GHashTable *choice_name_to_index;
-
- /*
- * Array of `struct bt_ctf_field_type_common_variant_choice`,
- * owned by this */
- GArray *choices;
-};
-
-struct bt_ctf_field_type_common_array {
- struct bt_ctf_field_type_common common;
-
- /* Owned by this */
- struct bt_ctf_field_type_common *element_ft;
-
- unsigned int length;
-};
-
-struct bt_ctf_field_type_common_sequence {
- struct bt_ctf_field_type_common common;
-
- /* Owned by this */
- struct bt_ctf_field_type_common *element_ft;
-
- GString *length_field_name;
-
- /* Owned by this */
- struct bt_ctf_field_path *length_field_path;
-};
-
-struct bt_ctf_field_type_common_string {
- struct bt_ctf_field_type_common common;
- enum bt_ctf_string_encoding encoding;
-};
-
-typedef struct bt_ctf_field_common *(* bt_ctf_field_common_create_func)(
- struct bt_ctf_field_type_common *);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_initialize(struct bt_ctf_field_type_common *ft,
- bool init_bo, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_integer_initialize(
- struct bt_ctf_field_type_common *ft,
- unsigned int size, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_floating_point_initialize(
- struct bt_ctf_field_type_common *ft,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_initialize(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *container_ft,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_string_initialize(
- struct bt_ctf_field_type_common *ft,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_structure_initialize(
- struct bt_ctf_field_type_common *ft,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_array_initialize(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *element_ft,
- unsigned int length, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_sequence_initialize(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *element_ft,
- const char *length_field_name,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_variant_initialize(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *tag_ft,
- const char *tag_name,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_integer_destroy(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_floating_point_destroy(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_string_destroy(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_array_destroy_recursive(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_ctf_object *obj);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_validate(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_validate_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_sequence_validate_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_array_validate_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_validate_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_validate_recursive(
- struct bt_ctf_field_type_common *type);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_validate(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_get_size(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_type_common_integer_is_signed(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_is_signed(struct bt_ctf_field_type_common *ft,
- bt_bool is_signed);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_size(struct bt_ctf_field_type_common *ft,
- unsigned int size);
-
-BT_HIDDEN
-enum bt_ctf_integer_base bt_ctf_field_type_common_integer_get_base(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_base(struct bt_ctf_field_type_common *ft,
- enum bt_ctf_integer_base base);
-
-BT_HIDDEN
-enum bt_ctf_string_encoding bt_ctf_field_type_common_integer_get_encoding(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_encoding(struct bt_ctf_field_type_common *ft,
- enum bt_ctf_string_encoding encoding);
-
-BT_HIDDEN
-struct bt_ctf_clock_class *bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_set_mapped_clock_class(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-struct bt_ctf_field_type_enumeration_mapping_iterator *
-bt_ctf_field_type_common_enumeration_find_mappings_by_name(
- struct bt_ctf_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-struct bt_ctf_field_type_enumeration_mapping_iterator *
-bt_ctf_field_type_common_enumeration_signed_find_mappings_by_value(
- struct bt_ctf_field_type_common *ft, int64_t value);
-
-BT_HIDDEN
-struct bt_ctf_field_type_enumeration_mapping_iterator *
-bt_ctf_field_type_common_enumeration_unsigned_find_mappings_by_value(
- struct bt_ctf_field_type_common *ft, uint64_t value);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_signed_get_mapping_by_index(
- struct bt_ctf_field_type_common *ft, uint64_t index,
- const char **mapping_name, int64_t *range_begin,
- int64_t *range_end);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_unsigned_get_mapping_by_index(
- struct bt_ctf_field_type_common *ft, uint64_t index,
- const char **mapping_name, uint64_t *range_begin,
- uint64_t *range_end);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_enumeration_borrow_container_field_type(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_signed_add_mapping(
- struct bt_ctf_field_type_common *ft, const char *string,
- int64_t range_start, int64_t range_end);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_unsigned_add_mapping(
- struct bt_ctf_field_type_common *ft, const char *string,
- uint64_t range_start, uint64_t range_end);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_enumeration_get_mapping_count(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_floating_point_get_exponent_digits(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_floating_point_set_exponent_digits(
- struct bt_ctf_field_type_common *ft,
- unsigned int exponent_digits);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_floating_point_get_mantissa_digits(
- struct bt_ctf_field_type_common *type);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_floating_point_set_mantissa_digits(
- struct bt_ctf_field_type_common *ft, unsigned int mantissa_digits);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_replace_field(
- struct bt_ctf_field_type_common *ft,
- const char *field_name,
- struct bt_ctf_field_type_common *field_type);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_add_field(struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *field_type,
- const char *field_name);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_structure_get_field_count(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_borrow_field_by_index(
- struct bt_ctf_field_type_common *ft,
- const char **field_name,
- struct bt_ctf_field_type_common **field_type, uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_structure_borrow_field_type_by_name(
- struct bt_ctf_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_variant_borrow_tag_field_type(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-const char *bt_ctf_field_type_common_variant_get_tag_name(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_set_tag_name(
- struct bt_ctf_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_add_field(struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *field_type,
- const char *field_name);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_update_choices(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_variant_borrow_field_type_by_name(
- struct bt_ctf_field_type_common *ft,
- const char *field_name);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_variant_get_field_count(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_borrow_field_by_index(
- struct bt_ctf_field_type_common *ft,
- const char **field_name,
- struct bt_ctf_field_type_common **field_type, uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_array_borrow_element_field_type(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_array_set_element_field_type(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *element_ft);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_array_get_length(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_sequence_borrow_element_field_type(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_sequence_set_element_field_type(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *element_ft);
-
-BT_HIDDEN
-const char *bt_ctf_field_type_common_sequence_get_length_field_name(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-enum bt_ctf_string_encoding bt_ctf_field_type_common_string_get_encoding(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_string_set_encoding(struct bt_ctf_field_type_common *ft,
- enum bt_ctf_string_encoding encoding);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_get_alignment(struct bt_ctf_field_type_common *type);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_set_alignment(struct bt_ctf_field_type_common *ft,
- unsigned int alignment);
-
-BT_HIDDEN
-enum bt_ctf_byte_order bt_ctf_field_type_common_get_byte_order(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_set_byte_order(struct bt_ctf_field_type_common *ft,
- enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-enum bt_ctf_field_type_id bt_ctf_field_type_common_get_type_id(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_freeze(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_variant_borrow_field_type_signed(
- struct bt_ctf_field_type_common_variant *var_ft,
- int64_t tag_value);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *
-bt_ctf_field_type_common_variant_borrow_field_type_unsigned(
- struct bt_ctf_field_type_common_variant *var_ft,
- uint64_t tag_value);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *bt_ctf_field_type_common_copy(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_get_field_name_index(
- struct bt_ctf_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_get_field_name_index(
- struct bt_ctf_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_sequence_set_length_field_path(
- struct bt_ctf_field_type_common *ft, struct bt_ctf_field_path *path);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_set_tag_field_path(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_path *path);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_set_tag_field_type(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_field_type_common *tag_ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_generic_freeze(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_freeze_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_structure_freeze_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_variant_freeze_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_array_freeze_recursive(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_sequence_freeze_recursive(
- struct bt_ctf_field_type_common *type);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_integer_set_byte_order(
- struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_enumeration_set_byte_order_recursive(
- struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_floating_point_set_byte_order(
- struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_structure_set_byte_order_recursive(
- struct bt_ctf_field_type_common *ft,
- enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_variant_set_byte_order_recursive(
- struct bt_ctf_field_type_common *ft,
- enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_array_set_byte_order_recursive(
- struct bt_ctf_field_type_common *ft,
- enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_field_type_common_sequence_set_byte_order_recursive(
- struct bt_ctf_field_type_common *ft,
- enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_integer_compare(struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_floating_point_compare(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_enumeration_compare_recursive(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_string_compare(struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_structure_compare_recursive(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_variant_compare_recursive(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_array_compare_recursive(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_sequence_compare_recursive(
- struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_compare(struct bt_ctf_field_type_common *ft_a,
- struct bt_ctf_field_type_common *ft_b);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_get_field_count(struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_ctf_field_type_common *bt_ctf_field_type_common_borrow_field_at_index(
- struct bt_ctf_field_type_common *ft, int index);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_get_field_index(struct bt_ctf_field_type_common *ft,
- const char *name);
-
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_type_common_variant_borrow_tag_field_path(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_type_common_sequence_borrow_length_field_path(
- struct bt_ctf_field_type_common *ft);
-
-BT_HIDDEN
-int bt_ctf_field_type_common_validate_single_clock_class(
- struct bt_ctf_field_type_common *ft,
- struct bt_ctf_clock_class **expected_clock_class);
-
-BT_HIDDEN
-int64_t bt_ctf_field_type_common_variant_find_choice_index(
- struct bt_ctf_field_type_common *ft, uint64_t uval,
- bool is_signed);
-
-BT_HIDDEN
-int bt_ctf_field_type_serialize_recursive(struct bt_ctf_field_type *type,
- struct metadata_context *context);
-
-BT_HIDDEN
-struct bt_ctf_field_type *bt_ctf_field_type_copy(struct bt_ctf_field_type *ft);
-
-#endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_H
-#define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_field;
-struct bt_ctf_field_type;
-
-enum bt_ctf_scope {
- /// Unknown, used for errors.
- BT_CTF_SCOPE_UNKNOWN = -1,
-
- /// Trace packet header.
- BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1,
-
- /// Stream packet context.
- BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2,
-
- /// Stream event header.
- BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3,
-
- /// Stream event context.
- BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4,
-
- /// Event context.
- BT_CTF_SCOPE_EVENT_CONTEXT = 5,
-
- /// Event payload.
- BT_CTF_SCOPE_EVENT_PAYLOAD = 6,
-
- /// @cond DOCUMENT
- BT_CTF_SCOPE_ENV = 0,
- BT_CTF_SCOPE_EVENT_FIELDS = 6,
- /// @endcond
-};
-
-enum bt_ctf_field_type_id {
- BT_CTF_FIELD_TYPE_ID_UNKNOWN = -1,
- BT_CTF_FIELD_TYPE_ID_INTEGER = 0,
- BT_CTF_FIELD_TYPE_ID_FLOAT = 1,
- BT_CTF_FIELD_TYPE_ID_ENUM = 2,
- BT_CTF_FIELD_TYPE_ID_STRING = 3,
- BT_CTF_FIELD_TYPE_ID_STRUCT = 4,
- BT_CTF_FIELD_TYPE_ID_ARRAY = 5,
- BT_CTF_FIELD_TYPE_ID_SEQUENCE = 6,
- BT_CTF_FIELD_TYPE_ID_VARIANT = 7,
- BT_CTF_FIELD_TYPE_ID_NR,
-};
-
-extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
- struct bt_ctf_field_type *field_type);
-
-enum bt_ctf_byte_order {
- BT_CTF_BYTE_ORDER_UNKNOWN = -1,
- BT_CTF_BYTE_ORDER_NATIVE = 0,
- BT_CTF_BYTE_ORDER_UNSPECIFIED,
- BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
- BT_CTF_BYTE_ORDER_BIG_ENDIAN,
- BT_CTF_BYTE_ORDER_NETWORK,
-};
-
-enum bt_ctf_string_encoding {
- BT_CTF_STRING_ENCODING_UNKNOWN = -1,
- BT_CTF_STRING_ENCODING_NONE,
- BT_CTF_STRING_ENCODING_UTF8,
- BT_CTF_STRING_ENCODING_ASCII,
-};
-
-/* Pre-2.0 CTF writer compatibility */
-#define ctf_string_encoding bt_ctf_string_encoding
-
-extern int bt_ctf_field_type_get_alignment(
- struct bt_ctf_field_type *field_type);
-
-extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type,
- unsigned int alignment);
-
-extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
- struct bt_ctf_field_type *field_type);
-
-extern int bt_ctf_field_type_set_byte_order(
- struct bt_ctf_field_type *field_type,
- enum bt_ctf_byte_order byte_order);
-
-enum bt_ctf_integer_base {
- /// Unknown, used for errors.
- BT_CTF_INTEGER_BASE_UNKNOWN = -1,
-
- /// Unspecified by the tracer.
- BT_CTF_INTEGER_BASE_UNSPECIFIED = 0,
-
- /// Binary.
- BT_CTF_INTEGER_BASE_BINARY = 2,
-
- /// Octal.
- BT_CTF_INTEGER_BASE_OCTAL = 8,
-
- /// Decimal.
- BT_CTF_INTEGER_BASE_DECIMAL = 10,
-
- /// Hexadecimal.
- BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
-};
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
- unsigned int size);
-
-extern int bt_ctf_field_type_integer_get_size(
- struct bt_ctf_field_type *int_field_type);
-
-extern int bt_ctf_field_type_integer_set_size(
- struct bt_ctf_field_type *int_field_type, unsigned int size);
-
-extern bt_bool bt_ctf_field_type_integer_is_signed(
- struct bt_ctf_field_type *int_field_type);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_type_integer_get_signed(
- struct bt_ctf_field_type *int_field_type)
-{
- return bt_ctf_field_type_integer_is_signed(int_field_type) ? 1 : 0;
-}
-
-extern int bt_ctf_field_type_integer_set_is_signed(
- struct bt_ctf_field_type *int_field_type, bt_bool is_signed);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_type_integer_set_signed(
- struct bt_ctf_field_type *int_field_type, int is_signed)
-{
- return bt_ctf_field_type_integer_set_is_signed(int_field_type,
- is_signed ? BT_TRUE : BT_FALSE);
-}
-
-extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
- struct bt_ctf_field_type *int_field_type);
-
-extern int bt_ctf_field_type_integer_set_base(
- struct bt_ctf_field_type *int_field_type,
- enum bt_ctf_integer_base base);
-
-extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
- struct bt_ctf_field_type *int_field_type);
-
-extern int bt_ctf_field_type_integer_set_encoding(
- struct bt_ctf_field_type *int_field_type,
- enum bt_ctf_string_encoding encoding);
-
-extern struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
- struct bt_ctf_field_type *int_field_type);
-
-extern int bt_ctf_field_type_integer_set_mapped_clock_class(
- struct bt_ctf_field_type *int_field_type,
- struct bt_ctf_clock_class *clock_class);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
-
-extern int bt_ctf_field_type_floating_point_get_exponent_digits(
- struct bt_ctf_field_type *float_field_type);
-
-extern int bt_ctf_field_type_floating_point_set_exponent_digits(
- struct bt_ctf_field_type *float_field_type,
- unsigned int exponent_size);
-
-extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
- struct bt_ctf_field_type *float_field_type);
-
-extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
- struct bt_ctf_field_type *float_field_type,
- unsigned int mantissa_sign_size);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
- struct bt_ctf_field_type *int_field_type);
-
-extern
-struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
- struct bt_ctf_field_type *enum_field_type);
-
-extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
- struct bt_ctf_field_type *enum_field_type);
-
-extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
- struct bt_ctf_field_type *enum_field_type, uint64_t index,
- const char **name, int64_t *range_begin, int64_t *range_end);
-
-extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
- struct bt_ctf_field_type *enum_field_type, uint64_t index,
- const char **name, uint64_t *range_begin,
- uint64_t *range_end);
-
-extern int bt_ctf_field_type_enumeration_signed_add_mapping(
- struct bt_ctf_field_type *enum_field_type,
- const char *name, int64_t range_begin, int64_t range_end);
-
-extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
- struct bt_ctf_field_type *enum_field_type,
- const char *name, uint64_t range_begin, uint64_t range_end);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_type_enumeration_add_mapping(
- struct bt_ctf_field_type *enumeration, const char *name,
- int64_t range_start, int64_t range_end)
-{
- return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration,
- name, range_start, range_end);
-}
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
-
-extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
- struct bt_ctf_field_type *string_field_type);
-
-extern int bt_ctf_field_type_string_set_encoding(
- struct bt_ctf_field_type *string_field_type,
- enum bt_ctf_string_encoding encoding);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
-
-extern int64_t bt_ctf_field_type_structure_get_field_count(
- struct bt_ctf_field_type *struct_field_type);
-
-extern int bt_ctf_field_type_structure_get_field_by_index(
- struct bt_ctf_field_type *struct_field_type,
- const char **field_name, struct bt_ctf_field_type **field_type,
- uint64_t index);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure,
- const char **field_name, struct bt_ctf_field_type **field_type,
- int index)
-{
- return bt_ctf_field_type_structure_get_field_by_index(structure,
- field_name, field_type, (uint64_t) index);
-}
-
-extern
-struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
- struct bt_ctf_field_type *struct_field_type,
- const char *field_name);
-
-extern int bt_ctf_field_type_structure_add_field(
- struct bt_ctf_field_type *struct_field_type,
- struct bt_ctf_field_type *field_type,
- const char *field_name);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
- struct bt_ctf_field_type *element_field_type,
- unsigned int length);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
- struct bt_ctf_field_type *array_field_type);
-
-extern int64_t bt_ctf_field_type_array_get_length(
- struct bt_ctf_field_type *array_field_type);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
- struct bt_ctf_field_type *element_field_type,
- const char *length_name);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
- struct bt_ctf_field_type *sequence_field_type);
-
-extern const char *bt_ctf_field_type_sequence_get_length_field_name(
- struct bt_ctf_field_type *sequence_field_type);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
- struct bt_ctf_field_type *tag_field_type,
- const char *tag_name);
-
-extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
- struct bt_ctf_field_type *variant_field_type);
-
-extern const char *bt_ctf_field_type_variant_get_tag_name(
- struct bt_ctf_field_type *variant_field_type);
-
-extern int bt_ctf_field_type_variant_set_tag_name(
- struct bt_ctf_field_type *variant_field_type,
- const char *tag_name);
-
-extern int64_t bt_ctf_field_type_variant_get_field_count(
- struct bt_ctf_field_type *variant_field_type);
-
-extern int bt_ctf_field_type_variant_get_field_by_index(
- struct bt_ctf_field_type *variant_field_type,
- const char **field_name,
- struct bt_ctf_field_type **field_type, uint64_t index);
-
-extern
-struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
- struct bt_ctf_field_type *variant_field_type,
- const char *field_name);
-
-extern
-struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
- struct bt_ctf_field_type *variant_field_type,
- struct bt_ctf_field *tag_field);
-
-extern int bt_ctf_field_type_variant_add_field(
- struct bt_ctf_field_type *variant_field_type,
- struct bt_ctf_field_type *field_type,
- const char *field_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/object-pool-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-
-struct bt_ctf_field_wrapper {
- struct bt_ctf_object base;
-
- /* Owned by this */
- struct bt_ctf_field_common *field;
-};
-
-BT_HIDDEN
-struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_new(void *data);
-
-BT_HIDDEN
-void bt_ctf_field_wrapper_destroy(struct bt_ctf_field_wrapper *field);
-
-BT_HIDDEN
-struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
- struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft);
-
-#endif /* BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctfser-internal.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-
-#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name) \
- BT_ASSERT_PRE((_field)->type->id == ((int) (_type_id)), \
- _name " has the wrong type ID: expected-type-id=%s, " \
- "field-addr=%p", \
- bt_ctf_field_type_id_string((int) (_type_id)), (_field))
-
-#define BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(_field, _name) \
- BT_ASSERT_PRE(bt_ctf_field_common_is_set_recursive(_field), \
- _name " is not set: field-addr=%p", (_field))
-
-#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(_field, _name) \
- BT_ASSERT_PRE_HOT((_field), (_name), ": field-addr=%p", (_field))
-
-struct bt_ctf_field_common;
-
-typedef void (*bt_ctf_field_common_method_set_is_frozen)(struct bt_ctf_field_common *,
- bool);
-typedef int (*bt_ctf_field_common_method_validate)(struct bt_ctf_field_common *);
-typedef struct bt_ctf_field_common *(*bt_ctf_field_common_method_copy)(
- struct bt_ctf_field_common *);
-typedef bt_bool (*bt_ctf_field_common_method_is_set)(struct bt_ctf_field_common *);
-typedef void (*bt_ctf_field_common_method_reset)(struct bt_ctf_field_common *);
-
-struct bt_ctf_field_common_methods {
- bt_ctf_field_common_method_set_is_frozen set_is_frozen;
- bt_ctf_field_common_method_validate validate;
- bt_ctf_field_common_method_copy copy;
- bt_ctf_field_common_method_is_set is_set;
- bt_ctf_field_common_method_reset reset;
-};
-
-struct bt_ctf_field_common {
- struct bt_ctf_object base;
- struct bt_ctf_field_type_common *type;
- struct bt_ctf_field_common_methods *methods;
- bool payload_set;
- bool frozen;
-
- /*
- * Specialized data for either CTF IR or CTF writer APIs.
- * See comment in `field-types-internal.h` for more details.
- */
- union {
- struct {
- } ir;
- struct {
- void *serialize_func;
- } writer;
- } spec;
-};
-
-struct bt_ctf_field_common_integer {
- struct bt_ctf_field_common common;
- union {
- int64_t signd;
- uint64_t unsignd;
- } payload;
-};
-
-struct bt_ctf_field_common_floating_point {
- struct bt_ctf_field_common common;
- double payload;
-};
-
-struct bt_ctf_field_common_structure {
- struct bt_ctf_field_common common;
-
- /* Array of `struct bt_ctf_field_common *`, owned by this */
- GPtrArray *fields;
-};
-
-struct bt_ctf_field_common_variant {
- struct bt_ctf_field_common common;
-
- union {
- uint64_t u;
- int64_t i;
- } tag_value;
-
- /* Weak: belongs to `choices` below */
- struct bt_ctf_field_common *current_field;
-
- /* Array of `struct bt_ctf_field_common *`, owned by this */
- GPtrArray *fields;
-};
-
-struct bt_ctf_field_common_array {
- struct bt_ctf_field_common common;
-
- /* Array of `struct bt_ctf_field_common *`, owned by this */
- GPtrArray *elements;
-};
-
-struct bt_ctf_field_common_sequence {
- struct bt_ctf_field_common common;
-
- /*
- * This is the true sequence field's length: its value can be
- * less than `elements->len` below because we never shrink the
- * array of elements to avoid reallocation.
- */
- uint64_t length;
-
- /* Array of `struct bt_ctf_field_common *`, owned by this */
- GPtrArray *elements;
-};
-
-struct bt_ctf_field_common_string {
- struct bt_ctf_field_common common;
- GArray *buf;
- size_t size;
-};
-
-BT_HIDDEN
-struct bt_ctf_field_common *bt_ctf_field_common_copy(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *type,
- bool is_shared, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods,
- bt_ctf_field_common_create_func field_create_func,
- GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *type,
- bool is_shared, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods,
- bt_ctf_field_common_create_func field_create_func,
- GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *type,
- bool is_shared, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods,
- GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *type,
- bool is_shared, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods,
- bt_ctf_field_common_create_func field_create_func,
- GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *type,
- bool is_shared, bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods);
-
-BT_HIDDEN
-int bt_ctf_field_common_generic_validate(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-int bt_ctf_field_common_structure_validate_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-int bt_ctf_field_common_variant_validate_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-int bt_ctf_field_common_array_validate_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-int bt_ctf_field_common_sequence_validate_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_generic_reset(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_structure_reset_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_variant_reset_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_array_reset_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_sequence_reset_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-void bt_ctf_field_common_generic_set_is_frozen(struct bt_ctf_field_common *field,
- bool is_frozen);
-
-BT_HIDDEN
-void bt_ctf_field_common_structure_set_is_frozen_recursive(
- struct bt_ctf_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_ctf_field_common_variant_set_is_frozen_recursive(
- struct bt_ctf_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_ctf_field_common_array_set_is_frozen_recursive(
- struct bt_ctf_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_ctf_field_common_sequence_set_is_frozen_recursive(
- struct bt_ctf_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void _bt_ctf_field_common_set_is_frozen_recursive(struct bt_ctf_field_common *field,
- bool is_frozen);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_common_generic_is_set(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_common_structure_is_set_recursive(
- struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_common_variant_is_set_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_common_array_is_set_recursive(struct bt_ctf_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_ctf_field_common_sequence_is_set_recursive(struct bt_ctf_field_common *field);
-
-#ifdef BT_DEV_MODE
-# define bt_ctf_field_common_validate_recursive _bt_ctf_field_common_validate_recursive
-# define bt_ctf_field_common_set_is_frozen_recursive _bt_ctf_field_common_set_is_frozen_recursive
-# define bt_ctf_field_common_is_set_recursive _bt_ctf_field_common_is_set_recursive
-# define bt_ctf_field_common_reset_recursive _bt_ctf_field_common_reset_recursive
-# define bt_ctf_field_common_set _bt_ctf_field_common_set
-#else
-# define bt_ctf_field_common_validate_recursive(_field) (-1)
-# define bt_ctf_field_common_set_is_frozen_recursive(_field, _is_frozen)
-# define bt_ctf_field_common_is_set_recursive(_field) (BT_FALSE)
-# define bt_ctf_field_common_reset_recursive(_field)
-# define bt_ctf_field_common_set(_field, _val)
-#endif
-
-BT_ASSERT_FUNC
-static inline bool field_type_common_has_known_id(
- struct bt_ctf_field_type_common *ft)
-{
- return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN ||
- (int) ft->id < BT_CTF_FIELD_TYPE_ID_NR;
-}
-
-static inline
-int _bt_ctf_field_common_validate_recursive(struct bt_ctf_field_common *field)
-{
- int ret = 0;
-
- if (!field) {
- BT_ASSERT_PRE_MSG("%s", "Invalid field: field is NULL.");
- ret = -1;
- goto end;
- }
-
- BT_ASSERT(field_type_common_has_known_id(field->type));
-
- if (field->methods->validate) {
- ret = field->methods->validate(field);
- }
-
-end:
- return ret;
-}
-
-static inline
-void _bt_ctf_field_common_reset_recursive(struct bt_ctf_field_common *field)
-{
- BT_ASSERT(field);
- BT_ASSERT(field->methods->reset);
- field->methods->reset(field);
-}
-
-static inline
-void _bt_ctf_field_common_set(struct bt_ctf_field_common *field, bool value)
-{
- BT_ASSERT(field);
- field->payload_set = value;
-}
-
-static inline
-bt_bool _bt_ctf_field_common_is_set_recursive(struct bt_ctf_field_common *field)
-{
- bt_bool is_set = BT_FALSE;
-
- if (!field) {
- goto end;
- }
-
- BT_ASSERT(field_type_common_has_known_id(field->type));
- BT_ASSERT(field->methods->is_set);
- is_set = field->methods->is_set(field);
-
-end:
- return is_set;
-}
-
-static inline
-void bt_ctf_field_common_initialize(struct bt_ctf_field_common *field,
- struct bt_ctf_field_type_common *ft, bool is_shared,
- bt_ctf_object_release_func release_func,
- struct bt_ctf_field_common_methods *methods)
-{
- BT_ASSERT(field);
- BT_ASSERT(ft);
- bt_ctf_object_init(&field->base, is_shared, release_func);
- field->methods = methods;
- field->type = (void *) bt_ctf_object_get_ref(ft);
-}
-
-static inline
-struct bt_ctf_field_type_common *bt_ctf_field_common_borrow_type(
- struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_type_common *ret = NULL;
-
- BT_ASSERT_PRE_NON_NULL(field, "Field");
- ret = field->type;
- return ret;
-}
-
-static inline
-int64_t bt_ctf_field_common_sequence_get_length(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE,
- "Field");
- return (int64_t) sequence->length;
-}
-
-static inline
-int bt_ctf_field_common_sequence_set_length(struct bt_ctf_field_common *field,
- uint64_t length, bt_ctf_field_common_create_func field_create_func)
-{
- int ret = 0;
- struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
- BT_ASSERT_PRE(((int64_t) length) >= 0,
- "Invalid sequence length (too large): length=%" PRId64,
- length);
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Sequence field");
-
- if (unlikely(length > sequence->elements->len)) {
- /* Make more room */
- struct bt_ctf_field_type_common_sequence *sequence_ft;
- uint64_t cur_len = sequence->elements->len;
- uint64_t i;
-
- g_ptr_array_set_size(sequence->elements, length);
- sequence_ft = BT_CTF_FROM_COMMON(sequence->common.type);
-
- for (i = cur_len; i < sequence->elements->len; i++) {
- struct bt_ctf_field_common *elem_field =
- field_create_func(sequence_ft->element_ft);
-
- if (!elem_field) {
- ret = -1;
- goto end;
- }
-
- BT_ASSERT(!sequence->elements->pdata[i]);
- sequence->elements->pdata[i] = elem_field;
- }
- }
-
- sequence->length = length;
-
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_name(
- struct bt_ctf_field_common *field, const char *name)
-{
- struct bt_ctf_field_common *ret = NULL;
- GQuark field_quark;
- struct bt_ctf_field_type_common_structure *structure_ft;
- struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
- size_t index;
- GHashTable *field_name_to_index;
-
- BT_ASSERT_PRE_NON_NULL(field, "Structure field");
- BT_ASSERT_PRE_NON_NULL(name, "Field name");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRUCT, "Field");
- structure_ft = BT_CTF_FROM_COMMON(field->type);
- field_name_to_index = structure_ft->field_name_to_index;
- field_quark = g_quark_from_string(name);
- if (!g_hash_table_lookup_extended(field_name_to_index,
- GUINT_TO_POINTER(field_quark),
- NULL, (gpointer *) &index)) {
- BT_LOGV("Invalid parameter: no such field in structure field's type: "
- "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
- field, field->type, name);
- goto error;
- }
-
- ret = structure->fields->pdata[index];
- BT_ASSERT(ret);
-
-error:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_index(
- struct bt_ctf_field_common *field, uint64_t index)
-{
- struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Structure field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRUCT, "Field");
- BT_ASSERT_PRE(index < structure->fields->len,
- "Index is out of bound: struct-field-addr=%p, "
- "index=%" PRIu64 ", count=%u", field, index,
- structure->fields->len);
- return structure->fields->pdata[index];
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_field_common_array_borrow_field(
- struct bt_ctf_field_common *field, uint64_t index)
-{
- struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Array field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_ARRAY,
- "Field");
- BT_ASSERT_PRE(index < array->elements->len,
- "Index is out of bound: array-field-addr=%p, "
- "index=%" PRIu64 ", count=%u", field,
- index, array->elements->len);
- return array->elements->pdata[(size_t) index];
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_field_common_sequence_borrow_field(
- struct bt_ctf_field_common *field, uint64_t index)
-{
- struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE,
- "Field");
- BT_ASSERT_PRE(index < sequence->length,
- "Index is out of bound: seq-field-addr=%p, "
- "index=%" PRIu64 ", count=%u", field, index,
- sequence->elements->len);
- return sequence->elements->pdata[(size_t) index];
-}
-
-static inline
-int bt_ctf_field_common_variant_set_tag(struct bt_ctf_field_common *variant_field,
- uint64_t tag_uval, bool is_signed)
-{
- int ret = 0;
- int64_t choice_index;
- struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
-
- BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
- BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
-
- /* Find matching index in variant field's type */
- choice_index = bt_ctf_field_type_common_variant_find_choice_index(
- variant_field->type, tag_uval, is_signed);
- if (choice_index < 0) {
- ret = -1;
- goto end;
- }
-
- /* Select corresponding field */
- BT_ASSERT(choice_index < variant->fields->len);
- variant->current_field = variant->fields->pdata[choice_index];
- variant->tag_value.u = tag_uval;
-
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_common *bt_ctf_field_common_variant_borrow_current_field(
- struct bt_ctf_field_common *variant_field)
-{
- struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
-
- BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
- BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: field-addr=%p", variant_field);
- return variant->current_field;
-}
-
-static inline
-int bt_ctf_field_common_variant_get_tag_signed(struct bt_ctf_field_common *variant_field,
- int64_t *tag)
-{
- struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
-
- BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
- BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: field-addr=%p", variant_field);
- *tag = variant->tag_value.i;
- return 0;
-}
-
-static inline
-int bt_ctf_field_common_variant_get_tag_unsigned(struct bt_ctf_field_common *variant_field,
- uint64_t *tag)
-{
- struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
-
- BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
- BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: field-addr=%p", variant_field);
- *tag = variant->tag_value.u;
- return 0;
-}
-
-static inline
-int bt_ctf_field_common_floating_point_get_value(struct bt_ctf_field_common *field,
- double *value)
-{
- struct bt_ctf_field_common_floating_point *floating_point =
- BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_FLOAT, "Field");
- *value = floating_point->payload;
- return 0;
-}
-
-static inline
-int bt_ctf_field_common_floating_point_set_value(struct bt_ctf_field_common *field,
- double value)
-{
- struct bt_ctf_field_common_floating_point *floating_point =
- BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Floating point number field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_FLOAT, "Field");
- floating_point->payload = value;
- bt_ctf_field_common_set(field, true);
- return 0;
-}
-
-static inline
-const char *bt_ctf_field_common_string_get_value(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRING, "Field");
- return (const char *) string->buf->data;
-}
-
-static inline
-int bt_ctf_field_common_string_clear(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_string *string_field = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRING, "Field");
- string_field->size = 0;
- bt_ctf_field_common_set(field, true);
- return 0;
-}
-
-static inline
-int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field,
- const char *value, unsigned int length)
-{
- struct bt_ctf_field_common_string *string_field = BT_CTF_FROM_COMMON(field);
- char *data;
- size_t new_size;
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRING, "Field");
-
- /* Make sure no null bytes are appended */
- BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
- "String value to append contains a null character: "
- "partial-value=\"%.32s\", length=%u", value, length);
-
- new_size = string_field->size + length;
-
- if (unlikely(new_size + 1 > string_field->buf->len)) {
- g_array_set_size(string_field->buf, new_size + 1);
- }
-
- data = string_field->buf->data;
- memcpy(data + string_field->size, value, length);
- ((char *) string_field->buf->data)[new_size] = '\0';
- string_field->size = new_size;
- bt_ctf_field_common_set(field, true);
- return 0;
-}
-
-static inline
-int bt_ctf_field_common_string_append(struct bt_ctf_field_common *field,
- const char *value)
-{
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- return bt_ctf_field_common_string_append_len(field, value,
- strlen(value));
-}
-
-static inline
-int bt_ctf_field_common_string_set_value(struct bt_ctf_field_common *field,
- const char *value)
-{
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_CTF_FIELD_TYPE_ID_STRING, "Field");
- bt_ctf_field_common_string_clear(field);
- return bt_ctf_field_common_string_append_len(field,
- value, strlen(value));
-}
-
-static inline
-void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD_STR("Putting field's type.");
- bt_ctf_object_put_ref(field->type);
-}
-
-static inline
-void bt_ctf_field_common_integer_finalize(struct bt_ctf_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD("Finalizing common integer field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-}
-
-static inline
-void bt_ctf_field_common_floating_point_finalize(struct bt_ctf_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-}
-
-static inline
-void bt_ctf_field_common_structure_finalize_recursive(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common structure field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-
- if (structure->fields) {
- g_ptr_array_free(structure->fields, TRUE);
- }
-}
-
-static inline
-void bt_ctf_field_common_variant_finalize_recursive(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common variant field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-
- if (variant->fields) {
- g_ptr_array_free(variant->fields, TRUE);
- }
-}
-
-static inline
-void bt_ctf_field_common_array_finalize_recursive(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common array field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-
- if (array->elements) {
- g_ptr_array_free(array->elements, TRUE);
- }
-}
-
-static inline
-void bt_ctf_field_common_sequence_finalize_recursive(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common sequence field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-
- if (sequence->elements) {
- g_ptr_array_free(sequence->elements, TRUE);
- }
-}
-
-static inline
-void bt_ctf_field_common_string_finalize(struct bt_ctf_field_common *field)
-{
- struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common string field object: addr=%p", field);
- bt_ctf_field_common_finalize(field);
-
- if (string->buf) {
- g_array_free(string->buf, TRUE);
- }
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
-{
- bool ret = true;
- int64_t min_value, max_value;
-
- min_value = -(1ULL << (size - 1));
- max_value = (1ULL << (size - 1)) - 1;
- if (value < min_value || value > max_value) {
- BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
- "min-value=%" PRId64 ", max-value=%" PRId64,
- value, min_value, max_value);
- ret = false;
- }
-
- return ret;
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
-{
- bool ret = true;
- int64_t max_value;
-
- max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
- if (value > max_value) {
- BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
- "max-value=%" PRIu64,
- value, max_value);
- ret = false;
- }
-
- return ret;
-}
-
-struct bt_ctf_field_enumeration {
- struct bt_ctf_field_common common;
- struct bt_ctf_field_common_integer *container;
-};
-
-struct bt_ctf_field_variant {
- struct bt_ctf_field_common_variant common;
- struct bt_ctf_field_enumeration *tag;
-};
-
-BT_HIDDEN
-int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field,
- struct bt_ctfser *ctfser,
- enum bt_ctf_byte_order native_byte_order);
-
-BT_HIDDEN
-int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field,
- const char *name, struct bt_ctf_field *value);
-
-BT_HIDDEN
-struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container(
- struct bt_ctf_field *field);
-
-static inline
-bt_bool bt_ctf_field_is_set_recursive(struct bt_ctf_field *field)
-{
- return bt_ctf_field_common_is_set_recursive((void *) field);
-}
-
-#endif /* BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FIELDS_H
-#define BABELTRACE_CTF_WRITER_FIELDS_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_field;
-struct bt_ctf_event_class;
-struct bt_ctf_event;
-struct bt_ctf_field_type;
-struct bt_ctf_field_type_enumeration_mapping_iterator;
-
-extern struct bt_ctf_field *bt_ctf_field_create(
- struct bt_ctf_field_type *field_type);
-
-extern struct bt_ctf_field_type *bt_ctf_field_get_type(
- struct bt_ctf_field *field);
-
-extern enum bt_ctf_field_type_id bt_ctf_field_get_type_id(
- struct bt_ctf_field *field);
-
-extern struct bt_ctf_field *bt_ctf_field_copy(struct bt_ctf_field *field);
-
-extern int bt_ctf_field_integer_signed_get_value(
- struct bt_ctf_field *integer_field, int64_t *value);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_signed_integer_set_value(
- struct bt_ctf_field *integer_field, int64_t *value)
-{
- return bt_ctf_field_integer_signed_get_value(integer_field, value);
-}
-
-extern int bt_ctf_field_integer_signed_set_value(
- struct bt_ctf_field *integer_field, int64_t value);
-
-extern int bt_ctf_field_integer_unsigned_get_value(
- struct bt_ctf_field *integer_field, uint64_t *value);
-
-extern int bt_ctf_field_integer_unsigned_set_value(
- struct bt_ctf_field *integer_field, uint64_t value);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-int bt_ctf_field_unsigned_integer_set_value(
- struct bt_ctf_field *integer_field, uint64_t *value)
-{
- return bt_ctf_field_integer_unsigned_get_value(integer_field, value);
-}
-
-extern int bt_ctf_field_floating_point_get_value(
- struct bt_ctf_field *float_field, double *value);
-
-extern int bt_ctf_field_floating_point_set_value(
- struct bt_ctf_field *float_field, double value);
-
-extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
- struct bt_ctf_field *enum_field);
-
-extern const char *bt_ctf_field_string_get_value(
- struct bt_ctf_field *string_field);
-
-extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field,
- const char *value);
-
-extern int bt_ctf_field_string_append(struct bt_ctf_field *string_field,
- const char *value);
-
-extern int bt_ctf_field_string_append_len(
- struct bt_ctf_field *string_field, const char *value,
- unsigned int length);
-
-extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
- struct bt_ctf_field *struct_field, const char *name);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-struct bt_ctf_field *bt_ctf_field_structure_get_field(
- struct bt_ctf_field *structure, const char *name)
-{
- return bt_ctf_field_structure_get_field_by_name(structure, name);
-}
-
-extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
- struct bt_ctf_field *struct_field, uint64_t index);
-
-extern struct bt_ctf_field *bt_ctf_field_array_get_field(
- struct bt_ctf_field *array_field, uint64_t index);
-
-extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
- struct bt_ctf_field *sequence_field, uint64_t index);
-
-extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence_field,
- struct bt_ctf_field *length_field);
-
-extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
- struct bt_ctf_field *variant_field,
- struct bt_ctf_field *tag_field);
-
-extern struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
- struct bt_ctf_field *variant_field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_FIELDS_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-
-BT_HIDDEN
-void value_exists(gpointer element, gpointer search_query);
-
-#endif /* BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
-
-/*
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <stdbool.h>
-
-struct bt_ctf_object;
-
-typedef void (*bt_ctf_object_release_func)(struct bt_ctf_object *);
-typedef void (*bt_ctf_object_parent_is_owner_listener_func)(
- struct bt_ctf_object *);
-
-static inline
-void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj);
-
-static inline
-void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj);
-
-/*
- * Babeltrace object base.
- *
- * All objects publicly exposed by Babeltrace APIs must contain this
- * object as their first member.
- */
-struct bt_ctf_object {
- /*
- * True if this object is shared, that is, it has a reference
- * count.
- */
- bool is_shared;
-
- /*
- * Current reference count.
- */
- unsigned long long ref_count;
-
- /*
- * Release function called when the object's reference count
- * falls to zero. For an object with a parent, this function is
- * bt_ctf_object_with_parent_release_func(), which calls
- * `spec_release_func` below if there's no current parent.
- */
- bt_ctf_object_release_func release_func;
-
- /*
- * Specific release function called by
- * bt_ctf_object_with_parent_release_func() or directly by a
- * parent object.
- */
- bt_ctf_object_release_func spec_release_func;
-
- /*
- * Optional callback for an object with a parent, called by
- * bt_ctf_object_with_parent_release_func() to indicate to the
- * object that its parent is its owner.
- */
- bt_ctf_object_parent_is_owner_listener_func
- parent_is_owner_listener_func;
-
- /*
- * Optional parent object.
- */
- struct bt_ctf_object *parent;
-};
-
-static inline
-unsigned long long bt_ctf_object_get_ref_count(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- return obj->ref_count;
-}
-
-static inline
-struct bt_ctf_object *bt_ctf_object_borrow_parent(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- return obj->parent;
-}
-
-static inline
-struct bt_ctf_object *bt_ctf_object_get_parent(struct bt_ctf_object *obj)
-{
- struct bt_ctf_object *parent = bt_ctf_object_borrow_parent(obj);
-
- if (parent) {
- bt_ctf_object_get_no_null_check(parent);
- }
-
- return parent;
-}
-
-static inline
-void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object *parent)
-{
- BT_ASSERT(child);
- BT_ASSERT(child->is_shared);
-
-#ifdef BT_LOGV
- BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p",
- child, parent);
-#endif
-
- /*
- * It is assumed that a "child" having a parent is publicly
- * reachable. Therefore, a reference to its parent must be
- * taken. The reference to the parent will be released once the
- * object's reference count falls to zero.
- */
- if (parent) {
- BT_ASSERT(!child->parent);
- child->parent = parent;
- bt_ctf_object_get_no_null_check(parent);
- } else {
- if (child->parent) {
- bt_ctf_object_put_no_null_check(child->parent);
- }
-
- child->parent = NULL;
- }
-}
-
-static inline
-void bt_ctf_object_try_spec_release(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
-
- if (bt_ctf_object_get_ref_count(obj) == 0) {
- obj->spec_release_func(obj);
- }
-}
-
-static inline
-void bt_ctf_object_with_parent_release_func(struct bt_ctf_object *obj)
-{
- if (obj->parent) {
- /*
- * Keep our own copy of the parent address because `obj`
- * could be destroyed in
- * obj->parent_is_owner_listener_func().
- */
- struct bt_ctf_object *parent = obj->parent;
-
-#ifdef BT_LOGV
- BT_LOGV("Releasing parented object: addr=%p, ref-count=%llu, "
- "parent-addr=%p, parent-ref-count=%llu",
- obj, obj->ref_count,
- parent, parent->ref_count);
-#endif
-
- if (obj->parent_is_owner_listener_func) {
- /*
- * Object has a chance to destroy itself here
- * under certain conditions and notify its
- * parent. At this point the parent is
- * guaranteed to exist because it's not put yet.
- */
- obj->parent_is_owner_listener_func(obj);
- }
-
- /* The release function will be invoked by the parent. */
- bt_ctf_object_put_no_null_check(parent);
- } else {
- bt_ctf_object_try_spec_release(obj);
- }
-}
-
-static inline
-void bt_ctf_object_init(struct bt_ctf_object *obj, bool is_shared,
- bt_ctf_object_release_func release_func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(!is_shared || release_func);
- obj->is_shared = is_shared;
- obj->release_func = release_func;
- obj->parent_is_owner_listener_func = NULL;
- obj->spec_release_func = NULL;
- obj->parent = NULL;
- obj->ref_count = 1;
-}
-
-static inline
-void bt_ctf_object_init_shared(struct bt_ctf_object *obj,
- bt_ctf_object_release_func release_func)
-{
- bt_ctf_object_init(obj, true, release_func);
-}
-
-static inline
-void bt_ctf_object_init_unique(struct bt_ctf_object *obj)
-{
- bt_ctf_object_init(obj, false, NULL);
-}
-
-static inline
-void bt_ctf_object_init_shared_with_parent(struct bt_ctf_object *obj,
- bt_ctf_object_release_func spec_release_func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(spec_release_func);
- bt_ctf_object_init_shared(obj, bt_ctf_object_with_parent_release_func);
- obj->spec_release_func = spec_release_func;
-}
-
-static inline
-void bt_ctf_object_set_parent_is_owner_listener_func(struct bt_ctf_object *obj,
- bt_ctf_object_parent_is_owner_listener_func func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
- ((struct bt_ctf_object *) obj)->parent_is_owner_listener_func = func;
-}
-
-static inline
-void bt_ctf_object_inc_ref_count(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- obj->ref_count++;
- BT_ASSERT(obj->ref_count != 0);
-}
-
-static inline
-void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
-
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count + 1,
- obj, obj->ref_count, obj->ref_count + 1);
-#endif
-
- bt_ctf_object_inc_ref_count(obj);
- return obj;
-}
-
-static inline
-void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
-
- if (unlikely(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) {
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's parent's reference count: "
- "addr=%p, parent-addr=%p", obj, obj->parent);
-#endif
-
- bt_ctf_object_get_no_null_check(obj->parent);
- }
-
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count + 1,
- obj, obj->ref_count, obj->ref_count + 1);
-#endif
-
- bt_ctf_object_inc_ref_count(obj);
- return obj;
-}
-
-static inline
-void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->ref_count > 0);
-
-#ifdef BT_LOGV
- BT_LOGV("Decrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count - 1,
- obj, obj->ref_count, obj->ref_count - 1);
-#endif
-
- obj->ref_count--;
-
- if (obj->ref_count == 0) {
- BT_ASSERT(obj->release_func);
- obj->release_func(obj);
- }
-}
-
-#endif /* BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
-
-/*
- * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-/*
- * This is a generic object pool to avoid memory allocation/deallocation
- * for objects of which the lifespan is typically short, but which are
- * created a lot.
- *
- * The object pool, thanks to two user functions, knows how to allocate
- * a brand new object in memory when the pool is empty and how to
- * destroy an object when we destroy the pool.
- *
- * The object pool's user is responsible for:
- *
- * * Setting whatever references the object needs to keep and reset some
- * properties _after_ calling bt_ctf_object_pool_create_object(). This is
- * typically done in the bt_*_create() function which calls
- * bt_ctf_object_pool_create_object() (which could call the user-provided
- * allocation function if the pool is empty) and then sets the
- * appropriate properties on the possibly recycled object.
- *
- * * Releasing whatever references the object keeps _before_ calling
- * bt_ctf_object_pool_recycle_object(). This is typically done in a custom
- * bt_*_recycle() function which does the necessary before calling
- * bt_ctf_object_pool_recycle_object() with an object ready to be reused
- * at any time.
- */
-
-#include <glib.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-
-typedef void *(*bt_ctf_object_pool_new_object_func)(void *data);
-typedef void *(*bt_ctf_object_pool_destroy_object_func)(void *obj, void *data);
-
-struct bt_ctf_object_pool {
- /*
- * Container of recycled objects, owned by this. The array's size
- * is the pool's capacity.
- */
- GPtrArray *objects;
-
- /*
- * Pool's size, that is, number of elements in the array above,
- * starting at index 0, which exist as recycled objects.
- */
- size_t size;
-
- /* User functions */
- struct {
- /* Allocate a new object in memory */
- bt_ctf_object_pool_new_object_func new_object;
-
- /* Free direct and indirect memory occupied by object */
- bt_ctf_object_pool_destroy_object_func destroy_object;
- } funcs;
-
- /* User data passed to user functions */
- void *data;
-};
-
-/*
- * Initializes an object pool which is already allocated.
- */
-int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool,
- bt_ctf_object_pool_new_object_func new_object_func,
- bt_ctf_object_pool_destroy_object_func destroy_object_func,
- void *data);
-
-/*
- * Finalizes an object pool without deallocating it.
- */
-void bt_ctf_object_pool_finalize(struct bt_ctf_object_pool *pool);
-
-/*
- * Creates an object from an object pool. If the pool is empty, this
- * function calls the "new" user function to allocate a new object
- * before returning it. Otherwise this function returns a recycled
- * object, removing it from the pool.
- *
- * The returned object is owned by the caller.
- */
-static inline
-void *bt_ctf_object_pool_create_object(struct bt_ctf_object_pool *pool)
-{
- struct bt_ctf_object *obj;
-
- BT_ASSERT(pool);
-
-#ifdef BT_LOGV
- BT_LOGV("Creating object from pool: pool-addr=%p, pool-size=%zu, pool-cap=%u",
- pool, pool->size, pool->objects->len);
-#endif
-
- if (pool->size > 0) {
- /* Pick one from the pool */
- pool->size--;
- obj = pool->objects->pdata[pool->size];
- pool->objects->pdata[pool->size] = NULL;
- goto end;
- }
-
- /* Pool is empty: create a brand new object */
-#ifdef BT_LOGV
- BT_LOGV("Pool is empty: allocating new object: pool-addr=%p",
- pool);
-#endif
-
- obj = pool->funcs.new_object(pool->data);
-
-end:
-#ifdef BT_LOGV
- BT_LOGV("Created one object from pool: pool-addr=%p, obj-addr=%p",
- pool, obj);
-#endif
-
- return obj;
-}
-
-/*
- * Recycles an object, that is, puts it back into the pool.
- *
- * The pool becomes the sole owner of the object to recycle.
- */
-static inline
-void bt_ctf_object_pool_recycle_object(struct bt_ctf_object_pool *pool, void *obj)
-{
- struct bt_ctf_object *bt_obj = obj;
-
- BT_ASSERT(pool);
- BT_ASSERT(obj);
-
-#ifdef BT_LOGV
- BT_LOGV("Recycling object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
- pool, pool->size, pool->objects->len, obj);
-#endif
-
- if (pool->size == pool->objects->len) {
- /* Backing array is full: make place for recycled object */
-#ifdef BT_LOGV
- BT_LOGV("Object pool is full: increasing object pool capacity: "
- "pool-addr=%p, old-pool-cap=%u, new-pool-cap=%u",
- pool, pool->objects->len, pool->objects->len + 1);
-#endif
- g_ptr_array_set_size(pool->objects, pool->size + 1);
- }
-
- /* Reset reference count to 1 since it could be 0 now */
- bt_obj->ref_count = 1;
-
- /* Back to the pool */
- pool->objects->pdata[pool->size] = obj;
- pool->size++;
-
-#ifdef BT_LOGV
- BT_LOGV("Recycled object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
- pool, pool->size, pool->objects->len, obj);
-#endif
-}
-
-#endif /* BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_OBJECT_H
-#define BABELTRACE_CTF_WRITER_OBJECT_H
-
-/*
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
- * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-@defgroup refs Reference counting management
-@ingroup apiref
-@brief Common reference counting management for all Babeltrace objects.
-
-@code
-#include <babeltrace/ctf-writer/object.h>
-@endcode
-
-The macros and functions of this module are everything that is needed
-to handle the <strong><em>reference counting</em></strong> of
-Babeltrace objects.
-
-Any Babeltrace object can be shared by multiple owners thanks to
-<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
-counting</a>.
-
-The Babeltrace C API complies with the following key principles:
-
-1. When you call an API function which accepts a Babeltrace object
- pointer as a parameter, the API function <strong>borrows the
- reference</strong> for the <strong>duration of the function</strong>.
-
- @image html ref-count-user-calls.png
-
- The API function can also get a new reference if the system needs a
- more persistent reference, but the ownership is <strong>never
- transferred</strong> from the caller to the API function.
-
- In other words, the caller still owns the object after calling any
- API function: no function "steals" the user's reference (except
- bt_ctf_object_put_ref()).
-
-2. An API function which \em returns a Babeltrace object pointer to the
- user returns a <strong>new reference</strong>. The caller becomes an
- owner of the object.
-
- @image html ref-count-api-returns.png
-
- It is your responsibility to discard the object when you don't
- need it anymore with bt_ctf_object_put_ref().
-
- For example, see bt_ctf_value_array_get().
-
-3. A Babeltrace object pointer received as a parameter in a user
- function called back from an API function is a
- <strong>borrowed</strong>, or <strong>weak reference</strong>: if you
- need a reference which is more persistent than the duration of the
- user function, call bt_ctf_object_get_ref() on the pointer.
-
- @image html ref-count-callback.png
-
- For example, see bt_ctf_value_map_foreach_entry().
-
-The two macros BT_CTF_OBJECT_PUT_REF_AND_RESET() and BT_CTF_OBJECT_MOVE_REF() operate on \em variables rather
-than pointer values. You should use BT_CTF_OBJECT_PUT_REF_AND_RESET() instead of bt_ctf_object_put_ref() when
-possible to avoid "double puts". For the same reason, you should use use
-BT_CTF_OBJECT_MOVE_REF() instead of performing manual reference moves between
-variables.
-
-@file
-@brief Reference counting management macros and functions.
-@sa refs
-
-@addtogroup refs
-@{
-*/
-
-/**
-@brief Calls bt_ctf_object_put_ref() on a variable named \p _var, then
- sets \p _var to \c NULL.
-
-Using this macro is considered safer than calling bt_ctf_object_put_ref() because it
-makes sure that the variable which used to contain a reference to a
-Babeltrace object is set to \c NULL so that a future BT_CTF_OBJECT_PUT_REF_AND_RESET() or
-bt_ctf_object_put_ref() call will not cause another, unwanted reference decrementation.
-
-@param[in,out] _var Name of a variable containing a
- Babeltrace object's address (this address
- can be \c NULL).
-
-@post <strong>If \p _var does not contain \p NULL</strong>,
- its reference count is decremented.
-@post \p _var contains \c NULL.
-
-@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
- variable to another.
-*/
-#define BT_CTF_OBJECT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_ctf_object_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-/**
-@brief Transfers the ownership of a Babeltrace object from a variable
- named \p _var_src to a variable named \p _var_dst.
-
-This macro implements the following common pattern:
-
- 1. Call bt_ctf_object_put_ref() on \p _var_dst to make sure the previous reference
- held by \p _var_dst is discarded.
- 2. Assign \p _var_src to \p _var_dst.
- 3. Set \p _var_src to \c NULL to avoid future, unwanted reference
- decrementation of \p _var_src.
-
-@warning
-You must \em not use this macro when both \p _var_dst and
-\p _var_src contain the same Babeltrace object address and the reference
-count of this object is 1. The initial call to bt_ctf_object_put_ref() on \p _var_dst
-would destroy the object and leave a dangling pointer in \p _var_dst.
-
-@param[in,out] _var_dst Name of the destination variable, containing
- either the address of a Babeltrace object to
- put first, or \c NULL.
-@param[in,out] _var_src Name of the source variable, containing
- either the address of a Babeltrace object to
- move, or \c NULL.
-
-@pre <strong>If \p _var_dst and \p _var_src contain the same
- value which is not \c NULL</strong>, this object's reference
- count is greater than 1.
-@post <strong>If \c _var_dst is not \c NULL</strong>, its reference
- count is decremented.
-@post \p _var_dst is equal to the value of \p _var_src \em before
- you called this macro.
-@post \p _var_src is \c NULL.
-
-@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
-*/
-#define BT_CTF_OBJECT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_ctf_object_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-/**
-@brief Increments the reference count of the Babeltrace object \p obj.
-
-@param[in] obj Babeltrace object of which to get a new reference
- (can be \c NULL).
-@returns \p obj
-
-@post <strong>If \c obj is not \c NULL</strong>, its reference
- count is incremented.
-
-@sa bt_ctf_object_put_ref(): Decrements the reference count of a Babeltrace object.
-*/
-void *bt_ctf_object_get_ref(void *obj);
-
-/**
-@brief Decrements the reference count of the Babeltrace object
- \p obj.
-
-When the object's reference count reaches 0, the object can no longer
-be accessed and is considered \em destroyed.
-
-@remarks
-You should use the BT_CTF_OBJECT_PUT_REF_AND_RESET() macro instead of calling bt_ctf_object_put_ref() since the
-former is generally safer.
-
-@param[in] obj Babeltrace object of which to drop a reference
- (can be \c NULL).
-
-@post <strong>If \c obj is not \c NULL</strong>, its reference
- count is decremented.
-
-@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
-@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
- variable to another.
-@sa bt_ctf_object_get_ref(): Increments the reference count of a Babeltrace object.
-*/
-void bt_ctf_object_put_ref(void *obj);
-
-/**
-@}
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_OBJECT_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H
-
-/*
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- *
- * Authors: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-
-enum bt_ctf_resolve_flag {
- BT_CTF_RESOLVE_FLAG_PACKET_HEADER = 0x01,
- BT_CTF_RESOLVE_FLAG_PACKET_CONTEXT = 0x02,
- BT_CTF_RESOLVE_FLAG_EVENT_HEADER = 0x04,
- BT_CTF_RESOLVE_FLAG_STREAM_EVENT_CTX = 0x08,
- BT_CTF_RESOLVE_FLAG_EVENT_CONTEXT = 0x10,
- BT_CTF_RESOLVE_FLAG_EVENT_PAYLOAD = 0x20,
-};
-
-/*
- * Resolves CTF IR field types: recursively locates the tag and length
- * field types of resp. variant and sequence field types.
- *
- * All `*_type` parameters may be resolved, and may as well serve as
- * resolving targets.
- *
- * Resolving is performed based on the flags in `flags`.
- *
- * It is expected that, amongst all the provided types, no common
- * references to sequence variant field types exist. In other words,
- * this function does not copy field types.
- *
- * All parameters are owned by the caller.
- */
-BT_HIDDEN
-int bt_ctf_resolve_types(struct bt_ctf_private_value *environment,
- struct bt_ctf_field_type_common *packet_header_type,
- struct bt_ctf_field_type_common *packet_context_type,
- struct bt_ctf_field_type_common *event_header_type,
- struct bt_ctf_field_type_common *stream_event_ctx_type,
- struct bt_ctf_field_type_common *event_context_type,
- struct bt_ctf_field_type_common *event_payload_type,
- enum bt_ctf_resolve_flag flags);
-
-#endif /* BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H
-
-/*
- * Copyright 2014 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/visitor.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <inttypes.h>
-
-struct bt_ctf_stream_class_common {
- struct bt_ctf_object base;
- GString *name;
-
- /* Array of pointers to event class addresses */
- GPtrArray *event_classes;
-
- /* event class id (int64_t) to event class address */
- GHashTable *event_classes_ht;
- int id_set;
- int64_t id;
- int64_t next_event_id;
- struct bt_ctf_field_type_common *packet_context_field_type;
- struct bt_ctf_field_type_common *event_header_field_type;
- struct bt_ctf_field_type_common *event_context_field_type;
- int frozen;
- int byte_order;
-
- /*
- * This flag indicates if the stream class is valid. A valid
- * stream class is _always_ frozen.
- */
- int valid;
-
- /*
- * Unique clock class mapped to any field type within this
- * stream class, including all the stream class's event class
- * field types. This is only set if the stream class is frozen.
- *
- * If the stream class is frozen and this is still NULL, it is
- * still possible that it becomes non-NULL because
- * bt_ctf_stream_class_add_event_class() can add an event class
- * containing a field type mapped to some clock class. In this
- * case, this is the mapped clock class, and at this point, both
- * the new event class and the stream class are frozen, so the
- * next added event classes are expected to contain field types
- * which only map to this specific clock class.
- *
- * If this is a CTF writer stream class, then this is the
- * backing clock class of the `clock` member above.
- */
- struct bt_ctf_clock_class *clock_class;
-};
-
-struct bt_ctf_event_class_common;
-
-BT_HIDDEN
-int bt_ctf_stream_class_common_initialize(struct bt_ctf_stream_class_common *stream_class,
- const char *name, bt_ctf_object_release_func release_func);
-
-BT_HIDDEN
-void bt_ctf_stream_class_common_finalize(struct bt_ctf_stream_class_common *stream_class);
-
-BT_HIDDEN
-void bt_ctf_stream_class_common_freeze(struct bt_ctf_stream_class_common *stream_class);
-
-static inline
-const char *bt_ctf_stream_class_common_get_name(
- struct bt_ctf_stream_class_common *stream_class)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->name->len > 0 ? stream_class->name->str : NULL;
-}
-
-static inline
-int64_t bt_ctf_stream_class_common_get_id(
- struct bt_ctf_stream_class_common *stream_class)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->id_set) {
- BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class));
- ret = (int64_t) -1;
- goto end;
- }
-
- ret = stream_class->id;
-
-end:
- return ret;
-}
-
-BT_HIDDEN
-void bt_ctf_stream_class_common_set_byte_order(
- struct bt_ctf_stream_class_common *stream_class, int byte_order);
-
-BT_HIDDEN
-int bt_ctf_stream_class_common_validate_single_clock_class(
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_clock_class **expected_clock_class);
-
-BT_HIDDEN
-int bt_ctf_stream_class_common_add_event_class(
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_event_class_common *event_class,
- bt_ctf_validation_flag_copy_field_type_func copy_field_type_func);
-
-BT_HIDDEN
-int bt_ctf_stream_class_common_visit(struct bt_ctf_stream_class_common *stream_class,
- bt_ctf_visitor visitor, void *data);
-
-BT_HIDDEN
-int bt_ctf_stream_class_visit(struct bt_ctf_stream_class *stream_class,
- bt_ctf_visitor visitor, void *data);
-
-static inline
-struct bt_ctf_trace_common *bt_ctf_stream_class_common_borrow_trace(
- struct bt_ctf_stream_class_common *stream_class)
-{
- BT_ASSERT(stream_class);
- return (void *) bt_ctf_object_borrow_parent(&stream_class->base);
-}
-
-static inline
-int bt_ctf_stream_class_common_set_name(struct bt_ctf_stream_class_common *stream_class,
- const char *name)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (!name) {
- g_string_assign(stream_class->name, "");
- } else {
- if (strlen(name) == 0) {
- BT_LOGW("Invalid parameter: name is empty.");
- ret = -1;
- goto end;
- }
-
- g_string_assign(stream_class->name, name);
- }
-
- BT_LOGV("Set stream class's name: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
-end:
- return ret;
-}
-
-static inline
-void _bt_ctf_stream_class_common_set_id(
- struct bt_ctf_stream_class_common *stream_class, int64_t id)
-{
- BT_ASSERT(stream_class);
- stream_class->id = id;
- stream_class->id_set = 1;
- BT_LOGV("Set stream class's ID (internal): "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
-}
-
-static inline
-int bt_ctf_stream_class_common_set_id_no_check(
- struct bt_ctf_stream_class_common *stream_class, int64_t id)
-{
- _bt_ctf_stream_class_common_set_id(stream_class, id);
- return 0;
-}
-
-static inline
-int bt_ctf_stream_class_common_set_id(struct bt_ctf_stream_class_common *stream_class,
- uint64_t id_param)
-{
- int ret = 0;
- int64_t id = (int64_t) id_param;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (id < 0) {
- BT_LOGW("Invalid parameter: invalid stream class's ID: "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", id=%" PRIu64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- id_param);
- ret = -1;
- goto end;
- }
-
- ret = bt_ctf_stream_class_common_set_id_no_check(stream_class, id);
- if (ret == 0) {
- BT_LOGV("Set stream class's ID: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- }
-end:
- return ret;
-}
-
-static inline
-int64_t bt_ctf_stream_class_common_get_event_class_count(
- struct bt_ctf_stream_class_common *stream_class)
-{
- int64_t ret;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- ret = (int64_t) stream_class->event_classes->len;
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_by_index(
- struct bt_ctf_stream_class_common *stream_class, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE(index < stream_class->event_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, stream_class->event_classes->len);
- return g_ptr_array_index(stream_class->event_classes, index);
-}
-
-static inline
-struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_by_id(
- struct bt_ctf_stream_class_common *stream_class, uint64_t id)
-{
- int64_t id_key = (int64_t) id;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE(id_key >= 0,
- "Invalid event class ID: %" PRIu64, id);
- return g_hash_table_lookup(stream_class->event_classes_ht,
- &id_key);
-}
-
-static inline
-struct bt_ctf_field_type_common *
-bt_ctf_stream_class_common_borrow_packet_context_field_type(
- struct bt_ctf_stream_class_common *stream_class)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->packet_context_field_type;
-}
-
-static inline
-int bt_ctf_stream_class_common_set_packet_context_field_type(
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_field_type_common *packet_context_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (packet_context_type &&
- bt_ctf_field_type_common_get_type_id(packet_context_type) !=
- BT_CTF_FIELD_TYPE_ID_STRUCT) {
- /* A packet context must be a structure. */
- BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "packet-context-ft-addr=%p, packet-context-ft-id=%s",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- packet_context_type,
- bt_ctf_field_type_id_string(
- bt_ctf_field_type_common_get_type_id(packet_context_type)));
- ret = -1;
- goto end;
- }
-
- bt_ctf_object_put_ref(stream_class->packet_context_field_type);
- stream_class->packet_context_field_type = packet_context_type;
- bt_ctf_object_get_ref(stream_class->packet_context_field_type);
- BT_LOGV("Set stream class's packet context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "packet-context-ft-addr=%p",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- packet_context_type);
-
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_type_common *
-bt_ctf_stream_class_common_borrow_event_header_field_type(
- struct bt_ctf_stream_class_common *stream_class)
-{
- struct bt_ctf_field_type_common *ret = NULL;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->event_header_field_type) {
- BT_LOGV("Stream class has no event header field type: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- goto end;
- }
-
- ret = stream_class->event_header_field_type;
-
-end:
- return ret;
-}
-
-static inline
-int bt_ctf_stream_class_common_set_event_header_field_type(
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_field_type_common *event_header_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (event_header_type &&
- bt_ctf_field_type_common_get_type_id(event_header_type) !=
- BT_CTF_FIELD_TYPE_ID_STRUCT) {
- /* An event header must be a structure. */
- BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-header-ft-addr=%p, event-header-ft-id=%s",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- event_header_type,
- bt_ctf_field_type_id_string(
- bt_ctf_field_type_common_get_type_id(event_header_type)));
- ret = -1;
- goto end;
- }
-
- bt_ctf_object_put_ref(stream_class->event_header_field_type);
- stream_class->event_header_field_type = event_header_type;
- bt_ctf_object_get_ref(stream_class->event_header_field_type);
- BT_LOGV("Set stream class's event header field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-header-ft-addr=%p",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- event_header_type);
-end:
- return ret;
-}
-
-static inline
-struct bt_ctf_field_type_common *
-bt_ctf_stream_class_common_borrow_event_context_field_type(
- struct bt_ctf_stream_class_common *stream_class)
-{
- struct bt_ctf_field_type_common *ret = NULL;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->event_context_field_type) {
- goto end;
- }
-
- ret = stream_class->event_context_field_type;
-
-end:
- return ret;
-}
-
-static inline
-int bt_ctf_stream_class_common_set_event_context_field_type(
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_field_type_common *event_context_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (event_context_type &&
- bt_ctf_field_type_common_get_type_id(event_context_type) !=
- BT_CTF_FIELD_TYPE_ID_STRUCT) {
- /* A packet context must be a structure. */
- BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-context-ft-addr=%p, event-context-ft-id=%s",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- event_context_type,
- bt_ctf_field_type_id_string(
- bt_ctf_field_type_common_get_type_id(event_context_type)));
- ret = -1;
- goto end;
- }
-
- bt_ctf_object_put_ref(stream_class->event_context_field_type);
- stream_class->event_context_field_type = event_context_type;
- bt_ctf_object_get_ref(stream_class->event_context_field_type);
- BT_LOGV("Set stream class's event context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-context-ft-addr=%p",
- stream_class, bt_ctf_stream_class_common_get_name(stream_class),
- bt_ctf_stream_class_common_get_id(stream_class),
- event_context_type);
-end:
- return ret;
-}
-
-struct bt_ctf_stream_class {
- struct bt_ctf_stream_class_common common;
- struct bt_ctf_clock *clock;
- int64_t next_stream_id;
-};
-
-struct metadata_context;
-
-BT_HIDDEN
-int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
- struct metadata_context *context);
-
-BT_HIDDEN
-int bt_ctf_stream_class_map_clock_class(
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_field_type *packet_context_type,
- struct bt_ctf_field_type *event_header_type);
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_STREAM_CLASS_H
-#define BABELTRACE_CTF_WRITER_STREAM_CLASS_H
-
-/*
- * Copyright 2014 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/ctf-writer/object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_stream_class;
-struct bt_ctf_trace;
-struct bt_ctf_event_class;
-struct bt_ctf_field_type;
-struct bt_ctf_clock;
-
-extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(
- const char *name);
-
-extern struct bt_ctf_trace *bt_ctf_stream_class_get_trace(
- struct bt_ctf_stream_class *stream_class);
-
-extern const char *bt_ctf_stream_class_get_name(
- struct bt_ctf_stream_class *stream_class);
-
-extern int bt_ctf_stream_class_set_name(
- struct bt_ctf_stream_class *stream_class, const char *name);
-
-extern int64_t bt_ctf_stream_class_get_id(
- struct bt_ctf_stream_class *stream_class);
-
-extern int bt_ctf_stream_class_set_id(
- struct bt_ctf_stream_class *stream_class, uint64_t id);
-
-extern struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
- struct bt_ctf_stream_class *stream_class);
-
-extern int bt_ctf_stream_class_set_packet_context_type(
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_field_type *packet_context_type);
-
-extern struct bt_ctf_field_type *
-bt_ctf_stream_class_get_event_header_type(
- struct bt_ctf_stream_class *stream_class);
-
-extern int bt_ctf_stream_class_set_event_header_type(
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_field_type *event_header_type);
-
-extern struct bt_ctf_field_type *
-bt_ctf_stream_class_get_event_context_type(
- struct bt_ctf_stream_class *stream_class);
-
-extern int bt_ctf_stream_class_set_event_context_type(
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_field_type *event_context_type);
-
-extern int64_t bt_ctf_stream_class_get_event_class_count(
- struct bt_ctf_stream_class *stream_class);
-
-extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
- struct bt_ctf_stream_class *stream_class, uint64_t index);
-
-extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
- struct bt_ctf_stream_class *stream_class, uint64_t id);
-
-extern int bt_ctf_stream_class_add_event_class(
- struct bt_ctf_stream_class *stream_class,
- struct bt_ctf_event_class *event_class);
-
-extern int bt_ctf_stream_class_set_clock(
- struct bt_ctf_stream_class *ctf_stream_class,
- struct bt_ctf_clock *clock);
-
-extern struct bt_ctf_clock *bt_ctf_stream_class_get_clock(
- struct bt_ctf_stream_class *stream_class);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
-{
- bt_ctf_object_get_ref(stream_class);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
-{
- bt_ctf_object_put_ref(stream_class);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctfser-internal.h>
-#include <stdint.h>
-
-struct bt_ctf_stream_common;
-
-struct bt_ctf_stream_common {
- struct bt_ctf_object base;
- int64_t id;
- struct bt_ctf_stream_class_common *stream_class;
- GString *name;
-};
-
-BT_HIDDEN
-int bt_ctf_stream_common_initialize(
- struct bt_ctf_stream_common *stream,
- struct bt_ctf_stream_class_common *stream_class, const char *name,
- uint64_t id, bt_ctf_object_release_func release_func);
-
-BT_HIDDEN
-void bt_ctf_stream_common_finalize(struct bt_ctf_stream_common *stream);
-
-static inline
-struct bt_ctf_stream_class_common *bt_ctf_stream_common_borrow_class(
- struct bt_ctf_stream_common *stream)
-{
- BT_ASSERT(stream);
- return stream->stream_class;
-}
-
-static inline
-const char *bt_ctf_stream_common_get_name(struct bt_ctf_stream_common *stream)
-{
- BT_ASSERT_PRE_NON_NULL(stream, "Stream");
- return stream->name ? stream->name->str : NULL;
-}
-
-static inline
-int64_t bt_ctf_stream_common_get_id(struct bt_ctf_stream_common *stream)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(stream, "Stream");
- ret = stream->id;
- if (ret < 0) {
- BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
- stream, bt_ctf_stream_common_get_name(stream));
- }
-
- return ret;
-}
-
-struct bt_ctf_stream {
- struct bt_ctf_stream_common common;
- struct bt_ctf_field *packet_header;
- struct bt_ctf_field *packet_context;
-
- /* Array of pointers to bt_ctf_event for the current packet */
- GPtrArray *events;
- struct bt_ctfser ctfser;
- unsigned int flushed_packet_count;
- uint64_t discarded_events;
- uint64_t last_ts_end;
-};
-
-BT_HIDDEN
-struct bt_ctf_stream *bt_ctf_stream_create_with_id(
- struct bt_ctf_stream_class *stream_class,
- const char *name, uint64_t id);
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_STREAM_H
-#define BABELTRACE_CTF_WRITER_STREAM_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_stream;
-struct bt_ctf_event;
-
-/*
- * bt_ctf_stream_get_discarded_events_count: get the number of discarded
- * events associated with this stream.
- *
- * Note that discarded events are not stored if the stream's packet
- * context has no "events_discarded" field. An error will be returned
- * in that case.
- *
- * @param stream Stream instance.
- *
- * Returns the number of discarded events, a negative value on error.
- */
-extern int bt_ctf_stream_get_discarded_events_count(
- struct bt_ctf_stream *stream, uint64_t *count);
-
-/*
- * bt_ctf_stream_append_discarded_events: increment discarded events count.
- *
- * Increase the current packet's discarded event count. Has no effect if the
- * stream class' packet context has no "events_discarded" field.
- *
- * @param stream Stream instance.
- * @param event_count Number of discarded events to add to the stream's current
- * packet.
- */
-extern void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
- uint64_t event_count);
-
-/*
- * bt_ctf_stream_append_event: append an event to the stream.
- *
- * Append "event" to the stream's current packet. The stream's associated clock
- * will be sampled during this call. The event shall not be modified after
- * being appended to a stream. The stream will share the event's ownership by
- * incrementing its reference count. The current packet is not flushed to disk
- * until the next call to bt_ctf_stream_flush.
- *
- * The stream event context will be sampled for every appended event if
- * a stream event context was defined.
- *
- * @param stream Stream instance.
- * @param event Event instance to append to the stream's current packet.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
- struct bt_ctf_event *event);
-
-/*
- * bt_ctf_stream_get_packet_header: get a stream's packet header.
- *
- * @param stream Stream instance.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_stream_get_packet_header(
- struct bt_ctf_stream *stream);
-
-/*
- * bt_ctf_stream_set_packet_header: set a stream's packet header.
- *
- * The packet header's type must match the trace's packet header
- * type.
- *
- * @param stream Stream instance.
- * @param packet_header Packet header instance.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern int bt_ctf_stream_set_packet_header(
- struct bt_ctf_stream *stream,
- struct bt_ctf_field *packet_header);
-
-/*
- * bt_ctf_stream_get_packet_context: get a stream's packet context.
- *
- * @param stream Stream instance.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_stream_get_packet_context(
- struct bt_ctf_stream *stream);
-
-/*
- * bt_ctf_stream_set_packet_context: set a stream's packet context.
- *
- * The packet context's type must match the stream class' packet
- * context type.
- *
- * @param stream Stream instance.
- * @param packet_context Packet context field instance.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern int bt_ctf_stream_set_packet_context(
- struct bt_ctf_stream *stream,
- struct bt_ctf_field *packet_context);
-
-/*
- * bt_ctf_stream_flush: flush a stream.
- *
- * The stream's current packet's events will be flushed, thus closing the
- * current packet. Events subsequently appended to the stream will be
- * added to a new packet.
- *
- * Flushing will also set the packet context's default attributes if
- * they remained unset while populating the current packet. These default
- * attributes, along with their expected types, are detailed in stream-class.h.
- *
- * @param stream Stream instance.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
-
-extern int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream);
-
-extern
-struct bt_ctf_stream *bt_ctf_stream_create(
- struct bt_ctf_stream_class *stream_class,
- const char *name, uint64_t id);
-
-extern struct bt_ctf_stream_class *bt_ctf_stream_get_class(
- struct bt_ctf_stream *stream);
-
-extern const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream);
-
-extern int64_t bt_ctf_stream_get_id(struct bt_ctf_stream *stream);
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_stream_get(struct bt_ctf_stream *stream)
-{
- bt_ctf_object_get_ref(stream);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_stream_put(struct bt_ctf_stream *stream)
-{
- bt_ctf_object_put_ref(stream);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H
-
-/*
- * Copyright 2014 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/ctf-writer/attributes-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-#include <sys/types.h>
-
-struct bt_ctf_trace_common {
- struct bt_ctf_object base;
- GString *name;
- int frozen;
- unsigned char uuid[BABELTRACE_UUID_LEN];
- bt_bool uuid_set;
- enum bt_ctf_byte_order native_byte_order;
- struct bt_ctf_private_value *environment;
- GPtrArray *clock_classes; /* Array of pointers to bt_ctf_clock_class */
- GPtrArray *stream_classes; /* Array of ptrs to bt_ctf_stream_class_common */
- GPtrArray *streams; /* Array of ptrs to bt_ctf_stream_common */
- struct bt_ctf_field_type_common *packet_header_field_type;
- int64_t next_stream_id;
-
- /*
- * This flag indicates if the trace is valid. A valid
- * trace is _always_ frozen.
- */
- int valid;
-};
-
-BT_HIDDEN
-bt_bool bt_ctf_trace_common_has_clock_class(struct bt_ctf_trace_common *trace,
- struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace,
- bt_ctf_object_release_func release_func);
-
-BT_HIDDEN
-void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace);
-
-static inline
-const char *bt_ctf_trace_common_get_name(struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->name ? trace->name->str : NULL;
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_name(struct bt_ctf_trace_common *trace, const char *name);
-
-static inline
-const unsigned char *bt_ctf_trace_common_get_uuid(struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->uuid_set ? trace->uuid : NULL;
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace, const unsigned char *uuid);
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
- const char *name, struct bt_ctf_private_value *value);
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common *trace,
- const char *name, const char *value);
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_environment_field_integer(struct bt_ctf_trace_common *trace,
- const char *name, int64_t value);
-
-static inline
-int64_t bt_ctf_trace_common_get_environment_field_count(
- struct bt_ctf_trace_common *trace)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- ret = bt_ctf_attributes_get_count(trace->environment);
- BT_ASSERT(ret >= 0);
- return ret;
-}
-
-static inline
-const char *
-bt_ctf_trace_common_get_environment_field_name_by_index(
- struct bt_ctf_trace_common *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return bt_ctf_attributes_get_field_name(trace->environment, index);
-}
-
-static inline
-struct bt_ctf_private_value *
-bt_ctf_trace_common_borrow_environment_field_value_by_index(
- struct bt_ctf_trace_common *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return bt_ctf_attributes_borrow_field_value(trace->environment, index);
-}
-
-static inline
-struct bt_ctf_private_value *
-bt_ctf_trace_common_borrow_environment_field_value_by_name(
- struct bt_ctf_trace_common *trace, const char *name)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_ctf_attributes_borrow_field_value_by_name(trace->environment,
- name);
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_add_clock_class(struct bt_ctf_trace_common *trace,
- struct bt_ctf_clock_class *clock_class);
-
-static inline
-int64_t bt_ctf_trace_common_get_clock_class_count(struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->clock_classes->len;
-}
-
-static inline
-struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_index(
- struct bt_ctf_trace_common *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(index < trace->clock_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->clock_classes->len);
- return g_ptr_array_index(trace->clock_classes, index);
-}
-
-static inline
-int64_t bt_ctf_trace_common_get_stream_count(struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (int64_t) trace->streams->len;
-}
-
-static inline
-struct bt_ctf_stream_common *bt_ctf_trace_common_borrow_stream_by_index(
- struct bt_ctf_trace_common *trace,
- uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(index < trace->streams->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->streams->len);
- return g_ptr_array_index(trace->streams, index);
-}
-
-static inline
-int64_t bt_ctf_trace_common_get_stream_class_count(struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (int64_t) trace->stream_classes->len;
-}
-
-static inline
-struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_index(
- struct bt_ctf_trace_common *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(index < trace->stream_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->stream_classes->len);
- return g_ptr_array_index(trace->stream_classes, index);
-}
-
-static inline
-struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_id(
- struct bt_ctf_trace_common *trace, uint64_t id_param)
-{
- int i;
- struct bt_ctf_stream_class_common *stream_class = NULL;
- int64_t id = (int64_t) id_param;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(id >= 0,
- "Invalid stream class ID: %" PRIu64, id_param);
-
- for (i = 0; i < trace->stream_classes->len; i++) {
- struct bt_ctf_stream_class_common *stream_class_candidate;
-
- stream_class_candidate =
- g_ptr_array_index(trace->stream_classes, i);
-
- if (bt_ctf_stream_class_common_get_id(stream_class_candidate) ==
- (int64_t) id) {
- stream_class = stream_class_candidate;
- goto end;
- }
- }
-
-end:
- return stream_class;
-}
-
-static inline
-struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_name(
- struct bt_ctf_trace_common *trace, const char *name)
-{
- size_t i;
- struct bt_ctf_clock_class *clock_class = NULL;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
-
- for (i = 0; i < trace->clock_classes->len; i++) {
- struct bt_ctf_clock_class *cur_clk =
- g_ptr_array_index(trace->clock_classes, i);
- const char *cur_clk_name = bt_ctf_clock_class_get_name(cur_clk);
-
- if (!cur_clk_name) {
- goto end;
- }
-
- if (!strcmp(cur_clk_name, name)) {
- clock_class = cur_clk;
- goto end;
- }
- }
-
-end:
- return clock_class;
-}
-
-static inline
-enum bt_ctf_byte_order bt_ctf_trace_common_get_native_byte_order(
- struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->native_byte_order;
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_native_byte_order(struct bt_ctf_trace_common *trace,
- enum bt_ctf_byte_order byte_order, bool allow_unspecified);
-
-static inline
-struct bt_ctf_field_type_common *bt_ctf_trace_common_borrow_packet_header_field_type(
- struct bt_ctf_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->packet_header_field_type;
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_set_packet_header_field_type(struct bt_ctf_trace_common *trace,
- struct bt_ctf_field_type_common *packet_header_field_type);
-
-static inline
-void bt_ctf_trace_common_freeze(struct bt_ctf_trace_common *trace)
-{
- int i;
-
- if (trace->frozen) {
- return;
- }
-
- BT_LOGD("Freezing trace: addr=%p, name=\"%s\"",
- trace, bt_ctf_trace_common_get_name(trace));
- BT_LOGD_STR("Freezing packet header field type.");
- bt_ctf_field_type_common_freeze(trace->packet_header_field_type);
- BT_LOGD_STR("Freezing environment attributes.");
- bt_ctf_attributes_freeze(trace->environment);
-
- if (trace->clock_classes->len > 0) {
- BT_LOGD_STR("Freezing clock classes.");
- }
-
- for (i = 0; i < trace->clock_classes->len; i++) {
- struct bt_ctf_clock_class *clock_class =
- g_ptr_array_index(trace->clock_classes, i);
-
- bt_ctf_clock_class_freeze(clock_class);
- }
-
- trace->frozen = 1;
-}
-
-BT_HIDDEN
-int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace,
- struct bt_ctf_stream_class_common *stream_class,
- bt_ctf_validation_flag_copy_field_type_func copy_field_type_func,
- struct bt_ctf_clock_class *init_expected_clock_class,
- int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_field_type_common *packet_context_field_type,
- struct bt_ctf_field_type_common *event_header_field_type),
- bool check_ts_begin_end_mapped);
-
-struct bt_ctf_trace {
- struct bt_ctf_trace_common common;
-};
-
-/*
- * bt_ctf_trace_get_metadata_string: get metadata string.
- *
- * Get the trace's TSDL metadata. The caller assumes the ownership of the
- * returned string.
- *
- * @param trace Trace instance.
- *
- * Returns the metadata string on success, NULL on error.
- */
-BT_HIDDEN
-char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
-
-BT_HIDDEN
-struct bt_ctf_trace *bt_ctf_trace_create(void);
-
-BT_HIDDEN
-int64_t bt_ctf_trace_get_clock_class_count(
- struct bt_ctf_trace *trace);
-
-BT_HIDDEN
-struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
- struct bt_ctf_trace *trace, uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
- struct bt_ctf_trace *trace, const char *name);
-
-BT_HIDDEN
-int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace,
- struct bt_ctf_clock_class *clock_class);
-
-BT_HIDDEN
-int64_t bt_ctf_trace_get_environment_field_count(
- struct bt_ctf_trace *trace);
-
-BT_HIDDEN
-const char *bt_ctf_trace_get_environment_field_name_by_index(
- struct bt_ctf_trace *trace, uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_value *
-bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace,
- uint64_t index);
-
-BT_HIDDEN
-struct bt_ctf_value *
-bt_ctf_trace_get_environment_field_value_by_name(
- struct bt_ctf_trace *trace, const char *name);
-
-#endif /* BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_TRACE_H
-#define BABELTRACE_CTF_WRITER_TRACE_H
-
-/*
- * Copyright 2014 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_trace;
-struct bt_ctf_stream_class;
-struct bt_ctf_stream;
-
-extern enum bt_ctf_byte_order bt_ctf_trace_get_native_byte_order(
- struct bt_ctf_trace *trace);
-
-extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace,
- enum bt_ctf_byte_order native_byte_order);
-
-extern const unsigned char *bt_ctf_trace_get_uuid(
- struct bt_ctf_trace *trace);
-
-extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
- const unsigned char *uuid);
-
-extern int bt_ctf_trace_set_environment_field_integer(
- struct bt_ctf_trace *trace, const char *name,
- int64_t value);
-
-extern int bt_ctf_trace_set_environment_field_string(
- struct bt_ctf_trace *trace, const char *name,
- const char *value);
-
-extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
- struct bt_ctf_trace *trace);
-
-extern int bt_ctf_trace_set_packet_header_field_type(struct bt_ctf_trace *trace,
- struct bt_ctf_field_type *packet_header_type);
-
-extern int64_t bt_ctf_trace_get_stream_class_count(
- struct bt_ctf_trace *trace);
-
-extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
- struct bt_ctf_trace *trace, uint64_t index);
-
-extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
- struct bt_ctf_trace *trace, uint64_t id);
-
-extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
- struct bt_ctf_stream_class *stream_class);
-
-extern int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace);
-
-extern struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
- struct bt_ctf_trace *trace, uint64_t index);
-
-extern const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_TRACE_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H
-
-/*
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/field-path-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <stdint.h>
-
-#define BT_CTF_TO_COMMON(_obj) (&(_obj)->common)
-#define BT_CTF_FROM_COMMON(_obj) ((void *) _obj)
-
-struct bt_ctf_search_query {
- gpointer value;
- int found;
-};
-
-BT_HIDDEN
-const char *bt_ctf_get_byte_order_string(enum bt_ctf_byte_order byte_order);
-
-static inline
-const char *bt_ctf_field_type_id_string(enum bt_ctf_field_type_id type_id)
-{
- switch (type_id) {
- case BT_CTF_FIELD_TYPE_ID_UNKNOWN:
- return "BT_CTF_FIELD_TYPE_ID_UNKNOWN";
- case BT_CTF_FIELD_TYPE_ID_INTEGER:
- return "BT_CTF_FIELD_TYPE_ID_INTEGER";
- case BT_CTF_FIELD_TYPE_ID_FLOAT:
- return "BT_CTF_FIELD_TYPE_ID_FLOAT";
- case BT_CTF_FIELD_TYPE_ID_ENUM:
- return "BT_CTF_FIELD_TYPE_ID_ENUM";
- case BT_CTF_FIELD_TYPE_ID_STRING:
- return "BT_CTF_FIELD_TYPE_ID_STRING";
- case BT_CTF_FIELD_TYPE_ID_STRUCT:
- return "BT_CTF_FIELD_TYPE_ID_STRUCT";
- case BT_CTF_FIELD_TYPE_ID_ARRAY:
- return "BT_CTF_FIELD_TYPE_ID_ARRAY";
- case BT_CTF_FIELD_TYPE_ID_SEQUENCE:
- return "BT_CTF_FIELD_TYPE_ID_SEQUENCE";
- case BT_CTF_FIELD_TYPE_ID_VARIANT:
- return "BT_CTF_FIELD_TYPE_ID_VARIANT";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_ctf_byte_order_string(enum bt_ctf_byte_order bo)
-{
- switch (bo) {
- case BT_CTF_BYTE_ORDER_UNKNOWN:
- return "BT_CTF_BYTE_ORDER_UNKNOWN";
- case BT_CTF_BYTE_ORDER_UNSPECIFIED:
- return "BT_CTF_BYTE_ORDER_UNSPECIFIED";
- case BT_CTF_BYTE_ORDER_NATIVE:
- return "BT_CTF_BYTE_ORDER_NATIVE";
- case BT_CTF_BYTE_ORDER_LITTLE_ENDIAN:
- return "BT_CTF_BYTE_ORDER_LITTLE_ENDIAN";
- case BT_CTF_BYTE_ORDER_BIG_ENDIAN:
- return "BT_CTF_BYTE_ORDER_BIG_ENDIAN";
- case BT_CTF_BYTE_ORDER_NETWORK:
- return "BT_CTF_BYTE_ORDER_NETWORK";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_ctf_string_encoding_string(enum bt_ctf_string_encoding encoding)
-{
- switch (encoding) {
- case BT_CTF_STRING_ENCODING_UNKNOWN:
- return "BT_CTF_STRING_ENCODING_UNKNOWN";
- case BT_CTF_STRING_ENCODING_NONE:
- return "BT_CTF_STRING_ENCODING_NONE";
- case BT_CTF_STRING_ENCODING_UTF8:
- return "BT_CTF_STRING_ENCODING_UTF8";
- case BT_CTF_STRING_ENCODING_ASCII:
- return "BT_CTF_STRING_ENCODING_ASCII";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-const char *bt_ctf_integer_base_string(enum bt_ctf_integer_base base)
-{
- switch (base) {
- case BT_CTF_INTEGER_BASE_UNKNOWN:
- return "BT_CTF_INTEGER_BASE_UNKNOWN";
- case BT_CTF_INTEGER_BASE_UNSPECIFIED:
- return "BT_CTF_INTEGER_BASE_UNSPECIFIED";
- case BT_CTF_INTEGER_BASE_BINARY:
- return "BT_CTF_INTEGER_BASE_BINARY";
- case BT_CTF_INTEGER_BASE_OCTAL:
- return "BT_CTF_INTEGER_BASE_OCTAL";
- case BT_CTF_INTEGER_BASE_DECIMAL:
- return "BT_CTF_INTEGER_BASE_DECIMAL";
- case BT_CTF_INTEGER_BASE_HEXADECIMAL:
- return "BT_CTF_INTEGER_BASE_HEXADECIMAL";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_ctf_scope_string(enum bt_ctf_scope scope)
-{
- switch (scope) {
- case BT_CTF_SCOPE_UNKNOWN:
- return "BT_CTF_SCOPE_UNKNOWN";
- case BT_CTF_SCOPE_TRACE_PACKET_HEADER:
- return "BT_CTF_SCOPE_TRACE_PACKET_HEADER";
- case BT_CTF_SCOPE_STREAM_PACKET_CONTEXT:
- return "BT_CTF_SCOPE_STREAM_PACKET_CONTEXT";
- case BT_CTF_SCOPE_STREAM_EVENT_HEADER:
- return "BT_CTF_SCOPE_STREAM_EVENT_HEADER";
- case BT_CTF_SCOPE_STREAM_EVENT_CONTEXT:
- return "BT_CTF_SCOPE_STREAM_EVENT_CONTEXT";
- case BT_CTF_SCOPE_EVENT_CONTEXT:
- return "BT_CTF_SCOPE_EVENT_CONTEXT";
- case BT_CTF_SCOPE_EVENT_PAYLOAD:
- return "BT_CTF_SCOPE_EVENT_PAYLOAD";
- case BT_CTF_SCOPE_ENV:
- return "BT_CTF_SCOPE_ENV";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_ctf_event_class_log_level_string(
- enum bt_ctf_event_class_log_level level)
-{
- switch (level) {
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE";
- case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG:
- return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG";
- default:
- return "(unknown)";
- }
-};
-
-static inline
-GString *bt_ctf_field_path_string(struct bt_ctf_field_path *path)
-{
- GString *str = g_string_new(NULL);
- size_t i;
-
- BT_ASSERT(path);
-
- if (!str) {
- goto end;
- }
-
- g_string_append_printf(str, "[%s", bt_common_scope_string(
- bt_ctf_field_path_get_root_scope(path)));
-
- for (i = 0; i < bt_ctf_field_path_get_index_count(path); i++) {
- int index = bt_ctf_field_path_get_index(path, i);
-
- g_string_append_printf(str, ", %d", index);
- }
-
- g_string_append(str, "]");
-
-end:
- return str;
-}
-
-#endif /* BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_UTILS_H
-#define BABELTRACE_CTF_WRITER_UTILS_H
-
-/*
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_bool */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_bool bt_ctf_identifier_is_valid(const char *identifier);
-
-static inline
-int bt_ctf_validate_identifier(const char *identifier)
-{
- return bt_ctf_identifier_is_valid(identifier) ? 1 : 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_UTILS_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
-
-/*
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-
-struct bt_ctf_trace_common;
-struct bt_ctf_stream_class_common;
-struct bt_ctf_event_class_common;
-struct bt_ctf_field_type_common;
-
-typedef struct bt_ctf_field_type_common *(*bt_ctf_validation_flag_copy_field_type_func)(
- struct bt_ctf_field_type_common *);
-
-enum bt_ctf_validation_flag {
- BT_CTF_VALIDATION_FLAG_TRACE = 1,
- BT_CTF_VALIDATION_FLAG_STREAM = 2,
- BT_CTF_VALIDATION_FLAG_EVENT = 4,
-};
-
-/*
- * Validation output structure.
- *
- * This is where the results of the validation function go. The field
- * types are the validated ones which should replace the original field
- * types of a trace, a stream class, and an event class.
- *
- * `valid_flags` contains the results of the validation.
- */
-struct bt_ctf_validation_output {
- struct bt_ctf_field_type_common *packet_header_type;
- struct bt_ctf_field_type_common *packet_context_type;
- struct bt_ctf_field_type_common *event_header_type;
- struct bt_ctf_field_type_common *stream_event_ctx_type;
- struct bt_ctf_field_type_common *event_context_type;
- struct bt_ctf_field_type_common *event_payload_type;
- enum bt_ctf_validation_flag valid_flags;
-};
-
-/*
- * This function resolves and validates the field types of an event
- * class, a stream class, and a trace. Copies are created if needed
- * and the resulting field types to use are placed in the `output`
- * validation structure, which also contains the results of the
- * validation. Copies can replace the original field types of a trace,
- * a stream class, and an event class using
- * bt_ctf_validation_replace_types().
- *
- * The current known validity of the field types of the trace,
- * stream class, and event class must be indicated with the
- * `trace_valid`, `stream_class_valid`, and `event_class_valid`
- * parameters. If a class is valid, its field types are not copied,
- * validated, or resolved during this call.
- *
- * The validation flags `validate_flags` indicate which classes should
- * have their field types validated.
- *
- * All parameters are owned by the caller.
- */
-BT_HIDDEN
-int bt_ctf_validate_class_types(struct bt_ctf_private_value *environment,
- struct bt_ctf_field_type_common *packet_header_type,
- struct bt_ctf_field_type_common *packet_context_type,
- struct bt_ctf_field_type_common *event_header_type,
- struct bt_ctf_field_type_common *stream_event_ctx_type,
- struct bt_ctf_field_type_common *event_context_type,
- struct bt_ctf_field_type_common *event_payload_type,
- int trace_valid, int stream_class_valid, int event_class_valid,
- struct bt_ctf_validation_output *output,
- enum bt_ctf_validation_flag validate_flags,
- bt_ctf_validation_flag_copy_field_type_func copy_field_type_func);
-
-/*
- * This function replaces the actual field types of a trace, a stream
- * class, and an event class with the appropriate field types contained
- * in a validation output structure.
- *
- * The replace flags `replace_flags` indicate which classes should have
- * their field types replaced.
- *
- * Note that the field types that are not used in the validation output
- * structure are still owned by it at the end of this call.
- * bt_ctf_validation_output_put_types() should be called to clean the
- * structure.
- *
- * All parameters are owned by the caller.
- */
-BT_HIDDEN
-void bt_ctf_validation_replace_types(struct bt_ctf_trace_common *trace,
- struct bt_ctf_stream_class_common *stream_class,
- struct bt_ctf_event_class_common *event_class,
- struct bt_ctf_validation_output *output,
- enum bt_ctf_validation_flag replace_flags);
-
-/*
- * This function puts all the field types contained in a given
- * validation output structure.
- *
- * `output` is owned by the caller and is not freed here.
- */
-BT_HIDDEN
-void bt_ctf_validation_output_put_types(
- struct bt_ctf_validation_output *output);
-
-#endif /* BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
-
-/*
- * Copyright (c) 2015-2017 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015-2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-
-struct bt_ctf_value;
-struct bt_ctf_private_value;
-
-/**
-@brief Status codes.
-*/
-enum bt_ctf_value_status {
- /// Operation canceled.
- BT_CTF_VALUE_STATUS_CANCELED = 125,
-
- /// Cannot allocate memory.
- BT_CTF_VALUE_STATUS_NOMEM = -12,
-
- /// Okay, no error.
- BT_CTF_VALUE_STATUS_OK = 0,
-};
-
-BT_HIDDEN
-enum bt_ctf_value_status _bt_ctf_value_freeze(struct bt_ctf_value *object);
-
-#ifdef BT_DEV_MODE
-# define bt_ctf_value_freeze _bt_ctf_value_freeze
-#else
-# define bt_ctf_value_freeze(_value)
-#endif /* BT_DEV_MODE */
-
-extern struct bt_ctf_value *const bt_ctf_value_null;
-
-enum bt_ctf_value_type {
- /// Null value object.
- BT_CTF_VALUE_TYPE_NULL = 0,
-
- /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
- BT_CTF_VALUE_TYPE_BOOL = 1,
-
- /// Integer value object (holds a signed 64-bit integer raw value).
- BT_CTF_VALUE_TYPE_INTEGER = 2,
-
- /// Floating point number value object (holds a \c double raw value).
- BT_CTF_VALUE_TYPE_REAL = 3,
-
- /// String value object.
- BT_CTF_VALUE_TYPE_STRING = 4,
-
- /// Array value object.
- BT_CTF_VALUE_TYPE_ARRAY = 5,
-
- /// Map value object.
- BT_CTF_VALUE_TYPE_MAP = 6,
-};
-
-BT_HIDDEN
-enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object);
-
-static inline
-bt_bool bt_ctf_value_is_null(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_NULL;
-}
-
-static inline
-bt_bool bt_ctf_value_is_bool(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_BOOL;
-}
-
-static inline
-bt_bool bt_ctf_value_is_integer(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_INTEGER;
-}
-
-static inline
-bt_bool bt_ctf_value_is_real(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_REAL;
-}
-
-static inline
-bt_bool bt_ctf_value_is_string(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_STRING;
-}
-
-static inline
-bt_bool bt_ctf_value_is_array(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_ARRAY;
-}
-
-static inline
-bt_bool bt_ctf_value_is_map(const struct bt_ctf_value *object)
-{
- return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_MAP;
-}
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy,
- const struct bt_ctf_value *object);
-
-BT_HIDDEN
-bt_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a,
- const struct bt_ctf_value *object_b);
-
-BT_HIDDEN
-bt_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj);
-
-BT_HIDDEN
-int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj);
-
-BT_HIDDEN
-double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj);
-
-BT_HIDDEN
-const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj);
-
-BT_HIDDEN
-uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj);
-
-static inline
-bt_bool bt_ctf_value_array_is_empty(const struct bt_ctf_value *array_obj)
-{
- return bt_ctf_value_array_get_size(array_obj) == 0;
-}
-
-BT_HIDDEN
-struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
- const struct bt_ctf_value *array_obj, uint64_t index);
-
-BT_HIDDEN
-uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj);
-
-static inline
-bt_bool bt_ctf_value_map_is_empty(const struct bt_ctf_value *map_obj)
-{
- return bt_ctf_value_map_get_size(map_obj) == 0;
-}
-
-BT_HIDDEN
-struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(
- const struct bt_ctf_value *map_obj, const char *key);
-
-typedef bt_bool (* bt_ctf_value_map_foreach_entry_cb)(const char *key,
- struct bt_ctf_value *object, void *data);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(
- const struct bt_ctf_value *map_obj,
- bt_ctf_value_map_foreach_entry_cb cb, void *data);
-
-BT_HIDDEN
-bt_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj,
- const char *key);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_value_map_extend(
- struct bt_ctf_private_value **extended_map_obj,
- const struct bt_ctf_value *base_map_obj,
- const struct bt_ctf_value *extension_map_obj);
-
-
-struct bt_ctf_value;
-struct bt_ctf_private_value;
-
-extern struct bt_ctf_private_value *const bt_ctf_private_value_null;
-
-static inline
-struct bt_ctf_value *bt_ctf_private_value_as_value(
- struct bt_ctf_private_value *priv_value)
-{
- return (void *) priv_value;
-}
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_bool_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_bool_create_init(bt_bool val);
-
-BT_HIDDEN
-void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj,
- bt_bool val);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_integer_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_integer_create_init(
- int64_t val);
-
-BT_HIDDEN
-void bt_ctf_private_value_integer_set(
- struct bt_ctf_private_value *integer_obj, int64_t val);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_real_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_real_create_init(double val);
-
-BT_HIDDEN
-void bt_ctf_private_value_real_set(
- struct bt_ctf_private_value *real_obj, double val);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_string_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_string_create_init(
- const char *val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_string_set(
- struct bt_ctf_private_value *string_obj,
- const char *val);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_array_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
- const struct bt_ctf_private_value *array_obj, uint64_t index);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
- struct bt_ctf_private_value *array_obj,
- struct bt_ctf_value *element_obj);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
- struct bt_ctf_private_value *array_obj,
- bt_bool val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
- struct bt_ctf_private_value *array_obj,
- int64_t val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
- struct bt_ctf_private_value *array_obj,
- double val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
- struct bt_ctf_private_value *array_obj, const char *val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
- struct bt_ctf_private_value *array_obj);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
- struct bt_ctf_private_value *array_obj);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
- struct bt_ctf_private_value *array_obj, uint64_t index,
- struct bt_ctf_value *element_obj);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_map_create(void);
-
-BT_HIDDEN
-struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value(
- const struct bt_ctf_private_value *map_obj, const char *key);
-
-typedef bt_bool (* bt_ctf_private_value_map_foreach_entry_cb)(const char *key,
- struct bt_ctf_private_value *object, void *data);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_foreach_entry(
- const struct bt_ctf_private_value *map_obj,
- bt_ctf_private_value_map_foreach_entry_cb cb, void *data);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
- struct bt_ctf_private_value *map_obj, const char *key,
- struct bt_ctf_value *element_obj);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
- struct bt_ctf_private_value *map_obj, const char *key, bt_bool val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
- struct bt_ctf_private_value *map_obj, const char *key, int64_t val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
- struct bt_ctf_private_value *map_obj, const char *key, double val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
- struct bt_ctf_private_value *map_obj, const char *key,
- const char *val);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
- struct bt_ctf_private_value *map_obj, const char *key);
-
-BT_HIDDEN
-enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
- struct bt_ctf_private_value *map_obj, const char *key);
-
-static inline
-const char *bt_ctf_value_type_string(enum bt_ctf_value_type type)
-{
- switch (type) {
- case BT_CTF_VALUE_TYPE_NULL:
- return "BT_CTF_VALUE_TYPE_NULL";
- case BT_CTF_VALUE_TYPE_BOOL:
- return "BT_CTF_VALUE_TYPE_BOOL";
- case BT_CTF_VALUE_TYPE_INTEGER:
- return "BT_CTF_VALUE_TYPE_INTEGER";
- case BT_CTF_VALUE_TYPE_REAL:
- return "BT_CTF_VALUE_TYPE_REAL";
- case BT_CTF_VALUE_TYPE_STRING:
- return "BT_CTF_VALUE_TYPE_STRING";
- case BT_CTF_VALUE_TYPE_ARRAY:
- return "BT_CTF_VALUE_TYPE_ARRAY";
- case BT_CTF_VALUE_TYPE_MAP:
- return "BT_CTF_VALUE_TYPE_MAP";
- default:
- return "(unknown)";
- }
-};
-
-#endif /* BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H
-
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/visitor.h>
-#include <babeltrace/babeltrace-internal.h>
-
-typedef void *(*bt_ctf_child_accessor)(void *object, int index);
-typedef int64_t (*bt_ctf_child_count_accessor)(void *object);
-typedef int (*bt_ctf_child_visitor)(void *object, bt_ctf_visitor visitor,
- void *data);
-
-struct bt_ctf_visitor_object {
- enum bt_ctf_visitor_object_type type;
- void *object;
-};
-
-BT_HIDDEN
-int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root,
- bt_ctf_child_count_accessor child_counter,
- bt_ctf_child_accessor child_accessor,
- bt_ctf_child_visitor child_visitor,
- bt_ctf_visitor visitor,
- void *data);
-
-#endif /* BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_VISITOR_H
-#define BABELTRACE_CTF_WRITER_VISITOR_H
-
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-@defgroup ctfirvisitor CTF IR visitor
-@ingroup ctfir
-@brief CTF IR visitor.
-
-@code
-#include <babeltrace/trace-ir/visitor.h>
-@endcode
-
-A CTF IR <strong><em>visitor</em></strong> is a function that you
-can use to visit the hierarchy of a
-\link ctfirtraceclass CTF IR trace class\endlink with
-bt_ctf_trace_visit() or of a
-\link ctfirstreamclass CTF IR stream class\endlink with
-bt_ctf_stream_class_visit().
-
-The traversal of the object's hierarchy is always done in a
-pre-order fashion.
-
-@sa ctfirstreamclass
-@sa ctfirtraceclass
-
-@file
-@brief CTF IR visitor types and functions.
-@sa ctfirvisitor
-
-@addtogroup ctfirvisitor
-@{
-*/
-
-/**
-@struct bt_ctf_object
-@brief A CTF IR object wrapper.
-
-This structure wraps both a CTF IR object and its type
-(see #bt_ctf_object_type). It is used in the visiting function.
-
-You can use the bt_ctf_object_get_type() and
-bt_ctf_object_get_object() accessors to get the type and wrapped
-CTF IR object of a CTF IR object wrapper.
-
-A CTF IR object wrapper has <strong>no reference count</strong>: do \em
-not use bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
-
-@sa ctfirvisitor
-*/
-struct bt_ctf_visitor_object;
-
-/**
-@brief CTF IR object wrapper type.
-*/
-enum bt_ctf_visitor_object_type {
- /// Unknown (used for errors).
- BT_CTF_VISITOR_OBJECT_TYPE_UNKNOWN = -1,
-
- /// \ref ctfirtraceclass.
- BT_CTF_VISITOR_OBJECT_TYPE_TRACE = 0,
-
- /// \ref ctfirstreamclass.
- BT_CTF_VISITOR_OBJECT_TYPE_STREAM_CLASS = 1,
-
- /// \ref ctfirstream.
- BT_CTF_VISITOR_OBJECT_TYPE_STREAM = 2,
-
- /// \ref ctfireventclass.
- BT_CTF_VISITOR_OBJECT_TYPE_EVENT_CLASS = 3,
-
- /// \ref ctfirevent.
- BT_CTF_VISITOR_OBJECT_TYPE_EVENT = 4,
-
- /// Number of entries in this enumeration.
- BT_CTF_VISITOR_OBJECT_TYPE_NR,
-};
-
-/**
-@brief Visting function type.
-
-A function of this type is called by bt_ctf_trace_visit() or
-bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper
-\p object.
-
-\p object has <strong>no reference count</strong>: do \em not use
-bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
-
-@param[in] object Currently visited CTF IR object wrapper.
-@param[in] data User data.
-@returns 0 on success, or a negative value on error.
-
-@prenotnull{object}
-
-@sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class.
-@sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream
- class.
-*/
-typedef int (*bt_ctf_visitor)(struct bt_ctf_visitor_object *object,
- void *data);
-
-/**
-@brief Returns the type of the CTF IR object wrapped by the CTF IR
- object wrapper \p object.
-
-@param[in] object Object wrapper of which to get the type.
-@returns Type of \p object.
-
-@prenotnull{object}
-
-@sa bt_ctf_visitor_object_get_object(): Returns the object wrapped by a given
- CTF IR object wrapper.
-*/
-enum bt_ctf_visitor_object_type bt_ctf_visitor_object_get_type(
- struct bt_ctf_visitor_object *object);
-
-/**
-@brief Returns the CTF IR object wrapped by the CTF IR object
- wrapper \p object.
-
-The reference count of \p object is \em not incremented by this
-function. On success, you must call bt_ctf_object_get_ref() on the return value to
-have your own reference.
-
-@param[in] object Object wrapper of which to get the wrapped
- CTF IR object.
-@returns CTF IR object wrapped by \p object.
-
-@prenotnull{object}
-@post The reference count of the returned object is not modified.
-
-@sa bt_ctf_visitor_object_get_type(): Returns the type of a given
- CTF IR object wrapper.
-*/
-void *bt_ctf_visitor_object_get_object(struct bt_ctf_visitor_object *object);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_VISITOR_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/ctf-writer/writer.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-
-struct metadata_context {
- GString *string;
- GString *field_name;
- unsigned int current_indentation_level;
-};
-
-struct bt_ctf_writer {
- struct bt_ctf_object base;
- int frozen; /* Protects attributes that can't be changed mid-trace */
- struct bt_ctf_trace *trace;
- GString *path;
- int metadata_fd;
-};
-
-enum field_type_alias {
- FIELD_TYPE_ALIAS_UINT5_T = 0,
- FIELD_TYPE_ALIAS_UINT8_T,
- FIELD_TYPE_ALIAS_UINT16_T,
- FIELD_TYPE_ALIAS_UINT27_T,
- FIELD_TYPE_ALIAS_UINT32_T,
- FIELD_TYPE_ALIAS_UINT64_T,
- NR_FIELD_TYPE_ALIAS,
-};
-
-BT_HIDDEN
-struct bt_ctf_field_type *get_field_type(enum field_type_alias alias);
-
-BT_HIDDEN
-const char *bt_ctf_get_byte_order_string(enum bt_ctf_byte_order byte_order);
-
-BT_HIDDEN
-void bt_ctf_writer_freeze(struct bt_ctf_writer *writer);
-
-#endif /* BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_WRITER_H
-#define BABELTRACE_CTF_WRITER_WRITER_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/trace.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_writer;
-struct bt_ctf_stream;
-struct bt_ctf_stream_class;
-struct bt_ctf_clock;
-
-/*
- * bt_ctf_writer_create: create a writer instance.
- *
- * Allocate a new writer that will produce a trace in the given path.
- * The creation of a writer sets its reference count to 1.
- *
- * @param path Path to the trace's containing folder (string is copied).
- *
- * Returns an allocated writer on success, NULL on error.
- */
-extern struct bt_ctf_writer *bt_ctf_writer_create(const char *path);
-
-/*
- * bt_ctf_writer_get_trace: Get a writer's associated trace.
- *
- * @param writer Writer instance.
- *
- * Return the writer's associated instance, NULL on error.
- */
-extern struct bt_ctf_trace *bt_ctf_writer_get_trace(
- struct bt_ctf_writer *writer);
-
-/*
- * bt_ctf_writer_create_stream: create a stream instance.
- *
- * Allocate a new stream instance and register it to the writer. The creation of
- * a stream sets its reference count to 1.
- *
- * @param writer Writer instance.
- * @param stream_class Stream class to instantiate.
- *
- * Returns an allocated stream on success, NULL on error.
- */
-extern struct bt_ctf_stream *bt_ctf_writer_create_stream(
- struct bt_ctf_writer *writer,
- struct bt_ctf_stream_class *stream_class);
-
-/*
- * bt_ctf_writer_add_environment_field: add an environment field to the trace.
- *
- * Add an environment field to the trace. The name and value parameters are
- * copied.
- *
- * @param writer Writer instance.
- * @param name Name of the environment field (will be copied).
- * @param value Value of the environment field (will be copied).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer,
- const char *name,
- const char *value);
-
-/*
- * bt_ctf_writer_add_environment_field_int64: add an environment field to the trace.
- *
- * Add an environment field to the trace. The name and value parameters are
- * copied.
- *
- * @param writer Writer instance.
- * @param name Name of the environment field (will be copied).
- * @param value Value of the environment field.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_writer_add_environment_field_int64(
- struct bt_ctf_writer *writer,
- const char *name,
- int64_t value);
-
-/*
- * bt_ctf_writer_add_clock: add a clock to the trace.
- *
- * Add a clock to the trace. Clocks assigned to stream classes must be
- * registered to the writer.
- *
- * @param writer Writer instance.
- * @param clock Clock to add to the trace.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer,
- struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_writer_get_metadata_string: get meta-data string.
- *
- * Get the trace's TSDL meta-data. The caller assumes the ownership of the
- * returned string.
- *
- * @param writer Writer instance.
- *
- * Returns the metadata string on success, NULL on error.
- */
-extern char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
-
-/*
- * bt_ctf_writer_flush_metadata: flush the trace's metadata to disk.
- *
- * Flush the trace's metadata to the metadata file. Note that the metadata will
- * be flushed automatically when the Writer instance is released (last call to
- * bt_ctf_writer_put).
- *
- * @param writer Writer instance.
- */
-extern void bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
-
-/*
- * bt_ctf_writer_set_byte_order: set a field type's byte order.
- *
- * Set the trace's byte order. Defaults to the host machine's endianness.
- *
- * @param writer Writer instance.
- * @param byte_order Trace's byte order.
- *
- * Returns 0 on success, a negative value on error.
- *
- * Note: byte_order must not be BT_CTF_BYTE_ORDER_NATIVE since, according
- * to the CTF specification, is defined as "the byte order described in the
- * trace description".
- */
-extern int bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer,
- enum bt_ctf_byte_order byte_order);
-
-/*
- * bt_ctf_writer_get and bt_ctf_writer_put: increment and decrement the
- * writer's reference count.
- *
- * You may also use bt_ctf_get() and bt_ctf_put() with writer objects.
- *
- * These functions ensure that the writer won't be destroyed while it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) have to be done to
- * destroy a writer.
- *
- * When the writer's reference count is decremented to 0 by a
- * bt_ctf_writer_put, the writer is freed.
- *
- * @param writer Writer instance.
- */
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_writer_get(struct bt_ctf_writer *writer)
-{
- bt_ctf_object_get_ref(writer);
-}
-
-/* Pre-2.0 CTF writer compatibility */
-static inline
-void bt_ctf_writer_put(struct bt_ctf_writer *writer)
-{
- bt_ctf_object_put_ref(writer);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_WRITER_H */
+++ /dev/null
-/* Pre-2.0 CTF writer backward compatibility */
-#include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/writer.h>
+++ /dev/null
-#ifndef BABELTRACE_CTFSER_INTERNAL_H
-#define BABELTRACE_CTFSER_INTERNAL_H
-
-/*
- * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017-2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <limits.h>
-#include <babeltrace/compat/mman-internal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/mmap-align-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/bitfield-internal.h>
-#include <glib.h>
-
-struct bt_ctfser {
- /* Stream file's descriptor */
- int fd;
-
- /* Offset (bytes) of memory map (current packet) in the stream file */
- off_t mmap_offset;
-
- /* Offset (bytes) of packet's first byte in the memory map */
- off_t mmap_base_offset;
-
- /* Current offset (bits) within current packet */
- uint64_t offset_in_cur_packet_bits;
-
- /* Current packet size (bytes) */
- uint64_t cur_packet_size_bytes;
-
- /* Previous packet size (bytes) */
- uint64_t prev_packet_size_bytes;
-
- /* Current stream size (bytes) */
- uint64_t stream_size_bytes;
-
- /* Memory map base address */
- struct mmap_align *base_mma;
-
- /* Stream file's path (for debugging) */
- GString *path;
-};
-
-/*
- * Initializes a CTF serializer.
- *
- * This function opens the file `path` for writing.
- */
-BT_HIDDEN
-int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path);
-
-/*
- * Finalizes a CTF serializer.
- *
- * This function truncates the stream file so that there's no extra
- * padding after the last packet, and then closes the file.
- */
-BT_HIDDEN
-int bt_ctfser_fini(struct bt_ctfser *ctfser);
-
-/*
- * Opens a new packet.
- *
- * All the next writing functions are performed within this new packet.
- */
-BT_HIDDEN
-int bt_ctfser_open_packet(struct bt_ctfser *ctfser);
-
-/*
- * Closes the current packet, making its size `packet_size_bytes`.
- */
-BT_HIDDEN
-void bt_ctfser_close_current_packet(struct bt_ctfser *ctfser,
- uint64_t packet_size_bytes);
-
-BT_HIDDEN
-int _bt_ctfser_increase_cur_packet_size(struct bt_ctfser *ctfser);
-
-static inline
-uint64_t _bt_ctfser_cur_packet_size_bits(struct bt_ctfser *ctfser)
-{
- return ctfser->cur_packet_size_bytes * 8;
-}
-
-static inline
-uint64_t _bt_ctfser_prev_packet_size_bits(struct bt_ctfser *ctfser)
-{
- return ctfser->prev_packet_size_bytes * 8;
-}
-
-static inline
-uint64_t _bt_ctfser_offset_bytes(struct bt_ctfser *ctfser)
-{
- return ctfser->offset_in_cur_packet_bits / 8;
-}
-
-static inline
-uint8_t *_bt_ctfser_get_addr(struct bt_ctfser *ctfser)
-{
- /* Only makes sense to get the address after aligning on byte */
- BT_ASSERT(ctfser->offset_in_cur_packet_bits % 8 == 0);
- return ((uint8_t *) mmap_align_addr(ctfser->base_mma)) +
- ctfser->mmap_base_offset + _bt_ctfser_offset_bytes(ctfser);
-}
-
-static inline
-bool _bt_ctfser_has_space_left(struct bt_ctfser *ctfser, uint64_t size_bits)
-{
- bool has_space_left = true;
-
- if (unlikely((ctfser->offset_in_cur_packet_bits + size_bits >
- _bt_ctfser_cur_packet_size_bits(ctfser)))) {
- has_space_left = false;
- goto end;
- }
-
- if (unlikely(size_bits > UINT64_MAX - ctfser->offset_in_cur_packet_bits)) {
- has_space_left = false;
- goto end;
- }
-
-end:
- return has_space_left;
-}
-
-static inline
-void _bt_ctfser_incr_offset(struct bt_ctfser *ctfser, uint64_t size_bits)
-{
- BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
- ctfser->offset_in_cur_packet_bits += size_bits;
-}
-
-/*
- * Aligns the current offset within the current packet to
- * `alignment_bits` bits (power of two, > 0).
- */
-static inline
-int bt_ctfser_align_offset_in_current_packet(struct bt_ctfser *ctfser,
- uint64_t alignment_bits)
-{
- int ret = 0;
- uint64_t align_size_bits;
-
- BT_ASSERT(alignment_bits > 0);
- align_size_bits = ALIGN(ctfser->offset_in_cur_packet_bits,
- alignment_bits) - ctfser->offset_in_cur_packet_bits;
-
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, align_size_bits))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- _bt_ctfser_incr_offset(ctfser, align_size_bits);
-
-end:
- return ret;
-}
-
-static inline
-int _bt_ctfser_write_byte_aligned_unsigned_int_no_align(
- struct bt_ctfser *ctfser, uint64_t value,
- unsigned int size_bits, int byte_order)
-{
- int ret = 0;
-
- /* Reverse byte order? */
- bool rbo = byte_order != BYTE_ORDER;
-
- BT_ASSERT(size_bits % 8 == 0);
- BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
-
- switch (size_bits) {
- case 8:
- {
- uint8_t v = (uint8_t) value;
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 16:
- {
- uint16_t v = (uint16_t) value;
-
- if (rbo) {
- v = GUINT16_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 32:
- {
- uint32_t v = (uint32_t) value;
-
- if (rbo) {
- v = GUINT32_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 64:
- {
- uint64_t v = (uint64_t) value;
-
- if (rbo) {
- v = GUINT64_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- default:
- abort();
- }
-
- _bt_ctfser_incr_offset(ctfser, size_bits);
- return ret;
-}
-
-static inline
-int _bt_ctfser_write_byte_aligned_signed_int_no_align(
- struct bt_ctfser *ctfser, int64_t value,
- unsigned int size_bits, int byte_order)
-{
- int ret = 0;
-
- /* Reverse byte order? */
- bool rbo = byte_order != BYTE_ORDER;
-
- BT_ASSERT(size_bits % 8 == 0);
- BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
-
- switch (size_bits) {
- case 8:
- {
- int8_t v = (int8_t) value;
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 16:
- {
- int16_t v = (int16_t) value;
-
- if (rbo) {
- v = GUINT16_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 32:
- {
- int32_t v = (int32_t) value;
-
- if (rbo) {
- v = GUINT32_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- case 64:
- {
- int64_t v = (int64_t) value;
-
- if (rbo) {
- v = GUINT64_SWAP_LE_BE(v);
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
- break;
- }
- default:
- abort();
- }
-
- _bt_ctfser_incr_offset(ctfser, size_bits);
- return ret;
-}
-
-/*
- * Writes an unsigned integer known to have a size that is a multiple of
- * 8 and an alignment that is >= 8 at the current offset within the
- * current packet.
- */
-static inline
-int bt_ctfser_write_byte_aligned_unsigned_int(struct bt_ctfser *ctfser,
- uint64_t value, unsigned int alignment_bits,
- unsigned int size_bits, int byte_order)
-{
- int ret;
-
- BT_ASSERT(alignment_bits % 8 == 0);
- ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
- if (unlikely(ret)) {
- goto end;
- }
-
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- ret = _bt_ctfser_write_byte_aligned_unsigned_int_no_align(ctfser, value,
- size_bits, byte_order);
- if (unlikely(ret)) {
- goto end;
- }
-
-end:
- return ret;
-}
-
-/*
- * Writes a signed integer known to have a size that is a multiple of 8
- * and an alignment that is >= 8 at the current offset within the
- * current packet.
- */
-static inline
-int bt_ctfser_write_byte_aligned_signed_int(struct bt_ctfser *ctfser,
- int64_t value, unsigned int alignment_bits,
- unsigned int size_bits, int byte_order)
-{
- int ret;
-
- BT_ASSERT(alignment_bits % 8 == 0);
- ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
- if (unlikely(ret)) {
- goto end;
- }
-
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- ret = _bt_ctfser_write_byte_aligned_signed_int_no_align(ctfser, value,
- size_bits, byte_order);
- if (unlikely(ret)) {
- goto end;
- }
-
-end:
- return ret;
-}
-
-/*
- * Writes an unsigned integer at the current offset within the current
- * packet.
- */
-static inline
-int bt_ctfser_write_unsigned_int(struct bt_ctfser *ctfser, uint64_t value,
- unsigned int alignment_bits, unsigned int size_bits,
- int byte_order)
-{
- int ret = 0;
-
- ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
- if (unlikely(ret)) {
- goto end;
- }
-
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- if (alignment_bits % 8 == 0 && size_bits % 8 == 0) {
- ret = _bt_ctfser_write_byte_aligned_unsigned_int_no_align(
- ctfser, value, size_bits, byte_order);
- goto end;
- }
-
- if (byte_order == LITTLE_ENDIAN) {
- bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) +
- ctfser->mmap_base_offset, uint8_t,
- ctfser->offset_in_cur_packet_bits, size_bits, value);
- } else {
- bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) +
- ctfser->mmap_base_offset, uint8_t,
- ctfser->offset_in_cur_packet_bits, size_bits, value);
- }
-
- _bt_ctfser_incr_offset(ctfser, size_bits);
-
-end:
- return ret;
-}
-
-/*
- * Writes a signed integer at the current offset within the current
- * packet.
- */
-static inline
-int bt_ctfser_write_signed_int(struct bt_ctfser *ctfser, int64_t value,
- unsigned int alignment_bits, unsigned int size_bits,
- int byte_order)
-{
- int ret = 0;
-
- ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
- if (unlikely(ret)) {
- goto end;
- }
-
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- if (alignment_bits % 8 == 0 && size_bits % 8 == 0) {
- ret = _bt_ctfser_write_byte_aligned_signed_int_no_align(
- ctfser, value, size_bits, byte_order);
- goto end;
- }
-
- if (byte_order == LITTLE_ENDIAN) {
- bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) +
- ctfser->mmap_base_offset, uint8_t,
- ctfser->offset_in_cur_packet_bits, size_bits, value);
- } else {
- bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) +
- ctfser->mmap_base_offset, uint8_t,
- ctfser->offset_in_cur_packet_bits, size_bits, value);
- }
-
- _bt_ctfser_incr_offset(ctfser, size_bits);
-
-end:
- return ret;
-}
-
-/*
- * Writes a 32-bit floating point number at the current offset within
- * the current packet.
- */
-static inline
-int bt_ctfser_write_float32(struct bt_ctfser *ctfser, double value,
- unsigned int alignment_bits, int byte_order)
-{
- union u32f {
- uint32_t u;
- float f;
- } u32f;
-
- u32f.f = (float) value;
- return bt_ctfser_write_unsigned_int(ctfser, (uint64_t) u32f.u,
- alignment_bits, 32, byte_order);
-}
-
-/*
- * Writes a 64-bit floating point number at the current offset within
- * the current packet.
- */
-static inline
-int bt_ctfser_write_float64(struct bt_ctfser *ctfser, double value,
- unsigned int alignment_bits, int byte_order)
-{
- union u64f {
- uint64_t u;
- float f;
- } u64f;
-
- u64f.f = value;
- return bt_ctfser_write_unsigned_int(ctfser, u64f.u, alignment_bits,
- 64, byte_order);
-}
-
-/*
- * Writes a C string, including the terminating null character, at the
- * current offset within the current packet.
- */
-static inline
-int bt_ctfser_write_string(struct bt_ctfser *ctfser, const char *value)
-{
- int ret = 0;
- const char *at = value;
-
- ret = bt_ctfser_align_offset_in_current_packet(ctfser, 8);
- if (unlikely(ret)) {
- goto end;
- }
-
- while (true) {
- if (unlikely(!_bt_ctfser_has_space_left(ctfser, 8))) {
- ret = _bt_ctfser_increase_cur_packet_size(ctfser);
- if (unlikely(ret)) {
- goto end;
- }
- }
-
- memcpy(_bt_ctfser_get_addr(ctfser), at, sizeof(*at));
- _bt_ctfser_incr_offset(ctfser, 8);
-
- if (unlikely(*at == '\0')) {
- break;
- }
-
- at++;
- }
-
-end:
- return ret;
-}
-
-/*
- * Returns the current offset within the current packet (bits).
- */
-static inline
-uint64_t bt_ctfser_get_offset_in_current_packet_bits(struct bt_ctfser *ctfser)
-{
- return ctfser->offset_in_cur_packet_bits;
-}
-
-/*
- * Sets the current offset within the current packet (bits).
- */
-static inline
-void bt_ctfser_set_offset_in_current_packet_bits(struct bt_ctfser *ctfser,
- uint64_t offset_bits)
-{
- BT_ASSERT(offset_bits <= _bt_ctfser_cur_packet_size_bits(ctfser));
- ctfser->offset_in_cur_packet_bits = offset_bits;
-}
-
-static inline
-const char *bt_ctfser_get_file_path(struct bt_ctfser *ctfser)
-{
- return ctfser->path->str;
-}
-
-#endif /* BABELTRACE_CTFSER_INTERNAL_H */
+++ /dev/null
-#ifndef _BABELTRACE_ENDIAN_H
-#define _BABELTRACE_ENDIAN_H
-
-/*
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * endian.h compatibility layer.
- *
- * 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.
- */
-
-#ifdef __FreeBSD__
-#include <machine/endian.h>
-
-#elif defined(__sun__)
-#include <sys/byteorder.h>
-
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
-#ifdef _LITTLE_ENDIAN
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#ifdef _BIG_ENDIAN
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#define betoh16(x) BE_16(x)
-#define letoh16(x) LE_16(x)
-#define betoh32(x) BE_32(x)
-#define letoh32(x) LE_32(x)
-#define betoh64(x) BE_64(x)
-#define letoh64(x) LE_64(x)
-#define htobe16(x) BE_16(x)
-#define be16toh(x) BE_16(x)
-#define htobe32(x) BE_32(x)
-#define be32toh(x) BE_32(x)
-#define htobe64(x) BE_64(x)
-#define be64toh(x) BE_64(x)
-
-#elif defined(__MINGW32__)
-#include <stdint.h>
-
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
-#ifndef __BYTE_ORDER
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define PDP_ENDIAN __PDP_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#define htobe16(x) (uint16_t) _byteswap_ushort(x)
-#define htole16(x) (x)
-#define be16toh(x) (uint16_t) _byteswap_ushort(x)
-#define le16toh(x) (x)
-
-#define htobe32(x) (uint32_t) _byteswap_ulong(x)
-#define htole32(x) (x)
-#define be32toh(x) (uint32_t) _byteswap_ulong(x)
-#define le32toh(x) (x)
-
-#define htobe64(x) (uint64_t) _byteswap_uint64(x)
-#define htole64(x) (x)
-#define be64toh(x) (uint64_t) _byteswap_uint64(x)
-#define le64toh(x) (x)
-
-#elif defined(__APPLE__)
-# include <machine/endian.h>
-# include <libkern/OSByteOrder.h>
-
-# if BYTE_ORDER == LITTLE_ENDIAN
-# define htobe16(x) OSSwapConstInt16(x)
-# define htole16(x) (x)
-# define be16toh(x) OSSwapConstInt16(x)
-# define le16toh(x) (x)
-
-# define htobe32(x) OSSwapConstInt32(x)
-# define htole32(x) (x)
-# define be32toh(x) OSSwapConstInt32(x)
-# define le32toh(x) (x)
-
-# define htobe64(x) OSSwapConstInt64(x)
-# define htole64(x) (x)
-# define be64toh(x) OSSwapConstInt64(x)
-# define le64toh(x) (x)
-
-# else /* BYTE_ORDER == LITTLE_ENDIAN */
-# define htobe16(x) (x)
-# define htole16(x) OSSwapConstInt16(x)
-# define be16toh(x) (x)
-# define le16toh(x) OSSwapConstInt16(x)
-
-# define htobe32(x) (x)
-# define htole32(x) OSSwapConstInt32(x)
-# define be32toh(x) (x)
-# define le32toh(x) OSSwapConstInt32(x)
-
-# define htobe64(x) (x)
-# define htole64(x) OSSwapConstInt64(x)
-# define be64toh(x) (x)
-# define le64toh(x) OSSwapConstInt64(x)
-# endif
-
-#else
-#include <endian.h>
-
-/*
- * htobe/betoh are not defined for glibc < 2.9, so add them explicitly
- * if they are missing.
- */
-# ifdef __USE_BSD
-/* Conversion interfaces. */
-# include <byteswap.h>
-
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# ifndef htobe16
-# define htobe16(x) __bswap_16(x)
-# endif
-# ifndef htole16
-# define htole16(x) (x)
-# endif
-# ifndef be16toh
-# define be16toh(x) __bswap_16(x)
-# endif
-# ifndef le16toh
-# define le16toh(x) (x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) __bswap_32(x)
-# endif
-# ifndef htole32
-# define htole32(x) (x)
-# endif
-# ifndef be32toh
-# define be32toh(x) __bswap_32(x)
-# endif
-# ifndef le32toh
-# define le32toh(x) (x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) __bswap_64(x)
-# endif
-# ifndef htole64
-# define htole64(x) (x)
-# endif
-# ifndef be64toh
-# define be64toh(x) __bswap_64(x)
-# endif
-# ifndef le64toh
-# define le64toh(x) (x)
-# endif
-
-# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-# ifndef htobe16
-# define htobe16(x) (x)
-# endif
-# ifndef htole16
-# define htole16(x) __bswap_16(x)
-# endif
-# ifndef be16toh
-# define be16toh(x) (x)
-# endif
-# ifndef le16toh
-# define le16toh(x) __bswap_16(x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) (x)
-# endif
-# ifndef htole32
-# define htole32(x) __bswap_32(x)
-# endif
-# ifndef be32toh
-# define be32toh(x) (x)
-# endif
-# ifndef le32toh
-# define le32toh(x) __bswap_32(x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) (x)
-# endif
-# ifndef htole64
-# define htole64(x) __bswap_64(x)
-# endif
-# ifndef be64toh
-# define be64toh(x) (x)
-# endif
-# ifndef le64toh
-# define le64toh(x) __bswap_64(x)
-# endif
-
-# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
-# endif /* __USE_BSD */
-#endif /* else -- __FreeBSD__ */
-
-#ifndef FLOAT_WORD_ORDER
-#ifdef __FLOAT_WORD_ORDER
-#define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
-#else /* __FLOAT_WORD_ORDER */
-#define FLOAT_WORD_ORDER BYTE_ORDER
-#endif /* __FLOAT_WORD_ORDER */
-#endif /* FLOAT_WORD_ORDER */
-
-#endif /* _BABELTRACE_ENDIAN_H */
+++ /dev/null
-#ifndef BABELTRACE_FD_CACHE_INTERNAL_H
-#define BABELTRACE_FD_CACHE_INTERNAL_H
-/*
- * fd-cache-internal.h
- *
- * Babeltrace - File descriptor cache
- *
- * Copyright 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * Author: Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-
-struct bt_fd_cache_handle {
- int fd;
-};
-
-struct bt_fd_cache {
- GHashTable *cache;
-};
-
-static inline
-int bt_fd_cache_handle_get_fd(struct bt_fd_cache_handle *handle)
-{
- return handle->fd;
-}
-
-BT_HIDDEN
-int bt_fd_cache_init(struct bt_fd_cache *fdc);
-
-BT_HIDDEN
-void bt_fd_cache_fini(struct bt_fd_cache *fdc);
-
-BT_HIDDEN
-struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc,
- const char *path);
-
-BT_HIDDEN
-void bt_fd_cache_put_handle(struct bt_fd_cache *fdc,
- struct bt_fd_cache_handle *handle);
-
-#endif /* BABELTRACE_FD_CACHE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_bool, bt_component_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_component_class_status {
- BT_COMPONENT_CLASS_STATUS_OK = 0,
- BT_COMPONENT_CLASS_STATUS_NOMEM = -12,
-} bt_component_class_status;
-
-typedef enum bt_component_class_type {
- BT_COMPONENT_CLASS_TYPE_SOURCE = 0,
- BT_COMPONENT_CLASS_TYPE_FILTER = 1,
- BT_COMPONENT_CLASS_TYPE_SINK = 2,
-} bt_component_class_type;
-
-extern const char *bt_component_class_get_name(
- const bt_component_class *component_class);
-
-extern const char *bt_component_class_get_description(
- const bt_component_class *component_class);
-
-extern const char *bt_component_class_get_help(
- const bt_component_class *component_class);
-
-extern bt_component_class_type bt_component_class_get_type(
- const bt_component_class *component_class);
-
-static inline
-bt_bool bt_component_class_is_source(
- const bt_component_class *component_class)
-{
- return bt_component_class_get_type(component_class) ==
- BT_COMPONENT_CLASS_TYPE_SOURCE;
-}
-
-static inline
-bt_bool bt_component_class_is_filter(
- const bt_component_class *component_class)
-{
- return bt_component_class_get_type(component_class) ==
- BT_COMPONENT_CLASS_TYPE_FILTER;
-}
-
-static inline
-bt_bool bt_component_class_is_sink(
- const bt_component_class *component_class)
-{
- return bt_component_class_get_type(component_class) ==
- BT_COMPONENT_CLASS_TYPE_SINK;
-}
-
-extern void bt_component_class_get_ref(
- const bt_component_class *component_class);
-
-extern void bt_component_class_put_ref(
- const bt_component_class *component_class);
-
-#define BT_COMPONENT_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class, bt_component_class_filter,
- * __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class *
-bt_component_class_filter_as_component_class_const(
- const bt_component_class_filter *comp_cls_filter)
-{
- return __BT_UPCAST_CONST(bt_component_class, comp_cls_filter);
-}
-
-extern void bt_component_class_filter_get_ref(
- const bt_component_class_filter *component_class_filter);
-
-extern void bt_component_class_filter_put_ref(
- const bt_component_class_filter *component_class_filter);
-
-#define BT_COMPONENT_CLASS_FILTER_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_class_filter_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_CLASS_FILTER_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_class_filter_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/* For bt_self_message_iterator_status */
-#include <babeltrace/graph/self-message-iterator.h>
-
-/* For bt_query_status */
-#include <babeltrace/graph/component-class.h>
-
-/* For bt_component_class_status */
-#include <babeltrace/graph/component-class-const.h>
-
-/*
- * 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_message_array_const,
- * bt_bool, bt_self_message_iterator, __BT_UPCAST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef bt_self_component_status
-(*bt_component_class_filter_init_method)(
- bt_self_component_filter *self_component,
- const bt_value *params, void *init_method_data);
-
-typedef void (*bt_component_class_filter_finalize_method)(
- bt_self_component_filter *self_component);
-
-typedef 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_message_iterator_finalize_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef 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 bt_self_message_iterator_status
-(*bt_component_class_filter_message_iterator_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_self_message_iterator_status
-(*bt_component_class_filter_message_iterator_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_bool
-(*bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_bool
-(*bt_component_class_filter_message_iterator_can_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_query_status
-(*bt_component_class_filter_query_method)(
- bt_self_component_class_filter *comp_class,
- const bt_query_executor *query_executor,
- const char *object, const bt_value *params,
- const bt_value **result);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_input_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_accept_output_port_connection_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_input_port_connected_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_filter_output_port_connected_method)(
- bt_self_component_filter *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
-static inline
-bt_component_class *bt_component_class_filter_as_component_class(
- bt_component_class_filter *comp_cls_filter)
-{
- return __BT_UPCAST(bt_component_class, comp_cls_filter);
-}
-
-extern
-bt_component_class_filter *bt_component_class_filter_create(
- const char *name,
- bt_component_class_filter_message_iterator_next_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_init_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_init_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_finalize_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_finalize_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_accept_input_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_input_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_accept_output_port_connection_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_accept_output_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_input_port_connected_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_input_port_connected_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_output_port_connected_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_output_port_connected_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_query_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_query_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_message_iterator_init_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_init_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_message_iterator_finalize_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_finalize_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_seek_ns_from_origin_method method);
-
-extern bt_component_class_status
-bt_component_class_filter_set_message_iterator_seek_beginning_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_seek_beginning_method method);
-
-extern bt_bool
-bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method);
-
-extern bt_bool
-bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
- bt_component_class_filter *comp_class,
- bt_component_class_filter_message_iterator_can_seek_beginning_method method);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/graph/component-const.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/list-internal.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-
-struct bt_component_class;
-struct bt_plugin_so_shared_lib_handle;
-
-typedef void (*bt_component_class_destroy_listener_func)(
- struct bt_component_class *class, void *data);
-
-struct bt_component_class_destroy_listener {
- bt_component_class_destroy_listener_func func;
- void *data;
-};
-
-struct bt_component_class {
- struct bt_object base;
- enum bt_component_class_type type;
- GString *name;
- GString *description;
- GString *help;
-
- /* Array of struct bt_component_class_destroy_listener */
- GArray *destroy_listeners;
- bool frozen;
- struct bt_list_head node;
- struct bt_plugin_so_shared_lib_handle *so_handle;
-};
-
-struct bt_component_class_source {
- struct bt_component_class parent;
- struct {
- bt_component_class_source_init_method init;
- bt_component_class_source_finalize_method finalize;
- 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_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
- 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;
- } methods;
-};
-
-struct bt_component_class_sink {
- struct bt_component_class parent;
- struct {
- bt_component_class_sink_init_method init;
- bt_component_class_sink_finalize_method finalize;
- bt_component_class_sink_query_method query;
- bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
- bt_component_class_sink_input_port_connected_method input_port_connected;
- bt_component_class_sink_graph_is_configured_method graph_is_configured;
- bt_component_class_sink_consume_method consume;
- } methods;
-};
-
-struct bt_component_class_filter {
- struct bt_component_class parent;
- struct {
- bt_component_class_filter_init_method init;
- bt_component_class_filter_finalize_method finalize;
- 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_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
- bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
- 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;
- bt_component_class_filter_input_port_connected_method input_port_connected;
- bt_component_class_filter_output_port_connected_method output_port_connected;
- } methods;
-};
-
-BT_HIDDEN
-void bt_component_class_add_destroy_listener(struct bt_component_class *class,
- bt_component_class_destroy_listener_func func, void *data);
-
-BT_HIDDEN
-void _bt_component_class_freeze(
- const struct bt_component_class *component_class);
-
-#ifdef BT_DEV_MODE
-# define bt_component_class_freeze _bt_component_class_freeze
-#else
-# define bt_component_class_freeze(_cc)
-#endif
-
-static inline
-const char *bt_component_class_type_string(enum bt_component_class_type type)
-{
- switch (type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- return "BT_COMPONENT_CLASS_TYPE_SOURCE";
- case BT_COMPONENT_CLASS_TYPE_SINK:
- return "BT_COMPONENT_CLASS_TYPE_SINK";
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- return "BT_COMPONENT_CLASS_TYPE_FILTER";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-#include <babeltrace/types.h>
-#include <babeltrace/graph/message-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_component_class_sink_colander_priv_data {
- bt_message_array_const msgs;
- uint64_t *count_addr;
- struct bt_self_component_port_input_message_iterator *msg_iter;
-};
-
-struct bt_component_class_sink_colander_data {
- bt_message_array_const msgs;
- uint64_t *count_addr;
-};
-
-extern struct bt_component_class_sink *
-bt_component_class_sink_colander_get(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class, bt_component_class_sink, __BT_UPCAST_CONST */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class *
-bt_component_class_sink_as_component_class_const(
- const bt_component_class_sink *comp_cls_sink)
-{
- return __BT_UPCAST_CONST(bt_component_class, comp_cls_sink);
-}
-
-extern void bt_component_class_sink_get_ref(
- const bt_component_class_sink *component_class_sink);
-
-extern void bt_component_class_sink_put_ref(
- const bt_component_class_sink *component_class_sink);
-
-#define BT_COMPONENT_CLASS_SINK_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_class_sink_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_CLASS_SINK_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_class_sink_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/* For bt_query_status */
-#include <babeltrace/graph/component-class.h>
-
-/* For bt_component_class_status */
-#include <babeltrace/graph/component-class-const.h>
-
-/*
- * For bt_component_class, bt_component_class_sink, bt_port_output,
- * bt_query_executor, bt_self_component_class_sink,
- * bt_self_component_sink, bt_self_component_port_input, bt_value,
- * __BT_UPCAST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef bt_self_component_status (*bt_component_class_sink_init_method)(
- bt_self_component_sink *self_component,
- const bt_value *params, void *init_method_data);
-
-typedef void (*bt_component_class_sink_finalize_method)(
- bt_self_component_sink *self_component);
-
-typedef bt_query_status
-(*bt_component_class_sink_query_method)(
- bt_self_component_class_sink *comp_class,
- const bt_query_executor *query_executor,
- const char *object, const bt_value *params,
- const bt_value **result);
-
-typedef bt_self_component_status
-(*bt_component_class_sink_accept_input_port_connection_method)(
- bt_self_component_sink *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_sink_input_port_connected_method)(
- bt_self_component_sink *self_component,
- bt_self_component_port_input *self_port,
- const bt_port_output *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_sink_graph_is_configured_method)(
- bt_self_component_sink *self_component);
-
-typedef bt_self_component_status (*bt_component_class_sink_consume_method)(
- bt_self_component_sink *self_component);
-
-static inline
-bt_component_class *bt_component_class_sink_as_component_class(
- bt_component_class_sink *comp_cls_sink)
-{
- return __BT_UPCAST(bt_component_class, comp_cls_sink);
-}
-
-extern
-bt_component_class_sink *bt_component_class_sink_create(
- const char *name,
- bt_component_class_sink_consume_method method);
-
-extern bt_component_class_status bt_component_class_sink_set_init_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_init_method method);
-
-extern bt_component_class_status bt_component_class_sink_set_finalize_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_finalize_method method);
-
-extern bt_component_class_status
-bt_component_class_sink_set_accept_input_port_connection_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_accept_input_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_sink_set_input_port_connected_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_input_port_connected_method method);
-
-extern bt_component_class_status
-bt_component_class_sink_set_graph_is_configured_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_graph_is_configured_method method);
-
-extern bt_component_class_status bt_component_class_sink_set_query_method(
- bt_component_class_sink *comp_class,
- bt_component_class_sink_query_method method);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class, bt_component_class_source,
- * __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class *
-bt_component_class_source_as_component_class_const(
- const bt_component_class_source *comp_cls_source)
-{
- return __BT_UPCAST_CONST(bt_component_class, comp_cls_source);
-}
-
-extern void bt_component_class_source_get_ref(
- const bt_component_class_source *component_class_source);
-
-extern void bt_component_class_source_put_ref(
- const bt_component_class_source *component_class_source);
-
-#define BT_COMPONENT_CLASS_SOURCE_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_class_source_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_CLASS_SOURCE_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_class_source_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/* For bt_self_message_iterator_status */
-#include <babeltrace/graph/self-message-iterator.h>
-
-/* For bt_query_status */
-#include <babeltrace/graph/component-class.h>
-
-/* For bt_component_class_status */
-#include <babeltrace/graph/component-class-const.h>
-
-/*
- * 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_message_array_const, bt_bool, bt_self_message_iterator,
- * __BT_UPCAST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef bt_self_component_status
-(*bt_component_class_source_init_method)(
- bt_self_component_source *self_component,
- const bt_value *params, void *init_method_data);
-
-typedef void (*bt_component_class_source_finalize_method)(
- bt_self_component_source *self_component);
-
-typedef 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_message_iterator_finalize_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef 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 bt_self_message_iterator_status
-(*bt_component_class_source_message_iterator_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_self_message_iterator_status
-(*bt_component_class_source_message_iterator_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_bool
-(*bt_component_class_source_message_iterator_can_seek_ns_from_origin_method)(
- bt_self_message_iterator *message_iterator,
- int64_t ns_from_origin);
-
-typedef bt_bool
-(*bt_component_class_source_message_iterator_can_seek_beginning_method)(
- bt_self_message_iterator *message_iterator);
-
-typedef bt_query_status (*bt_component_class_source_query_method)(
- bt_self_component_class_source *comp_class,
- const bt_query_executor *query_executor,
- const char *object, const bt_value *params,
- const bt_value **result);
-
-typedef bt_self_component_status
-(*bt_component_class_source_accept_output_port_connection_method)(
- bt_self_component_source *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
-typedef bt_self_component_status
-(*bt_component_class_source_output_port_connected_method)(
- bt_self_component_source *self_component,
- bt_self_component_port_output *self_port,
- const bt_port_input *other_port);
-
-static inline
-bt_component_class *bt_component_class_source_as_component_class(
- bt_component_class_source *comp_cls_source)
-{
- return __BT_UPCAST(bt_component_class, comp_cls_source);
-}
-
-extern
-bt_component_class_source *bt_component_class_source_create(
- const char *name,
- bt_component_class_source_message_iterator_next_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_init_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_init_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_finalize_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_finalize_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_accept_output_port_connection_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_accept_output_port_connection_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_output_port_connected_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_output_port_connected_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_query_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_query_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_message_iterator_init_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_init_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_message_iterator_finalize_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_finalize_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_seek_ns_from_origin_method method);
-
-extern bt_component_class_status
-bt_component_class_source_set_message_iterator_seek_beginning_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_seek_beginning_method method);
-
-extern bt_bool
-bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method);
-
-extern bt_bool
-bt_component_class_source_set_message_iterator_can_seek_beginning_method(
- bt_component_class_source *comp_class,
- bt_component_class_source_message_iterator_can_seek_beginning_method method);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_H
-#define BABELTRACE_GRAPH_COMPONENT_CLASS_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_QUERY_EXECUTOR_STATUS_* */
-#include <babeltrace/graph/query-executor-const.h>
-
-/* For bt_component_class */
-#include <babeltrace/types.h>
-
-/* For bt_component_class_status */
-#include <babeltrace/graph/component-class-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_query_status {
- BT_QUERY_STATUS_OK = BT_QUERY_EXECUTOR_STATUS_OK,
- BT_QUERY_STATUS_AGAIN = BT_QUERY_EXECUTOR_STATUS_AGAIN,
- BT_QUERY_STATUS_ERROR = BT_QUERY_EXECUTOR_STATUS_ERROR,
- BT_QUERY_STATUS_NOMEM = BT_QUERY_EXECUTOR_STATUS_NOMEM,
- BT_QUERY_STATUS_INVALID_OBJECT = BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT,
- BT_QUERY_STATUS_INVALID_PARAMS = BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS,
-} bt_query_status;
-
-extern bt_component_class_status bt_component_class_set_description(
- bt_component_class *component_class,
- const char *description);
-
-extern bt_component_class_status bt_component_class_set_help(
- bt_component_class *component_class,
- const char *help);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class_type */
-#include <babeltrace/graph/component-class-const.h>
-
-/*
- * For bt_bool, bt_component_class, bt_component_graph, bt_component,
- * bt_value, bt_port
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Get component's name.
- *
- * @param component Component instance of which to get the name
- * @returns Returns a pointer to the component's name
- */
-extern const char *bt_component_get_name(const bt_component *component);
-
-/**
- * Get component's class.
- *
- * @param component Component instance of which to get the class
- * @returns The component's class
- */
-extern const bt_component_class *bt_component_borrow_class_const(
- const bt_component *component);
-
-extern bt_component_class_type bt_component_get_class_type(
- const bt_component *component);
-
-static inline
-bt_bool bt_component_is_source(const bt_component *component)
-{
- return bt_component_get_class_type(component) ==
- BT_COMPONENT_CLASS_TYPE_SOURCE;
-}
-
-static inline
-bt_bool bt_component_is_filter(const bt_component *component)
-{
- return bt_component_get_class_type(component) ==
- BT_COMPONENT_CLASS_TYPE_FILTER;
-}
-
-static inline
-bt_bool bt_component_is_sink(const bt_component *component)
-{
- return bt_component_get_class_type(component) ==
- BT_COMPONENT_CLASS_TYPE_SINK;
-}
-
-extern bt_bool bt_component_graph_is_canceled(
- const bt_component *component);
-
-extern void bt_component_get_ref(const bt_component *component);
-
-extern void bt_component_put_ref(const bt_component *component);
-
-#define BT_COMPONENT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/*
- * For bt_component, bt_component_filter, bt_port_input, bt_port_output,
- * __BT_UPCAST_CONST, bt_component_class_filter
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component *bt_component_filter_as_component_const(
- const bt_component_filter *component)
-{
- return __BT_UPCAST_CONST(bt_component, component);
-}
-
-extern const bt_component_class_filter *
-bt_component_filter_borrow_class_const(
- const bt_component_filter *component);
-
-extern uint64_t bt_component_filter_get_input_port_count(
- const bt_component_filter *component);
-
-extern const bt_port_input *
-bt_component_filter_borrow_input_port_by_name_const(
- const bt_component_filter *component, const char *name);
-
-extern const bt_port_input *
-bt_component_filter_borrow_input_port_by_index_const(
- const bt_component_filter *component, uint64_t index);
-
-extern uint64_t bt_component_filter_get_output_port_count(
- const bt_component_filter *component);
-
-extern const bt_port_output *
-bt_component_filter_borrow_output_port_by_name_const(
- const bt_component_filter *component, const char *name);
-
-extern const bt_port_output *
-bt_component_filter_borrow_output_port_by_index_const(
- const bt_component_filter *component, uint64_t index);
-
-extern void bt_component_filter_get_ref(
- const bt_component_filter *component_filter);
-
-extern void bt_component_filter_put_ref(
- const bt_component_filter *component_filter);
-
-#define BT_COMPONENT_FILTER_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_filter_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_FILTER_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_filter_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H
-#define BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/graph/component-filter-const.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-
-struct bt_component_filter {
- struct bt_component parent;
-};
-
-BT_HIDDEN
-struct bt_component *bt_component_filter_create(
- const struct bt_component_class *class);
-
-BT_HIDDEN
-void bt_component_filter_destroy(struct bt_component *component);
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
-#define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/graph/component-const.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-internal.h>
-#include <glib.h>
-#include <stdio.h>
-
-typedef void (*bt_component_destroy_listener_func)(
- struct bt_component *class, void *data);
-
-struct bt_component_destroy_listener {
- bt_component_destroy_listener_func func;
- void *data;
-};
-
-struct bt_graph;
-
-struct bt_component {
- struct bt_object base;
- struct bt_component_class *class;
- GString *name;
-
- /*
- * Internal destroy function specific to a source, filter, or
- * sink component object.
- */
- void (*destroy)(struct bt_component *);
-
- /* User-defined data */
- void *user_data;
-
- /* Input and output ports (weak references) */
- GPtrArray *input_ports;
- GPtrArray *output_ports;
-
- /* Array of struct bt_component_destroy_listener */
- GArray *destroy_listeners;
-
- bool initialized;
-};
-
-static inline
-struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
-{
- BT_ASSERT(comp);
- return (void *) bt_object_borrow_parent(&comp->base);
-}
-
-BT_HIDDEN
-int bt_component_create(struct bt_component_class *component_class,
- const char *name, struct bt_component **component);
-
-BT_HIDDEN
-enum bt_self_component_status bt_component_accept_port_connection(
- struct bt_component *component, struct bt_port *self_port,
- struct bt_port *other_port);
-
-BT_HIDDEN
-enum bt_self_component_status bt_component_port_connected(
- struct bt_component *comp,
- struct bt_port *self_port, struct bt_port *other_port);
-
-BT_HIDDEN
-void bt_component_set_graph(struct bt_component *component,
- struct bt_graph *graph);
-
-BT_HIDDEN
-uint64_t bt_component_get_input_port_count(const struct bt_component *comp);
-
-BT_HIDDEN
-uint64_t bt_component_get_output_port_count(const struct bt_component *comp);
-
-BT_HIDDEN
-struct bt_port_input *bt_component_borrow_input_port_by_index(
- struct bt_component *comp, uint64_t index);
-
-BT_HIDDEN
-struct bt_port_output *bt_component_borrow_output_port_by_index(
- struct bt_component *comp, uint64_t index);
-
-BT_HIDDEN
-struct bt_port_input *bt_component_borrow_input_port_by_name(
- struct bt_component *comp, const char *name);
-
-BT_HIDDEN
-struct bt_port_output *bt_component_borrow_output_port_by_name(
- struct bt_component *comp, const char *name);
-
-BT_HIDDEN
-enum bt_self_component_status bt_component_add_input_port(
- struct bt_component *component, const char *name,
- void *user_data, struct bt_port **port);
-
-BT_HIDDEN
-enum bt_self_component_status bt_component_add_output_port(
- struct bt_component *component, const char *name,
- void *user_data, struct bt_port **port);
-
-BT_HIDDEN
-void bt_component_remove_port(struct bt_component *component,
- struct bt_port *port);
-
-BT_HIDDEN
-void bt_component_add_destroy_listener(struct bt_component *component,
- bt_component_destroy_listener_func func, void *data);
-
-BT_HIDDEN
-void bt_component_remove_destroy_listener(struct bt_component *component,
- bt_component_destroy_listener_func func, void *data);
-
-static inline
-const char *bt_self_component_status_string(
- enum bt_self_component_status status)
-{
- switch (status) {
- case BT_SELF_COMPONENT_STATUS_OK:
- return "BT_SELF_COMPONENT_STATUS_OK";
- case BT_SELF_COMPONENT_STATUS_END:
- return "BT_SELF_COMPONENT_STATUS_END";
- case BT_SELF_COMPONENT_STATUS_AGAIN:
- return "BT_SELF_COMPONENT_STATUS_AGAIN";
- case BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
- return "BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION";
- case BT_SELF_COMPONENT_STATUS_ERROR:
- return "BT_SELF_COMPONENT_STATUS_ERROR";
- case BT_SELF_COMPONENT_STATUS_NOMEM:
- return "BT_SELF_COMPONENT_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/*
- * For bt_component, bt_component_filter, bt_port_input,
- * __BT_UPCAST_CONST, bt_component_class_sink
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component *bt_component_sink_as_component_const(
- const bt_component_sink *component)
-{
- return __BT_UPCAST_CONST(bt_component, component);
-}
-
-extern const bt_component_class_sink *
-bt_component_sink_borrow_class_const(
- const bt_component_sink *component);
-
-extern uint64_t bt_component_sink_get_input_port_count(
- const bt_component_sink *component);
-
-extern const bt_port_input *
-bt_component_sink_borrow_input_port_by_name_const(
- const bt_component_sink *component, const char *name);
-
-extern const bt_port_input *
-bt_component_sink_borrow_input_port_by_index_const(
- const bt_component_sink *component, uint64_t index);
-
-extern void bt_component_sink_get_ref(
- const bt_component_sink *component_sink);
-
-extern void bt_component_sink_put_ref(
- const bt_component_sink *component_sink);
-
-#define BT_COMPONENT_SINK_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_sink_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_SINK_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_sink_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H
-#define BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/component-sink-const.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-
-struct bt_component_sink {
- struct bt_component parent;
- bool graph_is_configured_method_called;
-};
-
-BT_HIDDEN
-struct bt_component *bt_component_sink_create(
- const struct bt_component_class *class);
-
-BT_HIDDEN
-void bt_component_sink_destroy(struct bt_component *component);
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H
-#define BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/*
- * For bt_component, bt_component_filter, bt_port_output,
- * __BT_UPCAST_CONST, bt_component_class_source
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component *bt_component_source_as_component_const(
- const bt_component_source *component)
-{
- return __BT_UPCAST_CONST(bt_component, component);
-}
-
-extern const bt_component_class_source *
-bt_component_source_borrow_class_const(
- const bt_component_source *component);
-
-extern uint64_t bt_component_source_get_output_port_count(
- const bt_component_source *component);
-
-extern const bt_port_output *
-bt_component_source_borrow_output_port_by_name_const(
- const bt_component_source *component, const char *name);
-
-extern const bt_port_output *
-bt_component_source_borrow_output_port_by_index_const(
- const bt_component_source *component, uint64_t index);
-
-extern void bt_component_source_get_ref(
- const bt_component_source *component_source);
-
-extern void bt_component_source_put_ref(
- const bt_component_source *component_source);
-
-#define BT_COMPONENT_SOURCE_PUT_REF_AND_RESET(_var) \
- do { \
- bt_component_source_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_COMPONENT_SOURCE_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_component_source_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H
-#define BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-
-struct bt_component_source {
- struct bt_component parent;
-};
-
-BT_HIDDEN
-struct bt_component *bt_component_source_create(
- const struct bt_component_class *class);
-
-BT_HIDDEN
-void bt_component_source_destroy(struct bt_component *component);
-
-#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_CONNECTION_CONST_H
-#define BABELTRACE_GRAPH_CONNECTION_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_bool, bt_port_input, bt_port_output, bt_connection */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_port_input *bt_connection_borrow_downstream_port_const(
- const bt_connection *connection);
-
-extern const bt_port_output *bt_connection_borrow_upstream_port_const(
- const bt_connection *connection);
-
-extern void bt_connection_get_ref(const bt_connection *connection);
-
-extern void bt_connection_put_ref(const bt_connection *connection);
-
-#define BT_CONNECTION_PUT_REF_AND_RESET(_var) \
- do { \
- bt_connection_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_CONNECTION_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_connection_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_CONNECTION_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
-#define BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/graph/connection-const.h>
-#include <babeltrace/graph/message-iterator-const.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <stdbool.h>
-
-struct bt_graph;
-
-struct bt_connection {
- /*
- * The graph is a connection's parent and the connection is the parent
- * of all iterators it has created.
- */
- struct bt_object base;
- /*
- * Weak references are held to both ports. Their existence is guaranteed
- * by the existence of the graph and thus, of their respective
- * components.
- */
- /* Downstream port. */
- struct bt_port *downstream_port;
- /* Upstream port. */
- struct bt_port *upstream_port;
-
- /*
- * Weak references to all the message iterators that were
- * created on this connection.
- */
- GPtrArray *iterators;
-
- bool notified_upstream_port_connected;
- bool notified_downstream_port_connected;
- bool notified_graph_ports_connected;
-};
-
-BT_HIDDEN
-struct bt_connection *bt_connection_create(struct bt_graph *graph,
- struct bt_port *upstream_port,
- struct bt_port *downstream_port);
-
-BT_HIDDEN
-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_message_iterator *iterator);
-
-static inline
-struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn)
-{
- BT_ASSERT(conn);
- return (void *) conn->base.parent;
-}
-
-#endif /* BABELTRACE_GRAPH_CONNECTION_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_GRAPH_CONST_H
-#define BABELTRACE_GRAPH_GRAPH_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_bool, bt_graph */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_graph_status {
- BT_GRAPH_STATUS_OK = 0,
- BT_GRAPH_STATUS_END = 1,
- BT_GRAPH_STATUS_AGAIN = 11,
- BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
- BT_GRAPH_STATUS_CANCELED = 125,
- BT_GRAPH_STATUS_ERROR = -1,
- BT_GRAPH_STATUS_NOMEM = -12,
-} bt_graph_status;
-
-extern bt_bool bt_graph_is_canceled(const bt_graph *graph);
-
-extern void bt_graph_get_ref(const bt_graph *graph);
-
-extern void bt_graph_put_ref(const bt_graph *graph);
-
-#define BT_GRAPH_PUT_REF_AND_RESET(_var) \
- do { \
- bt_graph_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_GRAPH_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_graph_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_GRAPH_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_GRAPH_INTERNAL_H
-#define BABELTRACE_GRAPH_GRAPH_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/graph/graph.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <stdlib.h>
-#include <glib.h>
-
-struct bt_component;
-struct bt_port;
-
-enum bt_graph_configuration_state {
- BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
- BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED,
- BT_GRAPH_CONFIGURATION_STATE_CONFIGURED,
- BT_GRAPH_CONFIGURATION_STATE_FAULTY,
-};
-
-struct bt_graph {
- /**
- * A component graph contains components and point-to-point connection
- * between these components.
- *
- * In terms of ownership:
- * 1) The graph is the components' parent,
- * 2) The graph is the connnections' parent,
- * 3) Components share the ownership of their connections,
- * 4) A connection holds weak references to its two component endpoints.
- */
- struct bt_object base;
-
- /* Array of pointers to bt_connection. */
- GPtrArray *connections;
- /* Array of pointers to bt_component. */
- GPtrArray *components;
- /* Queue of pointers (weak references) to sink bt_components. */
- GQueue *sinks_to_consume;
-
- bool canceled;
- bool in_remove_listener;
- bool has_sink;
-
- /*
- * If this is false, then the public API's consuming
- * functions (bt_graph_consume() and bt_graph_run()) return
- * BT_GRAPH_STATUS_CANNOT_CONSUME. The internal "no check"
- * functions always work.
- *
- * 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.
- */
- bool can_consume;
-
- enum bt_graph_configuration_state config_state;
-
- struct {
- GArray *source_output_port_added;
- GArray *filter_output_port_added;
- GArray *filter_input_port_added;
- GArray *sink_input_port_added;
- GArray *source_filter_ports_connected;
- GArray *source_sink_ports_connected;
- GArray *filter_filter_ports_connected;
- GArray *filter_sink_ports_connected;
- } listeners;
-
- /* Pool of `struct bt_message_event *` */
- struct bt_object_pool event_msg_pool;
-
- /* Pool of `struct bt_message_packet_beginning *` */
- struct bt_object_pool packet_begin_msg_pool;
-
- /* Pool of `struct bt_message_packet_end *` */
- struct bt_object_pool packet_end_msg_pool;
-
- /*
- * Array of `struct bt_message *` (weak).
- *
- * 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 message has a
- * weak pointer to the graph containing its pool, we need to
- * 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 message to remove itself from this
- * array (on destruction).
- */
- GPtrArray *messages;
-};
-
-static inline
-void _bt_graph_set_can_consume(struct bt_graph *graph, bool can_consume)
-{
- BT_ASSERT(graph);
- graph->can_consume = can_consume;
-}
-
-#ifdef BT_DEV_MODE
-# define bt_graph_set_can_consume _bt_graph_set_can_consume
-#else
-# define bt_graph_set_can_consume(_graph, _can_consume)
-#endif
-
-BT_HIDDEN
-enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph,
- struct bt_component_sink *sink);
-
-BT_HIDDEN
-enum bt_graph_listener_status bt_graph_notify_port_added(struct bt_graph *graph,
- struct bt_port *port);
-
-BT_HIDDEN
-enum bt_graph_listener_status bt_graph_notify_ports_connected(
- struct bt_graph *graph, struct bt_port *upstream_port,
- struct bt_port *downstream_port);
-
-BT_HIDDEN
-void bt_graph_remove_connection(struct bt_graph *graph,
- struct bt_connection *connection);
-
-/*
- * This only works with a component which is not connected at this
- * point.
- *
- * Also the reference count of `component` should be 0 when you call
- * this function, which means only `graph` owns the component, so it
- * is safe to destroy.
- */
-BT_HIDDEN
-int bt_graph_remove_unconnected_component(struct bt_graph *graph,
- struct bt_component *component);
-
-BT_HIDDEN
-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)
-{
- switch (status) {
- case BT_GRAPH_STATUS_CANCELED:
- return "BT_GRAPH_STATUS_CANCELED";
- case BT_GRAPH_STATUS_AGAIN:
- return "BT_GRAPH_STATUS_AGAIN";
- case BT_GRAPH_STATUS_END:
- return "BT_GRAPH_STATUS_END";
- case BT_GRAPH_STATUS_OK:
- return "BT_GRAPH_STATUS_OK";
- case BT_GRAPH_STATUS_ERROR:
- return "BT_GRAPH_STATUS_ERROR";
- case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
- return "BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION";
- case BT_GRAPH_STATUS_NOMEM:
- return "BT_GRAPH_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_graph_configuration_state_string(
- enum bt_graph_configuration_state state)
-{
- switch (state) {
- case BT_GRAPH_CONFIGURATION_STATE_CONFIGURING:
- return "BT_GRAPH_CONFIGURATION_STATE_CONFIGURING";
- case BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED:
- return "BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED";
- case BT_GRAPH_CONFIGURATION_STATE_CONFIGURED:
- return "BT_GRAPH_CONFIGURATION_STATE_CONFIGURED";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-enum bt_graph_status bt_graph_configure(struct bt_graph *graph)
-{
- enum bt_graph_status status = BT_GRAPH_STATUS_OK;
- uint64_t i;
-
- BT_ASSERT(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY);
-
- if (likely(graph->config_state ==
- BT_GRAPH_CONFIGURATION_STATE_CONFIGURED)) {
- goto end;
- }
-
-#ifdef BT_ASSERT_PRE
- BT_ASSERT_PRE(graph->has_sink, "Graph has no sink component: %!+g", graph);
-#endif
-
- graph->config_state = BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED;
-
- for (i = 0; i < graph->components->len; i++) {
- struct bt_component *comp = graph->components->pdata[i];
- struct bt_component_sink *comp_sink = (void *) comp;
- struct bt_component_class_sink *comp_cls_sink =
- (void *) comp->class;
-
- if (comp->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
- continue;
- }
-
- if (comp_sink->graph_is_configured_method_called) {
- continue;
- }
-
- if (comp_cls_sink->methods.graph_is_configured) {
- enum bt_self_component_status comp_status;
-
-#ifdef BT_LIB_LOGD
- BT_LIB_LOGD("Calling user's \"graph is configured\" method: "
- "%![graph-]+g, %![comp-]+c",
- graph, comp);
-#endif
-
- comp_status = comp_cls_sink->methods.graph_is_configured(
- (void *) comp_sink);
-
-#ifdef BT_LIB_LOGD
- BT_LIB_LOGD("User method returned: status=%s",
- bt_self_component_status_string(comp_status));
-#endif
-
-#ifdef BT_ASSERT_PRE
- BT_ASSERT_PRE(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
- comp_status == BT_SELF_COMPONENT_STATUS_ERROR ||
- comp_status == BT_SELF_COMPONENT_STATUS_NOMEM,
- "Unexpected returned status: status=%s",
- bt_self_component_status_string(comp_status));
-#endif
-
- if (comp_status != BT_SELF_COMPONENT_STATUS_OK) {
- status = BT_GRAPH_STATUS_ERROR;
-#ifdef BT_LIB_LOGW
- BT_LIB_LOGW("User's \"graph is configured\" method failed: "
- "%![comp-]+c, status=%s",
- comp,
- bt_self_component_status_string(
- comp_status));
-#endif
-
- goto end;
- }
- }
-
- comp_sink->graph_is_configured_method_called = true;
- }
-
- graph->config_state = BT_GRAPH_CONFIGURATION_STATE_CONFIGURED;
-
-end:
- return status;
-}
-
-static inline
-void bt_graph_make_faulty(struct bt_graph *graph)
-{
- graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
-#ifdef BT_LIB_LOGD
- BT_LIB_LOGD("Set graph's state to faulty: %![graph-]+g", graph);
-#endif
-}
-
-#endif /* BABELTRACE_GRAPH_GRAPH_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_GRAPH_H
-#define BABELTRACE_GRAPH_GRAPH_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_bool, bt_component, bt_component_class,
- * bt_component_class_filter, bt_component_class_sink,
- * bt_component_class_source, bt_component_filter, bt_component_sink,
- * bt_component_source, bt_connection, bt_graph, bt_port_input,
- * bt_port_output, bt_value
- */
-#include <babeltrace/types.h>
-
-/* For bt_graph_status */
-#include <babeltrace/graph/graph-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_graph_listener_status {
- BT_GRAPH_LISTENER_STATUS_OK = 0,
- BT_GRAPH_LISTENER_STATUS_ERROR = -1,
- BT_GRAPH_LISTENER_STATUS_NOMEM = -12,
-} bt_graph_listener_status;
-
-typedef bt_graph_listener_status
-(*bt_graph_filter_component_input_port_added_listener_func)(
- const bt_component_filter *component,
- const bt_port_input *port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_sink_component_input_port_added_listener_func)(
- const bt_component_sink *component,
- const bt_port_input *port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_source_component_output_port_added_listener_func)(
- const bt_component_source *component,
- const bt_port_output *port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_filter_component_output_port_added_listener_func)(
- const bt_component_filter *component,
- const bt_port_output *port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_source_filter_component_ports_connected_listener_func)(
- const bt_component_source *source_component,
- const bt_component_filter *filter_component,
- const bt_port_output *upstream_port,
- const bt_port_input *downstream_port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_source_sink_component_ports_connected_listener_func)(
- const bt_component_source *source_component,
- const bt_component_sink *sink_component,
- const bt_port_output *upstream_port,
- const bt_port_input *downstream_port, void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_filter_filter_component_ports_connected_listener_func)(
- const bt_component_filter *filter_component_upstream,
- const bt_component_filter *filter_component_downstream,
- const bt_port_output *upstream_port,
- const bt_port_input *downstream_port,
- void *data);
-
-typedef bt_graph_listener_status
-(*bt_graph_filter_sink_component_ports_connected_listener_func)(
- const bt_component_filter *filter_component,
- const bt_component_sink *sink_component,
- const bt_port_output *upstream_port,
- const bt_port_input *downstream_port, void *data);
-
-typedef void (* bt_graph_listener_removed_func)(void *data);
-
-extern bt_graph *bt_graph_create(void);
-
-extern bt_graph_status bt_graph_add_source_component(bt_graph *graph,
- const bt_component_class_source *component_class,
- const char *name, const bt_value *params,
- const bt_component_source **component);
-
-extern bt_graph_status bt_graph_add_source_component_with_init_method_data(
- bt_graph *graph,
- const bt_component_class_source *component_class,
- const char *name, const bt_value *params,
- void *init_method_data,
- const bt_component_source **component);
-
-extern bt_graph_status bt_graph_add_filter_component(bt_graph *graph,
- const bt_component_class_filter *component_class,
- const char *name, const bt_value *params,
- const bt_component_filter **component);
-
-extern bt_graph_status bt_graph_add_filter_component_with_init_method_data(
- bt_graph *graph,
- const bt_component_class_filter *component_class,
- const char *name, const bt_value *params,
- void *init_method_data,
- const bt_component_filter **component);
-
-extern bt_graph_status bt_graph_add_sink_component(
- bt_graph *graph, const bt_component_class_sink *component_class,
- const char *name, const bt_value *params,
- const bt_component_sink **component);
-
-extern bt_graph_status bt_graph_add_sink_component_with_init_method_data(
- bt_graph *graph, const bt_component_class_sink *component_class,
- const char *name, const bt_value *params,
- void *init_method_data,
- const bt_component_sink **component);
-
-extern bt_graph_status bt_graph_connect_ports(bt_graph *graph,
- const bt_port_output *upstream,
- const bt_port_input *downstream,
- const bt_connection **connection);
-
-extern bt_graph_status bt_graph_run(bt_graph *graph);
-
-extern bt_graph_status bt_graph_consume(bt_graph *graph);
-
-extern bt_graph_status bt_graph_add_filter_component_input_port_added_listener(
- bt_graph *graph,
- bt_graph_filter_component_input_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status bt_graph_add_sink_component_input_port_added_listener(
- bt_graph *graph,
- bt_graph_sink_component_input_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status bt_graph_add_source_component_output_port_added_listener(
- bt_graph *graph,
- bt_graph_source_component_output_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status bt_graph_add_filter_component_output_port_added_listener(
- bt_graph *graph,
- bt_graph_filter_component_output_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status
-bt_graph_add_source_filter_component_ports_connected_listener(
- bt_graph *graph,
- bt_graph_source_filter_component_ports_connected_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status
-bt_graph_add_filter_filter_component_ports_connected_listener(
- bt_graph *graph,
- bt_graph_filter_filter_component_ports_connected_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status
-bt_graph_add_source_sink_component_ports_connected_listener(
- bt_graph *graph,
- bt_graph_source_sink_component_ports_connected_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status
-bt_graph_add_filter_sink_component_ports_connected_listener(
- bt_graph *graph,
- bt_graph_filter_sink_component_ports_connected_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- int *listener_id);
-
-extern bt_graph_status bt_graph_cancel(bt_graph *graph);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_GRAPH_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Message types. Unhandled message types should be ignored.
- */
-typedef enum bt_message_type {
- BT_MESSAGE_TYPE_EVENT = 0,
- BT_MESSAGE_TYPE_MESSAGE_ITERATOR_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,
- BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING = 6,
- BT_MESSAGE_TYPE_STREAM_ACTIVITY_END = 7,
- BT_MESSAGE_TYPE_DISCARDED_EVENTS = 8,
- BT_MESSAGE_TYPE_DISCARDED_PACKETS = 9,
-} bt_message_type;
-
-/**
- * Get a message's type.
- *
- * @param message Message instance
- * @returns One of #bt_message_type
- */
-extern bt_message_type bt_message_get_type(const bt_message *message);
-
-extern void bt_message_get_ref(const bt_message *message);
-
-extern void bt_message_put_ref(const bt_message *message);
-
-#define BT_MESSAGE_PUT_REF_AND_RESET(_var) \
- do { \
- bt_message_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_MESSAGE_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_message_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_clock_snapshot, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_clock_snapshot *
-bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_snapshot *
-bt_message_discarded_events_borrow_end_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_class *
-bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-extern const bt_stream *
-bt_message_discarded_events_borrow_stream_const(const bt_message *message);
-
-extern bt_property_availability bt_message_discarded_events_get_count(
- const bt_message *message, uint64_t *count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
-#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message *bt_message_discarded_events_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream, uint64_t beginning_raw_value,
- uint64_t end_raw_value);
-
-extern bt_stream *bt_message_discarded_events_borrow_stream(
- bt_message *message);
-
-extern void bt_message_discarded_events_set_count(bt_message *message,
- uint64_t count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <glib.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/property-internal.h>
-#include <babeltrace/graph/message-const.h>
-
-struct bt_message_discarded_items {
- struct bt_message parent;
- struct bt_stream *stream;
- struct bt_clock_snapshot *default_begin_cs;
- struct bt_clock_snapshot *default_end_cs;
- struct bt_property_uint count;
-};
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_clock_snapshot, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_clock_snapshot *
-bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_snapshot *
-bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_class *
-bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-extern const bt_stream *
-bt_message_discarded_packets_borrow_stream_const(const bt_message *message);
-
-extern bt_property_availability bt_message_discarded_packets_get_count(
- const bt_message *message, uint64_t *count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H
-#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message *bt_message_discarded_packets_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern bt_message *bt_message_discarded_packets_create_with_default_clock_snapshots(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream, uint64_t beginning_raw_value,
- uint64_t end_raw_value);
-
-extern bt_stream *bt_message_discarded_packets_borrow_stream(
- bt_message *message);
-
-extern void bt_message_discarded_packets_set_count(bt_message *message,
- uint64_t count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_bool, bt_message, bt_event. bt_clock_class, bt_clock_snapshot */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_event *bt_message_event_borrow_event_const(
- const bt_message *message);
-
-extern const bt_clock_snapshot *
-bt_message_event_borrow_default_clock_snapshot_const(const bt_message *msg);
-
-extern const bt_clock_class *
-bt_message_event_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/assert-internal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_message_event {
- struct bt_message parent;
- struct bt_event *event;
- struct bt_clock_snapshot *default_cs;
-};
-
-BT_HIDDEN
-struct bt_message *bt_message_event_new(struct bt_graph *graph);
-
-BT_HIDDEN
-void bt_message_event_recycle(struct bt_message *msg);
-
-BT_HIDDEN
-void bt_message_event_destroy(struct bt_message *msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_H
-#define BABELTRACE_GRAPH_MESSAGE_EVENT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/*
- * For bt_self_message_iterator, bt_event, bt_packet,
- * bt_event_class, bt_message
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_event_create(
- bt_self_message_iterator *message_iterator,
- const bt_event_class *event_class,
- const bt_packet *packet);
-
-extern
-bt_message *bt_message_event_create_with_default_clock_snapshot(
- bt_self_message_iterator *message_iterator,
- const bt_event_class *event_class,
- const bt_packet *packet, uint64_t raw_clock_value);
-
-extern bt_event *bt_message_event_borrow_event(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/types.h>
-
-typedef struct bt_stream *(*get_stream_func)(
- struct bt_message *message);
-
-struct bt_message {
- struct bt_object base;
- enum bt_message_type type;
- 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;
-#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_MESSAGE_ITERATOR_INACTIVITY:
- return "BT_MESSAGE_TYPE_MESSAGE_ITERATOR_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";
- case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
- return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING";
- case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
- return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_END";
- case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
- return "BT_MESSAGE_TYPE_DISCARDED_EVENTS";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef 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_ERROR = -1,
- BT_MESSAGE_ITERATOR_STATUS_NOMEM = -12,
-} bt_message_iterator_status;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/graph/connection-const.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/message-iterator-const.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-internal.h>
-#include <stdbool.h>
-
-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 currently being finalized */
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING,
-
- /* Iterator is finalized */
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED,
-
- /* Iterator is seeking */
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING,
-
- /* Iterator did seek, but returned `BT_MESSAGE_ITERATOR_STATUS_AGAIN` */
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN,
-
- /* Iterator did seek, but returned error status */
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR,
-};
-
-struct bt_message_iterator {
- struct bt_object base;
- enum bt_message_iterator_type type;
- GPtrArray *msgs;
-};
-
-typedef enum bt_self_message_iterator_status
-(*bt_self_component_port_input_message_iterator_next_method)(
- void *, bt_message_array_const, uint64_t, uint64_t *);
-
-typedef enum bt_self_message_iterator_status
-(*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)(
- void *, int64_t);
-
-typedef enum bt_self_message_iterator_status
-(*bt_self_component_port_input_message_iterator_seek_beginning_method)(
- void *);
-
-typedef bt_bool
-(*bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)(
- void *, int64_t);
-
-typedef bt_bool
-(*bt_self_component_port_input_message_iterator_can_seek_beginning_method)(
- void *);
-
-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 */
-
- struct {
- bt_self_component_port_input_message_iterator_next_method next;
- bt_self_component_port_input_message_iterator_seek_ns_from_origin_method seek_ns_from_origin;
- bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning;
- bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin;
- bt_self_component_port_input_message_iterator_can_seek_beginning_method can_seek_beginning;
- } methods;
-
- enum bt_self_component_port_input_message_iterator_state state;
- GQueue *auto_seek_msgs;
- 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_try_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_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_FINALIZING:
- return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING";
- 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_SEEKING:
- return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING";
- case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN:
- return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN";
- case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR:
- return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR";
- default:
- return "(unknown)";
- }
-};
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_clock_snapshot */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_clock_snapshot *
-bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
- const bt_message *msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <glib.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/graph/message-const.h>
-
-struct bt_message_message_iterator_inactivity {
- struct bt_message parent;
- struct bt_clock_snapshot *default_cs;
-};
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H
-#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_message_iterator, bt_message, bt_clock_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_message_iterator_inactivity_create(
- bt_self_message_iterator *message_iterator,
- const bt_clock_class *default_clock_class, uint64_t raw_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_packet, bt_clock_snapshot, bt_clock_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_packet *bt_message_packet_beginning_borrow_packet_const(
- const bt_message *message);
-
-extern const bt_clock_snapshot *
-bt_message_packet_beginning_borrow_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_class *
-bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H
-#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_packet */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_packet_beginning_create(
- bt_self_message_iterator *message_iterator,
- const bt_packet *packet);
-
-extern
-bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot(
- bt_self_message_iterator *message_iterator,
- const bt_packet *packet, uint64_t raw_value);
-
-extern bt_packet *bt_message_packet_beginning_borrow_packet(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_packet, bt_clock_snapshot, bt_clock_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_packet *bt_message_packet_end_borrow_packet_const(
- const bt_message *message);
-
-extern const bt_clock_snapshot *
-bt_message_packet_end_borrow_default_clock_snapshot_const(
- const bt_message *msg);
-
-extern const bt_clock_class *
-bt_message_packet_end_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_H
-#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_packet */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_packet_end_create(
- bt_self_message_iterator *message_iterator,
- const bt_packet *packet);
-
-extern
-bt_message *bt_message_packet_end_create_with_default_clock_snapshot(
- bt_self_message_iterator *message_iterator,
- const bt_packet *packet, uint64_t raw_value);
-
-extern bt_packet *bt_message_packet_end_borrow_packet(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/assert-internal.h>
-
-struct bt_message_packet {
- struct bt_message parent;
- struct bt_packet *packet;
- struct bt_clock_snapshot *default_cs;
-};
-
-BT_HIDDEN
-void bt_message_packet_destroy(struct bt_message *msg);
-
-BT_HIDDEN
-struct bt_message *bt_message_packet_beginning_new(
- struct bt_graph *graph);
-BT_HIDDEN
-void bt_message_packet_beginning_recycle(struct bt_message *msg);
-
-BT_HIDDEN
-struct bt_message *bt_message_packet_end_new(struct bt_graph *graph);
-
-BT_HIDDEN
-void bt_message_packet_end_recycle(struct bt_message *msg);
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_clock_snapshot, bt_stream, bt_clock_class */
-#include <babeltrace/types.h>
-
-/* For bt_message_stream_activity_clock_snapshot_state */
-#include <babeltrace/graph/message-stream-activity-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message_stream_activity_clock_snapshot_state
-bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const(
- const bt_message *msg, const bt_clock_snapshot **snapshot);
-
-extern const bt_clock_class *
-bt_message_stream_activity_beginning_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-extern const bt_stream *
-bt_message_stream_activity_beginning_borrow_stream_const(
- const bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_stream */
-#include <babeltrace/types.h>
-
-/* For bt_message_stream_activity_clock_snapshot_state */
-#include <babeltrace/graph/message-stream-activity-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message *bt_message_stream_activity_beginning_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern bt_stream *bt_message_stream_activity_beginning_borrow_stream(
- bt_message *message);
-
-extern void bt_message_stream_activity_beginning_set_default_clock_snapshot_state(
- bt_message *msg,
- bt_message_stream_activity_clock_snapshot_state state);
-
-extern void bt_message_stream_activity_beginning_set_default_clock_snapshot(
- bt_message *msg, uint64_t raw_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_message_stream_activity_clock_snapshot_state {
- BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN,
- BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN,
- BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE,
-} bt_message_stream_activity_clock_snapshot_state;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_clock_snapshot, bt_stream, bt_clock_class */
-#include <babeltrace/types.h>
-
-/* For bt_message_stream_activity_clock_snapshot_state */
-#include <babeltrace/graph/message-stream-activity-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message_stream_activity_clock_snapshot_state
-bt_message_stream_activity_end_borrow_default_clock_snapshot_const(
- const bt_message *msg, const bt_clock_snapshot **snapshot);
-
-extern const bt_clock_class *
-bt_message_stream_activity_end_borrow_stream_class_default_clock_class_const(
- const bt_message *msg);
-
-extern const bt_stream *
-bt_message_stream_activity_end_borrow_stream_const(
- const bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message, bt_self_message_iterator, bt_stream */
-#include <babeltrace/types.h>
-
-/* For bt_message_stream_activity_clock_snapshot_state */
-#include <babeltrace/graph/message-stream-activity-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_message *bt_message_stream_activity_end_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern void bt_message_stream_activity_end_set_default_clock_snapshot_state(
- bt_message *msg,
- bt_message_stream_activity_clock_snapshot_state state);
-
-extern void bt_message_stream_activity_end_set_default_clock_snapshot(
- bt_message *msg, uint64_t raw_value);
-
-extern bt_stream *bt_message_stream_activity_end_borrow_stream(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H
-
-/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <glib.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/message-stream-activity-const.h>
-
-struct bt_message_stream_activity {
- struct bt_message parent;
- struct bt_stream *stream;
- struct bt_clock_snapshot *default_cs;
- enum bt_message_stream_activity_clock_snapshot_state default_cs_state;
-};
-
-static inline
-const char *bt_message_stream_activity_clock_snapshot_state_string(
- enum bt_message_stream_activity_clock_snapshot_state state)
-{
- switch (state) {
- case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN:
- return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN";
- case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN:
- return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN";
- case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE:
- return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_clock_snapshot, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_stream *bt_message_stream_beginning_borrow_stream_const(
- const bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_stream_beginning_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern bt_stream *bt_message_stream_beginning_borrow_stream(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_clock_snapshot, bt_stream */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_stream *bt_message_stream_end_borrow_stream_const(
- const bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_END_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_END_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_message *bt_message_stream_end_create(
- bt_self_message_iterator *message_iterator,
- const bt_stream *stream);
-
-extern bt_stream *bt_message_stream_end_borrow_stream(
- bt_message *message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_END_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/assert-internal.h>
-
-struct bt_message_stream {
- struct bt_message parent;
- struct bt_stream *stream;
-};
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PORT_CONST_H
-#define BABELTRACE_GRAPH_PORT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_bool, bt_port, bt_connection, bt_component */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_port_type {
- BT_PORT_TYPE_INPUT = 0,
- BT_PORT_TYPE_OUTPUT = 1,
-} bt_port_type;
-
-extern const char *bt_port_get_name(const bt_port *port);
-
-extern bt_port_type bt_port_get_type(const bt_port *port);
-
-extern const bt_connection *bt_port_borrow_connection_const(
- const bt_port *port);
-
-extern const bt_component *bt_port_borrow_component_const(
- const bt_port *port);
-
-extern bt_bool bt_port_is_connected(const bt_port *port);
-
-static inline
-bt_bool bt_port_is_input(const bt_port *port)
-{
- return bt_port_get_type(port) == BT_PORT_TYPE_INPUT;
-}
-
-static inline
-bt_bool bt_port_is_output(const bt_port *port)
-{
- return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT;
-}
-
-extern void bt_port_get_ref(const bt_port *port);
-
-extern void bt_port_put_ref(const bt_port *port);
-
-#define BT_PORT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_port_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PORT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_port_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PORT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PORT_INPUT_CONST_H
-#define BABELTRACE_GRAPH_PORT_INPUT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_port, bt_port_input, __BT_UPCAST_CONST */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_port *bt_port_input_as_port_const(const bt_port_input *port_input)
-{
- return __BT_UPCAST_CONST(bt_port, port_input);
-}
-
-extern void bt_port_input_get_ref(const bt_port_input *port_input);
-
-extern void bt_port_input_put_ref(const bt_port_input *port_input);
-
-#define BT_PORT_INPUT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_port_input_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PORT_INPUT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_port_input_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PORT_INPUT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PORT_INTERNAL_H
-#define BABELTRACE_GRAPH_PORT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/graph/port-const.h>
-
-struct bt_port {
- struct bt_object base;
- enum bt_port_type type;
- GString *name;
- struct bt_connection *connection;
- void *user_data;
-};
-
-struct bt_component;
-
-BT_HIDDEN
-struct bt_port *bt_port_create(struct bt_component *parent_component,
- enum bt_port_type type, const char *name, void *user_data);
-
-BT_HIDDEN
-void bt_port_set_connection(struct bt_port *port,
- struct bt_connection *connection);
-
-static inline
-struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port)
-{
- BT_ASSERT(port);
- return (void *) bt_object_borrow_parent(&port->base);
-}
-
-static inline
-const char *bt_port_type_string(enum bt_port_type port_type)
-{
- switch (port_type) {
- case BT_PORT_TYPE_INPUT:
- return "BT_PORT_TYPE_INPUT";
- case BT_PORT_TYPE_OUTPUT:
- return "BT_PORT_TYPE_OUTPUT";
- default:
- return "(unknown)";
- }
-}
-
-#endif /* BABELTRACE_GRAPH_PORT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H
-#define BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_port, bt_port_output, __BT_UPCAST_CONST */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_port *bt_port_output_as_port_const(const bt_port_output *port_output)
-{
- return __BT_UPCAST_CONST(bt_port, port_output);
-}
-
-extern void bt_port_output_get_ref(const bt_port_output *port_output);
-
-extern void bt_port_output_put_ref(const bt_port_output *port_output);
-
-#define BT_PORT_OUTPUT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_port_output_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PORT_OUTPUT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_port_output_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H
-#define BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message_iterator_status */
-#include <babeltrace/graph/message-iterator-const.h>
-
-/*
- * For bt_port, bt_message, bt_message_iterator,
- * bt_port_output_message_iterator, bt_graph, bt_port_output,
- * bt_message_array_const, bt_bool, __BT_UPCAST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_message_iterator *
-bt_port_output_message_iterator_as_message_iterator(
- bt_port_output_message_iterator *iterator)
-{
- return __BT_UPCAST(bt_message_iterator, iterator);
-}
-
-extern bt_port_output_message_iterator *
-bt_port_output_message_iterator_create(
- bt_graph *graph,
- const bt_port_output *output_port);
-
-extern 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 bt_bool bt_port_output_message_iterator_can_seek_ns_from_origin(
- bt_port_output_message_iterator *iterator,
- int64_t ns_from_origin);
-
-extern bt_bool bt_port_output_message_iterator_can_seek_beginning(
- bt_port_output_message_iterator *iterator);
-
-extern bt_message_iterator_status
-bt_port_output_message_iterator_seek_ns_from_origin(
- bt_port_output_message_iterator *iterator,
- int64_t ns_from_origin);
-
-extern bt_message_iterator_status
-bt_port_output_message_iterator_seek_beginning(
- bt_port_output_message_iterator *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_message_iterator_put_ref(
- const bt_port_output_message_iterator *port_output_message_iterator);
-
-#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(_var) \
- do { \
- bt_port_output_message_iterator_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_port_output_message_iterator_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H
-#define BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_bool, bt_query_executor */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_query_executor_status {
- BT_QUERY_EXECUTOR_STATUS_OK = 0,
- BT_QUERY_EXECUTOR_STATUS_AGAIN = 11,
- BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED = 95,
- BT_QUERY_EXECUTOR_STATUS_CANCELED = 125,
- BT_QUERY_EXECUTOR_STATUS_ERROR = -1,
- BT_QUERY_EXECUTOR_STATUS_NOMEM = -12,
- BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT = -23,
- BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS = -24,
-} bt_query_executor_status;
-
-extern
-bt_bool bt_query_executor_is_canceled(
- const bt_query_executor *query_executor);
-
-extern void bt_query_executor_get_ref(
- const bt_query_executor *query_executor);
-
-extern void bt_query_executor_put_ref(
- const bt_query_executor *query_executor);
-
-#define BT_QUERY_EXECUTOR_PUT_REF_AND_RESET(_var) \
- do { \
- bt_query_executor_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_QUERY_EXECUTOR_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_query_executor_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H
-#define BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/types.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/graph/query-executor.h>
-#include <babeltrace/graph/component-class.h>
-
-struct bt_query_executor {
- struct bt_object base;
- bool canceled;
-};
-
-static inline const char *bt_query_status_string(enum bt_query_status status)
-{
- switch (status) {
- case BT_QUERY_STATUS_OK:
- return "BT_QUERY_STATUS_OK";
- case BT_QUERY_STATUS_AGAIN:
- return "BT_QUERY_STATUS_AGAIN";
- case BT_QUERY_STATUS_ERROR:
- return "BT_QUERY_STATUS_ERROR";
- case BT_QUERY_STATUS_INVALID_OBJECT:
- return "BT_QUERY_STATUS_INVALID_OBJECT";
- case BT_QUERY_STATUS_INVALID_PARAMS:
- return "BT_QUERY_STATUS_INVALID_PARAMS";
- case BT_QUERY_STATUS_NOMEM:
- return "BT_QUERY_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-};
-
-static inline const char *bt_query_executor_status_string(
- enum bt_query_executor_status status)
-{
- switch (status) {
- case BT_QUERY_EXECUTOR_STATUS_OK:
- return "BT_QUERY_EXECUTOR_STATUS_OK";
- case BT_QUERY_EXECUTOR_STATUS_AGAIN:
- return "BT_QUERY_EXECUTOR_STATUS_AGAIN";
- case BT_QUERY_EXECUTOR_STATUS_CANCELED:
- return "BT_QUERY_EXECUTOR_STATUS_CANCELED";
- case BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED:
- return "BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED";
- case BT_QUERY_EXECUTOR_STATUS_ERROR:
- return "BT_QUERY_EXECUTOR_STATUS_ERROR";
- case BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT:
- return "BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT";
- case BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS:
- return "BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS";
- case BT_QUERY_EXECUTOR_STATUS_NOMEM:
- return "BT_QUERY_EXECUTOR_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-};
-
-#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_H
-#define BABELTRACE_GRAPH_QUERY_EXECUTOR_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_query_executor_status */
-#include <babeltrace/graph/query-executor.h>
-
-/* For bt_query_executor, bt_component_class, bt_value */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_query_executor *bt_query_executor_create(void);
-
-extern
-bt_query_executor_status bt_query_executor_query(
- bt_query_executor *query_executor,
- const bt_component_class *component_class,
- const char *object, const bt_value *params,
- const bt_value **result);
-
-extern
-bt_query_executor_status bt_query_executor_cancel(
- bt_query_executor *query_executor);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class_filter, bt_self_component_class_filter,
- * __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class_filter *
-bt_self_component_class_filter_as_component_class_filter(
- bt_self_component_class_filter *self_comp_cls_filter)
-{
- return __BT_UPCAST_CONST(bt_component_class_filter,
- self_comp_cls_filter);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class_sink, bt_self_component_class_sink,
- * __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class_sink *
-bt_self_component_class_sink_as_component_class_sink(
- bt_self_component_class_sink *self_comp_cls_sink)
-{
- return __BT_UPCAST_CONST(bt_component_class_sink, self_comp_cls_sink);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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_component_class_source, bt_self_component_class_source,
- * __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-const bt_component_class_source *
-bt_self_component_class_source_as_component_class_source(
- bt_self_component_class_source *self_comp_cls_source)
-{
- return __BT_UPCAST_CONST(bt_component_class_source,
- self_comp_cls_source);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/*
- * For bt_component_filter, bt_self_component, bt_self_component_filter,
- * bt_self_component_port_input, bt_self_component_port_output,
- * __BT_UPCAST, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_self_component *bt_self_component_filter_as_self_component(
- bt_self_component_filter *self_comp_filter)
-{
- return __BT_UPCAST(bt_self_component, self_comp_filter);
-}
-
-static inline
-const bt_component_filter *
-bt_self_component_filter_as_component_filter(
- bt_self_component_filter *self_comp_filter)
-{
- return __BT_UPCAST_CONST(bt_component_filter, self_comp_filter);
-}
-
-extern bt_self_component_port_output *
-bt_self_component_filter_borrow_output_port_by_name(
- bt_self_component_filter *self_component,
- const char *name);
-
-extern bt_self_component_port_output *
-bt_self_component_filter_borrow_output_port_by_index(
- bt_self_component_filter *self_component,
- uint64_t index);
-
-extern bt_self_component_status
-bt_self_component_filter_add_output_port(
- bt_self_component_filter *self_component,
- const char *name, void *data,
- bt_self_component_port_output **self_component_port);
-
-extern bt_self_component_port_input *
-bt_self_component_filter_borrow_input_port_by_name(
- bt_self_component_filter *self_component,
- const char *name);
-
-extern bt_self_component_port_input *
-bt_self_component_filter_borrow_input_port_by_index(
- bt_self_component_filter *self_component,
- uint64_t index);
-
-extern bt_self_component_status
-bt_self_component_filter_add_input_port(
- bt_self_component_filter *self_component,
- const char *name, void *data,
- bt_self_component_port_input **self_component_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H */
+++ /dev/null
-#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 <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_message_iterator_status */
-#include <babeltrace/graph/message-iterator-const.h>
-
-/*
- * For bt_component, bt_message_iterator,
- * bt_self_component_port_input_message_iterator,
- * bt_self_component_port_input, bt_message_array_const, bt_bool,
- * __BT_UPCAST
- */
-#include <babeltrace/types.h>
-
-#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 __BT_UPCAST(bt_message_iterator, 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 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 bt_bool
-bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
- bt_self_component_port_input_message_iterator *iterator,
- int64_t ns_from_origin);
-
-extern bt_bool bt_self_component_port_input_message_iterator_can_seek_beginning(
- bt_self_component_port_input_message_iterator *iterator);
-
-extern bt_message_iterator_status
-bt_self_component_port_input_message_iterator_seek_ns_from_origin(
- bt_self_component_port_input_message_iterator *iterator,
- int64_t ns_from_origin);
-
-extern bt_message_iterator_status
-bt_self_component_port_input_message_iterator_seek_beginning(
- bt_self_component_port_input_message_iterator *iterator);
-
-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 */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_port_input, bt_self_component_port,
- * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_self_component_port *
-bt_self_component_port_input_as_self_component_port(
- bt_self_component_port_input *self_component_port)
-{
- return __BT_UPCAST(bt_self_component_port, self_component_port);
-}
-
-static inline
-const bt_port_input *bt_self_component_port_input_as_port_input(
- const bt_self_component_port_input *self_component_port)
-{
- return __BT_UPCAST_CONST(bt_port_input, self_component_port);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_port_output, bt_self_component_port,
- * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_self_component_port *
-bt_self_component_port_output_as_self_component_port(
- bt_self_component_port_output *self_component_port)
-{
- return __BT_UPCAST(bt_self_component_port, self_component_port);
-}
-
-static inline
-const bt_port_output *bt_self_component_port_output_as_port_output(
- bt_self_component_port_output *self_component_port)
-{
- return __BT_UPCAST_CONST(bt_port_output, self_component_port);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_port, bt_self_component_port, bt_self_component,
- * bt_connection, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_self_component_port_status {
- BT_SELF_PORT_STATUS_OK = 0,
-} bt_self_component_port_status;
-
-static inline
-const bt_port *bt_self_component_port_as_port(
- bt_self_component_port *self_port)
-{
- return __BT_UPCAST_CONST(bt_port, self_port);
-}
-
-extern bt_self_component *bt_self_component_port_borrow_component(
- bt_self_component_port *self_port);
-
-extern void *bt_self_component_port_get_data(
- const bt_self_component_port *self_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/*
- * For bt_component_sink, bt_self_component, bt_self_component_sink,
- * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_self_component *bt_self_component_sink_as_self_component(
- bt_self_component_sink *self_comp_sink)
-{
- return __BT_UPCAST(bt_self_component, self_comp_sink);
-}
-
-static inline
-const bt_component_sink *
-bt_self_component_sink_as_component_sink(
- bt_self_component_sink *self_comp_sink)
-{
- return __BT_UPCAST_CONST(bt_component_sink, self_comp_sink);
-}
-
-extern bt_self_component_port_input *
-bt_self_component_sink_borrow_input_port_by_name(
- bt_self_component_sink *self_component,
- const char *name);
-
-extern bt_self_component_port_input *
-bt_self_component_sink_borrow_input_port_by_index(
- bt_self_component_sink *self_component, uint64_t index);
-
-extern bt_self_component_status
-bt_self_component_sink_add_input_port(
- bt_self_component_sink *self_component,
- const char *name, void *user_data,
- bt_self_component_port_input **self_component_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_self_component_status */
-#include <babeltrace/graph/self-component.h>
-
-/*
- * For bt_component_source, bt_self_component, bt_self_component_source,
- * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline
-bt_self_component *bt_self_component_source_as_self_component(
- bt_self_component_source *self_comp_source)
-{
- return __BT_UPCAST(bt_self_component, self_comp_source);
-}
-
-static inline
-const bt_component_source *
-bt_self_component_source_as_component_source(
- bt_self_component_source *self_comp_source)
-{
- return __BT_UPCAST_CONST(bt_component_source, self_comp_source);
-}
-
-extern bt_self_component_port_output *
-bt_self_component_source_borrow_output_port_by_name(
- bt_self_component_source *self_component,
- const char *name);
-
-extern bt_self_component_port_output *
-bt_self_component_source_borrow_output_port_by_index(
- bt_self_component_source *self_component,
- uint64_t index);
-
-extern bt_self_component_status
-bt_self_component_source_add_output_port(
- bt_self_component_source *self_component,
- const char *name, void *user_data,
- bt_self_component_port_output **self_component_port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_H
-#define BABELTRACE_GRAPH_SELF_COMPONENT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_component, bt_self_component, __BT_UPCAST */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_self_component_status {
- BT_SELF_COMPONENT_STATUS_OK = 0,
- BT_SELF_COMPONENT_STATUS_END = 1,
- BT_SELF_COMPONENT_STATUS_AGAIN = 11,
- BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
- BT_SELF_COMPONENT_STATUS_ERROR = -1,
- BT_SELF_COMPONENT_STATUS_NOMEM = -12,
-} bt_self_component_status;
-
-static inline
-const bt_component *bt_self_component_as_component(
- bt_self_component *self_component)
-{
- return __BT_UPCAST(bt_component, self_component);
-}
-
-extern void *bt_self_component_get_data(
- const bt_self_component *self_component);
-
-extern void bt_self_component_set_data(
- bt_self_component *self_component, void *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H
-#define BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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_ITERATOR_STATUS_* */
-#include <babeltrace/graph/message-iterator-const.h>
-
-/* For bt_self_component, bt_self_message_iterator, bt_self_port_output */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef 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,
-} bt_self_message_iterator_status;
-
-extern bt_self_component *
-bt_self_message_iterator_borrow_component(
- bt_self_message_iterator *message_iterator);
-
-extern bt_self_port_output *
-bt_self_message_iterator_borrow_port(
- bt_self_message_iterator *message_iterator);
-
-extern void bt_self_message_iterator_set_data(
- bt_self_message_iterator *message_iterator,
- void *user_data);
-
-extern void *bt_self_message_iterator_get_data(
- const bt_self_message_iterator *message_iterator);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H */
+++ /dev/null
-#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
-#define BABELTRACE_LIB_LOGGING_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <stdarg.h>
-
-#ifndef BT_LOG_TAG
-# error Please define a tag with BT_LOG_TAG before including this file.
-#endif
-
-#define BT_LOG_OUTPUT_LEVEL bt_lib_log_level
-
-#include <babeltrace/logging-internal.h>
-
-extern
-int bt_lib_log_level;
-
-#define BT_LIB_LOG(_lvl, _fmt, ...) \
- do { \
- if (BT_LOG_ON(_lvl)) { \
- bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, _lvl, _BT_LOG_TAG, \
- (_fmt), ##__VA_ARGS__); \
- } \
- } while (0)
-
-/*
- * The six macros below are logging statements which are specialized
- * for the Babeltrace library.
- *
- * `_fmt` is a typical printf()-style format string, with the following
- * limitations:
- *
- * * The `*` width specifier is not accepted.
- * * The `*` precision specifier is not accepted.
- * * The `j` and `t` length modifiers are not accepted.
- * * The `n` format specifier is not accepted.
- * * The format specifiers defined in <inttypes.h> are not accepted
- * except for `PRId64`, `PRIu64`, `PRIx64`, `PRIX64`, `PRIo64`, and
- * `PRIi64`.
- *
- * The Babeltrace extension conversion specifier is accepted. Its syntax
- * is either `%!u` to format a UUID (`bt_uuid` type) or:
- *
- * 1. Introductory `%!` sequence.
- *
- * 2. Optional: `[` followed by a custom prefix for the printed fields
- * of this specifier, followed by `]`. The standard form is to end
- * this prefix with `-` so that, for example, with the prefix
- * `prefix-`, the complete field name is `prefix-addr`.
- *
- * 3. Optional: `+` to print extended fields. This depends on the
- * provided format specifier.
- *
- * 4. Format specifier (see below).
- *
- * The available format specifiers are:
- *
- * `F`:
- * Trace IR field class. The parameter type is
- * `struct bt_field_class *`.
- *
- * `f`:
- * Trace IR field. The parameter type is `struct bt_field *`.
- *
- * `P`:
- * Field path. The parameter type is `struct bt_field_path *`.
- *
- * `E`:
- * Trace IR event class. The parameter type is
- * `struct bt_event_class *`.
- *
- * `e`:
- * Trace IR event. The parameter type is `struct bt_event *`.
- *
- * `S`:
- * Trace IR stream class. The parameter type is
- * `struct bt_stream_class *`.
- *
- * `s`:
- * Trace IR stream. The parameter type is `struct bt_stream *`.
- *
- * `a`:
- * Packet. The parameter type is `struct bt_packet *`.
- *
- * `T`:
- * Trace IR trace class. The parameter type is `struct bt_trace_class *`.
- *
- * `t`:
- * Trace IR trace. The parameter type is `struct bt_trace *`.
- *
- * `K`:
- * Clock class. The parameter type is `struct bt_clock_class *`.
- *
- * `k`:
- * Clock snapshot. The parameter type is `struct bt_clock_snapshot *`.
- *
- * `v`:
- * Value. The parameter type is `struct bt_value *`.
- *
- * `n`:
- * Message. The parameter type is `struct bt_message *`.
- *
- * `i`:
- * Message iterator. The parameter type is
- * `struct bt_message_iterator *`.
- *
- * `C`:
- * Component class. The parameter type is
- * `struct bt_component_class *`.
- *
- * `c`:
- * Component. The parameter type is `struct bt_component *`.
- *
- * `p`:
- * Port. The parameter type is `struct bt_port *`.
- *
- * `x`:
- * Connection. The parameter type is `struct bt_connection *`.
- *
- * `g`:
- * Graph. The parameter type is `struct bt_graph *`.
- *
- * `l`:
- * Plugin. The parameter type is `const struct bt_plugin *`.
- *
- * `o`:
- * Object pool. The parameter type is `struct bt_object_pool *`.
- *
- * `O`:
- * Object. The parameter type is `struct bt_object *`.
- *
- * Conversion specifier examples:
- *
- * %!f
- * %![my-event-]+e
- * %!t
- * %!+F
- *
- * The string `, ` is printed between individual fields, but not after
- * the last one. Therefore you must put this separator in the format
- * string between two conversion specifiers, e.g.:
- *
- * BT_LIB_LOGW("Message: count=%u, %!E, %!+K", count, event_class,
- * clock_class);
- *
- * Example with a custom prefix:
- *
- * BT_LIB_LOGI("Some message: %![ec-a-]e, %![ec-b-]+e", ec_a, ec_b);
- *
- * It is safe to pass NULL as any Babeltrace object parameter: the
- * macros only print its null address.
- */
-#define BT_LIB_LOGF(_fmt, ...) BT_LIB_LOG(BT_LOG_FATAL, _fmt, ##__VA_ARGS__)
-#define BT_LIB_LOGE(_fmt, ...) BT_LIB_LOG(BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
-#define BT_LIB_LOGW(_fmt, ...) BT_LIB_LOG(BT_LOG_WARN, _fmt, ##__VA_ARGS__)
-#define BT_LIB_LOGI(_fmt, ...) BT_LIB_LOG(BT_LOG_INFO, _fmt, ##__VA_ARGS__)
-#define BT_LIB_LOGD(_fmt, ...) BT_LIB_LOG(BT_LOG_DEBUG, _fmt, ##__VA_ARGS__)
-#define BT_LIB_LOGV(_fmt, ...) BT_LIB_LOG(BT_LOG_VERBOSE, _fmt, ##__VA_ARGS__)
-
-/*
- * Log statement, specialized for the Babeltrace library.
- *
- * Use one of the BT_LIB_LOGF*() macros above instead of calling this
- * function directly.
- */
-
-void bt_lib_log(const char *func, const char *file, unsigned line,
- int lvl, const char *tag, const char *fmt, ...);
-
-#endif /* BABELTRACE_LIB_LOGGING_INTERNAL_H */
+++ /dev/null
-/*
- * Copyright (C) 2002 Free Software Foundation, Inc.
- * This file is part of the GNU C Library.
- * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef _BT_LIST_H
-#define _BT_LIST_H 1
-
-/* The definitions of this file are adopted from those which can be
- found in the Linux kernel headers to enable people familiar with
- the latter find their way in these sources as well. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Basic type for the double-link list. */
-struct bt_list_head
-{
- struct bt_list_head *next;
- struct bt_list_head *prev;
-};
-
-
-/* Define a variable with the head and tail of the list. */
-#define BT_LIST_HEAD(name) \
- struct bt_list_head name = { &(name), &(name) }
-
-/* Initialize a new list head. */
-#define BT_INIT_LIST_HEAD(ptr) \
- (ptr)->next = (ptr)->prev = (ptr)
-
-#define BT_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
-
-/* Add new element at the head of the list. */
-static inline void
-bt_list_add (struct bt_list_head *newp, struct bt_list_head *head)
-{
- head->next->prev = newp;
- newp->next = head->next;
- newp->prev = head;
- head->next = newp;
-}
-
-
-/* Add new element at the tail of the list. */
-static inline void
-bt_list_add_tail (struct bt_list_head *newp, struct bt_list_head *head)
-{
- head->prev->next = newp;
- newp->next = head;
- newp->prev = head->prev;
- head->prev = newp;
-}
-
-
-/* Remove element from list. */
-static inline void
-__bt_list_del (struct bt_list_head *prev, struct bt_list_head *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-/* Remove element from list. */
-static inline void
-bt_list_del (struct bt_list_head *elem)
-{
- __bt_list_del (elem->prev, elem->next);
-}
-
-/* delete from list, add to another list as head */
-static inline void
-bt_list_move (struct bt_list_head *elem, struct bt_list_head *head)
-{
- __bt_list_del (elem->prev, elem->next);
- bt_list_add (elem, head);
-}
-
-/* replace an old entry.
- */
-static inline void
-bt_list_replace(struct bt_list_head *old, struct bt_list_head *_new)
-{
- _new->next = old->next;
- _new->prev = old->prev;
- _new->prev->next = _new;
- _new->next->prev = _new;
-}
-
-/* Join two lists. */
-static inline void
-bt_list_splice (struct bt_list_head *add, struct bt_list_head *head)
-{
- /* Do nothing if the list which gets added is empty. */
- if (add != add->next)
- {
- add->next->prev = head;
- add->prev->next = head->next;
- head->next->prev = add->prev;
- head->next = add->next;
- }
-}
-
-
-/* Get typed element from list at a given position. */
-#define bt_list_entry(ptr, type, member) \
- ((type *) ((char *) (ptr) - (uintptr_t) (&((type *) 0)->member)))
-
-
-
-/* Iterate forward over the elements of the list. */
-#define bt_list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
-
-
-/* Iterate forward over the elements of the list. */
-#define bt_list_for_each_prev(pos, head) \
- for (pos = (head)->prev; pos != (head); pos = pos->prev)
-
-
-/* Iterate backwards over the elements list. The list elements can be
- removed from the list while doing this. */
-#define bt_list_for_each_prev_safe(pos, p, head) \
- for (pos = (head)->prev, p = pos->prev; \
- pos != (head); \
- pos = p, p = pos->prev)
-
-#define bt_list_for_each_entry(pos, head, member) \
- for (pos = bt_list_entry((head)->next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = bt_list_entry(pos->member.next, typeof(*pos), member))
-
-#define bt_list_for_each_entry_reverse(pos, head, member) \
- for (pos = bt_list_entry((head)->prev, typeof(*pos), member); \
- &pos->member != (head); \
- pos = bt_list_entry(pos->member.prev, typeof(*pos), member))
-
-#define bt_list_for_each_entry_safe(pos, p, head, member) \
- for (pos = bt_list_entry((head)->next, typeof(*pos), member), \
- p = bt_list_entry(pos->member.next,typeof(*pos), member); \
- &pos->member != (head); \
- pos = p, p = bt_list_entry(pos->member.next, typeof(*pos), member))
-
-static inline int bt_list_empty(struct bt_list_head *head)
-{
- return head == head->next;
-}
-
-static inline void bt_list_replace_init(struct bt_list_head *old,
- struct bt_list_head *_new)
-{
- struct bt_list_head *head = old->next;
- bt_list_del(old);
- bt_list_add_tail(_new, head);
- BT_INIT_LIST_HEAD(old);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _BT_LIST_H */
+++ /dev/null
-/*
- * This is zf_log.h, modified with Babeltrace prefixes.
- * See <https://github.com/wonder-mice/zf_log/>.
- * See logging/LICENSE in the Babeltrace source tree.
- */
-
-#pragma once
-
-#ifndef BABELTRACE_LOGGING_INTERNAL_H
-#define BABELTRACE_LOGGING_INTERNAL_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <babeltrace/logging.h>
-#include <babeltrace/babeltrace-internal.h>
-
-/* To detect incompatible changes you can define BT_LOG_VERSION_REQUIRED to be
- * the current value of BT_LOG_VERSION before including this file (or via
- * compiler command line):
- *
- * #define BT_LOG_VERSION_REQUIRED 4
- * #include <babeltrace/logging-internal.h>
- *
- * Compilation will fail when included file has different version.
- */
-#define BT_LOG_VERSION 4
-#if defined(BT_LOG_VERSION_REQUIRED)
- #if BT_LOG_VERSION_REQUIRED != BT_LOG_VERSION
- #error different bt_log version required
- #endif
-#endif
-
-/* Log level guideline:
- * - BT_LOG_FATAL - happened something impossible and absolutely unexpected.
- * Process can't continue and must be terminated.
- * Example: division by zero, unexpected modifications from other thread.
- * - BT_LOG_ERROR - happened something possible, but highly unexpected. The
- * process is able to recover and continue execution.
- * Example: out of memory (could also be FATAL if not handled properly).
- * - BT_LOG_WARN - happened something that *usually* should not happen and
- * significantly changes application behavior for some period of time.
- * Example: configuration file not found, auth error.
- * - BT_LOG_INFO - happened significant life cycle event or major state
- * transition.
- * Example: app started, user logged in.
- * - BT_LOG_DEBUG - minimal set of events that could help to reconstruct the
- * execution path. Usually disabled in release builds.
- * - BT_LOG_VERBOSE - all other events. Usually disabled in release builds.
- *
- * *Ideally*, log file of debugged, well tested, production ready application
- * should be empty or very small. Choosing a right log level is as important as
- * providing short and self descriptive log message.
- */
-#define BT_LOG_VERBOSE BT_LOGGING_LEVEL_VERBOSE
-#define BT_LOG_DEBUG BT_LOGGING_LEVEL_DEBUG
-#define BT_LOG_INFO BT_LOGGING_LEVEL_INFO
-#define BT_LOG_WARN BT_LOGGING_LEVEL_WARN
-#define BT_LOG_ERROR BT_LOGGING_LEVEL_ERROR
-#define BT_LOG_FATAL BT_LOGGING_LEVEL_FATAL
-#define BT_LOG_NONE BT_LOGGING_LEVEL_NONE
-
-/* "Current" log level is a compile time check and has no runtime overhead. Log
- * level that is below current log level it said to be "disabled". Otherwise,
- * it's "enabled". Log messages that are disabled has no runtime overhead - they
- * are converted to no-op by preprocessor and then eliminated by compiler.
- * Current log level is configured per compilation module (.c/.cpp/.m file) by
- * defining BT_LOG_DEF_LEVEL or BT_LOG_LEVEL. BT_LOG_LEVEL has higer priority
- * and when defined overrides value provided by BT_LOG_DEF_LEVEL.
- *
- * Common practice is to define default current log level with BT_LOG_DEF_LEVEL
- * in build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
- * project or target:
- *
- * CC_ARGS := -DBT_LOG_DEF_LEVEL=BT_LOG_INFO
- *
- * And when necessary to override it with BT_LOG_LEVEL in .c/.cpp/.m files
- * before including bt_log.h:
- *
- * #define BT_LOG_LEVEL BT_LOG_VERBOSE
- * #include <babeltrace/logging-internal.h>
- *
- * If both BT_LOG_DEF_LEVEL and BT_LOG_LEVEL are undefined, then BT_LOG_INFO
- * will be used for release builds (NDEBUG is defined) and BT_LOG_DEBUG
- * otherwise (NDEBUG is not defined).
- */
-#if defined(BT_LOG_LEVEL)
- #define _BT_LOG_LEVEL BT_LOG_LEVEL
-#elif defined(BT_LOG_DEF_LEVEL)
- #define _BT_LOG_LEVEL BT_LOG_DEF_LEVEL
-#else
- #ifdef NDEBUG
- #define _BT_LOG_LEVEL BT_LOG_INFO
- #else
- #define _BT_LOG_LEVEL BT_LOG_DEBUG
- #endif
-#endif
-
-/* "Output" log level is a runtime check. When log level is below output log
- * level it said to be "turned off" (or just "off" for short). Otherwise it's
- * "turned on" (or just "on"). Log levels that were "disabled" (see
- * BT_LOG_LEVEL and BT_LOG_DEF_LEVEL) can't be "turned on", but "enabled" log
- * levels could be "turned off". Only messages with log level which is
- * "turned on" will reach output facility. All other messages will be ignored
- * (and their arguments will not be evaluated). Output log level is a global
- * property and configured per process using bt_log_set_output_level() function
- * which can be called at any time.
- *
- * Though in some cases it could be useful to configure output log level per
- * compilation module or per library. There are two ways to achieve that:
- * - Define BT_LOG_OUTPUT_LEVEL to expresion that evaluates to desired output
- * log level.
- * - Copy bt_log.h and bt_log.c files into your library and build it with
- * BT_LOG_LIBRARY_PREFIX defined to library specific prefix. See
- * BT_LOG_LIBRARY_PREFIX for more details.
- *
- * When defined, BT_LOG_OUTPUT_LEVEL must evaluate to integral value that
- * corresponds to desired output log level. Use it only when compilation module
- * is required to have output log level which is different from global output
- * log level set by bt_log_set_output_level() function. For other cases,
- * consider defining BT_LOG_LEVEL or using bt_log_set_output_level() function.
- *
- * Example:
- *
- * #define BT_LOG_OUTPUT_LEVEL g_module_log_level
- * #include <babeltrace/logging-internal.h>
- * static int g_module_log_level = BT_LOG_INFO;
- * static void foo() {
- * BT_LOGI("Will check g_module_log_level for output log level");
- * }
- * void debug_log(bool on) {
- * g_module_log_level = on? BT_LOG_DEBUG: BT_LOG_INFO;
- * }
- *
- * Note on performance. This expression will be evaluated each time message is
- * logged (except when message log level is "disabled" - see BT_LOG_LEVEL for
- * details). Keep this expression as simple as possible, otherwise it will not
- * only add runtime overhead, but also will increase size of call site (which
- * will result in larger executable). The prefered way is to use integer
- * variable (as in example above). If structure must be used, log_level field
- * must be the first field in this structure:
- *
- * #define BT_LOG_OUTPUT_LEVEL (g_config.log_level)
- * #include <babeltrace/logging-internal.h>
- * struct config {
- * int log_level;
- * unsigned other_field;
- * [...]
- * };
- * static config g_config = {BT_LOG_INFO, 0, ...};
- *
- * This allows compiler to generate more compact load instruction (no need to
- * specify offset since it's zero). Calling a function to get output log level
- * is generaly a bad idea, since it will increase call site size and runtime
- * overhead even further.
- */
-#if defined(BT_LOG_OUTPUT_LEVEL)
- #define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
-#else
- /*
- * We disallow this to make sure Babeltrace modules always
- * have their own local log level.
- */
- #error No log level symbol specified: please define BT_LOG_OUTPUT_LEVEL before including this header.
-#endif
-
-/* "Tag" is a compound string that could be associated with a log message. It
- * consists of tag prefix and tag (both are optional).
- *
- * Tag prefix is a global property and configured per process using
- * bt_log_set_tag_prefix() function. Tag prefix identifies context in which
- * component or module is running (e.g. process name). For example, the same
- * library could be used in both client and server processes that work on the
- * same machine. Tag prefix could be used to easily distinguish between them.
- * For more details about tag prefix see bt_log_set_tag_prefix() function. Tag
- * prefix
- *
- * Tag identifies component or module. It is configured per compilation module
- * (.c/.cpp/.m file) by defining BT_LOG_TAG or BT_LOG_DEF_TAG. BT_LOG_TAG has
- * higer priority and when defined overrides value provided by BT_LOG_DEF_TAG.
- * When defined, value must evaluate to (const char *), so for strings double
- * quotes must be used.
- *
- * Default tag could be defined with BT_LOG_DEF_TAG in build script (e.g.
- * Makefile, CMakeLists.txt, gyp, etc.) for the entire project or target:
- *
- * CC_ARGS := -DBT_LOG_DEF_TAG=\"MISC\"
- *
- * And when necessary could be overriden with BT_LOG_TAG in .c/.cpp/.m files
- * before including bt_log.h:
- *
- * #define BT_LOG_TAG "MAIN"
- * #include <babeltrace/logging-internal.h>
- *
- * If both BT_LOG_DEF_TAG and BT_LOG_TAG are undefined no tag will be added to
- * the log message (tag prefix still could be added though).
- *
- * Output example:
- *
- * 04-29 22:43:20.244 40059 1299 I hello.MAIN Number of arguments: 1
- * | |
- * | +- tag (e.g. module)
- * +- tag prefix (e.g. process name)
- */
-#if defined(BT_LOG_TAG)
- #define _BT_LOG_TAG BT_LOG_TAG
-#elif defined(BT_LOG_DEF_TAG)
- #define _BT_LOG_TAG BT_LOG_DEF_TAG
-#else
- #define _BT_LOG_TAG 0
-#endif
-
-/* Source location is part of a log line that describes location (function or
- * method name, file name and line number, e.g. "runloop@main.cpp:68") of a
- * log statement that produced it.
- * Source location formats are:
- * - BT_LOG_SRCLOC_NONE - don't add source location to log line.
- * - BT_LOG_SRCLOC_SHORT - add source location in short form (file and line
- * number, e.g. "@main.cpp:68").
- * - BT_LOG_SRCLOC_LONG - add source location in long form (function or method
- * name, file and line number, e.g. "runloop@main.cpp:68").
- */
-#define BT_LOG_SRCLOC_NONE 0
-#define BT_LOG_SRCLOC_SHORT 1
-#define BT_LOG_SRCLOC_LONG 2
-
-/* Source location format is configured per compilation module (.c/.cpp/.m
- * file) by defining BT_LOG_DEF_SRCLOC or BT_LOG_SRCLOC. BT_LOG_SRCLOC has
- * higer priority and when defined overrides value provided by
- * BT_LOG_DEF_SRCLOC.
- *
- * Common practice is to define default format with BT_LOG_DEF_SRCLOC in
- * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
- * project or target:
- *
- * CC_ARGS := -DBT_LOG_DEF_SRCLOC=BT_LOG_SRCLOC_LONG
- *
- * And when necessary to override it with BT_LOG_SRCLOC in .c/.cpp/.m files
- * before including bt_log.h:
- *
- * #define BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE
- * #include <babeltrace/logging-internal.h>
- *
- * If both BT_LOG_DEF_SRCLOC and BT_LOG_SRCLOC are undefined, then
- * BT_LOG_SRCLOC_NONE will be used for release builds (NDEBUG is defined) and
- * BT_LOG_SRCLOC_LONG otherwise (NDEBUG is not defined).
- */
-#if defined(BT_LOG_SRCLOC)
- #define _BT_LOG_SRCLOC BT_LOG_SRCLOC
-#elif defined(BT_LOG_DEF_SRCLOC)
- #define _BT_LOG_SRCLOC BT_LOG_DEF_SRCLOC
-#else
- #ifdef NDEBUG
- #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE
- #else
- #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_LONG
- #endif
-#endif
-#if BT_LOG_SRCLOC_LONG == _BT_LOG_SRCLOC
- #define _BT_LOG_SRCLOC_FUNCTION _BT_LOG_FUNCTION
-#else
- #define _BT_LOG_SRCLOC_FUNCTION 0
-#endif
-
-/* Censoring provides conditional logging of secret information, also known as
- * Personally Identifiable Information (PII) or Sensitive Personal Information
- * (SPI). Censoring can be either enabled (BT_LOG_CENSORED) or disabled
- * (BT_LOG_UNCENSORED). When censoring is enabled, log statements marked as
- * "secrets" will be ignored and will have zero overhead (arguments also will
- * not be evaluated).
- */
-#define BT_LOG_CENSORED 1
-#define BT_LOG_UNCENSORED 0
-
-/* Censoring is configured per compilation module (.c/.cpp/.m file) by defining
- * BT_LOG_DEF_CENSORING or BT_LOG_CENSORING. BT_LOG_CENSORING has higer priority
- * and when defined overrides value provided by BT_LOG_DEF_CENSORING.
- *
- * Common practice is to define default censoring with BT_LOG_DEF_CENSORING in
- * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
- * project or target:
- *
- * CC_ARGS := -DBT_LOG_DEF_CENSORING=BT_LOG_CENSORED
- *
- * And when necessary to override it with BT_LOG_CENSORING in .c/.cpp/.m files
- * before including bt_log.h (consider doing it only for debug purposes and be
- * very careful not to push such temporary changes to source control):
- *
- * #define BT_LOG_CENSORING BT_LOG_UNCENSORED
- * #include <babeltrace/logging-internal.h>
- *
- * If both BT_LOG_DEF_CENSORING and BT_LOG_CENSORING are undefined, then
- * BT_LOG_CENSORED will be used for release builds (NDEBUG is defined) and
- * BT_LOG_UNCENSORED otherwise (NDEBUG is not defined).
- */
-#if defined(BT_LOG_CENSORING)
- #define _BT_LOG_CENSORING BT_LOG_CENSORING
-#elif defined(BT_LOG_DEF_CENSORING)
- #define _BT_LOG_CENSORING BT_LOG_DEF_CENSORING
-#else
- #ifdef NDEBUG
- #define _BT_LOG_CENSORING BT_LOG_CENSORED
- #else
- #define _BT_LOG_CENSORING BT_LOG_UNCENSORED
- #endif
-#endif
-
-/* Check censoring at compile time. Evaluates to true when censoring is disabled
- * (i.e. when secrets will be logged). For example:
- *
- * #if BT_LOG_SECRETS
- * char ssn[16];
- * getSocialSecurityNumber(ssn);
- * BT_LOGI("Customer ssn: %s", ssn);
- * #endif
- *
- * See BT_LOG_SECRET() macro for a more convenient way of guarding single log
- * statement.
- */
-#define BT_LOG_SECRETS (BT_LOG_UNCENSORED == _BT_LOG_CENSORING)
-
-/* Static (compile-time) initialization support allows to configure logging
- * before entering main() function. This mostly useful in C++ where functions
- * and methods could be called during initialization of global objects. Those
- * functions and methods could record log messages too and for that reason
- * static initialization of logging configuration is customizable.
- *
- * Macros below allow to specify values to use for initial configuration:
- * - BT_LOG_EXTERN_TAG_PREFIX - tag prefix (default: none)
- * - BT_LOG_EXTERN_GLOBAL_FORMAT - global format options (default: see
- * BT_LOG_MEM_WIDTH in bt_log.c)
- * - BT_LOG_EXTERN_GLOBAL_OUTPUT - global output facility (default: stderr or
- * platform specific, see BT_LOG_USE_XXX macros in bt_log.c)
- * - BT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL - global output log level (default: 0 -
- * all levals are "turned on")
- *
- * For example, in log_config.c:
- *
- * #include <babeltrace/logging-internal.h>
- * BT_LOG_DEFINE_TAG_PREFIX = "MyApp";
- * BT_LOG_DEFINE_GLOBAL_FORMAT = {CUSTOM_MEM_WIDTH};
- * BT_LOG_DEFINE_GLOBAL_OUTPUT = {BT_LOG_PUT_STD, custom_output_callback, 0};
- * BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = BT_LOG_INFO;
- *
- * However, to use any of those macros bt_log library must be compiled with
- * following macros defined:
- * - to use BT_LOG_DEFINE_TAG_PREFIX define BT_LOG_EXTERN_TAG_PREFIX
- * - to use BT_LOG_DEFINE_GLOBAL_FORMAT define BT_LOG_EXTERN_GLOBAL_FORMAT
- * - to use BT_LOG_DEFINE_GLOBAL_OUTPUT define BT_LOG_EXTERN_GLOBAL_OUTPUT
- * - to use BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL define
- * BT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL
- *
- * When bt_log library compiled with one of BT_LOG_EXTERN_XXX macros defined,
- * corresponding BT_LOG_DEFINE_XXX macro MUST be used exactly once somewhere.
- * Otherwise build will fail with link error (undefined symbol).
- */
-#define BT_LOG_DEFINE_TAG_PREFIX BT_HIDDEN const char *_bt_log_tag_prefix
-#define BT_LOG_DEFINE_GLOBAL_FORMAT BT_HIDDEN bt_log_format _bt_log_global_format
-#define BT_LOG_DEFINE_GLOBAL_OUTPUT BT_HIDDEN bt_log_output _bt_log_global_output
-#define BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL BT_HIDDEN int _bt_log_global_output_lvl
-
-/* Pointer to global format options. Direct modification is not allowed. Use
- * bt_log_set_mem_width() instead. Could be used to initialize bt_log_spec
- * structure:
- *
- * const bt_log_output g_output = {BT_LOG_PUT_STD, output_callback, 0};
- * const bt_log_spec g_spec = {BT_LOG_GLOBAL_FORMAT, &g_output};
- * BT_LOGI_AUX(&g_spec, "Hello");
- */
-#define BT_LOG_GLOBAL_FORMAT ((const bt_log_format *)&_bt_log_global_format)
-
-/* Pointer to global output variable. Direct modification is not allowed. Use
- * bt_log_set_output_v() or bt_log_set_output_p() instead. Could be used to
- * initialize bt_log_spec structure:
- *
- * const bt_log_format g_format = {40};
- * const bt_log_spec g_spec = {g_format, BT_LOG_GLOBAL_OUTPUT};
- * BT_LOGI_AUX(&g_spec, "Hello");
- */
-#define BT_LOG_GLOBAL_OUTPUT ((const bt_log_output *)&_bt_log_global_output)
-
-/* When defined, all library symbols produced by linker will be prefixed with
- * provided value. That allows to use bt_log library privately in another
- * libraries without exposing bt_log symbols in their original form (to avoid
- * possible conflicts with other libraries / components that also could use
- * bt_log for logging). Value must be without quotes, for example:
- *
- * CC_ARGS := -DBT_LOG_LIBRARY_PREFIX=my_lib_
- *
- * Note, that in this mode BT_LOG_LIBRARY_PREFIX must be defined when building
- * bt_log library AND it also must be defined to the same value when building
- * a library that uses it. For example, consider fictional KittyHttp library
- * that wants to use bt_log for logging. First approach that could be taken is
- * to add bt_log.h and bt_log.c to the KittyHttp's source code tree directly.
- * In that case it will be enough just to define BT_LOG_LIBRARY_PREFIX in
- * KittyHttp's build script:
- *
- * // KittyHttp/CMakeLists.txt
- * target_compile_definitions(KittyHttp PRIVATE
- * "BT_LOG_LIBRARY_PREFIX=KittyHttp_")
- *
- * If KittyHttp doesn't want to include bt_log source code in its source tree
- * and wants to build bt_log as a separate library than bt_log library must be
- * built with BT_LOG_LIBRARY_PREFIX defined to KittyHttp_ AND KittyHttp library
- * itself also needs to define BT_LOG_LIBRARY_PREFIX to KittyHttp_. It can do
- * so either in its build script, as in example above, or by providing a
- * wrapper header that KittyHttp library will need to use instead of bt_log.h:
- *
- * // KittyHttpLogging.h
- * #define BT_LOG_LIBRARY_PREFIX KittyHttp_
- * #include <babeltrace/logging-internal.h>
- *
- * Regardless of the method chosen, the end result is that bt_log symbols will
- * be prefixed with "KittyHttp_", so if a user of KittyHttp (say DogeBrowser)
- * also uses bt_log for logging, they will not interferer with each other. Both
- * will have their own log level, output facility, format options etc.
- */
-#ifdef BT_LOG_LIBRARY_PREFIX
- #define _BT_LOG_DECOR__(prefix, name) prefix ## name
- #define _BT_LOG_DECOR_(prefix, name) _BT_LOG_DECOR__(prefix, name)
- #define _BT_LOG_DECOR(name) _BT_LOG_DECOR_(BT_LOG_LIBRARY_PREFIX, name)
-
- #define bt_log_set_tag_prefix _BT_LOG_DECOR(bt_log_set_tag_prefix)
- #define bt_log_set_mem_width _BT_LOG_DECOR(bt_log_set_mem_width)
- #define bt_log_set_output_level _BT_LOG_DECOR(bt_log_set_output_level)
- #define bt_log_set_output_v _BT_LOG_DECOR(bt_log_set_output_v)
- #define bt_log_set_output_p _BT_LOG_DECOR(bt_log_set_output_p)
- #define bt_log_out_stderr_callback _BT_LOG_DECOR(bt_log_out_stderr_callback)
- #define _bt_log_tag_prefix _BT_LOG_DECOR(_bt_log_tag_prefix)
- #define _bt_log_global_format _BT_LOG_DECOR(_bt_log_global_format)
- #define _bt_log_global_output _BT_LOG_DECOR(_bt_log_global_output)
- #define _bt_log_global_output_lvl _BT_LOG_DECOR(_bt_log_global_output_lvl)
- #define _bt_log_write_d _BT_LOG_DECOR(_bt_log_write_d)
- #define _bt_log_write_aux_d _BT_LOG_DECOR(_bt_log_write_aux_d)
- #define _bt_log_write _BT_LOG_DECOR(_bt_log_write)
- #define _bt_log_write_aux _BT_LOG_DECOR(_bt_log_write_aux)
- #define _bt_log_write_mem_d _BT_LOG_DECOR(_bt_log_write_mem_d)
- #define _bt_log_write_mem_aux_d _BT_LOG_DECOR(_bt_log_write_mem_aux_d)
- #define _bt_log_write_mem _BT_LOG_DECOR(_bt_log_write_mem)
- #define _bt_log_write_mem_aux _BT_LOG_DECOR(_bt_log_write_mem_aux)
- #define _bt_log_stderr_spec _BT_LOG_DECOR(_bt_log_stderr_spec)
-#endif
-
-#if defined(__printflike)
- #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
- __printflike(str_index, first_to_check)
-#elif defined(__MINGW_PRINTF_FORMAT)
- #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
- __attribute__((format(__MINGW_PRINTF_FORMAT, str_index, first_to_check)))
-#elif defined(__GNUC__)
- #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
- __attribute__((format(__printf__, str_index, first_to_check)))
-#else
- #define _BT_LOG_PRINTFLIKE(str_index, first_to_check)
-#endif
-
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__)
- #define _BT_LOG_FUNCTION __FUNCTION__
-#else
- #define _BT_LOG_FUNCTION __func__
-#endif
-
-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
- #define _BT_LOG_INLINE __inline
- #define _BT_LOG_IF(cond) \
- __pragma(warning(push)) \
- __pragma(warning(disable:4127)) \
- if(cond) \
- __pragma(warning(pop))
- #define _BT_LOG_WHILE(cond) \
- __pragma(warning(push)) \
- __pragma(warning(disable:4127)) \
- while(cond) \
- __pragma(warning(pop))
-#else
- #define _BT_LOG_INLINE inline
- #define _BT_LOG_IF(cond) if(cond)
- #define _BT_LOG_WHILE(cond) while(cond)
-#endif
-#define _BT_LOG_NEVER _BT_LOG_IF(0)
-#define _BT_LOG_ONCE _BT_LOG_WHILE(0)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Set tag prefix. Prefix will be separated from the tag with dot ('.').
- * Use 0 or empty string to disable (default). Common use is to set it to
- * the process (or build target) name (e.g. to separate client and server
- * processes). Function will NOT copy provided prefix string, but will store the
- * pointer. Hence specified prefix string must remain valid. See
- * BT_LOG_DEFINE_TAG_PREFIX for a way to set it before entering main() function.
- * See BT_LOG_TAG for more information about tag and tag prefix.
- */
-void bt_log_set_tag_prefix(const char *const prefix);
-
-/* Set number of bytes per log line in memory (ASCII-HEX) output. Example:
- *
- * I hello.MAIN 4c6f72656d20697073756d20646f6c6f Lorem ipsum dolo
- * |<- w bytes ->| |<- w chars ->|
- *
- * See BT_LOGF_MEM and BT_LOGF_MEM_AUX for more details.
- */
-void bt_log_set_mem_width(const unsigned w);
-
-/* Set "output" log level. See BT_LOG_LEVEL and BT_LOG_OUTPUT_LEVEL for more
- * info about log levels.
- */
-void bt_log_set_output_level(const int lvl);
-
-/* Put mask is a set of flags that define what fields will be added to each
- * log message. Default value is BT_LOG_PUT_STD and other flags could be used to
- * alter its behavior. See bt_log_set_output_v() for more details.
- *
- * Note about BT_LOG_PUT_SRC: it will be added only in debug builds (NDEBUG is
- * not defined).
- */
-enum
-{
- BT_LOG_PUT_CTX = 1 << 0, /* context (time, pid, tid, log level) */
- BT_LOG_PUT_TAG = 1 << 1, /* tag (including tag prefix) */
- BT_LOG_PUT_SRC = 1 << 2, /* source location (file, line, function) */
- BT_LOG_PUT_MSG = 1 << 3, /* message text (formatted string) */
- BT_LOG_PUT_STD = 0xffff, /* everything (default) */
-};
-
-typedef struct bt_log_message
-{
- int lvl; /* Log level of the message */
- const char *tag; /* Associated tag (without tag prefix) */
- char *buf; /* Buffer start */
- char *e; /* Buffer end (last position where EOL with 0 could be written) */
- char *p; /* Buffer content end (append position) */
- char *tag_b; /* Prefixed tag start */
- char *tag_e; /* Prefixed tag end (if != tag_b, points to msg separator) */
- char *msg_b; /* Message start (expanded format string) */
-}
-bt_log_message;
-
-/* Type of output callback function. It will be called for each log line allowed
- * by both "current" and "output" log levels ("enabled" and "turned on").
- * Callback function is allowed to modify content of the buffers pointed by the
- * msg, but it's not allowed to modify any of msg fields. Buffer pointed by msg
- * is UTF-8 encoded (no BOM mark).
- */
-typedef void (*bt_log_output_cb)(const bt_log_message *msg, void *arg);
-
-/* Format options. For more details see bt_log_set_mem_width().
- */
-typedef struct bt_log_format
-{
- unsigned mem_width; /* Bytes per line in memory (ASCII-HEX) dump */
-}
-bt_log_format;
-
-/* Output facility.
- */
-typedef struct bt_log_output
-{
- unsigned mask; /* What to put into log line buffer (see BT_LOG_PUT_XXX) */
- void *arg; /* User provided output callback argument */
- bt_log_output_cb callback; /* Output callback function */
-}
-bt_log_output;
-
-/* Set output callback function.
- *
- * Mask allows to control what information will be added to the log line buffer
- * before callback function is invoked. Default mask value is BT_LOG_PUT_STD.
- */
-void bt_log_set_output_v(const unsigned mask, void *const arg,
- const bt_log_output_cb callback);
-static _BT_LOG_INLINE void bt_log_set_output_p(const bt_log_output *const output)
-{
- bt_log_set_output_v(output->mask, output->arg, output->callback);
-}
-
-/* Used with _AUX macros and allows to override global format and output
- * facility. Use BT_LOG_GLOBAL_FORMAT and BT_LOG_GLOBAL_OUTPUT for values from
- * global configuration. Example:
- *
- * static const bt_log_output module_output = {
- * BT_LOG_PUT_STD, 0, custom_output_callback
- * };
- * static const bt_log_spec module_spec = {
- * BT_LOG_GLOBAL_FORMAT, &module_output
- * };
- * BT_LOGI_AUX(&module_spec, "Position: %ix%i", x, y);
- *
- * See BT_LOGF_AUX and BT_LOGF_MEM_AUX for details.
- */
-typedef struct bt_log_spec
-{
- const bt_log_format *format;
- const bt_log_output *output;
-}
-bt_log_spec;
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Execute log statement if condition is true. Example:
- *
- * BT_LOG_IF(1 < 2, BT_LOGI("Log this"));
- * BT_LOG_IF(1 > 2, BT_LOGI("Don't log this"));
- *
- * Keep in mind though, that if condition can't be evaluated at compile time,
- * then it will be evaluated at run time. This will increase exectuable size
- * and can have noticeable performance overhead. Try to limit conditions to
- * expressions that can be evaluated at compile time.
- */
-#define BT_LOG_IF(cond, f) do { _BT_LOG_IF((cond)) { f; } } _BT_LOG_ONCE
-
-/* Mark log statement as "secret". Log statements that are marked as secrets
- * will NOT be executed when censoring is enabled (see BT_LOG_CENSORED).
- * Example:
- *
- * BT_LOG_SECRET(BT_LOGI("Credit card: %s", credit_card));
- * BT_LOG_SECRET(BT_LOGD_MEM(cipher, cipher_sz, "Cipher bytes:"));
- */
-#define BT_LOG_SECRET(f) BT_LOG_IF(BT_LOG_SECRETS, f)
-
-/* Check "current" log level at compile time (ignoring "output" log level).
- * Evaluates to true when specified log level is enabled. For example:
- *
- * #if BT_LOG_ENABLED_DEBUG
- * const char *const g_enum_strings[] = {
- * "enum_value_0", "enum_value_1", "enum_value_2"
- * };
- * #endif
- * // ...
- * #if BT_LOG_ENABLED_DEBUG
- * BT_LOGD("enum value: %s", g_enum_strings[v]);
- * #endif
- *
- * See BT_LOG_LEVEL for details.
- */
-#define BT_LOG_ENABLED(lvl) ((lvl) >= _BT_LOG_LEVEL)
-#define BT_LOG_ENABLED_VERBOSE BT_LOG_ENABLED(BT_LOG_VERBOSE)
-#define BT_LOG_ENABLED_DEBUG BT_LOG_ENABLED(BT_LOG_DEBUG)
-#define BT_LOG_ENABLED_INFO BT_LOG_ENABLED(BT_LOG_INFO)
-#define BT_LOG_ENABLED_WARN BT_LOG_ENABLED(BT_LOG_WARN)
-#define BT_LOG_ENABLED_ERROR BT_LOG_ENABLED(BT_LOG_ERROR)
-#define BT_LOG_ENABLED_FATAL BT_LOG_ENABLED(BT_LOG_FATAL)
-
-/* Check "output" log level at run time (taking into account "current" log
- * level as well). Evaluates to true when specified log level is turned on AND
- * enabled. For example:
- *
- * if (BT_LOG_ON_DEBUG)
- * {
- * char hash[65];
- * sha256(data_ptr, data_sz, hash);
- * BT_LOGD("data: len=%u, sha256=%s", data_sz, hash);
- * }
- *
- * See BT_LOG_OUTPUT_LEVEL for details.
- */
-#define BT_LOG_ON(lvl) \
- (BT_LOG_ENABLED((lvl)) && (lvl) >= _BT_LOG_OUTPUT_LEVEL)
-#define BT_LOG_ON_VERBOSE BT_LOG_ON(BT_LOG_VERBOSE)
-#define BT_LOG_ON_DEBUG BT_LOG_ON(BT_LOG_DEBUG)
-#define BT_LOG_ON_INFO BT_LOG_ON(BT_LOG_INFO)
-#define BT_LOG_ON_WARN BT_LOG_ON(BT_LOG_WARN)
-#define BT_LOG_ON_ERROR BT_LOG_ON(BT_LOG_ERROR)
-#define BT_LOG_ON_FATAL BT_LOG_ON(BT_LOG_FATAL)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const char *_bt_log_tag_prefix;
-extern bt_log_format _bt_log_global_format;
-extern bt_log_output _bt_log_global_output;
-extern int _bt_log_global_output_lvl;
-extern const bt_log_spec _bt_log_stderr_spec;
-
-BT_HIDDEN
-void _bt_log_write_d(
- const char *const func, const char *const file, const unsigned line,
- const int lvl, const char *const tag,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(6, 7);
-
-BT_HIDDEN
-void _bt_log_write_aux_d(
- const char *const func, const char *const file, const unsigned line,
- const bt_log_spec *const log, const int lvl, const char *const tag,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(7, 8);
-
-BT_HIDDEN
-void _bt_log_write(
- const int lvl, const char *const tag,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(3, 4);
-
-BT_HIDDEN
-void _bt_log_write_aux(
- const bt_log_spec *const log, const int lvl, const char *const tag,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(4, 5);
-
-BT_HIDDEN
-void _bt_log_write_mem_d(
- const char *const func, const char *const file, const unsigned line,
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(8, 9);
-
-BT_HIDDEN
-void _bt_log_write_mem_aux_d(
- const char *const func, const char *const file, const unsigned line,
- const bt_log_spec *const log, const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(9, 10);
-
-BT_HIDDEN
-void _bt_log_write_mem(
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(5, 6);
-
-BT_HIDDEN
-void _bt_log_write_mem_aux(
- const bt_log_spec *const log, const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _BT_LOG_PRINTFLIKE(6, 7);
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Message logging macros:
- * - BT_LOGV("format string", args, ...)
- * - BT_LOGD("format string", args, ...)
- * - BT_LOGI("format string", args, ...)
- * - BT_LOGW("format string", args, ...)
- * - BT_LOGE("format string", args, ...)
- * - BT_LOGF("format string", args, ...)
- *
- * Message and error string (errno) logging macros:
- * - BT_LOGV_ERRNO("initial message", "format string", args, ...)
- * - BT_LOGD_ERRNO("initial message", "format string", args, ...)
- * - BT_LOGI_ERRNO("initial message", "format string", args, ...)
- * - BT_LOGW_ERRNO("initial message", "format string", args, ...)
- * - BT_LOGE_ERRNO("initial message", "format string", args, ...)
- * - BT_LOGF_ERRNO("initial message", "format string", args, ...)
- *
- * Memory logging macros:
- * - BT_LOGV_MEM(data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGD_MEM(data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGI_MEM(data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGW_MEM(data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGE_MEM(data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGF_MEM(data_ptr, data_sz, "format string", args, ...)
- *
- * Auxiliary logging macros:
- * - BT_LOGV_AUX(&log_instance, "format string", args, ...)
- * - BT_LOGD_AUX(&log_instance, "format string", args, ...)
- * - BT_LOGI_AUX(&log_instance, "format string", args, ...)
- * - BT_LOGW_AUX(&log_instance, "format string", args, ...)
- * - BT_LOGE_AUX(&log_instance, "format string", args, ...)
- * - BT_LOGF_AUX(&log_instance, "format string", args, ...)
- *
- * Auxiliary memory logging macros:
- * - BT_LOGV_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGD_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGI_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGW_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGE_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOGF_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
- *
- * Preformatted string logging macros:
- * - BT_LOGV_STR("preformatted string");
- * - BT_LOGD_STR("preformatted string");
- * - BT_LOGI_STR("preformatted string");
- * - BT_LOGW_STR("preformatted string");
- * - BT_LOGE_STR("preformatted string");
- * - BT_LOGF_STR("preformatted string");
- *
- * Explicit log level and tag macros:
- * - BT_LOG_WRITE(level, tag, "format string", args, ...)
- * - BT_LOG_WRITE_MEM(level, tag, data_ptr, data_sz, "format string", args, ...)
- * - BT_LOG_WRITE_AUX(&log_instance, level, tag, "format string", args, ...)
- * - BT_LOG_WRITE_MEM_AUX(&log_instance, level, tag, data_ptr, data_sz,
- * "format string", args, ...)
- *
- * Format string follows printf() conventions. Both data_ptr and data_sz could
- * be 0. Tag can be 0 as well. Most compilers will verify that type of arguments
- * match format specifiers in format string.
- *
- * Library assuming UTF-8 encoding for all strings (char *), including format
- * string itself.
- */
-#if BT_LOG_SRCLOC_NONE == _BT_LOG_SRCLOC
- #define BT_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write(lvl, tag, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_mem(lvl, tag, d, d_sz, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_aux(log, lvl, tag, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_mem_aux(log, lvl, tag, d, d_sz, __VA_ARGS__); \
- } _BT_LOG_ONCE
-#else
- #define BT_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- lvl, tag, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_mem_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- lvl, tag, d, d_sz, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_aux_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- log, lvl, tag, __VA_ARGS__); \
- } _BT_LOG_ONCE
- #define BT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (BT_LOG_ON(lvl)) \
- _bt_log_write_mem_aux_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- log, lvl, tag, d, d_sz, __VA_ARGS__); \
- } _BT_LOG_ONCE
-#endif
-
-#define BT_LOG_WRITE_ERRNO(lvl, tag, _msg, _fmt, args...) \
- do { \
- const char *error_str; \
- error_str = g_strerror(errno); \
- BT_LOG_WRITE(lvl, tag, _msg ": %s" _fmt, error_str, ## args); \
- } _BT_LOG_ONCE
-
-static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;}
-
-#define _BT_LOG_UNUSED(...) \
- do { _BT_LOG_NEVER _bt_log_unused(0, __VA_ARGS__); } _BT_LOG_ONCE
-
-#if BT_LOG_ENABLED_VERBOSE
- #define BT_LOGV(...) \
- BT_LOG_WRITE(BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGV_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGV_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGV_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_VERBOSE, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGV_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM(log, BT_LOG_VERBOSE, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGV(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGV_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGV_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGV_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if BT_LOG_ENABLED_DEBUG
- #define BT_LOGD(...) \
- BT_LOG_WRITE(BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGD_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGD_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGD_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_DEBUG, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGD_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM_AUX(log, BT_LOG_DEBUG, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGD(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGD_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGD_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGD_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if BT_LOG_ENABLED_INFO
- #define BT_LOGI(...) \
- BT_LOG_WRITE(BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGI_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGI_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGI_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_INFO, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGI_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM_AUX(log, BT_LOG_INFO, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGI(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGI_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGI_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGI_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if BT_LOG_ENABLED_WARN
- #define BT_LOGW(...) \
- BT_LOG_WRITE(BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGW_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGW_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGW_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_WARN, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGW_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM_AUX(log, BT_LOG_WARN, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGW(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGW_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGW_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGW_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if BT_LOG_ENABLED_ERROR
- #define BT_LOGE(...) \
- BT_LOG_WRITE(BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGE_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGE_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGE_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_ERROR, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGE_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM_AUX(log, BT_LOG_ERROR, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGE(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGE_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGE_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGE_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if BT_LOG_ENABLED_FATAL
- #define BT_LOGF(...) \
- BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGF_ERRNO(...) \
- BT_LOG_WRITE_ERRNO(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGF_AUX(log, ...) \
- BT_LOG_WRITE_AUX(log, BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
- #define BT_LOGF_MEM(d, d_sz, ...) \
- BT_LOG_WRITE_MEM(BT_LOG_FATAL, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define BT_LOGF_MEM_AUX(log, d, d_sz, ...) \
- BT_LOG_WRITE_MEM_AUX(log, BT_LOG_FATAL, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
-#else
- #define BT_LOGF(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGF_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGF_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
- #define BT_LOGF_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#define BT_LOGV_STR(s) BT_LOGV("%s", (s))
-#define BT_LOGD_STR(s) BT_LOGD("%s", (s))
-#define BT_LOGI_STR(s) BT_LOGI("%s", (s))
-#define BT_LOGW_STR(s) BT_LOGW("%s", (s))
-#define BT_LOGE_STR(s) BT_LOGE("%s", (s))
-#define BT_LOGF_STR(s) BT_LOGF("%s", (s))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Output to standard error stream. Library uses it by default, though in few
- * cases it could be necessary to specify it explicitly. For example, when
- * bt_log library is compiled with BT_LOG_EXTERN_GLOBAL_OUTPUT, application must
- * define and initialize global output variable:
- *
- * BT_LOG_DEFINE_GLOBAL_OUTPUT = {BT_LOG_OUT_STDERR};
- *
- * Another example is when using custom output, stderr could be used as a
- * fallback when custom output facility failed to initialize:
- *
- * bt_log_set_output_v(BT_LOG_OUT_STDERR);
- */
-enum { BT_LOG_OUT_STDERR_MASK = BT_LOG_PUT_STD };
-
-BT_HIDDEN
-void bt_log_out_stderr_callback(const bt_log_message *const msg, void *arg);
-#define BT_LOG_OUT_STDERR BT_LOG_OUT_STDERR_MASK, 0, bt_log_out_stderr_callback
-
-/* Predefined spec for stderr. Uses global format options (BT_LOG_GLOBAL_FORMAT)
- * and BT_LOG_OUT_STDERR. Could be used to force output to stderr for a
- * particular message. Example:
- *
- * f = fopen("foo.log", "w");
- * if (!f)
- * BT_LOGE_AUX(BT_LOG_STDERR, "Failed to open log file");
- */
-#define BT_LOG_STDERR (&_bt_log_stderr_spec)
-
-static inline
-int bt_log_get_level_from_env(const char *var)
-{
- const char *varval = getenv(var);
- int level = BT_LOG_NONE;
-
- if (!varval) {
- goto end;
- }
-
- if (strcmp(varval, "VERBOSE") == 0 ||
- strcmp(varval, "V") == 0) {
- level = BT_LOG_VERBOSE;
- } else if (strcmp(varval, "DEBUG") == 0 ||
- strcmp(varval, "D") == 0) {
- level = BT_LOG_DEBUG;
- } else if (strcmp(varval, "INFO") == 0 ||
- strcmp(varval, "I") == 0) {
- level = BT_LOG_INFO;
- } else if (strcmp(varval, "WARN") == 0 ||
- strcmp(varval, "WARNING") == 0 ||
- strcmp(varval, "W") == 0) {
- level = BT_LOG_WARN;
- } else if (strcmp(varval, "ERROR") == 0 ||
- strcmp(varval, "E") == 0) {
- level = BT_LOG_ERROR;
- } else if (strcmp(varval, "FATAL") == 0 ||
- strcmp(varval, "F") == 0) {
- level = BT_LOG_FATAL;
- } else if (strcmp(varval, "NONE") == 0 ||
- strcmp(varval, "N") == 0) {
- level = BT_LOG_NONE;
- } else {
- /* Should we warn here? How? */
- }
-
-end:
- return level;
-}
-
-#define BT_LOG_LEVEL_EXTERN_SYMBOL(_level_sym) \
- extern int _level_sym
-
-#define BT_LOG_INIT_LOG_LEVEL(_level_sym, _env_var) \
- BT_HIDDEN int _level_sym = BT_LOG_NONE; \
- static \
- void __attribute__((constructor)) _bt_log_level_ctor(void) \
- { \
- _level_sym = bt_log_get_level_from_env(_env_var); \
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_LOGGING_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_LOGGING_H
-#define BABELTRACE_LOGGING_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-@defgroup logging Logging
-@ingroup apiref
-@brief Logging.
-
-@code
-#include <babeltrace/logging.h>
-@endcode
-
-The functions in this module control the Babeltrace library's logging
-behaviour.
-
-You can set the current global log level of the library with
-bt_logging_set_global_level(). Note that, if the level you set is below
-the minimal logging level (configured at build time, which you can get
-with bt_logging_get_minimal_level()), the logging statement between the
-current global log level and the minimal log level are not executed.
-
-@file
-@brief Logging functions.
-@sa logging
-
-@addtogroup logging
-@{
-*/
-
-/**
-@brief Log levels.
-*/
-typedef enum bt_logging_level {
- /// Additional, low-level debugging context information.
- BT_LOGGING_LEVEL_VERBOSE = 1,
-
- /**
- Debugging information, only useful when searching for the
- cause of a bug.
- */
- BT_LOGGING_LEVEL_DEBUG = 2,
-
- /**
- Non-debugging information and failure to load optional
- subsystems.
- */
- BT_LOGGING_LEVEL_INFO = 3,
-
- /**
- Errors caused by a bad usage of the library, that is, a
- non-observance of the documented function preconditions.
-
- The library's and object's states remain consistent when a
- warning is issued.
- */
- BT_LOGGING_LEVEL_WARN = 4,
-
- /**
- An important error from which the library cannot recover, but
- the executed stack of functions can still return cleanly.
- */
- BT_LOGGING_LEVEL_ERROR = 5,
-
- /**
- The library cannot continue to work in this condition: it must
- terminate immediately, without even returning to the user's
- execution.
- */
- BT_LOGGING_LEVEL_FATAL = 6,
-
- /// Logging is disabled.
- BT_LOGGING_LEVEL_NONE = 0xff,
-} bt_logging_level;
-
-/**
-@brief Returns the minimal log level of the Babeltrace library.
-
-The minimal log level is defined at the library's build time. Any
-logging statement with a level below the minimal log level is not
-compiled. This means that it is useless, although possible, to set the
-global log level with bt_logging_set_global_level() below this level.
-
-@returns Minimal, build time log level.
-
-@sa bt_logging_get_global_level(): Returns the current global log level.
-*/
-extern bt_logging_level bt_logging_get_minimal_level(void);
-
-/**
-@brief Returns the current global log level of the Babeltrace library.
-
-@returns Current global log level.
-
-@sa bt_logging_set_global_level(): Sets the current global log level.
-@sa bt_logging_get_minimal_level(): Returns the minimal log level.
-*/
-extern bt_logging_level bt_logging_get_global_level(void);
-
-/**
-@brief Sets the current global log level of the Babeltrace library
- to \p log_level.
-
-If \p log_level is below what bt_logging_get_minimal_level() returns,
-the logging statements with a level between \p log_level and the minimal
-log level cannot be executed.
-
-@param[in] log_level Library's new global log level.
-
-@sa bt_logging_get_global_level(): Returns the global log level.
-*/
-extern void bt_logging_set_global_level(bt_logging_level log_level);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_LOGGING_H */
+++ /dev/null
-#ifndef _BABELTRACE_MMAP_ALIGN_H
-#define _BABELTRACE_MMAP_ALIGN_H
-
-/*
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <babeltrace/align-internal.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <babeltrace/compat/mman-internal.h>
-#include <babeltrace/common-internal.h>
-
-/*
- * This header implements a wrapper over mmap (mmap_align) that memory
- * maps a file region that is not necessarily multiple of the page size.
- * It returns a structure (instead of a pointer) that contains the mmap
- * pointer (page-aligned) and a pointer to the offset requested within
- * that page. Note: in the current implementation, the "addr" parameter
- * cannot be forced, so we allocate at an address chosen by the OS.
- */
-
-struct mmap_align {
- void *page_aligned_addr; /* mmap address, aligned to floor */
- size_t page_aligned_length; /* mmap length, containing range */
-
- void *addr; /* virtual mmap address */
- size_t length; /* virtual mmap length */
-};
-
-#ifdef __WIN32__
-#include <windows.h>
-
-/*
- * On windows the memory mapping offset must be aligned to the memory
- * allocator allocation granularity and not the page size.
- */
-static inline
-off_t get_page_aligned_offset(off_t offset, size_t page_size)
-{
- SYSTEM_INFO sysinfo;
-
- GetNativeSystemInfo(&sysinfo);
-
- return ALIGN_FLOOR(offset, sysinfo.dwAllocationGranularity);
-}
-#else
-static inline
-off_t get_page_aligned_offset(off_t offset, size_t page_size)
-{
- return ALIGN_FLOOR(offset, page_size);
-}
-#endif
-
-static inline
-struct mmap_align *mmap_align(size_t length, int prot,
- int flags, int fd, off_t offset)
-{
- struct mmap_align *mma;
- off_t page_aligned_offset; /* mmap offset, aligned to floor */
- size_t page_size;
-
- page_size = bt_common_get_page_size();
-
- mma = malloc(sizeof(*mma));
- if (!mma)
- return MAP_FAILED;
- mma->length = length;
- page_aligned_offset = get_page_aligned_offset(offset, page_size);
- /*
- * Page aligned length needs to contain the requested range.
- * E.g., for a small range that fits within a single page, we might
- * require a 2 pages page_aligned_length if the range crosses a page
- * boundary.
- */
- mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
- mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length,
- prot, flags, fd, page_aligned_offset);
- if (mma->page_aligned_addr == MAP_FAILED) {
- free(mma);
- return MAP_FAILED;
- }
- mma->addr = ((uint8_t *) mma->page_aligned_addr) + (offset - page_aligned_offset);
- return mma;
-}
-
-static inline
-int munmap_align(struct mmap_align *mma)
-{
- void *page_aligned_addr;
- size_t page_aligned_length;
-
- page_aligned_addr = mma->page_aligned_addr;
- page_aligned_length = mma->page_aligned_length;
- free(mma);
- return bt_munmap(page_aligned_addr, page_aligned_length);
-}
-
-static inline
-void *mmap_align_addr(struct mmap_align *mma)
-{
- return mma->addr;
-}
-
-/*
- * Helper for special-cases, normally unused.
- */
-static inline
-void mmap_align_set_addr(struct mmap_align *mma, void *addr)
-{
- mma->addr = addr;
-}
-
-#endif /* _BABELTRACE_MMAP_ALIGN_H */
+++ /dev/null
-#ifndef BABELTRACE_OBJECT_INTERNAL_H
-#define BABELTRACE_OBJECT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <stdbool.h>
-
-struct bt_object;
-
-typedef void (*bt_object_release_func)(struct bt_object *);
-typedef void (*bt_object_parent_is_owner_listener_func)(
- struct bt_object *);
-
-static inline
-void bt_object_get_no_null_check(const void *obj);
-
-static inline
-void bt_object_put_no_null_check(const void *obj);
-
-/*
- * Babeltrace object base.
- *
- * All objects publicly exposed by Babeltrace APIs must contain this
- * object as their first member.
- */
-struct bt_object {
- /*
- * True if this object is shared, that is, it has a reference
- * count.
- */
- bool is_shared;
-
- /*
- * Current reference count.
- */
- unsigned long long ref_count;
-
- /*
- * Release function called when the object's reference count
- * falls to zero. For an object with a parent, this function is
- * bt_object_with_parent_release_func(), which calls
- * `spec_release_func` below if there's no current parent.
- */
- bt_object_release_func release_func;
-
- /*
- * Specific release function called by
- * bt_object_with_parent_release_func() or directly by a
- * parent object.
- */
- bt_object_release_func spec_release_func;
-
- /*
- * Optional callback for an object with a parent, called by
- * bt_object_with_parent_release_func() to indicate to the
- * object that its parent is its owner.
- */
- bt_object_parent_is_owner_listener_func
- parent_is_owner_listener_func;
-
- /*
- * Optional parent object.
- */
- struct bt_object *parent;
-};
-
-static inline
-unsigned long long bt_object_get_ref_count(const struct bt_object *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- return obj->ref_count;
-}
-
-static inline
-struct bt_object *bt_object_borrow_parent(const struct bt_object *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- return obj->parent;
-}
-
-static inline
-struct bt_object *bt_object_get_parent(const struct bt_object *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
- struct bt_object *parent = bt_object_borrow_parent(obj);
-
- if (parent) {
- bt_object_get_no_null_check(parent);
- }
-
- return parent;
-}
-
-static inline
-void bt_object_set_parent(struct bt_object *child, struct bt_object *parent)
-{
- BT_ASSERT(child);
- BT_ASSERT(child->is_shared);
-
-#ifdef BT_LOGV
- BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p",
- child, parent);
-#endif
-
- /*
- * It is assumed that a "child" having a parent is publicly
- * reachable. Therefore, a reference to its parent must be
- * taken. The reference to the parent will be released once the
- * object's reference count falls to zero.
- */
- if (parent) {
- BT_ASSERT(!child->parent);
- child->parent = parent;
- bt_object_get_no_null_check(parent);
- } else {
- if (child->parent) {
- bt_object_put_no_null_check(child->parent);
- }
-
- child->parent = NULL;
- }
-}
-
-static inline
-void bt_object_try_spec_release(struct bt_object *obj)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
-
- if (bt_object_get_ref_count(obj) == 0) {
- obj->spec_release_func(obj);
- }
-}
-
-static inline
-void bt_object_with_parent_release_func(struct bt_object *obj)
-{
- if (obj->parent) {
- /*
- * Keep our own copy of the parent address because `obj`
- * could be destroyed in
- * obj->parent_is_owner_listener_func().
- */
- struct bt_object *parent = obj->parent;
-
-#ifdef BT_LOGV
- BT_LOGV("Releasing parented object: addr=%p, ref-count=%llu, "
- "parent-addr=%p, parent-ref-count=%llu",
- obj, obj->ref_count,
- parent, parent->ref_count);
-#endif
-
- if (obj->parent_is_owner_listener_func) {
- /*
- * Object has a chance to destroy itself here
- * under certain conditions and notify its
- * parent. At this point the parent is
- * guaranteed to exist because it's not put yet.
- */
- obj->parent_is_owner_listener_func(obj);
- }
-
- /* The release function will be invoked by the parent. */
- bt_object_put_no_null_check(parent);
- } else {
- bt_object_try_spec_release(obj);
- }
-}
-
-static inline
-void bt_object_init(struct bt_object *obj, bool is_shared,
- bt_object_release_func release_func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(!is_shared || release_func);
- obj->is_shared = is_shared;
- obj->release_func = release_func;
- obj->parent_is_owner_listener_func = NULL;
- obj->spec_release_func = NULL;
- obj->parent = NULL;
- obj->ref_count = 1;
-}
-
-static inline
-void bt_object_init_shared(struct bt_object *obj,
- bt_object_release_func release_func)
-{
- bt_object_init(obj, true, release_func);
-}
-
-static inline
-void bt_object_init_unique(struct bt_object *obj)
-{
- bt_object_init(obj, false, NULL);
-}
-
-static inline
-void bt_object_init_shared_with_parent(struct bt_object *obj,
- bt_object_release_func spec_release_func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(spec_release_func);
- bt_object_init_shared(obj, bt_object_with_parent_release_func);
- obj->spec_release_func = spec_release_func;
-}
-
-static inline
-void bt_object_set_parent_is_owner_listener_func(struct bt_object *obj,
- bt_object_parent_is_owner_listener_func func)
-{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
- ((struct bt_object *) obj)->parent_is_owner_listener_func = func;
-}
-
-static inline
-void bt_object_inc_ref_count(const struct bt_object *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- obj->ref_count++;
- BT_ASSERT(obj->ref_count != 0);
-}
-
-static inline
-void bt_object_get_no_null_check_no_parent_check(const struct bt_object *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
-
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count + 1,
- obj, obj->ref_count, obj->ref_count + 1);
-#endif
-
- bt_object_inc_ref_count(obj);
-}
-
-static inline
-void bt_object_get_no_null_check(const void *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
-
- if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) {
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's parent's reference count: "
- "addr=%p, parent-addr=%p", obj, obj->parent);
-#endif
-
- bt_object_get_no_null_check(obj->parent);
- }
-
-#ifdef BT_LOGV
- BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count + 1,
- obj, obj->ref_count, obj->ref_count + 1);
-#endif
-
- bt_object_inc_ref_count(obj);
-}
-
-static inline
-void bt_object_put_no_null_check(const void *c_obj)
-{
- struct bt_object *obj = (void *) c_obj;
-
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->ref_count > 0);
-
-#ifdef BT_LOGV
- BT_LOGV("Decrementing object's reference count: %llu -> %llu: "
- "addr=%p, cur-count=%llu, new-count=%llu",
- obj->ref_count, obj->ref_count - 1,
- obj, obj->ref_count, obj->ref_count - 1);
-#endif
-
- obj->ref_count--;
-
- if (obj->ref_count == 0) {
- BT_ASSERT(obj->release_func);
- obj->release_func(obj);
- }
-}
-
-static inline
-void bt_object_get_ref(const void *ptr)
-{
- struct bt_object *obj = (void *) ptr;
-
- if (unlikely(!obj)) {
- return;
- }
-
-#ifdef BT_ASSERT_PRE
- BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj);
-#endif
-
- bt_object_get_no_null_check(obj);
-}
-
-static inline
-void bt_object_put_ref(const void *ptr)
-{
- struct bt_object *obj = (void *) ptr;
-
- if (unlikely(!obj)) {
- return;
- }
-
-#ifdef BT_ASSERT_PRE
- BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj);
- BT_ASSERT_PRE(bt_object_get_ref_count(obj) > 0,
- "Decrementing a reference count set to 0: %!+O", ptr);
-#endif
-
- bt_object_put_no_null_check(obj);
-}
-
-#define BT_OBJECT_PUT_REF_AND_RESET(_var) \
- do { \
- bt_object_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_OBJECT_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_object_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#endif /* BABELTRACE_OBJECT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_OBJECT_POOL_INTERNAL_H
-#define BABELTRACE_OBJECT_POOL_INTERNAL_H
-
-/*
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-/*
- * This is a generic object pool to avoid memory allocation/deallocation
- * for objects of which the lifespan is typically short, but which are
- * created a lot.
- *
- * The object pool, thanks to two user functions, knows how to allocate
- * a brand new object in memory when the pool is empty and how to
- * destroy an object when we destroy the pool.
- *
- * The object pool's user is responsible for:
- *
- * * Setting whatever references the object needs to keep and reset some
- * properties _after_ calling bt_object_pool_create_object(). This is
- * typically done in the bt_*_create() function which calls
- * bt_object_pool_create_object() (which could call the user-provided
- * allocation function if the pool is empty) and then sets the
- * appropriate properties on the possibly recycled object.
- *
- * * Releasing whatever references the object keeps _before_ calling
- * bt_object_pool_recycle_object(). This is typically done in a custom
- * bt_*_recycle() function which does the necessary before calling
- * bt_object_pool_recycle_object() with an object ready to be reused
- * at any time.
- */
-
-#include <glib.h>
-#include <babeltrace/object-internal.h>
-
-typedef void *(*bt_object_pool_new_object_func)(void *data);
-typedef void *(*bt_object_pool_destroy_object_func)(void *obj, void *data);
-
-struct bt_object_pool {
- /*
- * Container of recycled objects, owned by this. The array's size
- * is the pool's capacity.
- */
- GPtrArray *objects;
-
- /*
- * Pool's size, that is, number of elements in the array above,
- * starting at index 0, which exist as recycled objects.
- */
- size_t size;
-
- /* User functions */
- struct {
- /* Allocate a new object in memory */
- bt_object_pool_new_object_func new_object;
-
- /* Free direct and indirect memory occupied by object */
- bt_object_pool_destroy_object_func destroy_object;
- } funcs;
-
- /* User data passed to user functions */
- void *data;
-};
-
-/*
- * Initializes an object pool which is already allocated.
- */
-int bt_object_pool_initialize(struct bt_object_pool *pool,
- bt_object_pool_new_object_func new_object_func,
- bt_object_pool_destroy_object_func destroy_object_func,
- void *data);
-
-/*
- * Finalizes an object pool without deallocating it.
- */
-void bt_object_pool_finalize(struct bt_object_pool *pool);
-
-/*
- * Creates an object from an object pool. If the pool is empty, this
- * function calls the "new" user function to allocate a new object
- * before returning it. Otherwise this function returns a recycled
- * object, removing it from the pool.
- *
- * The returned object is owned by the caller.
- */
-static inline
-void *bt_object_pool_create_object(struct bt_object_pool *pool)
-{
- struct bt_object *obj;
-
- BT_ASSERT(pool);
-
-#ifdef BT_LOGV
- BT_LOGV("Creating object from pool: pool-addr=%p, pool-size=%zu, pool-cap=%u",
- pool, pool->size, pool->objects->len);
-#endif
-
- if (pool->size > 0) {
- /* Pick one from the pool */
- pool->size--;
- obj = pool->objects->pdata[pool->size];
- pool->objects->pdata[pool->size] = NULL;
- goto end;
- }
-
- /* Pool is empty: create a brand new object */
-#ifdef BT_LOGV
- BT_LOGV("Pool is empty: allocating new object: pool-addr=%p",
- pool);
-#endif
-
- obj = pool->funcs.new_object(pool->data);
-
-end:
-#ifdef BT_LOGV
- BT_LOGV("Created one object from pool: pool-addr=%p, obj-addr=%p",
- pool, obj);
-#endif
-
- return obj;
-}
-
-/*
- * Recycles an object, that is, puts it back into the pool.
- *
- * The pool becomes the sole owner of the object to recycle.
- */
-static inline
-void bt_object_pool_recycle_object(struct bt_object_pool *pool, void *obj)
-{
- struct bt_object *bt_obj = obj;
-
- BT_ASSERT(pool);
- BT_ASSERT(obj);
-
-#ifdef BT_LOGV
- BT_LOGV("Recycling object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
- pool, pool->size, pool->objects->len, obj);
-#endif
-
- if (pool->size == pool->objects->len) {
- /* Backing array is full: make place for recycled object */
-#ifdef BT_LOGV
- BT_LOGV("Object pool is full: increasing object pool capacity: "
- "pool-addr=%p, old-pool-cap=%u, new-pool-cap=%u",
- pool, pool->objects->len, pool->objects->len + 1);
-#endif
- g_ptr_array_set_size(pool->objects, pool->size + 1);
- }
-
- /* Reset reference count to 1 since it could be 0 now */
- bt_obj->ref_count = 1;
-
- /* Back to the pool */
- pool->objects->pdata[pool->size] = obj;
- pool->size++;
-
-#ifdef BT_LOGV
- BT_LOGV("Recycled object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
- pool, pool->size, pool->objects->len, obj);
-#endif
-}
-
-#endif /* BABELTRACE_OBJECT_POOL_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_CONST_H
-#define BABELTRACE_PLUGIN_PLUGIN_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-#include <stddef.h>
-
-/*
- * For bt_bool, bt_plugin, bt_plugin_set, bt_component_class,
- * bt_component_class_source, bt_component_class_filter,
- * bt_component_class_sink
- */
-#include <babeltrace/types.h>
-
-/* For bt_property_availability */
-#include <babeltrace/property.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const bt_plugin *bt_plugin_find(const char *plugin_name);
-
-extern const bt_plugin_set *bt_plugin_find_all_from_file(
- const char *path);
-
-extern const bt_plugin_set *bt_plugin_find_all_from_dir(
- const char *path, bt_bool recurse);
-
-extern const bt_plugin_set *bt_plugin_find_all_from_static(void);
-
-extern const char *bt_plugin_get_name(const bt_plugin *plugin);
-
-extern const char *bt_plugin_get_author(const bt_plugin *plugin);
-
-extern const char *bt_plugin_get_license(const bt_plugin *plugin);
-
-extern const char *bt_plugin_get_description(const bt_plugin *plugin);
-
-extern const char *bt_plugin_get_path(const bt_plugin *plugin);
-
-extern bt_property_availability bt_plugin_get_version(
- const bt_plugin *plugin, unsigned int *major,
- unsigned int *minor, unsigned int *patch, const char **extra);
-
-extern uint64_t bt_plugin_get_source_component_class_count(
- const bt_plugin *plugin);
-
-extern uint64_t bt_plugin_get_filter_component_class_count(
- const bt_plugin *plugin);
-
-extern uint64_t bt_plugin_get_sink_component_class_count(
- const bt_plugin *plugin);
-
-extern const bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_index_const(
- const bt_plugin *plugin, uint64_t index);
-
-extern const bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_index_const(
- const bt_plugin *plugin, uint64_t index);
-
-extern const bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_index_const(
- const bt_plugin *plugin, uint64_t index);
-
-extern const bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_name_const(
- const bt_plugin *plugin, const char *name);
-
-extern const bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_name_const(
- const bt_plugin *plugin, const char *name);
-
-extern const bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_name_const(
- const bt_plugin *plugin, const char *name);
-
-extern void bt_plugin_get_ref(const bt_plugin *plugin);
-
-extern void bt_plugin_put_ref(const bt_plugin *plugin);
-
-#define BT_PLUGIN_PUT_REF_AND_RESET(_var) \
- do { \
- bt_plugin_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PLUGIN_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_plugin_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_DEV_H
-#define BABELTRACE_PLUGIN_PLUGIN_DEV_H
-
-/*
- * This is the header that you need to include for the development of
- * a Babeltrace plug-in.
- *
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For enum bt_plugin_status */
-#include <babeltrace/plugin/plugin-const.h>
-
-/* For bt_component_class_type */
-#include <babeltrace/graph/component-class-const.h>
-
-/* For component class method type definitions */
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
-
-/*
- * _BT_HIDDEN: set the hidden attribute for internal functions
- * On Windows, symbols are local unless explicitly exported,
- * see https://gcc.gnu.org/wiki/Visibility
- */
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define _BT_HIDDEN
-#else
-#define _BT_HIDDEN __attribute__((visibility("hidden")))
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Plugin interface's version, not synced with Babeltrace's version
- * (internal use).
- */
-#define __BT_PLUGIN_VERSION_MAJOR 1
-#define __BT_PLUGIN_VERSION_MINOR 0
-
-/* Plugin initialization function type */
-typedef enum bt_self_plugin_status {
- BT_SELF_PLUGIN_STATUS_OK = 0,
- BT_SELF_PLUGIN_STATUS_NOMEM = -12,
- BT_SELF_PLUGIN_STATUS_ERROR = -1,
-} bt_self_plugin_status;
-
-typedef struct bt_self_plugin bt_self_plugin;
-
-typedef bt_self_plugin_status (*bt_plugin_init_func)(
- bt_self_plugin *plugin);
-
-/* Plugin exit function type */
-typedef void (*bt_plugin_exit_func)(void);
-
-/* Plugin descriptor: describes a single plugin (internal use) */
-struct __bt_plugin_descriptor {
- /* Plugin's interface major version number */
- uint32_t major;
-
- /* Plugin's interface minor version number */
- uint32_t minor;
-
- /* Plugin's name */
- const char *name;
-} __attribute__((packed));
-
-/* Type of a plugin attribute (internal use) */
-enum __bt_plugin_descriptor_attribute_type {
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT = 0,
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT = 1,
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR = 2,
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE = 3,
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 4,
- BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION = 5,
-};
-
-/* Plugin (user) version */
-struct __bt_plugin_descriptor_version {
- uint32_t major;
- uint32_t minor;
- uint32_t patch;
- const char *extra;
-};
-
-/* Plugin attribute (internal use) */
-struct __bt_plugin_descriptor_attribute {
- /* Plugin descriptor to which to associate this attribute */
- const struct __bt_plugin_descriptor *plugin_descriptor;
-
- /* Name of the attribute's type for debug purposes */
- const char *type_name;
-
- /* Attribute's type */
- enum __bt_plugin_descriptor_attribute_type type;
-
- /* Attribute's value (depends on attribute's type) */
- union {
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT */
- bt_plugin_init_func init;
-
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT */
- bt_plugin_exit_func exit;
-
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR */
- const char *author;
-
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE */
- const char *license;
-
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
- const char *description;
-
- /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION */
- struct __bt_plugin_descriptor_version version;
- } value;
-} __attribute__((packed));
-
-/* Component class descriptor (internal use) */
-struct __bt_plugin_component_class_descriptor {
- /*
- * Plugin descriptor to which to associate this component
- * class descriptor.
- */
- const struct __bt_plugin_descriptor *plugin_descriptor;
-
- /* Component class name */
- const char *name;
-
- /* Component class type */
- bt_component_class_type type;
-
- /* Mandatory methods (depends on component class type) */
- union {
- /* BT_COMPONENT_CLASS_TYPE_SOURCE */
- struct {
- bt_component_class_source_message_iterator_next_method msg_iter_next;
- } source;
-
- /* BT_COMPONENT_CLASS_TYPE_FILTER */
- struct {
- bt_component_class_filter_message_iterator_next_method msg_iter_next;
- } filter;
-
- /* BT_COMPONENT_CLASS_TYPE_SINK */
- struct {
- bt_component_class_sink_consume_method consume;
- } sink;
- } methods;
-} __attribute__((packed));
-
-/* Type of a component class attribute (internal use) */
-enum __bt_plugin_component_class_descriptor_attribute_type {
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP = 1,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 2,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD = 3,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD = 4,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD = 5,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD = 6,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD = 7,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD = 8,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD = 9,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD = 10,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD = 11,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD = 12,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD = 13,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD = 14,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD = 15,
-};
-
-/* Component class attribute (internal use) */
-struct __bt_plugin_component_class_descriptor_attribute {
- /*
- * Component class plugin attribute to which to associate this
- * component class attribute.
- */
- const struct __bt_plugin_component_class_descriptor *comp_class_descriptor;
-
- /* Name of the attribute's type for debug purposes */
- const char *type_name;
-
- /* Attribute's type */
- enum __bt_plugin_component_class_descriptor_attribute_type type;
-
- /* Attribute's value (depends on attribute's type) */
- union {
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
- const char *description;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP */
- const char *help;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD */
- bt_component_class_source_init_method source_init_method;
- bt_component_class_filter_init_method filter_init_method;
- bt_component_class_sink_init_method sink_init_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD */
- bt_component_class_source_finalize_method source_finalize_method;
- bt_component_class_filter_finalize_method filter_finalize_method;
- bt_component_class_sink_finalize_method sink_finalize_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD */
- bt_component_class_source_query_method source_query_method;
- bt_component_class_filter_query_method filter_query_method;
- bt_component_class_sink_query_method sink_query_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD */
- bt_component_class_filter_accept_input_port_connection_method filter_accept_input_port_connection_method;
- bt_component_class_sink_accept_input_port_connection_method sink_accept_input_port_connection_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD */
- bt_component_class_source_accept_output_port_connection_method source_accept_output_port_connection_method;
- bt_component_class_filter_accept_output_port_connection_method filter_accept_output_port_connection_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD */
- bt_component_class_filter_input_port_connected_method filter_input_port_connected_method;
- bt_component_class_sink_input_port_connected_method sink_input_port_connected_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD */
- bt_component_class_source_output_port_connected_method source_output_port_connected_method;
- bt_component_class_filter_output_port_connected_method filter_output_port_connected_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD */
- bt_component_class_sink_graph_is_configured_method sink_graph_is_configured_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_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;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD */
- bt_component_class_source_message_iterator_seek_ns_from_origin_method source_msg_iter_seek_ns_from_origin_method;
- bt_component_class_filter_message_iterator_seek_ns_from_origin_method filter_msg_iter_seek_ns_from_origin_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD */
- bt_component_class_source_message_iterator_seek_beginning_method source_msg_iter_seek_beginning_method;
- bt_component_class_filter_message_iterator_seek_beginning_method filter_msg_iter_seek_beginning_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD */
- bt_component_class_source_message_iterator_can_seek_ns_from_origin_method source_msg_iter_can_seek_ns_from_origin_method;
- bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method filter_msg_iter_can_seek_ns_from_origin_method;
-
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD */
- bt_component_class_source_message_iterator_can_seek_beginning_method source_msg_iter_can_seek_beginning_method;
- bt_component_class_filter_message_iterator_can_seek_beginning_method filter_msg_iter_can_seek_beginning_method;
- } value;
-} __attribute__((packed));
-
-struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void);
-struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void);
-struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void);
-struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void);
-struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void);
-struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void);
-struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void);
-struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void);
-
-/*
- * Variable attributes for a plugin descriptor pointer to be added to
- * the plugin descriptor section (internal use).
- */
-#ifdef __APPLE__
-#define __BT_PLUGIN_DESCRIPTOR_ATTRS \
- __attribute__((section("__DATA,btp_desc"), used))
-
-#define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
- __start___bt_plugin_descriptors
-
-#define __BT_PLUGIN_DESCRIPTOR_END_SYMBOL \
- __stop___bt_plugin_descriptors
-
-#define __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA \
- __asm("section$start$__DATA$btp_desc")
-
-#define __BT_PLUGIN_DESCRIPTOR_END_EXTRA \
- __asm("section$end$__DATA$btp_desc")
-
-#else
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRS \
- __attribute__((section("__bt_plugin_descriptors"), used))
-
-#define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
- __start___bt_plugin_descriptors
-
-#define __BT_PLUGIN_DESCRIPTOR_END_SYMBOL \
- __stop___bt_plugin_descriptors
-
-#define __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA
-
-#define __BT_PLUGIN_DESCRIPTOR_END_EXTRA
-#endif
-
-/*
- * Variable attributes for a plugin attribute pointer to be added to
- * the plugin attribute section (internal use).
- */
-#ifdef __APPLE__
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
- __attribute__((section("__DATA,btp_desc_att"), used))
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
- __start___bt_plugin_descriptor_attributes
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
- __stop___bt_plugin_descriptor_attributes
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA \
- __asm("section$start$__DATA$btp_desc_att")
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA \
- __asm("section$end$__DATA$btp_desc_att")
-
-#else
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
- __attribute__((section("__bt_plugin_descriptor_attributes"), used))
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
- __start___bt_plugin_descriptor_attributes
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
- __stop___bt_plugin_descriptor_attributes
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA
-
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA
-#endif
-
-/*
- * Variable attributes for a component class descriptor pointer to be
- * added to the component class descriptor section (internal use).
- */
-#ifdef __APPLE__
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
- __attribute__((section("__DATA,btp_cc_desc"), used))
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
- __start___bt_plugin_component_class_descriptors
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL \
- __stop___bt_plugin_component_class_descriptors
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA \
- __asm("section$start$__DATA$btp_cc_desc")
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA \
- __asm("section$end$__DATA$btp_cc_desc")
-
-#else
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
- __attribute__((section("__bt_plugin_component_class_descriptors"), used))
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
- __start___bt_plugin_component_class_descriptors
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL \
- __stop___bt_plugin_component_class_descriptors
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA
-#endif
-
-/*
- * Variable attributes for a component class descriptor attribute
- * pointer to be added to the component class descriptor attribute
- * section (internal use).
- */
-#ifdef __APPLE__
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
- __attribute__((section("__DATA,btp_cc_desc_att"), used))
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
- __start___bt_plugin_component_class_descriptor_attributes
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
- __stop___bt_plugin_component_class_descriptor_attributes
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA \
- __asm("section$start$__DATA$btp_cc_desc_att")
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA \
- __asm("section$end$__DATA$btp_cc_desc_att")
-
-#else
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
- __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used))
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
- __start___bt_plugin_component_class_descriptor_attributes
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
- __stop___bt_plugin_component_class_descriptor_attributes
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA
-
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA
-#endif
-
-/*
- * Declares a plugin descriptor pointer variable with a custom ID.
- *
- * _id: ID (any valid C identifier except `auto`).
- */
-#define BT_PLUGIN_DECLARE(_id) extern struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id
-
-/*
- * Defines a plugin descriptor with a custom ID.
- *
- * _id: ID (any valid C identifier except `auto`).
- * _name: Plugin's name (C string).
- */
-#define BT_PLUGIN_WITH_ID(_id, _name) \
- struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id = { \
- .major = __BT_PLUGIN_VERSION_MAJOR, \
- .minor = __BT_PLUGIN_VERSION_MINOR, \
- .name = _name, \
- }; \
- static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_##_id##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRS = &__bt_plugin_descriptor_##_id
-
-/*
- * Defines a plugin attribute (generic, internal use).
- *
- * _attr_name: Name of the attribute (C identifier).
- * _attr_type: Type of the attribute (enum __bt_plugin_descriptor_attribute_type).
- * _id: Plugin descriptor ID (C identifier).
- * _x: Value.
- */
-#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _x) \
- static struct __bt_plugin_descriptor_attribute __bt_plugin_descriptor_attribute_##_id##_##_attr_name = { \
- .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
- .type_name = #_attr_name, \
- .type = _attr_type, \
- .value._attr_name = _x, \
- }; \
- static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_##_id##_##_attr_name##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_descriptor_attribute_##_id##_##_attr_name
-
-/*
- * Defines a plugin initialization function attribute attached to a
- * specific plugin descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _x: Initialization function (bt_plugin_init_func).
- */
-#define BT_PLUGIN_INIT_WITH_ID(_id, _x) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(init, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT, _id, _x)
-
-/*
- * Defines a plugin exit function attribute attached to a specific
- * plugin descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _x: Exit function (bt_plugin_exit_func).
- */
-#define BT_PLUGIN_EXIT_WITH_ID(_id, _x) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(exit, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT, _id, _x)
-
-/*
- * Defines an author attribute attached to a specific plugin descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _x: Author (C string).
- */
-#define BT_PLUGIN_AUTHOR_WITH_ID(_id, _x) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(author, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR, _id, _x)
-
-/*
- * Defines a license attribute attached to a specific plugin descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _x: License (C string).
- */
-#define BT_PLUGIN_LICENSE_WITH_ID(_id, _x) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(license, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE, _id, _x)
-
-/*
- * Defines a description attribute attached to a specific plugin
- * descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_DESCRIPTION_WITH_ID(_id, _x) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _x)
-
-#define __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra) \
- {.major = _major, .minor = _minor, .patch = _patch, .extra = _extra,}
-
-/*
- * Defines a version attribute attached to a specific plugin descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _major: Plugin's major version (uint32_t).
- * _minor: Plugin's minor version (uint32_t).
- * _patch: Plugin's patch version (uint32_t).
- * _extra: Plugin's version extra information (C string).
- */
-#define BT_PLUGIN_VERSION_WITH_ID(_id, _major, _minor, _patch, _extra) \
- __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(version, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION, _id, __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra))
-
-/*
- * Defines a source component class descriptor with a custom ID.
- *
- * _id: ID (any valid C identifier except `auto`).
- * _comp_class_id: Component class ID (C identifier).
- * _name: Component class name (C string).
- * _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, _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 = { \
- .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
-
-/*
- * Defines a filter component class descriptor with a custom ID.
- *
- * _id: ID (any valid C identifier except `auto`).
- * _comp_class_id: Component class ID (C identifier).
- * _name: Component class name (C string).
- * _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, _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 = { \
- .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
-
-/*
- * Defines a sink component class descriptor with a custom ID.
- *
- * _id: ID (any valid C identifier except `auto`).
- * _comp_class_id: Component class ID (C identifier).
- * _name: Component class name (C string).
- * _consume_method: Component class's iterator consume method
- * (bt_component_class_sink_consume_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _consume_method) \
- static struct __bt_plugin_component_class_descriptor __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id = { \
- .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
- .name = _name, \
- .type = BT_COMPONENT_CLASS_TYPE_SINK, \
- .methods.sink = { \
- .consume = _consume_method, \
- }, \
- }; \
- static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id
-
-/*
- * Defines a component class descriptor attribute (generic, internal
- * use).
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class ID (C identifier).
- * _type: Component class type (`source`, `filter`, or `sink`).
- * _attr_name: Name of the attribute (C identifier).
- * _attr_type: Type of the attribute
- * (enum __bt_plugin_descriptor_attribute_type).
- * _x: Value.
- */
-#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _comp_class_id, _type, _x) \
- static struct __bt_plugin_component_class_descriptor_attribute __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name = { \
- .comp_class_descriptor = &__bt_plugin_##_type##_component_class_descriptor_##_id##_##_comp_class_id, \
- .type_name = #_attr_name, \
- .type = _attr_type, \
- .value._attr_name = _x, \
- }; \
- static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name
-
-/*
- * Defines a description attribute attached to a specific source
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, source, _x)
-
-/*
- * Defines a description attribute attached to a specific filter
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a description attribute attached to a specific sink
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines a help attribute attached to a specific source component
- * class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, source, _x)
-
-/*
- * Defines a help attribute attached to a specific filter component
- * class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a help attribute attached to a specific sink component class
- * descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an initialization method attribute attached to a specific
- * source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_source_init_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an initialization method attribute attached to a specific
- * filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_filter_init_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an initialization method attribute attached to a specific
- * sink component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Initialization method (bt_component_class_sink_init_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines a finalization method attribute attached to a specific source
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_source_finalize_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines a finalization method attribute attached to a specific filter
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_filter_finalize_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a finalization method attribute attached to a specific sink
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_sink_finalize_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines a query method attribute attached to a specific source
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_source_query_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines a query method attribute attached to a specific filter
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_filter_query_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a query method attribute attached to a specific sink
- * component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Finalize method (bt_component_class_sink_query_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a specific sink component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_sink_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_source_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an input port connected method attribute attached to a
- * specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Port connected method
- * (bt_component_class_filter_input_port_connected_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an input port connected method attribute attached to a
- * specific sink component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Port connected method
- * (bt_component_class_sink_input_port_connected_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an output port connected method attribute attached to a
- * specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Port connected method
- * (bt_component_class_source_output_port_connected_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an output port connected method attribute attached to a
- * specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Port connected method
- * (bt_component_class_filter_output_port_connected_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a "graph is configured" method attribute attached to a
- * specific sink component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: "Graph is configured" method
- * (bt_component_class_sink_graph_is_configured_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_graph_is_configured_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD, _id, _comp_class_id, sink, _x)
-
-/*
- * Defines an iterator initialization method attribute attached to a
- * specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator initialization method
- * (bt_component_class_source_message_iterator_init_method).
- */
-#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
- * source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator finalize method
- * (bt_component_class_source_message_iterator_finalize_method).
- */
-#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 "seek nanoseconds from origin" method attribute
- * attached to a specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "seek nanoseconds from origin" method
- * (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator "seek beginning" method attribute attached to a
- * specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "seek beginning" method
- * (bt_component_class_source_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "can seek nanoseconds from origin" method
- * (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator "can seek beginning" method attribute attached to a
- * specific source component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "can seek beginning" method
- * (bt_component_class_source_message_iterator_can_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
-
-/*
- * Defines an iterator initialization method attribute attached to a
- * specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator initialization method
- * (bt_component_class_filter_message_iterator_init_method).
- */
-#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
- * filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator finalize method
- * (bt_component_class_filter_message_iterator_finalize_method).
- */
-#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 an iterator "seek nanoseconds from origin" method attribute
- * attached to a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "seek nanoseconds from origin" method
- * (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an iterator "seek beginning" method attribute attached to a
- * specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "seek beginning" method
- * (bt_component_class_filter_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "can seek nanoseconds from origin" method
- * (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines an iterator "can seek beginning" method attribute attached to a
- * specific filter component class descriptor.
- *
- * _id: Plugin descriptor ID (C identifier).
- * _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Iterator "can seek beginning" method
- * (bt_component_class_filter_message_iterator_can_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
-
-/*
- * Defines a plugin descriptor with an automatic ID.
- *
- * _name: Plugin's name (C string).
- */
-#define BT_PLUGIN(_name) static BT_PLUGIN_WITH_ID(auto, #_name)
-
-/*
- * Defines a plugin initialization function attribute attached to the
- * automatic plugin descriptor.
- *
- * _x: Initialization function (bt_plugin_init_func).
- */
-#define BT_PLUGIN_INIT(_x) BT_PLUGIN_INIT_WITH_ID(auto, _x)
-
- /*
- * Defines a plugin exit function attribute attached to the automatic
- * plugin descriptor.
- *
- * _x: Exit function (bt_plugin_exit_func).
- */
-#define BT_PLUGIN_EXIT(_x) BT_PLUGIN_EXIT_WITH_ID(auto, _x)
-
-/*
- * Defines an author attribute attached to the automatic plugin
- * descriptor.
- *
- * _x: Author (C string).
- */
-#define BT_PLUGIN_AUTHOR(_x) BT_PLUGIN_AUTHOR_WITH_ID(auto, _x)
-
-/*
- * Defines a license attribute attached to the automatic plugin
- * descriptor.
- *
- * _x: License (C string).
- */
-#define BT_PLUGIN_LICENSE(_x) BT_PLUGIN_LICENSE_WITH_ID(auto, _x)
-
-/*
- * Defines a description attribute attached to the automatic plugin
- * descriptor.
- *
- * _x: Description (C string).
- */
-#define BT_PLUGIN_DESCRIPTION(_x) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _x)
-
-/*
- * Defines a version attribute attached to the automatic plugin
- * descriptor.
- *
- * _major: Plugin's major version (uint32_t).
- * _minor: Plugin's minor version (uint32_t).
- * _patch: Plugin's patch version (uint32_t).
- * _extra: Plugin's version extra information (C string).
- */
-#define BT_PLUGIN_VERSION(_major, _minor, _patch, _extra) BT_PLUGIN_VERSION_WITH_ID(auto, _major, _minor, _patch, _extra)
-
-/*
- * Defines a source component class attached to the automatic plugin
- * descriptor. Its ID is the same as its name, hence its name must be a
- * C identifier in this version.
- *
- * _name: Component class name (C identifier).
- * _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, _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
- * descriptor. Its ID is the same as its name, hence its name must be a
- * C identifier in this version.
- *
- * _name: Component class name (C identifier).
- * _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, _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
- * descriptor. Its ID is the same as its name, hence its name must be a
- * C identifier in this version.
- *
- * _name: Component class name (C identifier).
- * _consume_method: Component class's consume method
- * (bt_component_class_sink_consume_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS(_name, _consume_method) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _consume_method)
-
-/*
- * Defines a description attribute attached to a source component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a description attribute attached to a filter component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a description attribute attached to a sink component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Description (C string).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a help attribute attached to a source component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a help attribute attached to a filter component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a help attribute attached to a sink component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Help (C string).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an initialization method attribute attached to a source
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_source_init_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an initialization method attribute attached to a filter
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_filter_init_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an initialization method attribute attached to a sink
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_sink_init_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a finalization method attribute attached to a source component
- * class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_source_finalize_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a finalization method attribute attached to a filter component
- * class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_filter_finalize_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a finalization method attribute attached to a sink component class
- * descriptor which is attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_sink_finalize_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a query method attribute attached to a source component
- * class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_source_query_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a query method attribute attached to a filter component
- * class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_filter_query_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a query method attribute attached to a sink component
- * class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_sink_query_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a filter component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept input port connection method attribute attached to
- * a sink component class descriptor which is attached to the automatic
- * plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_sink_accept_input_port_connection_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a source component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_source_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an accept output port connection method attribute attached to
- * a filter component class descriptor which is attached to the
- * automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Accept port connection method
- * (bt_component_class_filter_accept_output_port_connection_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an input port connected method attribute attached to a filter
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_filter_input_port_connected_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an input port connected method attribute attached to a sink
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_sink_input_port_connected_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an output port connected method attribute attached to a source
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_source_output_port_connected_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an output port connected method attribute attached to a filter
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Port connected (bt_component_class_filter_output_port_connected_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines a "graph is configured" method attribute attached to
- * a sink component class descriptor which is attached to the automatic
- * plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: "Graph is configured" method
- * (bt_component_class_sink_graph_is_configured_method).
- */
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator initialization method attribute attached to a
- * source component class descriptor which is attached to the automatic
- * plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator initialization method
- * (bt_component_class_source_message_iterator_init_method).
- */
-#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
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator finalize method
- * (bt_component_class_source_message_iterator_finalize_method).
- */
-#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 "seek nanoseconds from origin" method attribute
- * attached to a source component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "seek nanoseconds from origin" method
- * (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "seek beginning" method attribute
- * attached to a source component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "seek beginning" method
- * (bt_component_class_source_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a source component class descriptor which is
- * attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "can seek nanoseconds from origin" method
- * (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek beginning" method attribute
- * attached to a source component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "can seek beginning" method
- * (bt_component_class_source_message_iterator_can_seek_beginning_method).
- */
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator initialization method attribute attached to a
- * filter component class descriptor which is attached to the automatic
- * plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator initialization method
- * (bt_component_class_filter_message_iterator_init_method).
- */
-#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
- * component class descriptor which is attached to the automatic plugin
- * descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator finalize method
- * (bt_component_class_filter_message_iterator_finalize_method).
- */
-#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)
-
-/*
- * Defines an iterator "seek nanoseconds from origin" method attribute
- * attached to a filter component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "seek nanoseconds from origin" method
- * (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "seek beginning" method attribute
- * attached to a filter component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "seek beginning" method
- * (bt_component_class_filter_message_iterator_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek nanoseconds from origin" method
- * attribute attached to a filter component class descriptor which is
- * attached to the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "can seek nanoseconds from origin" method
- * (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
-
-/*
- * Defines an iterator "can seek beginning" method attribute
- * attached to a filter component class descriptor which is attached to
- * the automatic plugin descriptor.
- *
- * _name: Component class name (C identifier).
- * _x: Iterator "can seek beginning" method
- * (bt_component_class_filter_message_iterator_can_seek_beginning_method).
- */
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_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; \
- _BT_HIDDEN extern struct __bt_plugin_descriptor const *__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA; \
- _BT_HIDDEN extern struct __bt_plugin_descriptor const *__BT_PLUGIN_DESCRIPTOR_END_SYMBOL __BT_PLUGIN_DESCRIPTOR_END_EXTRA; \
- \
- static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_dummy __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = NULL; \
- _BT_HIDDEN extern struct __bt_plugin_descriptor_attribute const *__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
- _BT_HIDDEN extern struct __bt_plugin_descriptor_attribute const *__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
- \
- static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_component_class_descriptor_dummy __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = NULL; \
- _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA; \
- _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA; \
- \
- static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_component_class_descriptor_attribute_dummy __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = NULL; \
- _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
- _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
- \
- struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
- { \
- return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \
- } \
- struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
- { \
- return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \
- } \
- struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
- { \
- return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
- } \
- struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
- { \
- return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
- } \
- struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
- { \
- return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \
- } \
- struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
- { \
- return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \
- } \
- struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
- { \
- return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
- } \
- struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
- { \
- return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_DEV_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
-#define BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/plugin/plugin-const.h>
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/plugin/plugin-so-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/lib-logging-internal.h>
-#include <glib.h>
-
-enum bt_plugin_type {
- BT_PLUGIN_TYPE_SO = 0,
- BT_PLUGIN_TYPE_PYTHON = 1,
-};
-
-enum bt_plugin_status {
- BT_PLUGIN_STATUS_OK = 0,
- BT_PLUGIN_STATUS_ERROR = -1,
- BT_PLUGIN_STATUS_NOMEM = -12,
-};
-
-struct bt_plugin {
- struct bt_object base;
- enum bt_plugin_type type;
-
- /* Arrays of `struct bt_component_class *` (owned by this) */
- GPtrArray *src_comp_classes;
- GPtrArray *flt_comp_classes;
- GPtrArray *sink_comp_classes;
-
- /* Info (owned by this) */
- struct {
- GString *path;
- GString *name;
- GString *author;
- GString *license;
- GString *description;
- struct {
- unsigned int major;
- unsigned int minor;
- unsigned int patch;
- GString *extra;
- } version;
- bool path_set;
- bool name_set;
- bool author_set;
- bool license_set;
- bool description_set;
- bool version_set;
- } info;
-
- /* Value depends on the specific plugin type */
- void *spec_data;
- void (*destroy_spec_data)(struct bt_plugin *);
-};
-
-struct bt_plugin_set {
- struct bt_object base;
-
- /* Array of struct bt_plugin * */
- GPtrArray *plugins;
-};
-
-static inline
-const char *bt_plugin_status_string(enum bt_plugin_status status)
-{
- switch (status) {
- case BT_PLUGIN_STATUS_OK:
- return "BT_PLUGIN_STATUS_OK";
- case BT_PLUGIN_STATUS_ERROR:
- return "BT_PLUGIN_STATUS_ERROR";
- case BT_PLUGIN_STATUS_NOMEM:
- return "BT_PLUGIN_STATUS_NOMEM";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-const char *bt_plugin_type_string(enum bt_plugin_type type)
-{
- switch (type) {
- case BT_PLUGIN_TYPE_SO:
- return "BT_PLUGIN_TYPE_SO";
- case BT_PLUGIN_TYPE_PYTHON:
- return "BT_PLUGIN_TYPE_PYTHON";
- default:
- return "(unknown)";
- }
-}
-
-static inline
-void bt_plugin_destroy(struct bt_object *obj)
-{
- struct bt_plugin *plugin;
-
- BT_ASSERT(obj);
- plugin = container_of(obj, struct bt_plugin, base);
- BT_LIB_LOGD("Destroying plugin object: %!+l", plugin);
-
- if (plugin->destroy_spec_data) {
- plugin->destroy_spec_data(plugin);
- }
-
- if (plugin->src_comp_classes) {
- BT_LOGD_STR("Putting source component classes.");
- g_ptr_array_free(plugin->src_comp_classes, TRUE);
- plugin->src_comp_classes = NULL;
- }
-
- if (plugin->flt_comp_classes) {
- BT_LOGD_STR("Putting filter component classes.");
- g_ptr_array_free(plugin->flt_comp_classes, TRUE);
- plugin->flt_comp_classes = NULL;
- }
-
- if (plugin->sink_comp_classes) {
- BT_LOGD_STR("Putting sink component classes.");
- g_ptr_array_free(plugin->sink_comp_classes, TRUE);
- plugin->sink_comp_classes = NULL;
- }
-
- if (plugin->info.name) {
- g_string_free(plugin->info.name, TRUE);
- plugin->info.name = NULL;
- }
-
- if (plugin->info.path) {
- g_string_free(plugin->info.path, TRUE);
- plugin->info.path = NULL;
- }
-
- if (plugin->info.description) {
- g_string_free(plugin->info.description, TRUE);
- plugin->info.description = NULL;
- }
-
- if (plugin->info.author) {
- g_string_free(plugin->info.author, TRUE);
- plugin->info.author = NULL;
- }
-
- if (plugin->info.license) {
- g_string_free(plugin->info.license, TRUE);
- plugin->info.license = NULL;
- }
-
- if (plugin->info.version.extra) {
- g_string_free(plugin->info.version.extra, TRUE);
- plugin->info.version.extra = NULL;
- }
-
- g_free(plugin);
-}
-
-static inline
-struct bt_plugin *bt_plugin_create_empty(enum bt_plugin_type type)
-{
- struct bt_plugin *plugin = NULL;
-
- BT_LOGD("Creating empty plugin object: type=%s",
- bt_plugin_type_string(type));
-
- plugin = g_new0(struct bt_plugin, 1);
- if (!plugin) {
- BT_LOGE_STR("Failed to allocate one plugin.");
- goto error;
- }
-
- bt_object_init_shared(&plugin->base, bt_plugin_destroy);
- plugin->type = type;
-
- /* Create empty arrays of component classes */
- plugin->src_comp_classes =
- g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_put_ref);
- if (!plugin->src_comp_classes) {
- BT_LOGE_STR("Failed to allocate a GPtrArray.");
- goto error;
- }
-
- plugin->flt_comp_classes =
- g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_put_ref);
- if (!plugin->flt_comp_classes) {
- BT_LOGE_STR("Failed to allocate a GPtrArray.");
- goto error;
- }
-
- plugin->sink_comp_classes =
- g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_put_ref);
- if (!plugin->sink_comp_classes) {
- BT_LOGE_STR("Failed to allocate a GPtrArray.");
- goto error;
- }
-
- /* Create empty info */
- plugin->info.name = g_string_new(NULL);
- if (!plugin->info.name) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- plugin->info.path = g_string_new(NULL);
- if (!plugin->info.path) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- plugin->info.description = g_string_new(NULL);
- if (!plugin->info.description) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- plugin->info.author = g_string_new(NULL);
- if (!plugin->info.author) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- plugin->info.license = g_string_new(NULL);
- if (!plugin->info.license) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- plugin->info.version.extra = g_string_new(NULL);
- if (!plugin->info.version.extra) {
- BT_LOGE_STR("Failed to allocate a GString.");
- goto error;
- }
-
- BT_LIB_LOGD("Created empty plugin object: %!+l", plugin);
- goto end;
-
-error:
- BT_OBJECT_PUT_REF_AND_RESET(plugin);
-
-end:
- return plugin;
-}
-
-static inline
-void bt_plugin_set_path(struct bt_plugin *plugin, const char *path)
-{
- BT_ASSERT(plugin);
- BT_ASSERT(path);
- g_string_assign(plugin->info.path, path);
- plugin->info.path_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, path=\"%s\"",
- plugin, path);
-}
-
-static inline
-void bt_plugin_set_name(struct bt_plugin *plugin, const char *name)
-{
- BT_ASSERT(plugin);
- BT_ASSERT(name);
- g_string_assign(plugin->info.name, name);
- plugin->info.name_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's name: %![plugin-]+l, name=\"%s\"",
- plugin, name);
-}
-
-static inline
-void bt_plugin_set_description(struct bt_plugin *plugin,
- const char *description)
-{
- BT_ASSERT(plugin);
- BT_ASSERT(description);
- g_string_assign(plugin->info.description, description);
- plugin->info.description_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's description: %![plugin-]+l", plugin);
-}
-
-static inline
-void bt_plugin_set_author(struct bt_plugin *plugin, const char *author)
-{
- BT_ASSERT(plugin);
- BT_ASSERT(author);
- g_string_assign(plugin->info.author, author);
- plugin->info.author_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's author: %![plugin-]+l, author=\"%s\"",
- plugin, author);
-}
-
-static inline
-void bt_plugin_set_license(struct bt_plugin *plugin, const char *license)
-{
- BT_ASSERT(plugin);
- BT_ASSERT(license);
- g_string_assign(plugin->info.license, license);
- plugin->info.license_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, license=\"%s\"",
- plugin, license);
-}
-
-static inline
-void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major,
- unsigned int minor, unsigned int patch, const char *extra)
-{
- BT_ASSERT(plugin);
- plugin->info.version.major = major;
- plugin->info.version.minor = minor;
- plugin->info.version.patch = patch;
-
- if (extra) {
- g_string_assign(plugin->info.version.extra, extra);
- }
-
- plugin->info.version_set = BT_TRUE;
- BT_LIB_LOGV("Set plugin's version: %![plugin-]+l, "
- "major=%u, minor=%u, patch=%u, extra=\"%s\"",
- plugin, major, minor, patch, extra);
-}
-
-static inline
-enum bt_plugin_status bt_plugin_add_component_class(
- struct bt_plugin *plugin, struct bt_component_class *comp_class)
-{
- GPtrArray *comp_classes;
-
- BT_ASSERT(plugin);
- BT_ASSERT(comp_class);
-
- switch (comp_class->type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- comp_classes = plugin->src_comp_classes;
- break;
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- comp_classes = plugin->flt_comp_classes;
- break;
- case BT_COMPONENT_CLASS_TYPE_SINK:
- comp_classes = plugin->sink_comp_classes;
- break;
- default:
- abort();
- }
-
- /* Add new component class */
- bt_object_get_ref(comp_class);
- g_ptr_array_add(comp_classes, comp_class);
-
- /* Special case for a shared object plugin */
- if (plugin->type == BT_PLUGIN_TYPE_SO) {
- bt_plugin_so_on_add_component_class(plugin, comp_class);
- }
-
- BT_LIB_LOGD("Added component class to plugin: "
- "%![plugin-]+l, %![cc-]+C", plugin, comp_class);
- return BT_PLUGIN_STATUS_OK;
-}
-
-static
-void bt_plugin_set_destroy(struct bt_object *obj)
-{
- struct bt_plugin_set *plugin_set =
- container_of(obj, struct bt_plugin_set, base);
-
- if (!plugin_set) {
- return;
- }
-
- BT_LOGD("Destroying plugin set: addr=%p", plugin_set);
-
- if (plugin_set->plugins) {
- BT_LOGD_STR("Putting plugins.");
- g_ptr_array_free(plugin_set->plugins, TRUE);
- }
-
- g_free(plugin_set);
-}
-
-static inline
-struct bt_plugin_set *bt_plugin_set_create(void)
-{
- struct bt_plugin_set *plugin_set = g_new0(struct bt_plugin_set, 1);
-
- if (!plugin_set) {
- goto end;
- }
-
- BT_LOGD_STR("Creating empty plugin set.");
- bt_object_init_shared(&plugin_set->base, bt_plugin_set_destroy);
-
- plugin_set->plugins = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_object_put_ref);
- if (!plugin_set->plugins) {
- BT_LOGE_STR("Failed to allocate a GPtrArray.");
- BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
- goto end;
- }
-
- BT_LOGD("Created empty plugin set: addr=%p", plugin_set);
-
-end:
- return plugin_set;
-}
-
-static inline
-void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
- struct bt_plugin *plugin)
-{
- BT_ASSERT(plugin_set);
- BT_ASSERT(plugin);
- bt_object_get_ref(plugin);
- g_ptr_array_add(plugin_set->plugins, plugin);
- BT_LIB_LOGV("Added plugin to plugin set: "
- "plugin-set-addr=%p, %![plugin-]+l",
- plugin_set, plugin);
-}
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
-#define BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <stdint.h>
-
-/* For bt_plugin, bt_plugin_set */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern uint64_t bt_plugin_set_get_plugin_count(
- const bt_plugin_set *plugin_set);
-
-extern const bt_plugin *bt_plugin_set_borrow_plugin_by_index_const(
- const bt_plugin_set *plugin_set, uint64_t index);
-
-extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set);
-
-extern void bt_plugin_set_put_ref(const bt_plugin_set *plugin_set);
-
-#define BT_PLUGIN_SET_PUT_REF_AND_RESET(_var) \
- do { \
- bt_plugin_set_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PLUGIN_SET_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_plugin_set_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H
-#define BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <glib.h>
-#include <gmodule.h>
-#include <babeltrace/types.h>
-
-struct bt_plugin;
-struct bt_component_class;
-
-struct bt_plugin_so_shared_lib_handle {
- struct bt_object base;
- GString *path;
- GModule *module;
-
- /* True if initialization function was called */
- bt_bool init_called;
- bt_plugin_exit_func exit;
-};
-
-struct bt_plugin_so_spec_data {
- /* Shared lib. handle: owned by this */
- struct bt_plugin_so_shared_lib_handle *shared_lib_handle;
-
- /* Pointers to plugin's memory: do NOT free */
- const struct __bt_plugin_descriptor *descriptor;
- bt_plugin_init_func init;
- const struct __bt_plugin_descriptor_version *version;
-};
-
-BT_HIDDEN
-struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path);
-
-BT_HIDDEN
-struct bt_plugin_set *bt_plugin_so_create_all_from_static(void);
-
-void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
- struct bt_component_class *comp_class);
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H
-#define BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/plugin/plugin-const.h>
-
-extern
-struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path);
-
-#endif /* BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H */
+++ /dev/null
-#ifndef _BABELTRACE_PRIO_HEAP_H
-#define _BABELTRACE_PRIO_HEAP_H
-
-/*
- * Static-sized priority heap containing pointers. Based on CLRS,
- * chapter 6.
- *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <unistd.h>
-#include <babeltrace/babeltrace-internal.h>
-
-struct ptr_heap {
- size_t len, alloc_len;
- void **ptrs;
- int (*gt)(void *a, void *b);
-};
-
-#ifdef DEBUG_HEAP
-void check_heap(const struct ptr_heap *heap);
-#else
-static inline
-void check_heap(const struct ptr_heap *heap)
-{
-}
-#endif
-
-/**
- * bt_heap_maximum - return the largest element in the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap, without performing any modification
- * to the heap structure. Returns NULL if the heap is empty.
- */
-static inline void *bt_heap_maximum(const struct ptr_heap *heap)
-{
- check_heap(heap);
- return likely(heap->len) ? heap->ptrs[0] : NULL;
-}
-
-/**
- * bt_heap_init - initialize the heap
- * @heap: the heap to initialize
- * @alloc_len: number of elements initially allocated
- * @gt: function to compare the elements
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_init(struct ptr_heap *heap,
- size_t alloc_len,
- int gt(void *a, void *b));
-
-/**
- * bt_heap_free - free the heap
- * @heap: the heap to free
- */
-extern void bt_heap_free(struct ptr_heap *heap);
-
-/**
- * bt_heap_insert - insert an element into the heap
- * @heap: the heap to be operated on
- * @p: the element to add
- *
- * Insert an element into the heap.
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_insert(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_remove - remove the largest element from the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. Returns NULL if the heap is empty.
- */
-extern void *bt_heap_remove(struct ptr_heap *heap);
-
-/**
- * bt_heap_cherrypick - remove a given element from the heap
- * @heap: the heap to be operated on
- * @p: the element
- *
- * Remove the given element from the heap. Return the element if present, else
- * return NULL. This algorithm has a complexity of O(n), which is higher than
- * O(log(n)) provided by the rest of this API.
- */
-extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_replace_max - replace the the largest element from the heap
- * @heap: the heap to be operated on
- * @p: the pointer to be inserted as topmost element replacement
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. The heap is rebalanced only once after the insertion. Returns NULL if
- * the heap is empty.
- *
- * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but
- * it only rebalances the heap once. It never allocates memory.
- */
-extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_copy - copy a heap
- * @dst: the destination heap (must be allocated)
- * @src: the source heap
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
-
-#endif /* _BABELTRACE_PRIO_HEAP_H */
+++ /dev/null
-#ifndef BABELTRACE_PROPERTY_INTERNAL_H
-#define BABELTRACE_PROPERTY_INTERNAL_H
-
-/*
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/assert-internal.h>
-#include <babeltrace/property.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-
-struct bt_property {
- enum bt_property_availability avail;
-};
-
-struct bt_property_uint {
- struct bt_property base;
- uint64_t value;
-};
-
-static inline
-void bt_property_uint_set(struct bt_property_uint *prop, uint64_t value)
-{
- BT_ASSERT(prop);
- prop->base.avail = BT_PROPERTY_AVAILABILITY_AVAILABLE;
- prop->value = value;
-}
-
-static inline
-void bt_property_uint_init(struct bt_property_uint *prop,
- enum bt_property_availability avail, uint64_t value)
-{
- BT_ASSERT(prop);
- prop->base.avail = avail;
- prop->value = value;
-}
-
-#endif /* BABELTRACE_PROPERTY_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_PROPERTY_H
-#define BABELTRACE_PROPERTY_H
-
-/*
- * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_property_availability {
- BT_PROPERTY_AVAILABILITY_AVAILABLE,
- BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
-} bt_property_availability;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PROPERTY_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_ATTRIBUTES_H
-#define BABELTRACE_TRACE_IR_ATTRIBUTES_H
-
-/*
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-
-BT_HIDDEN
-struct bt_value *bt_attributes_create(void);
-
-BT_HIDDEN
-void bt_attributes_destroy(struct bt_value *attr_obj);
-
-BT_HIDDEN
-int64_t bt_attributes_get_count(const struct bt_value *attr_obj);
-
-BT_HIDDEN
-const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
- uint64_t index);
-
-BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value(
- struct bt_value *attr_obj,
- uint64_t index);
-
-BT_HIDDEN
-int bt_attributes_set_field_value(struct bt_value *attr_obj,
- const char *name, struct bt_value *value_obj);
-
-BT_HIDDEN
-struct bt_value *bt_attributes_borrow_field_value_by_name(
- struct bt_value *attr_obj, const char *name);
-
-BT_HIDDEN
-int bt_attributes_freeze(const struct bt_value *attr_obj);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_ATTRIBUTES_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H
-#define BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_bool, bt_uuid, bt_clock_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_clock_class_status {
- BT_CLOCK_CLASS_STATUS_OK = 0,
- BT_CLOCK_CLASS_STATUS_NOMEM = -12,
- BT_CLOCK_CLASS_STATUS_OVERFLOW = -75,
-} bt_clock_class_status;
-
-extern const char *bt_clock_class_get_name(
- const bt_clock_class *clock_class);
-
-extern const char *bt_clock_class_get_description(
- const bt_clock_class *clock_class);
-
-extern uint64_t bt_clock_class_get_frequency(
- const bt_clock_class *clock_class);
-
-extern uint64_t bt_clock_class_get_precision(
- const bt_clock_class *clock_class);
-
-extern void bt_clock_class_get_offset(const bt_clock_class *clock_class,
- int64_t *seconds, uint64_t *cycles);
-
-extern bt_bool bt_clock_class_origin_is_unix_epoch(
- const bt_clock_class *clock_class);
-
-extern bt_uuid bt_clock_class_get_uuid(
- const bt_clock_class *clock_class);
-
-extern bt_clock_class_status bt_clock_class_cycles_to_ns_from_origin(
- const bt_clock_class *clock_class,
- uint64_t cycles, int64_t *ns_from_origin);
-
-extern void bt_clock_class_get_ref(const bt_clock_class *clock_class);
-
-extern void bt_clock_class_put_ref(const bt_clock_class *clock_class);
-
-#define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_clock_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_CLOCK_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_clock_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/property-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <glib.h>
-
-struct bt_clock_class {
- struct bt_object base;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } description;
-
- uint64_t frequency;
- uint64_t precision;
- int64_t offset_seconds;
- uint64_t offset_cycles;
-
- struct {
- uint8_t uuid[BABELTRACE_UUID_LEN];
-
- /* NULL or `uuid` above */
- bt_uuid value;
- } uuid;
-
- bool origin_is_unix_epoch;
-
- /*
- * This is computed every time you call
- * bt_clock_class_set_frequency() or
- * bt_clock_class_set_offset(), as well as initially. It is the
- * base offset in nanoseconds including both `offset_seconds`
- * and `offset_cycles` above in the result. It is used to
- * accelerate future calls to
- * bt_clock_snapshot_get_ns_from_origin() and
- * bt_clock_class_cycles_to_ns_from_origin().
- *
- * `overflows` is true if the base offset cannot be computed
- * because of an overflow.
- */
- struct {
- int64_t value_ns;
- bool overflows;
- } base_offset;
-
- /* Pool of `struct bt_clock_snapshot *` */
- struct bt_object_pool cs_pool;
-
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_clock_class_freeze(const struct bt_clock_class *clock_class);
-
-#ifdef BT_DEV_MODE
-# define bt_clock_class_freeze _bt_clock_class_freeze
-#else
-# define bt_clock_class_freeze(_cc)
-#endif
-
-BT_HIDDEN
-bt_bool bt_clock_class_is_valid(struct bt_clock_class *clock_class);
-
-static inline
-int bt_clock_class_clock_value_from_ns_from_origin(
- struct bt_clock_class *cc, int64_t ns_from_origin,
- uint64_t *raw_value)
-{
- BT_ASSERT(cc);
-
- return bt_common_clock_value_from_ns_from_origin(cc->offset_seconds,
- cc->offset_cycles, cc->frequency, ns_from_origin,
- raw_value);
-}
-
-#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_H
-#define BABELTRACE_TRACE_IR_CLOCK_CLASS_H
-
-/*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_bool, bt_uuid, bt_clock_class, bt_trace_class */
-#include <babeltrace/types.h>
-
-/* For bt_clock_class_status */
-#include <babeltrace/trace-ir/clock-class-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_clock_class *bt_clock_class_create(bt_self_component *self_comp);
-
-extern bt_clock_class_status bt_clock_class_set_name(
- bt_clock_class *clock_class, const char *name);
-
-extern bt_clock_class_status bt_clock_class_set_description(
- bt_clock_class *clock_class, const char *description);
-
-extern void bt_clock_class_set_frequency(bt_clock_class *clock_class,
- uint64_t freq);
-
-extern void bt_clock_class_set_precision(bt_clock_class *clock_class,
- uint64_t precision);
-
-extern void bt_clock_class_set_offset(bt_clock_class *clock_class,
- int64_t seconds, uint64_t cycles);
-
-extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class *clock_class,
- bt_bool origin_is_unix_epoch);
-
-extern void bt_clock_class_set_uuid(bt_clock_class *clock_class,
- bt_uuid uuid);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H
-#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_clock_class, bt_clock_snapshot */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_clock_snapshot_status {
- BT_CLOCK_SNAPSHOT_STATUS_OK = 0,
- BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW = -75,
-} bt_clock_snapshot_status;
-
-extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const(
- const bt_clock_snapshot *clock_snapshot);
-
-extern uint64_t bt_clock_snapshot_get_value(
- const bt_clock_snapshot *clock_snapshot);
-
-extern bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin(
- const bt_clock_snapshot *clock_snapshot,
- int64_t *ns_from_origin);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
-#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-struct bt_clock_class;
-
-struct bt_clock_snapshot {
- struct bt_object base;
- struct bt_clock_class *clock_class;
- uint64_t value_cycles;
- bool ns_from_origin_overflows;
- int64_t ns_from_origin;
- bool is_set;
-};
-
-static inline
-void bt_clock_snapshot_set(struct bt_clock_snapshot *clock_snapshot)
-{
- BT_ASSERT(clock_snapshot);
- clock_snapshot->is_set = true;
-}
-
-static inline
-void bt_clock_snapshot_reset(struct bt_clock_snapshot *clock_snapshot)
-{
- BT_ASSERT(clock_snapshot);
- clock_snapshot->is_set = false;
-}
-
-static inline
-void set_ns_from_origin(struct bt_clock_snapshot *clock_snapshot)
-{
- if (bt_util_ns_from_origin_clock_class(clock_snapshot->clock_class,
- clock_snapshot->value_cycles,
- &clock_snapshot->ns_from_origin)) {
- clock_snapshot->ns_from_origin_overflows = true;
- }
-}
-
-static inline
-void bt_clock_snapshot_set_raw_value(struct bt_clock_snapshot *clock_snapshot,
- uint64_t cycles)
-{
- BT_ASSERT(clock_snapshot);
- clock_snapshot->value_cycles = cycles;
- set_ns_from_origin(clock_snapshot);
- bt_clock_snapshot_set(clock_snapshot);
-}
-
-BT_HIDDEN
-void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot);
-
-BT_HIDDEN
-struct bt_clock_snapshot *bt_clock_snapshot_new(struct bt_clock_class *clock_class);
-
-BT_HIDDEN
-struct bt_clock_snapshot *bt_clock_snapshot_create(
- struct bt_clock_class *clock_class);
-
-BT_HIDDEN
-void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot);
-
-#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H
-#define BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-#include <glib.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/assert-internal.h>
-
-struct bt_clock_snapshot_set {
- /* Unique objects owned by this */
- GPtrArray *clock_snapshots;
-
- /* Weak; points to one of the clock snapshots above */
- struct bt_clock_snapshot *default_cs;
-};
-
-static inline
-int bt_clock_snapshot_set_initialize(struct bt_clock_snapshot_set *cs_set)
-{
- int ret = 0;
-
- cs_set->clock_snapshots = g_ptr_array_sized_new(1);
- if (!cs_set->clock_snapshots) {
-#ifdef BT_LOGE_STR
- BT_LOGE_STR("Failed to allocate one GPtrArray.");
-#endif
-
- ret = -1;
- goto end;
- }
-
- cs_set->default_cs = NULL;
-
-end:
- return ret;
-}
-
-static inline
-void bt_clock_snapshot_set_reset(struct bt_clock_snapshot_set *cs_set)
-{
- uint64_t i;
-
- BT_ASSERT(cs_set);
- BT_ASSERT(cs_set->clock_snapshots);
-
- for (i = 0; i < cs_set->clock_snapshots->len; i++) {
- struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i];
-
- BT_ASSERT(cs);
- bt_clock_snapshot_reset(cs);
- }
-
- cs_set->default_cs = NULL;
-}
-
-static inline
-void bt_clock_snapshot_set_finalize(struct bt_clock_snapshot_set *cs_set)
-{
- uint64_t i;
-
- BT_ASSERT(cs_set);
-
- if (cs_set->clock_snapshots) {
- for (i = 0; i < cs_set->clock_snapshots->len; i++) {
- struct bt_clock_snapshot *cs =
- cs_set->clock_snapshots->pdata[i];
-
- BT_ASSERT(cs);
- bt_clock_snapshot_recycle(cs);
- }
-
- g_ptr_array_free(cs_set->clock_snapshots, TRUE);
- }
-
- cs_set->default_cs = NULL;
-}
-
-static inline
-int bt_clock_snapshot_set_set_clock_snapshot(struct bt_clock_snapshot_set *cs_set,
- struct bt_clock_class *cc, uint64_t raw_value)
-{
- int ret = 0;
- struct bt_clock_snapshot *clock_snapshot = NULL;
- uint64_t i;
-
- BT_ASSERT(cs_set);
- BT_ASSERT(cc);
-
- /*
- * Check if we already have a value for this clock class.
- *
- * TODO: When we have many clock classes, make this more
- * efficient.
- */
- for (i = 0; i < cs_set->clock_snapshots->len; i++) {
- struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i];
-
- BT_ASSERT(cs);
-
- if (cs->clock_class == cc) {
- clock_snapshot = cs;
- break;
- }
- }
-
- if (!clock_snapshot) {
- clock_snapshot = bt_clock_snapshot_create(cc);
- if (!clock_snapshot) {
-#ifdef BT_LIB_LOGE
- BT_LIB_LOGE("Cannot create a clock snapshot from a clock class: "
- "%![cc-]+K", cc);
-#endif
-
- ret = -1;
- goto end;
- }
-
- g_ptr_array_add(cs_set->clock_snapshots, clock_snapshot);
- }
-
- bt_clock_snapshot_set_raw_value(clock_snapshot, raw_value);
-
-end:
- return ret;
-}
-
-static inline
-void bt_clock_snapshot_set_set_default_clock_snapshot(
- struct bt_clock_snapshot_set *cs_set, uint64_t raw_value)
-{
- BT_ASSERT(cs_set);
- BT_ASSERT(cs_set->default_cs);
- bt_clock_snapshot_set_raw_value(cs_set->default_cs, raw_value);
-}
-
-#endif /* BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H
-#define BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_property_availability */
-#include <babeltrace/property.h>
-
-/* For bt_event_class, bt_field_class, bt_stream_class */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_event_class_status {
- BT_EVENT_CLASS_STATUS_OK = 0,
- BT_EVENT_CLASS_STATUS_NOMEM = -12,
-} bt_event_class_status;
-
-typedef enum bt_event_class_log_level {
- BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY,
- BT_EVENT_CLASS_LOG_LEVEL_ALERT,
- BT_EVENT_CLASS_LOG_LEVEL_CRITICAL,
- BT_EVENT_CLASS_LOG_LEVEL_ERROR,
- BT_EVENT_CLASS_LOG_LEVEL_WARNING,
- BT_EVENT_CLASS_LOG_LEVEL_NOTICE,
- BT_EVENT_CLASS_LOG_LEVEL_INFO,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE,
- BT_EVENT_CLASS_LOG_LEVEL_DEBUG,
-} bt_event_class_log_level;
-
-extern const bt_stream_class *bt_event_class_borrow_stream_class_const(
- const bt_event_class *event_class);
-
-extern const char *bt_event_class_get_name(const bt_event_class *event_class);
-
-extern uint64_t bt_event_class_get_id(const bt_event_class *event_class);
-
-extern bt_property_availability bt_event_class_get_log_level(
- const bt_event_class *event_class,
- bt_event_class_log_level *log_level);
-
-extern const char *bt_event_class_get_emf_uri(
- const bt_event_class *event_class);
-
-extern const bt_field_class *
-bt_event_class_borrow_specific_context_field_class_const(
- const bt_event_class *event_class);
-
-extern const bt_field_class *bt_event_class_borrow_payload_field_class_const(
- const bt_event_class *event_class);
-
-extern void bt_event_class_get_ref(const bt_event_class *event_class);
-
-extern void bt_event_class_put_ref(const bt_event_class *event_class);
-
-#define BT_EVENT_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_event_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_EVENT_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_event_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/property-internal.h>
-#include <glib.h>
-#include <stdbool.h>
-
-struct bt_event_class {
- struct bt_object base;
- struct bt_field_class *specific_context_fc;
- struct bt_field_class *payload_fc;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- uint64_t id;
- struct bt_property_uint log_level;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } emf_uri;
-
- /* Pool of `struct bt_event *` */
- struct bt_object_pool event_pool;
-
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_event_class_freeze(const struct bt_event_class *event_class);
-
-#ifdef BT_DEV_MODE
-# define bt_event_class_freeze _bt_event_class_freeze
-#else
-# define bt_event_class_freeze(_ec)
-#endif
-
-static inline
-struct bt_stream_class *bt_event_class_borrow_stream_class_inline(
- const struct bt_event_class *event_class)
-{
- BT_ASSERT(event_class);
- return (void *) bt_object_borrow_parent(&event_class->base);
-}
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_H
-#define BABELTRACE_TRACE_IR_EVENT_CLASS_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_event_class_status, bt_event_class_log_level */
-#include <babeltrace/trace-ir/event-class-const.h>
-
-/* For bt_event_class, bt_stream_class */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_event_class *bt_event_class_create(
- bt_stream_class *stream_class);
-
-extern bt_event_class *bt_event_class_create_with_id(
- bt_stream_class *stream_class, uint64_t id);
-
-extern bt_stream_class *bt_event_class_borrow_stream_class(
- bt_event_class *event_class);
-
-extern bt_event_class_status bt_event_class_set_name(
- bt_event_class *event_class, const char *name);
-
-extern void bt_event_class_set_log_level(bt_event_class *event_class,
- bt_event_class_log_level log_level);
-
-extern bt_event_class_status bt_event_class_set_emf_uri(
- bt_event_class *event_class, const char *emf_uri);
-
-extern bt_event_class_status
-bt_event_class_set_specific_context_field_class(bt_event_class *event_class,
- bt_field_class *field_class);
-
-extern bt_field_class *
-bt_event_class_borrow_specific_context_field_class(bt_event_class *event_class);
-
-extern bt_event_class_status bt_event_class_set_payload_field_class(
- bt_event_class *event_class,
- bt_field_class *field_class);
-
-extern bt_field_class *bt_event_class_borrow_payload_field_class(
- bt_event_class *event_class);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_CONST_H
-#define BABELTRACE_TRACE_IR_EVENT_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_event, bt_event_class, bt_field, bt_packet */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_event_status {
- BT_EVENT_STATUS_OK = 0,
- BT_EVENT_STATUS_NOMEM = -12,
-} bt_event_status;
-
-extern const bt_event_class *bt_event_borrow_class_const(
- const bt_event *event);
-
-extern const bt_packet *bt_event_borrow_packet_const(
- const bt_event *event);
-
-extern const bt_stream *bt_event_borrow_stream_const(
- const bt_event *event);
-
-extern const bt_field *bt_event_borrow_common_context_field_const(
- const bt_event *event);
-
-extern const bt_field *bt_event_borrow_specific_context_field_const(
- const bt_event *event);
-
-extern const bt_field *bt_event_borrow_payload_field_const(
- const bt_event *event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_INTERNAL_H
-#define BABELTRACE_TRACE_IR_EVENT_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- */
-
-/* Protection: this file uses BT_LIB_LOG*() macros directly */
-#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
-# error Please define include <babeltrace/lib-logging-internal.h> before including this file.
-#endif
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <glib.h>
-
-#define BT_ASSERT_PRE_EVENT_HOT(_event) \
- BT_ASSERT_PRE_HOT(((const struct bt_event *) (_event)), \
- "Event", ": %!+e", (_event))
-
-struct bt_event {
- struct bt_object base;
-
- /* Owned by this */
- struct bt_event_class *class;
-
- /* Owned by this */
- struct bt_packet *packet;
-
- struct bt_field *common_context_field;
- struct bt_field *specific_context_field;
- struct bt_field *payload_field;
- bool frozen;
-};
-
-BT_HIDDEN
-void bt_event_destroy(struct bt_event *event);
-
-BT_HIDDEN
-struct bt_event *bt_event_new(struct bt_event_class *event_class);
-
-BT_HIDDEN
-void _bt_event_set_is_frozen(const struct bt_event *event, bool is_frozen);
-
-#ifdef BT_DEV_MODE
-# define bt_event_set_is_frozen _bt_event_set_is_frozen
-#else
-# define bt_event_set_is_frozen(_event, _is_frozen)
-#endif
-
-BT_UNUSED
-static inline
-void _bt_event_reset_dev_mode(struct bt_event *event)
-{
- BT_ASSERT(event);
-
- if (event->common_context_field) {
- bt_field_set_is_frozen(
- event->common_context_field, false);
- bt_field_reset(
- event->common_context_field);
- }
-
- if (event->specific_context_field) {
- bt_field_set_is_frozen(
- event->specific_context_field, false);
- bt_field_reset(event->specific_context_field);
- }
-
- if (event->payload_field) {
- bt_field_set_is_frozen(
- event->payload_field, false);
- bt_field_reset(event->payload_field);
- }
-}
-
-#ifdef BT_DEV_MODE
-# define bt_event_reset_dev_mode _bt_event_reset_dev_mode
-#else
-# define bt_event_reset_dev_mode(_x)
-#endif
-
-static inline
-void bt_event_reset(struct bt_event *event)
-{
- BT_ASSERT(event);
- BT_LIB_LOGD("Resetting event: %!+e", event);
- bt_event_set_is_frozen(event, false);
- bt_object_put_no_null_check(&event->packet->base);
- event->packet = NULL;
-}
-
-static inline
-void bt_event_recycle(struct bt_event *event)
-{
- struct bt_event_class *event_class;
-
- BT_ASSERT(event);
- BT_LIB_LOGD("Recycling event: %!+e", event);
-
- /*
- * Those are the important ordered steps:
- *
- * 1. Reset the event object (put any permanent reference it
- * has, unfreeze it and its fields in developer mode, etc.),
- * but do NOT put its class's reference. This event class
- * contains the pool to which we're about to recycle this
- * event object, so we must guarantee its existence thanks
- * to this existing reference.
- *
- * 2. Move the event class reference to our `event_class`
- * variable so that we can set the event's class member
- * to NULL before recycling it. We CANNOT do this after
- * we put the event class reference because this bt_object_put_ref()
- * could destroy the event class, also destroying its
- * event pool, thus also destroying our event object (this
- * would result in an invalid write access).
- *
- * 3. Recycle the event object.
- *
- * 4. Put our event class reference.
- */
- bt_event_reset(event);
- event_class = event->class;
- BT_ASSERT(event_class);
- event->class = NULL;
- bt_object_pool_recycle_object(&event_class->event_pool, event);
- bt_object_put_no_null_check(&event_class->base);
-}
-
-static inline
-void bt_event_set_packet(struct bt_event *event, struct bt_packet *packet)
-{
- BT_ASSERT_PRE_NON_NULL(event, "Event");
- BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- BT_ASSERT_PRE_EVENT_HOT(event);
- BT_ASSERT_PRE(bt_event_class_borrow_stream_class(
- event->class) == packet->stream->class,
- "Packet's stream class and event's stream class differ: "
- "%![event-]+e, %![packet-]+a", event, packet);
-
- BT_ASSERT(!event->packet);
- event->packet = packet;
- bt_object_get_no_null_check_no_parent_check(&event->packet->base);
- BT_LIB_LOGV("Set event's packet: %![event-]+e, %![packet-]+a",
- event, packet);
-}
-
-static inline
-struct bt_event *bt_event_create(struct bt_event_class *event_class,
- struct bt_packet *packet)
-{
- struct bt_event *event = NULL;
-
- BT_ASSERT(event_class);
- event = bt_object_pool_create_object(&event_class->event_pool);
- if (unlikely(!event)) {
- BT_LIB_LOGE("Cannot allocate one event from event class's event pool: "
- "%![ec-]+E", event_class);
- goto end;
- }
-
- if (likely(!event->class)) {
- event->class = event_class;
- bt_object_get_no_null_check(&event_class->base);
- }
-
- BT_ASSERT(packet);
- bt_event_set_packet(event, packet);
- goto end;
-
-end:
- return event;
-}
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_EVENT_H
-#define BABELTRACE_TRACE_IR_EVENT_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_event, bt_event_class, bt_field, bt_packet */
-#include <babeltrace/types.h>
-
-/* For bt_event_status */
-#include <babeltrace/trace-ir/event-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_event_class *bt_event_borrow_class(bt_event *event);
-
-extern bt_packet *bt_event_borrow_packet(bt_event *event);
-
-extern bt_stream *bt_event_borrow_stream(bt_event *event);
-
-extern bt_field *
-bt_event_borrow_common_context_field(bt_event *event);
-
-extern bt_field *
-bt_event_borrow_specific_context_field(bt_event *event);
-
-extern bt_field *bt_event_borrow_payload_field(bt_event *event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_EVENT_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
-#define BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/*
- * For bt_bool, bt_field_class, bt_field_path,
- * bt_field_class_enumeration_mapping,
- * bt_field_class_unsigned_enumeration_mapping,
- * bt_field_class_signed_enumeration_mapping,
- * bt_field_class_enumeration_mapping_label_array, __BT_UPCAST_CONST
- */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_field_class_status {
- BT_FIELD_CLASS_STATUS_OK = 0,
- BT_FIELD_CLASS_STATUS_NOMEM = -12,
-} bt_field_class_status;
-
-typedef enum bt_field_class_type {
- BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
- BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
- BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
- BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
- BT_FIELD_CLASS_TYPE_REAL,
- BT_FIELD_CLASS_TYPE_STRING,
- BT_FIELD_CLASS_TYPE_STRUCTURE,
- BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
- BT_FIELD_CLASS_TYPE_VARIANT,
-} bt_field_class_type;
-
-typedef enum bt_field_class_integer_preferred_display_base {
- BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
- BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
- BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
- BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
-} bt_field_class_integer_preferred_display_base;
-
-extern bt_field_class_type bt_field_class_get_type(
- const bt_field_class *field_class);
-
-extern uint64_t bt_field_class_integer_get_field_value_range(
- const bt_field_class *field_class);
-
-extern bt_field_class_integer_preferred_display_base
-bt_field_class_integer_get_preferred_display_base(
- const bt_field_class *field_class);
-
-extern bt_bool bt_field_class_real_is_single_precision(
- const bt_field_class *field_class);
-
-extern uint64_t bt_field_class_enumeration_get_mapping_count(
- const bt_field_class *field_class);
-
-extern const bt_field_class_unsigned_enumeration_mapping *
-bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- const bt_field_class *field_class, uint64_t index);
-
-extern const bt_field_class_signed_enumeration_mapping *
-bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- const bt_field_class *field_class, uint64_t index);
-
-static inline
-const bt_field_class_enumeration_mapping *
-bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
- const bt_field_class_unsigned_enumeration_mapping *mapping)
-{
- return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
-}
-
-static inline
-const bt_field_class_enumeration_mapping *
-bt_field_class_signed_enumeration_mapping_as_mapping_const(
- const bt_field_class_signed_enumeration_mapping *mapping)
-{
- return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
-}
-
-extern const char *bt_field_class_enumeration_mapping_get_label(
- const bt_field_class_enumeration_mapping *mapping);
-
-extern uint64_t bt_field_class_enumeration_mapping_get_range_count(
- const bt_field_class_enumeration_mapping *mapping);
-
-extern void
-bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
- const bt_field_class_unsigned_enumeration_mapping *mapping,
- uint64_t index, uint64_t *lower, uint64_t *upper);
-
-extern void
-bt_field_class_signed_enumeration_mapping_get_range_by_index(
- const bt_field_class_signed_enumeration_mapping *mapping,
- uint64_t index, int64_t *lower, int64_t *upper);
-
-extern bt_field_class_status
-bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
- const bt_field_class *field_class, uint64_t value,
- bt_field_class_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern bt_field_class_status
-bt_field_class_signed_enumeration_get_mapping_labels_by_value(
- const bt_field_class *field_class, int64_t value,
- bt_field_class_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern uint64_t bt_field_class_structure_get_member_count(
- const bt_field_class *field_class);
-
-extern const bt_field_class_structure_member *
-bt_field_class_structure_borrow_member_by_index_const(
- const bt_field_class *field_class, uint64_t index);
-
-extern const bt_field_class_structure_member *
-bt_field_class_structure_borrow_member_by_name_const(
- const bt_field_class *field_class, const char *name);
-
-extern const char *bt_field_class_structure_member_get_name(
- const bt_field_class_structure_member *member);
-
-extern const bt_field_class *
-bt_field_class_structure_member_borrow_field_class_const(
- const bt_field_class_structure_member *member);
-
-extern const bt_field_class *
-bt_field_class_array_borrow_element_field_class_const(
- const bt_field_class *field_class);
-
-extern uint64_t bt_field_class_static_array_get_length(
- const bt_field_class *field_class);
-
-extern const bt_field_path *
-bt_field_class_dynamic_array_borrow_length_field_path_const(
- const bt_field_class *field_class);
-
-extern const bt_field_path *
-bt_field_class_variant_borrow_selector_field_path_const(
- const bt_field_class *field_class);
-
-extern uint64_t bt_field_class_variant_get_option_count(
- const bt_field_class *field_class);
-
-extern const bt_field_class_variant_option *
-bt_field_class_variant_borrow_option_by_index_const(
- const bt_field_class *field_class, uint64_t index);
-
-extern const bt_field_class_variant_option *
-bt_field_class_variant_borrow_option_by_name_const(
- const bt_field_class *field_class, const char *name);
-
-extern const char *bt_field_class_variant_option_get_name(
- const bt_field_class_variant_option *option);
-
-extern const bt_field_class *
-bt_field_class_variant_option_borrow_field_class_const(
- const bt_field_class_variant_option *option);
-
-extern void bt_field_class_get_ref(const bt_field_class *field_class);
-
-extern void bt_field_class_put_ref(const bt_field_class *field_class);
-
-#define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_field_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_field_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
-#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/types.h>
-#include <stdint.h>
-#include <glib.h>
-
-#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
- _name " is not an integer field class: %![fc-]+F", (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
- _name " is not an unsigned integer field class: %![fc-]+F", (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
- _name " is not an enumeration field class: %![fc-]+F", (_fc))
-
-#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
- _name " is not an array field class: %![fc-]+F", (_fc))
-
-#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \
- BT_ASSERT_PRE(((const struct bt_field_class *) (_fc))->type == (_type), \
- _name " has the wrong type: expected-type=%s, " \
- "%![fc-]+F", bt_common_field_class_type_string(_type), (_fc))
-
-#define BT_ASSERT_PRE_FC_HOT(_fc, _name) \
- BT_ASSERT_PRE_HOT((const struct bt_field_class *) (_fc), \
- (_name), ": %!+F", (_fc))
-
-#define BT_FIELD_CLASS_NAMED_FC_AT_INDEX(_fc, _index) \
- (&g_array_index(((struct bt_field_class_named_field_class_container *) (_fc))->named_fcs, \
- struct bt_named_field_class, (_index)))
-
-#define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \
- (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
- struct bt_field_class_enumeration_mapping, (_index)))
-
-#define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
- (&g_array_index((_mapping)->ranges, \
- struct bt_field_class_enumeration_mapping_range, (_index)))
-
-struct bt_field;
-struct bt_field_class;
-
-struct bt_field_class {
- struct bt_object base;
- enum bt_field_class_type type;
- bool frozen;
-
- /*
- * Only used in developer mode, this flag indicates whether or
- * not this field class is part of a trace class.
- */
- bool part_of_trace_class;
-};
-
-struct bt_field_class_integer {
- struct bt_field_class common;
-
- /*
- * Value range of fields built from this integer field class:
- * this is an equivalent integer size in bits. More formally,
- * `range` is `n` in:
- *
- * Unsigned range: [0, 2^n - 1]
- * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
- */
- uint64_t range;
-
- enum bt_field_class_integer_preferred_display_base base;
-};
-
-struct bt_field_class_enumeration_mapping_range {
- union {
- uint64_t u;
- int64_t i;
- } lower;
-
- union {
- uint64_t u;
- int64_t i;
- } upper;
-};
-
-struct bt_field_class_enumeration_mapping {
- GString *label;
-
- /* Array of `struct bt_field_class_enumeration_mapping_range` */
- GArray *ranges;
-};
-
-struct bt_field_class_unsigned_enumeration_mapping;
-struct bt_field_class_signed_enumeration_mapping;
-
-struct bt_field_class_enumeration {
- struct bt_field_class_integer common;
-
- /* Array of `struct bt_field_class_enumeration_mapping *` */
- GArray *mappings;
-
- /*
- * This is an array of `const char *` which acts as a temporary
- * (potentially growing) buffer for
- * bt_field_class_unsigned_enumeration_get_mapping_labels_by_value()
- * and
- * bt_field_class_signed_enumeration_get_mapping_labels_by_value().
- *
- * The actual strings are owned by the mappings above.
- */
- GPtrArray *label_buf;
-};
-
-struct bt_field_class_real {
- struct bt_field_class common;
- bool is_single_precision;
-};
-
-struct bt_field_class_string {
- struct bt_field_class common;
-};
-
-/* A named field class is a (name, field class) pair */
-struct bt_named_field_class {
- GString *name;
-
- /* Owned by this */
- struct bt_field_class *fc;
-
- bool frozen;
-};
-
-struct bt_field_class_structure_member;
-struct bt_field_class_variant_option;
-
-/*
- * This is the base field class for a container of named field classes.
- * Structure and variant field classes inherit this.
- */
-struct bt_field_class_named_field_class_container {
- struct bt_field_class common;
-
- /*
- * Key: `const char *`, not owned by this (owned by named field
- * type objects contained in `named_fcs` below).
- */
- GHashTable *name_to_index;
-
- /* Array of `struct bt_named_field_class` */
- GArray *named_fcs;
-};
-
-struct bt_field_class_structure {
- struct bt_field_class_named_field_class_container common;
-};
-
-struct bt_field_class_array {
- struct bt_field_class common;
-
- /* Owned by this */
- struct bt_field_class *element_fc;
-};
-
-struct bt_field_class_static_array {
- struct bt_field_class_array common;
- uint64_t length;
-};
-
-struct bt_field_class_dynamic_array {
- struct bt_field_class_array common;
-
- /* Weak: never dereferenced, only use to find it elsewhere */
- struct bt_field_class *length_fc;
-
- /* Owned by this */
- struct bt_field_path *length_field_path;
-};
-
-struct bt_field_class_variant {
- struct bt_field_class_named_field_class_container common;
-
- /* Weak: never dereferenced, only use to find it elsewhere */
- struct bt_field_class *selector_fc;
-
- /* Owned by this */
- struct bt_field_path *selector_field_path;
-};
-
-static inline
-bool bt_field_class_has_known_type(const struct bt_field_class *fc)
-{
- return fc->type >= BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER &&
- fc->type <= BT_FIELD_CLASS_TYPE_VARIANT;
-}
-
-BT_HIDDEN
-void _bt_field_class_freeze(const struct bt_field_class *field_class);
-
-#ifdef BT_DEV_MODE
-# define bt_field_class_freeze _bt_field_class_freeze
-#else
-# define bt_field_class_freeze(_fc) ((void) _fc)
-#endif
-
-BT_HIDDEN
-void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc);
-
-#ifdef BT_DEV_MODE
-# define bt_named_field_class_freeze _bt_named_field_class_freeze
-#else
-# define bt_named_field_class_freeze(_named_fc) ((void) _named_fc)
-#endif
-
-/*
- * This function recursively marks `field_class` and its children as
- * being part of a trace. This is used to validate that all field classes
- * are used at a single location within trace objects even if they are
- * shared objects for other purposes.
- */
-BT_HIDDEN
-void _bt_field_class_make_part_of_trace_class(
- const struct bt_field_class *field_class);
-
-#ifdef BT_DEV_MODE
-# define bt_field_class_make_part_of_trace_class _bt_field_class_make_part_of_trace_class
-#else
-# define bt_field_class_make_part_of_trace_class(_fc) ((void) _fc)
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_H
-#define BABELTRACE_TRACE_IR_FIELD_CLASSES_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_bool, bt_field_class, bt_trace_class */
-#include <babeltrace/types.h>
-
-/*
- * For bt_field_class_status,
- * bt_field_class_integer_preferred_display_base
- */
-#include <babeltrace/trace-ir/field-class-const.h>
-
-#include <stdint.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_field_class *bt_field_class_unsigned_integer_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class *bt_field_class_signed_integer_create(
- bt_trace_class *trace_class);
-
-extern void bt_field_class_integer_set_field_value_range(
- bt_field_class *field_class, uint64_t size);
-
-extern void bt_field_class_integer_set_preferred_display_base(
- bt_field_class *field_class,
- bt_field_class_integer_preferred_display_base base);
-
-extern bt_field_class *bt_field_class_real_create(bt_trace_class *trace_class);
-
-extern void bt_field_class_real_set_is_single_precision(
- bt_field_class *field_class,
- bt_bool is_single_precision);
-
-extern bt_field_class *bt_field_class_unsigned_enumeration_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class *bt_field_class_signed_enumeration_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class_status bt_field_class_unsigned_enumeration_map_range(
- bt_field_class *field_class, const char *label,
- uint64_t range_lower, uint64_t range_upper);
-
-extern bt_field_class_status bt_field_class_signed_enumeration_map_range(
- bt_field_class *field_class, const char *label,
- int64_t range_lower, int64_t range_upper);
-
-extern bt_field_class *bt_field_class_string_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class *bt_field_class_structure_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class_status bt_field_class_structure_append_member(
- bt_field_class *struct_field_class,
- const char *name, bt_field_class *field_class);
-
-extern bt_field_class_structure_member *
-bt_field_class_structure_borrow_member_by_index(
- bt_field_class *field_class, uint64_t index);
-
-extern bt_field_class_structure_member *
-bt_field_class_structure_borrow_member_by_name(
- bt_field_class *field_class, const char *name);
-
-extern bt_field_class *bt_field_class_static_array_create(
- bt_trace_class *trace_class,
- bt_field_class *elem_field_class, uint64_t length);
-
-extern bt_field_class *bt_field_class_dynamic_array_create(
- bt_trace_class *trace_class,
- bt_field_class *elem_field_class);
-
-extern bt_field_class *bt_field_class_array_borrow_element_field_class(
- bt_field_class *field_class);
-
-extern bt_field_class_status
-bt_field_class_dynamic_array_set_length_field_class(
- bt_field_class *field_class,
- bt_field_class *length_field_class);
-
-extern bt_field_class *bt_field_class_variant_create(
- bt_trace_class *trace_class);
-
-extern bt_field_class_status
-bt_field_class_variant_set_selector_field_class(bt_field_class *field_class,
- bt_field_class *selector_field_class);
-
-extern bt_field_class_status bt_field_class_variant_append_option(
- bt_field_class *var_field_class,
- const char *name, bt_field_class *field_class);
-
-extern bt_field_class_variant_option *
-bt_field_class_variant_borrow_option_by_index(
- bt_field_class *field_class, uint64_t index);
-
-extern bt_field_class_variant_option *
-bt_field_class_variant_borrow_option_by_name(
- bt_field_class *field_class, const char *name);
-
-extern bt_field_class *bt_field_class_variant_option_borrow_field_class(
- bt_field_class_variant_option *option);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELDS_CONST_H
-#define BABELTRACE_TRACE_IR_FIELDS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_field_class_type */
-#include <babeltrace/trace-ir/field-class.h>
-
-/* For bt_field, bt_field_class */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_field_status {
- BT_FIELD_STATUS_OK = 0,
- BT_FIELD_STATUS_NOMEM = -12,
-} bt_field_status;
-
-extern const bt_field_class *bt_field_borrow_class_const(
- const bt_field *field);
-
-extern bt_field_class_type bt_field_get_class_type(
- const bt_field *field);
-
-extern int64_t bt_field_signed_integer_get_value(const bt_field *field);
-
-extern uint64_t bt_field_unsigned_integer_get_value(
- const bt_field *field);
-
-extern double bt_field_real_get_value(const bt_field *field);
-
-extern bt_field_status bt_field_unsigned_enumeration_get_mapping_labels(
- const bt_field *field,
- bt_field_class_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern bt_field_status bt_field_signed_enumeration_get_mapping_labels(
- const bt_field *field,
- bt_field_class_enumeration_mapping_label_array *label_array,
- uint64_t *count);
-
-extern const char *bt_field_string_get_value(const bt_field *field);
-
-extern uint64_t bt_field_string_get_length(const bt_field *field);
-
-extern const bt_field *
-bt_field_structure_borrow_member_field_by_index_const(
- const bt_field *field, uint64_t index);
-
-extern const bt_field *
-bt_field_structure_borrow_member_field_by_name_const(
- const bt_field *field, const char *name);
-
-extern uint64_t bt_field_array_get_length(const bt_field *field);
-
-extern const bt_field *
-bt_field_array_borrow_element_field_by_index_const(
- const bt_field *field, uint64_t index);
-
-extern uint64_t bt_field_variant_get_selected_option_field_index(
- const bt_field *field);
-
-extern const bt_field *
-bt_field_variant_borrow_selected_option_field_const(
- const bt_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELDS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-pre-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/types.h>
-#include <stdint.h>
-#include <string.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <glib.h>
-
-#define BT_ASSERT_PRE_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
- BT_ASSERT_PRE(((const struct bt_field *) (_field))->class->type == (_cls_type), \
- _name " has the wrong class type: expected-class-type=%s, " \
- "%![field-]+f", \
- bt_common_field_class_type_string(_cls_type), (_field))
-
-#define BT_ASSERT_PRE_FIELD_IS_UNSIGNED_INT(_field, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
- _name " is not an unsigned integer field: %![field-]+f", \
- (_field))
-
-#define BT_ASSERT_PRE_FIELD_IS_SIGNED_INT(_field, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
- _name " is not a signed integer field: %![field-]+f", \
- (_field))
-
-#define BT_ASSERT_PRE_FIELD_IS_ARRAY(_field, _name) \
- BT_ASSERT_PRE( \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
- _name " is not an array field: %![field-]+f", (_field))
-
-#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name) \
- BT_ASSERT_PRE(bt_field_is_set(_field), \
- _name " is not set: %!+f", (_field))
-
-#define BT_ASSERT_PRE_FIELD_HOT(_field, _name) \
- BT_ASSERT_PRE_HOT((const struct bt_field *) (_field), (_name), \
- ": %!+f", (_field))
-
-struct bt_field;
-
-typedef struct bt_field *(* bt_field_create_func)(struct bt_field_class *);
-typedef void (*bt_field_method_set_is_frozen)(struct bt_field *, bool);
-typedef bool (*bt_field_method_is_set)(const struct bt_field *);
-typedef void (*bt_field_method_reset)(struct bt_field *);
-
-struct bt_field_methods {
- bt_field_method_set_is_frozen set_is_frozen;
- bt_field_method_is_set is_set;
- bt_field_method_reset reset;
-};
-
-struct bt_field {
- struct bt_object base;
-
- /* Owned by this */
- struct bt_field_class *class;
-
- /* Virtual table for slow path (dev mode) operations */
- struct bt_field_methods *methods;
-
- bool is_set;
- bool frozen;
-};
-
-struct bt_field_integer {
- struct bt_field common;
-
- union {
- uint64_t u;
- int64_t i;
- } value;
-};
-
-struct bt_field_real {
- struct bt_field common;
- double value;
-};
-
-struct bt_field_structure {
- struct bt_field common;
-
- /* Array of `struct bt_field *`, owned by this */
- GPtrArray *fields;
-};
-
-struct bt_field_variant {
- struct bt_field common;
-
- /* Weak: belongs to `fields` below */
- struct bt_field *selected_field;
-
- /* Index of currently selected field */
- uint64_t selected_index;
-
- /* Array of `struct bt_field *`, owned by this */
- GPtrArray *fields;
-};
-
-struct bt_field_array {
- struct bt_field common;
-
- /* Array of `struct bt_field *`, owned by this */
- GPtrArray *fields;
-
- /* Current effective length */
- uint64_t length;
-};
-
-struct bt_field_string {
- struct bt_field common;
- GArray *buf;
- uint64_t length;
-};
-
-#ifdef BT_DEV_MODE
-# define bt_field_set_is_frozen _bt_field_set_is_frozen
-# define bt_field_is_set _bt_field_is_set
-# define bt_field_reset _bt_field_reset
-# define bt_field_set_single _bt_field_set_single
-#else
-# define bt_field_set_is_frozen(_field, _is_frozen)
-# define bt_field_is_set(_field) (BT_FALSE)
-# define bt_field_reset(_field)
-# define bt_field_set_single(_field, _val)
-#endif
-
-BT_HIDDEN
-void _bt_field_set_is_frozen(const struct bt_field *field, bool is_frozen);
-
-static inline
-void _bt_field_reset(const struct bt_field *field)
-{
- BT_ASSERT(field);
- BT_ASSERT(field->methods->reset);
- field->methods->reset((void *) field);
-}
-
-static inline
-void _bt_field_set_single(struct bt_field *field, bool value)
-{
- BT_ASSERT(field);
- field->is_set = value;
-}
-
-static inline
-bt_bool _bt_field_is_set(const struct bt_field *field)
-{
- bt_bool is_set = BT_FALSE;
-
- if (!field) {
- goto end;
- }
-
- BT_ASSERT(bt_field_class_has_known_type(field->class));
- BT_ASSERT(field->methods->is_set);
- is_set = field->methods->is_set(field);
-
-end:
- return is_set;
-}
-
-BT_HIDDEN
-struct bt_field *bt_field_create(struct bt_field_class *class);
-
-BT_HIDDEN
-void bt_field_destroy(struct bt_field *field);
-
-#endif /* BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H
-#define BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_field_path, bt_field_path_item */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_field_path_item_type {
- BT_FIELD_PATH_ITEM_TYPE_INDEX,
- BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT,
-} bt_field_path_item_type;
-
-typedef enum bt_scope {
- BT_SCOPE_PACKET_CONTEXT,
- BT_SCOPE_EVENT_COMMON_CONTEXT,
- BT_SCOPE_EVENT_SPECIFIC_CONTEXT,
- BT_SCOPE_EVENT_PAYLOAD,
-} bt_scope;
-
-extern bt_scope bt_field_path_get_root_scope(
- const bt_field_path *field_path);
-
-extern uint64_t bt_field_path_get_item_count(
- const bt_field_path *field_path);
-
-extern const bt_field_path_item *bt_field_path_borrow_item_by_index_const(
- const bt_field_path *field_path, uint64_t index);
-
-extern bt_field_path_item_type bt_field_path_item_get_type(
- const bt_field_path_item *field_path_item);
-
-extern uint64_t bt_field_path_item_index_get_index(
- const bt_field_path_item *field_path_item);
-
-extern void bt_field_path_get_ref(const bt_field_path *field_path);
-
-extern void bt_field_path_put_ref(const bt_field_path *field_path);
-
-#define BT_FIELD_PATH_PUT_REF_AND_RESET(_var) \
- do { \
- bt_field_path_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_FIELD_PATH_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_field_path_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
-#define BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/field-path-const.h>
-#include <babeltrace/assert-internal.h>
-#include <glib.h>
-
-struct bt_field_path_item {
- enum bt_field_path_item_type type;
- uint64_t index;
-};
-
-struct bt_field_path {
- struct bt_object base;
- enum bt_scope root;
-
- /* Array of `struct bt_field_path_item` (items) */
- GArray *items;
-};
-
-BT_HIDDEN
-struct bt_field_path *bt_field_path_create(void);
-
-static inline
-struct bt_field_path_item *bt_field_path_borrow_item_by_index_inline(
- const struct bt_field_path *field_path, uint64_t index)
-{
- BT_ASSERT(field_path);
- BT_ASSERT(index < field_path->items->len);
- return &g_array_index(field_path->items, struct bt_field_path_item,
- index);
-}
-
-static inline
-void bt_field_path_append_item(struct bt_field_path *field_path,
- struct bt_field_path_item *item)
-{
- BT_ASSERT(field_path);
- BT_ASSERT(item);
- g_array_append_val(field_path->items, *item);
-}
-
-static inline
-void bt_field_path_remove_last_item(struct bt_field_path *field_path)
-{
- BT_ASSERT(field_path);
- BT_ASSERT(field_path->items->len > 0);
- g_array_set_size(field_path->items, field_path->items->len - 1);
-}
-
-static inline
-const char *bt_field_path_item_type_string(enum bt_field_path_item_type type)
-{
- switch (type) {
- case BT_FIELD_PATH_ITEM_TYPE_INDEX:
- return "BT_FIELD_PATH_ITEM_TYPE_INDEX";
- case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
- return "BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT";
- default:
- return "(unknown)";
- }
-};
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H
-#define BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/object-internal.h>
-
-struct bt_field_wrapper {
- struct bt_object base;
-
- /* Owned by this */
- struct bt_field *field;
-};
-
-BT_HIDDEN
-struct bt_field_wrapper *bt_field_wrapper_new(void *data);
-
-BT_HIDDEN
-void bt_field_wrapper_destroy(struct bt_field_wrapper *field);
-
-BT_HIDDEN
-struct bt_field_wrapper *bt_field_wrapper_create(
- struct bt_object_pool *pool, struct bt_field_class *fc);
-
-#endif /* BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_FIELDS_H
-#define BABELTRACE_TRACE_IR_FIELDS_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_field, bt_field_class */
-#include <babeltrace/types.h>
-
-/* For bt_field_status */
-#include <babeltrace/trace-ir/field-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void bt_field_signed_integer_set_value(bt_field *field,
- int64_t value);
-
-extern void bt_field_unsigned_integer_set_value(bt_field *field,
- uint64_t value);
-
-extern void bt_field_real_set_value(bt_field *field, double value);
-
-extern bt_field_status bt_field_string_set_value(bt_field *field,
- const char *value);
-
-extern bt_field_status bt_field_string_append(bt_field *field,
- const char *value);
-
-extern bt_field_status bt_field_string_append_with_length(bt_field *field,
- const char *value, uint64_t length);
-
-extern bt_field_status bt_field_string_clear(bt_field *field);
-
-extern bt_field *bt_field_structure_borrow_member_field_by_index(
- bt_field *field, uint64_t index);
-
-extern bt_field *bt_field_structure_borrow_member_field_by_name(
- bt_field *field, const char *name);
-
-extern bt_field *bt_field_array_borrow_element_field_by_index(
- bt_field *field, uint64_t index);
-
-extern bt_field_status bt_field_dynamic_array_set_length(bt_field *field,
- uint64_t length);
-
-extern bt_field_status bt_field_variant_select_option_field(
- bt_field *field, uint64_t index);
-
-extern bt_field *bt_field_variant_borrow_selected_option_field(
- bt_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_FIELDS_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_PACKET_CONST_H
-#define BABELTRACE_TRACE_IR_PACKET_CONST_H
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/* For bt_property_availability */
-#include <babeltrace/property.h>
-
-/*
- * For bt_packet, bt_packet_context_field, bt_stream
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_packet_status {
- BT_PACKET_STATUS_OK = 0,
- BT_PACKET_STATUS_NOMEM = -12,
-} bt_packet_status;
-
-extern const bt_stream *bt_packet_borrow_stream_const(
- const bt_packet *packet);
-
-extern
-const bt_field *bt_packet_borrow_context_field_const(
- const bt_packet *packet);
-
-extern void bt_packet_get_ref(const bt_packet *packet);
-
-extern void bt_packet_put_ref(const bt_packet *packet);
-
-#define BT_PACKET_PUT_REF_AND_RESET(_var) \
- do { \
- bt_packet_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_PACKET_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_packet_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_PACKET_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H
-#define BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H
-
-/*
- * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_stream_class, bt_packet_context_field, bt_field */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern
-bt_packet_context_field *bt_packet_context_field_create(
- bt_stream_class *stream_class);
-
-extern
-bt_field *bt_packet_context_field_borrow_field(
- bt_packet_context_field *field);
-
-extern
-void bt_packet_context_field_release(
- bt_packet_context_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_PACKET_INTERNAL_H
-#define BABELTRACE_TRACE_IR_PACKET_INTERNAL_H
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdbool.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-const.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/property-internal.h>
-
-struct bt_packet {
- struct bt_object base;
- struct bt_field_wrapper *context_field;
- struct bt_stream *stream;
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_packet_set_is_frozen(const struct bt_packet *packet, bool is_frozen);
-
-#ifdef BT_DEV_MODE
-# define bt_packet_set_is_frozen _bt_packet_set_is_frozen
-#else
-# define bt_packet_set_is_frozen(_packet, _is_frozen)
-#endif /* BT_DEV_MODE */
-
-BT_HIDDEN
-struct bt_packet *bt_packet_new(struct bt_stream *stream);
-
-BT_HIDDEN
-void bt_packet_recycle(struct bt_packet *packet);
-
-BT_HIDDEN
-void bt_packet_destroy(struct bt_packet *packet);
-
-#endif /* BABELTRACE_TRACE_IR_PACKET_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_PACKET_H
-#define BABELTRACE_TRACE_IR_PACKET_H
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_packet, bt_packet_context_field, bt_stream */
-#include <babeltrace/types.h>
-
-/* For bt_packet_status */
-#include <babeltrace/trace-ir/packet-const.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_packet *bt_packet_create(const bt_stream *stream);
-
-extern bt_stream *bt_packet_borrow_stream(bt_packet *packet);
-
-extern
-bt_field *bt_packet_borrow_context_field(bt_packet *packet);
-
-extern
-bt_packet_status bt_packet_move_context_field(bt_packet *packet,
- bt_packet_context_field *context);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_PACKET_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL
-#define BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL
-
-/*
- * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/field-class-const.h>
-#include <babeltrace/trace-ir/field-path-const.h>
-#include <glib.h>
-
-struct bt_resolve_field_path_context {
- struct bt_field_class *packet_context;
- struct bt_field_class *event_common_context;
- struct bt_field_class *event_specific_context;
- struct bt_field_class *event_payload;
-};
-
-BT_HIDDEN
-int bt_resolve_field_paths(struct bt_field_class *field_class,
- struct bt_resolve_field_path_context *ctx);
-
-#endif /* BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H
-#define BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/*
- * For bt_bool, bt_trace_class, bt_stream_class, bt_event_class,
- * bt_stream_class
- */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_stream_class_status {
- BT_STREAM_CLASS_STATUS_OK = 0,
- BT_STREAM_CLASS_STATUS_NOMEM = -12,
-} bt_stream_class_status;
-
-extern const bt_trace_class *bt_stream_class_borrow_trace_class_const(
- const bt_stream_class *stream_class);
-
-extern const char *bt_stream_class_get_name(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_assigns_automatic_event_class_id(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_assigns_automatic_stream_id(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_packets_have_end_default_clock_snapshot(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_supports_discarded_events(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_supports_discarded_packets(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots(
- const bt_stream_class *stream_class);
-
-extern bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots(
- const bt_stream_class *stream_class);
-
-extern uint64_t bt_stream_class_get_id(
- const bt_stream_class *stream_class);
-
-extern const bt_field_class *
-bt_stream_class_borrow_packet_context_field_class_const(
- const bt_stream_class *stream_class);
-
-extern const bt_field_class *
-bt_stream_class_borrow_event_common_context_field_class_const(
- const bt_stream_class *stream_class);
-
-extern uint64_t bt_stream_class_get_event_class_count(
- const bt_stream_class *stream_class);
-
-extern const bt_event_class *
-bt_stream_class_borrow_event_class_by_index_const(
- const bt_stream_class *stream_class, uint64_t index);
-
-extern const bt_event_class *
-bt_stream_class_borrow_event_class_by_id_const(
- const bt_stream_class *stream_class, uint64_t id);
-
-extern const bt_clock_class *
-bt_stream_class_borrow_default_clock_class_const(
- const bt_stream_class *stream_class);
-
-extern void bt_stream_class_get_ref(const bt_stream_class *stream_class);
-
-extern void bt_stream_class_put_ref(const bt_stream_class *stream_class);
-
-#define BT_STREAM_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_stream_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_STREAM_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_stream_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-#include <inttypes.h>
-
-struct bt_stream_class {
- struct bt_object base;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- uint64_t id;
- bool assigns_automatic_event_class_id;
- bool assigns_automatic_stream_id;
- bool packets_have_beginning_default_clock_snapshot;
- bool packets_have_end_default_clock_snapshot;
- bool supports_discarded_events;
- bool supports_discarded_packets;
- bool discarded_events_have_default_clock_snapshots;
- bool discarded_packets_have_default_clock_snapshots;
- struct bt_field_class *packet_context_fc;
- struct bt_field_class *event_common_context_fc;
- struct bt_clock_class *default_clock_class;
-
- /* Array of `struct bt_event_class *` */
- GPtrArray *event_classes;
-
- /* Pool of `struct bt_field_wrapper *` */
- struct bt_object_pool packet_context_field_pool;
-
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_stream_class_freeze(const struct bt_stream_class *stream_class);
-
-#ifdef BT_DEV_MODE
-# define bt_stream_class_freeze _bt_stream_class_freeze
-#else
-# define bt_stream_class_freeze(_sc)
-#endif
-
-static inline
-struct bt_trace_class *bt_stream_class_borrow_trace_class_inline(
- const struct bt_stream_class *stream_class)
-{
- BT_ASSERT(stream_class);
- return (void *) bt_object_borrow_parent(&stream_class->base);
-}
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_H
-#define BABELTRACE_TRACE_IR_STREAM_CLASS_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-#include <stdint.h>
-
-/*
- * For bt_bool, bt_trace_class, bt_stream_class, bt_event_class,
- * bt_clock_class
- */
-#include <babeltrace/types.h>
-
-/* For bt_stream_class_status */
-#include <babeltrace/trace-ir/stream-class-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_stream_class *bt_stream_class_create(
- bt_trace_class *trace_class);
-
-extern bt_stream_class *bt_stream_class_create_with_id(
- bt_trace_class *trace_class, uint64_t id);
-
-extern bt_trace_class *bt_stream_class_borrow_trace_class(
- bt_stream_class *stream_class);
-
-extern bt_stream_class_status bt_stream_class_set_name(
- bt_stream_class *stream_class, const char *name);
-
-extern void bt_stream_class_set_assigns_automatic_event_class_id(
- bt_stream_class *stream_class, bt_bool value);
-
-extern void bt_stream_class_set_assigns_automatic_stream_id(
- bt_stream_class *stream_class, bt_bool value);
-
-extern void bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
- bt_stream_class *stream_class, bt_bool value);
-
-extern void bt_stream_class_set_packets_have_end_default_clock_snapshot(
- bt_stream_class *stream_class, bt_bool value);
-
-extern void bt_stream_class_set_supports_discarded_events(
- bt_stream_class *stream_class,
- bt_bool supports_discarded_events,
- bt_bool with_default_clock_snapshots);
-
-extern void bt_stream_class_set_supports_discarded_packets(
- bt_stream_class *stream_class,
- bt_bool supports_discarded_packets,
- bt_bool with_default_clock_snapshots);
-
-extern bt_stream_class_status
-bt_stream_class_set_packet_context_field_class(
- bt_stream_class *stream_class,
- bt_field_class *field_class);
-
-extern bt_field_class *
-bt_stream_class_borrow_packet_context_field_class(
- bt_stream_class *stream_class);
-
-extern bt_stream_class_status
-bt_stream_class_set_event_common_context_field_class(
- bt_stream_class *stream_class,
- bt_field_class *field_class);
-
-extern bt_field_class *
-bt_stream_class_borrow_event_common_context_field_class(
- bt_stream_class *stream_class);
-
-extern bt_event_class *
-bt_stream_class_borrow_event_class_by_index(
- bt_stream_class *stream_class, uint64_t index);
-
-extern bt_event_class *
-bt_stream_class_borrow_event_class_by_id(
- bt_stream_class *stream_class, uint64_t id);
-
-extern bt_clock_class *bt_stream_class_borrow_default_clock_class(
- bt_stream_class *stream_class);
-
-extern bt_stream_class_status bt_stream_class_set_default_clock_class(
- bt_stream_class *stream_class,
- bt_clock_class *clock_class);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_CONST_H
-#define BABELTRACE_TRACE_IR_STREAM_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_trace, bt_stream, bt_stream_class */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_stream_status {
- BT_STREAM_STATUS_OK = 0,
- BT_STREAM_STATUS_NOMEM = -12,
-} bt_stream_status;
-
-extern const bt_stream_class *bt_stream_borrow_class_const(
- const bt_stream *stream);
-
-extern const bt_trace *bt_stream_borrow_trace_const(
- const bt_stream *stream);
-
-extern const char *bt_stream_get_name(const bt_stream *stream);
-
-extern uint64_t bt_stream_get_id(const bt_stream *stream);
-
-extern void bt_stream_get_ref(const bt_stream *stream);
-
-extern void bt_stream_put_ref(const bt_stream *stream);
-
-#define BT_STREAM_PUT_REF_AND_RESET(_var) \
- do { \
- bt_stream_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_STREAM_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_stream_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_INTERNAL_H
-#define BABELTRACE_TRACE_IR_STREAM_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-
-struct bt_stream_class;
-struct bt_stream;
-
-struct bt_stream {
- struct bt_object base;
-
- /* Owned by this */
- struct bt_stream_class *class;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- uint64_t id;
-
- /* Pool of `struct bt_packet *` */
- struct bt_object_pool packet_pool;
-
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_stream_freeze(const struct bt_stream *stream);
-
-#ifdef BT_DEV_MODE
-# define bt_stream_freeze _bt_stream_freeze
-#else
-# define bt_stream_freeze(_stream)
-#endif
-
-static inline
-struct bt_trace *bt_stream_borrow_trace_inline(const struct bt_stream *stream)
-{
- BT_ASSERT(stream);
- return (void *) bt_object_borrow_parent(&stream->base);
-}
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_STREAM_H
-#define BABELTRACE_TRACE_IR_STREAM_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_trace, bt_stream, bt_stream_class */
-#include <babeltrace/types.h>
-
-/* For bt_stream_status */
-#include <babeltrace/trace-ir/stream-const.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_stream *bt_stream_create(bt_stream_class *stream_class,
- bt_trace *trace);
-
-extern bt_stream *bt_stream_create_with_id(
- bt_stream_class *stream_class,
- bt_trace *trace, uint64_t id);
-
-extern bt_trace *bt_stream_borrow_trace(bt_stream *stream);
-
-extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream);
-
-extern bt_stream_status bt_stream_set_name(bt_stream *stream,
- const char *name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_STREAM_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
-#define BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/*
- * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class,
- * bt_field_class, bt_value
- */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_trace_class_status {
- BT_TRACE_CLASS_STATUS_OK = 0,
- BT_TRACE_CLASS_STATUS_NOMEM = -12,
-} bt_trace_class_status;
-
-typedef void (* bt_trace_class_destruction_listener_func)(
- const bt_trace_class *trace_class, void *data);
-
-extern bt_bool bt_trace_class_assigns_automatic_stream_class_id(
- const bt_trace_class *trace_class);
-
-extern const char *bt_trace_class_get_name(
- const bt_trace_class *trace_class);
-
-extern bt_uuid bt_trace_class_get_uuid(
- const bt_trace_class *trace_class);
-
-extern uint64_t bt_trace_class_get_environment_entry_count(
- const bt_trace_class *trace_class);
-
-extern void bt_trace_class_borrow_environment_entry_by_index_const(
- const bt_trace_class *trace_class, uint64_t index,
- const char **name, const bt_value **value);
-
-extern const bt_value *
-bt_trace_class_borrow_environment_entry_value_by_name_const(
- const bt_trace_class *trace_class, const char *name);
-
-extern uint64_t bt_trace_class_get_stream_class_count(
- const bt_trace_class *trace_class);
-
-extern const bt_stream_class *
-bt_trace_class_borrow_stream_class_by_index_const(
- const bt_trace_class *trace_class, uint64_t index);
-
-extern const bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const(
- const bt_trace_class *trace_class, uint64_t id);
-
-extern bt_trace_class_status bt_trace_class_add_destruction_listener(
- const bt_trace_class *trace_class,
- bt_trace_class_destruction_listener_func listener,
- void *data, uint64_t *listener_id);
-
-extern bt_trace_class_status bt_trace_class_remove_destruction_listener(
- const bt_trace_class *trace_class, uint64_t listener_id);
-
-extern void bt_trace_class_get_ref(const bt_trace_class *trace_class);
-
-extern void bt_trace_class_put_ref(const bt_trace_class *trace_class);
-
-#define BT_TRACE_CLASS_PUT_REF_AND_RESET(_var) \
- do { \
- bt_trace_class_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_TRACE_CLASS_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_trace_class_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/trace-class.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-#include <sys/types.h>
-#include <babeltrace/compat/uuid-internal.h>
-
-struct bt_trace_class {
- struct bt_object base;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- struct {
- uint8_t uuid[BABELTRACE_UUID_LEN];
-
- /* NULL or `uuid` above */
- bt_uuid value;
- } uuid;
-
- struct bt_value *environment;
-
- /* Array of `struct bt_stream_class *` */
- GPtrArray *stream_classes;
-
- bool assigns_automatic_stream_class_id;
- GArray *destruction_listeners;
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_trace_class_freeze(const struct bt_trace_class *trace_class);
-
-#ifdef BT_DEV_MODE
-# define bt_trace_class_freeze _bt_trace_class_freeze
-#else
-# define bt_trace_class_freeze(_tc)
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_H
-#define BABELTRACE_TRACE_IR_TRACE_CLASS_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/*
- * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class,
- * bt_field_class, bt_self_component
- */
-#include <babeltrace/types.h>
-
-/* For bt_trace_class_status */
-#include <babeltrace/trace-ir/trace-class-const.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_trace_class *bt_trace_class_create(bt_self_component *self_comp);
-
-extern void bt_trace_class_set_assigns_automatic_stream_class_id(
- bt_trace_class *trace_class, bt_bool value);
-
-extern bt_trace_class_status bt_trace_class_set_name(
- bt_trace_class *trace_class, const char *name);
-
-extern void bt_trace_class_set_uuid(bt_trace_class *trace_class,
- bt_uuid uuid);
-
-extern bt_trace_class_status bt_trace_class_set_environment_entry_integer(
- bt_trace_class *trace_class,
- const char *name, int64_t value);
-
-extern bt_trace_class_status bt_trace_class_set_environment_entry_string(
- bt_trace_class *trace_class,
- const char *name, const char *value);
-
-extern bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
- bt_trace_class *trace_class, uint64_t index);
-
-extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id(
- bt_trace_class *trace_class, uint64_t id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_CONST_H
-#define BABELTRACE_TRACE_IR_TRACE_CONST_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/*
- * For bt_bool, bt_uuid, bt_trace, bt_stream, bt_stream_class,
- * bt_field_class, bt_value
- */
-#include <babeltrace/types.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_trace_status {
- BT_TRACE_STATUS_OK = 0,
- BT_TRACE_STATUS_NOMEM = -12,
-} bt_trace_status;
-
-typedef void (* bt_trace_destruction_listener_func)(
- const bt_trace *trace, void *data);
-
-extern const bt_trace_class *bt_trace_borrow_class_const(
- const bt_trace *trace);
-
-extern const char *bt_trace_get_name(const bt_trace *trace);
-
-extern uint64_t bt_trace_get_stream_count(const bt_trace *trace);
-
-extern const bt_stream *bt_trace_borrow_stream_by_index_const(
- const bt_trace *trace, uint64_t index);
-
-extern const bt_stream *bt_trace_borrow_stream_by_id_const(
- const bt_trace *trace, uint64_t id);
-
-extern bt_trace_status bt_trace_add_destruction_listener(
- const bt_trace *trace,
- bt_trace_destruction_listener_func listener,
- void *data, uint64_t *listener_id);
-
-extern bt_trace_status bt_trace_remove_destruction_listener(
- const bt_trace *trace, uint64_t listener_id);
-
-extern void bt_trace_get_ref(const bt_trace *trace);
-
-extern void bt_trace_put_ref(const bt_trace *trace);
-
-#define BT_TRACE_PUT_REF_AND_RESET(_var) \
- do { \
- bt_trace_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_TRACE_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_trace_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_INTERNAL_H
-#define BABELTRACE_TRACE_IR_TRACE_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/trace-class-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-#include <sys/types.h>
-#include <babeltrace/compat/uuid-internal.h>
-
-struct bt_trace {
- struct bt_object base;
-
- /* Owned by this */
- struct bt_trace_class *class;
-
- struct {
- GString *str;
-
- /* NULL or `str->str` above */
- const char *value;
- } name;
-
- /* Array of `struct bt_stream *` */
- GPtrArray *streams;
-
- /*
- * Stream class (weak, owned by owned trace class) to number of
- * instantiated streams, used to automatically assign stream IDs
- * per stream class within this trace.
- */
- GHashTable *stream_classes_stream_count;
-
- GArray *destruction_listeners;
- bool frozen;
-};
-
-BT_HIDDEN
-void _bt_trace_freeze(const struct bt_trace *trace);
-
-#ifdef BT_DEV_MODE
-# define bt_trace_freeze _bt_trace_freeze
-#else
-# define bt_trace_freeze(_trace)
-#endif
-
-BT_HIDDEN
-void bt_trace_add_stream(struct bt_trace *trace, struct bt_stream *stream);
-
-BT_HIDDEN
-uint64_t bt_trace_get_automatic_stream_id(const struct bt_trace *trace,
- const struct bt_stream_class *stream_class);
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_TRACE_H
-#define BABELTRACE_TRACE_IR_TRACE_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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.
- *
- * The Common Trace Format (CTF) Specification is available at
- * http://www.efficios.com/ctf
- */
-
-/* For bt_bool, bt_trace, bt_trace_class, bt_stream */
-#include <babeltrace/types.h>
-
-/* For bt_trace_status */
-#include <babeltrace/trace-ir/trace-const.h>
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace);
-
-extern bt_trace *bt_trace_create(bt_trace_class *trace_class);
-
-extern bt_trace_status bt_trace_set_name(bt_trace *trace,
- const char *name);
-
-extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace,
- uint64_t index);
-
-extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace,
- uint64_t id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TRACE_IR_TRACE_H */
+++ /dev/null
-#ifndef BABELTRACE_TRACE_IR_UTILS_INTERNAL_H
-#define BABELTRACE_TRACE_IR_UTILS_INTERNAL_H
-
-/*
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/babeltrace-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <stdint.h>
-
-struct search_query {
- gpointer value;
- int found;
-};
-
-static inline
-uint64_t bt_util_ns_from_value(uint64_t frequency, uint64_t value_cycles)
-{
- uint64_t ns;
-
- if (frequency == UINT64_C(1000000000)) {
- ns = value_cycles;
- } else {
- double dblres = ((1e9 * (double) value_cycles) / (double) frequency);
-
- if (dblres >= (double) UINT64_MAX) {
- /* Overflows uint64_t */
- ns = UINT64_C(-1);
- } else {
- ns = (uint64_t) dblres;
- }
- }
-
- return ns;
-}
-
-static inline
-bool bt_util_get_base_offset_ns(int64_t offset_seconds, uint64_t offset_cycles,
- uint64_t frequency, int64_t *base_offset_ns)
-{
- bool overflows = false;
- uint64_t offset_cycles_ns;
-
- BT_ASSERT(base_offset_ns);
-
- /* Initialize nanosecond timestamp to clock's offset in seconds */
- if (offset_seconds <= (INT64_MIN / INT64_C(1000000000) - 1) ||
- offset_seconds >= (INT64_MAX / INT64_C(1000000000)) - 1) {
- /*
- * Overflow: offset in seconds converted to nanoseconds
- * is outside the int64_t range. We also subtract 1 here
- * to leave "space" for the offset in cycles converted
- * to nanoseconds (which is always less than 1 second by
- * contract).
- */
- overflows = true;
- goto end;
- }
-
- /* Offset (seconds) to nanoseconds */
- *base_offset_ns = offset_seconds * INT64_C(1000000000);
-
- /* Add offset in cycles */
- BT_ASSERT(offset_cycles < frequency);
- offset_cycles_ns = bt_util_ns_from_value(frequency,
- offset_cycles);
- BT_ASSERT(offset_cycles_ns < 1000000000);
- *base_offset_ns += (int64_t) offset_cycles_ns;
-
-end:
- return overflows;
-}
-
-static inline
-int bt_util_ns_from_origin_inline(int64_t base_offset_ns,
- int64_t offset_seconds, uint64_t offset_cycles,
- uint64_t frequency, uint64_t value, int64_t *ns_from_origin)
-{
- int ret = 0;
- uint64_t value_ns_unsigned;
- int64_t value_ns_signed;
-
- /* Initialize to clock class's base offset */
- *ns_from_origin = base_offset_ns;
-
- /* Add given value in cycles */
- value_ns_unsigned = bt_util_ns_from_value(frequency, value);
- if (value_ns_unsigned >= (uint64_t) INT64_MAX) {
- /*
- * FIXME: `value_ns_unsigned` could be greater than
- * `INT64_MAX` in fact: in this case, we need to
- * subtract `INT64_MAX` from `value_ns_unsigned`, make
- * sure that the difference is less than `INT64_MAX`,
- * and try to add them one after the other to
- * `*ns_from_origin`.
- */
- ret = -1;
- goto end;
- }
-
- value_ns_signed = (int64_t) value_ns_unsigned;
- BT_ASSERT(value_ns_signed >= 0);
-
- if (*ns_from_origin <= 0) {
- goto add_value;
- }
-
- if (value_ns_signed > INT64_MAX - *ns_from_origin) {
- ret = -1;
- goto end;
- }
-
-add_value:
- *ns_from_origin += value_ns_signed;
-
-end:
- return ret;
-}
-
-static inline
-int bt_util_ns_from_origin_clock_class(const struct bt_clock_class *clock_class,
- uint64_t value, int64_t *ns_from_origin)
-{
- int ret = 0;
-
- if (clock_class->base_offset.overflows) {
- ret = -1;
- goto end;
- }
-
- ret = bt_util_ns_from_origin_inline(clock_class->base_offset.value_ns,
- clock_class->offset_seconds, clock_class->offset_cycles,
- clock_class->frequency, value, ns_from_origin);
-
-end:
- return ret;
-}
-
-static inline
-bool bt_util_value_is_in_range_signed(uint64_t size, int64_t value)
-{
- int64_t min_value = UINT64_C(-1) << (size - 1);
- int64_t max_value = (UINT64_C(1) << (size - 1)) - 1;
- return value >= min_value && value <= max_value;
-}
-
-static inline
-bool bt_util_value_is_in_range_unsigned(unsigned int size, uint64_t value)
-{
- uint64_t max_value = (size == 64) ? UINT64_MAX :
- (UINT64_C(1) << size) - 1;
- return value <= max_value;
-}
-
-#endif /* BABELTRACE_TRACE_IR_UTILS_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_TYPES_H
-#define BABELTRACE_TYPES_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-/* Internal use */
-#ifdef __cplusplus
-# define __BT_UPCAST(_type, _p) static_cast<_type *>(static_cast<void *>(_p))
-# define __BT_UPCAST_CONST(_type, _p) static_cast<const _type *>(static_cast<const void *>(_p))
-#else
-# define __BT_UPCAST(_type, _p) ((_type *) (_p))
-# define __BT_UPCAST_CONST(_type, _p) ((const _type *) (_p))
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-@defgroup ctypes Babeltrace C types
-@ingroup apiref
-@brief Babeltrace C types.
-
-@code
-#include <babeltrace/types.h>
-@endcode
-
-This header contains custom type definitions used across the library.
-
-@file
-@brief Babeltrace C types.
-@sa ctypes
-
-@addtogroup ctypes
-@{
-*/
-
-/// False boolean value for the #bt_bool type.
-#define BT_FALSE 0
-
-/// True boolean value for the #bt_bool type.
-#define BT_TRUE 1
-
-/**
-@brief Babeltrace's boolean type.
-
-Use only the #BT_FALSE and #BT_TRUE definitions for #bt_bool parameters.
-It is guaranteed that the library functions which return a #bt_bool
-value return either #BT_FALSE or #BT_TRUE.
-
-You can always test the truthness of a #bt_bool value directly, without
-comparing it to #BT_TRUE directly:
-
-@code
-bt_bool ret = bt_some_function(...);
-
-if (ret) {
- // ret is true
-}
-@endcode
-*/
-typedef int bt_bool;
-
-typedef const uint8_t *bt_uuid;
-
-typedef struct bt_clock_class bt_clock_class;
-typedef struct bt_clock_snapshot bt_clock_snapshot;
-typedef struct bt_component bt_component;
-typedef struct bt_component_class bt_component_class;
-typedef struct bt_component_class_filter bt_component_class_filter;
-typedef struct bt_component_class_sink bt_component_class_sink;
-typedef struct bt_component_class_source bt_component_class_source;
-typedef struct bt_component_filter bt_component_filter;
-typedef struct bt_component_sink bt_component_sink;
-typedef struct bt_component_source bt_component_source;
-typedef struct bt_connection bt_connection;
-typedef struct bt_event bt_event;
-typedef struct bt_event_class bt_event_class;
-typedef struct bt_event_header_field bt_event_header_field;
-typedef struct bt_field bt_field;
-typedef struct bt_field_class bt_field_class;
-typedef struct bt_field_class_enumeration_mapping bt_field_class_enumeration_mapping;
-typedef struct bt_field_class_signed_enumeration_mapping bt_field_class_signed_enumeration_mapping;
-typedef struct bt_field_class_unsigned_enumeration_mapping bt_field_class_unsigned_enumeration_mapping;
-typedef struct bt_field_class_structure_member bt_field_class_structure_member;
-typedef struct bt_field_class_variant_option bt_field_class_variant_option;
-typedef struct bt_field_path bt_field_path;
-typedef struct bt_field_path_item bt_field_path_item;
-typedef struct bt_graph bt_graph;
-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;
-typedef struct bt_packet_header_field bt_packet_header_field;
-typedef struct bt_plugin bt_plugin;
-typedef struct bt_plugin_set bt_plugin_set;
-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_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;
-typedef struct bt_self_component_class_sink bt_self_component_class_sink;
-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_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_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_stream bt_stream;
-typedef struct bt_stream_class bt_stream_class;
-typedef struct bt_trace bt_trace;
-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_message **bt_message_array_const;
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_TYPES_H */
+++ /dev/null
-#ifndef BABELTRACE_UTIL_H
-#define BABELTRACE_UTIL_H
-
-/*
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_util_status {
- BT_UTIL_STATUS_OK = 0,
- BT_UTIL_STATUS_OVERFLOW = -75,
-} bt_util_status;
-
-bt_util_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
- uint64_t frequency, int64_t offset_seconds,
- uint64_t offset_cycles, int64_t *ns);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_UTIL_H */
+++ /dev/null
-#ifndef BABELTRACE_VALUES_CONST_H
-#define BABELTRACE_VALUES_CONST_H
-
-/*
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-#include <stddef.h>
-
-/* For bt_bool, bt_value */
-#include <babeltrace/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum bt_value_status {
- /// Operation canceled.
- BT_VALUE_STATUS_CANCELED = 125,
-
- /// Cannot allocate memory.
- BT_VALUE_STATUS_NOMEM = -12,
-
- /// Okay, no error.
- BT_VALUE_STATUS_OK = 0,
-} bt_value_status;
-
-typedef enum bt_value_type {
- /// Null value object.
- BT_VALUE_TYPE_NULL = 0,
-
- /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
- BT_VALUE_TYPE_BOOL = 1,
-
- /// Unsigned integer value object (holds an unsigned 64-bit integer raw value).
- BT_VALUE_TYPE_UNSIGNED_INTEGER = 2,
-
- /// Signed integer value object (holds a signed 64-bit integer raw value).
- BT_VALUE_TYPE_SIGNED_INTEGER = 3,
-
- /// Floating point number value object (holds a \c double raw value).
- BT_VALUE_TYPE_REAL = 4,
-
- /// String value object.
- BT_VALUE_TYPE_STRING = 5,
-
- /// Array value object.
- BT_VALUE_TYPE_ARRAY = 6,
-
- /// Map value object.
- BT_VALUE_TYPE_MAP = 7,
-} bt_value_type;
-
-extern bt_value_type bt_value_get_type(const bt_value *object);
-
-static inline
-bt_bool bt_value_is_null(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_NULL;
-}
-
-static inline
-bt_bool bt_value_is_bool(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
-}
-
-static inline
-bt_bool bt_value_is_unsigned_integer(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_UNSIGNED_INTEGER;
-}
-
-static inline
-bt_bool bt_value_is_signed_integer(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_SIGNED_INTEGER;
-}
-
-static inline
-bt_bool bt_value_is_real(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
-}
-
-static inline
-bt_bool bt_value_is_string(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
-}
-
-static inline
-bt_bool bt_value_is_array(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
-}
-
-static inline
-bt_bool bt_value_is_map(const bt_value *object)
-{
- return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
-}
-
-extern bt_value_status bt_value_copy(const bt_value *object,
- bt_value **copy);
-
-extern bt_bool bt_value_compare(const bt_value *object_a,
- const bt_value *object_b);
-
-extern bt_bool bt_value_bool_get(const bt_value *bool_obj);
-
-extern uint64_t bt_value_unsigned_integer_get(const bt_value *integer_obj);
-
-extern int64_t bt_value_signed_integer_get(const bt_value *integer_obj);
-
-extern double bt_value_real_get(const bt_value *real_obj);
-
-extern const char *bt_value_string_get(const bt_value *string_obj);
-
-extern uint64_t bt_value_array_get_size(const bt_value *array_obj);
-
-static inline
-bt_bool bt_value_array_is_empty(const bt_value *array_obj)
-{
- return bt_value_array_get_size(array_obj) == 0;
-}
-
-extern const bt_value *bt_value_array_borrow_element_by_index_const(
- const bt_value *array_obj, uint64_t index);
-
-extern uint64_t bt_value_map_get_size(const bt_value *map_obj);
-
-static inline
-bt_bool bt_value_map_is_empty(const bt_value *map_obj)
-{
- return bt_value_map_get_size(map_obj) == 0;
-}
-
-extern const bt_value *bt_value_map_borrow_entry_value_const(
- const bt_value *map_obj, const char *key);
-
-typedef bt_bool (* bt_value_map_foreach_entry_const_func)(const char *key,
- const bt_value *object, void *data);
-
-extern bt_value_status bt_value_map_foreach_entry_const(
- const bt_value *map_obj,
- bt_value_map_foreach_entry_const_func func, void *data);
-
-extern bt_bool bt_value_map_has_entry(const bt_value *map_obj,
- const char *key);
-
-extern bt_value_status bt_value_map_extend(
- const bt_value *base_map_obj,
- const bt_value *extension_map_obj,
- bt_value **extended_map_obj);
-
-extern void bt_value_get_ref(const bt_value *value);
-
-extern void bt_value_put_ref(const bt_value *value);
-
-#define BT_VALUE_PUT_REF_AND_RESET(_var) \
- do { \
- bt_value_put_ref(_var); \
- (_var) = NULL; \
- } while (0)
-
-#define BT_VALUE_MOVE_REF(_var_dst, _var_src) \
- do { \
- bt_value_put_ref(_var_dst); \
- (_var_dst) = (_var_src); \
- (_var_src) = NULL; \
- } while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_VALUES_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_VALUES_INTERNAL_H
-#define BABELTRACE_VALUES_INTERNAL_H
-
-/*
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <babeltrace/object-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/types.h>
-#include <glib.h>
-
-struct bt_value {
- struct bt_object base;
- enum bt_value_type type;
- bt_bool frozen;
-};
-
-struct bt_value_bool {
- struct bt_value base;
- bt_bool value;
-};
-
-struct bt_value_integer {
- struct bt_value base;
- union {
- uint64_t i;
- int64_t u;
- } value;
-};
-
-struct bt_value_real {
- struct bt_value base;
- double value;
-};
-
-struct bt_value_string {
- struct bt_value base;
- GString *gstr;
-};
-
-struct bt_value_array {
- struct bt_value base;
- GPtrArray *garray;
-};
-
-struct bt_value_map {
- struct bt_value base;
- GHashTable *ght;
-};
-
-BT_HIDDEN
-enum bt_value_status _bt_value_freeze(const struct bt_value *object);
-
-#ifdef BT_DEV_MODE
-# define bt_value_freeze _bt_value_freeze
-#else
-# define bt_value_freeze(_value)
-#endif /* BT_DEV_MODE */
-
-#endif /* BABELTRACE_VALUES_INTERNAL_H */
+++ /dev/null
-#ifndef BABELTRACE_VALUES_H
-#define BABELTRACE_VALUES_H
-
-/*
- * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 <stdint.h>
-#include <stddef.h>
-
-/* For bt_bool, bt_value */
-#include <babeltrace/types.h>
-
-/* For bt_value_status, bt_value_type */
-#include <babeltrace/value-const.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bt_value *const bt_value_null;
-
-extern bt_value *bt_value_bool_create(void);
-
-extern bt_value *bt_value_bool_create_init(bt_bool val);
-
-extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val);
-
-extern bt_value *bt_value_unsigned_integer_create(void);
-
-extern bt_value *bt_value_unsigned_integer_create_init(uint64_t val);
-
-extern void bt_value_unsigned_integer_set(bt_value *integer_obj, uint64_t val);
-
-extern bt_value *bt_value_signed_integer_create(void);
-
-extern bt_value *bt_value_signed_integer_create_init(int64_t val);
-
-extern void bt_value_signed_integer_set(bt_value *integer_obj, int64_t val);
-
-extern bt_value *bt_value_real_create(void);
-
-extern bt_value *bt_value_real_create_init(double val);
-
-extern void bt_value_real_set(bt_value *real_obj, double val);
-
-extern bt_value *bt_value_string_create(void);
-
-extern bt_value *bt_value_string_create_init(const char *val);
-
-extern bt_value_status bt_value_string_set(bt_value *string_obj,
- const char *val);
-
-extern bt_value *bt_value_array_create(void);
-
-extern bt_value *bt_value_array_borrow_element_by_index(
- bt_value *array_obj, uint64_t index);
-
-extern bt_value_status bt_value_array_append_element(
- bt_value *array_obj,
- bt_value *element_obj);
-
-extern bt_value_status bt_value_array_append_bool_element(
- bt_value *array_obj, bt_bool val);
-
-extern bt_value_status bt_value_array_append_unsigned_integer_element(
- bt_value *array_obj, uint64_t val);
-
-extern bt_value_status bt_value_array_append_signed_integer_element(
- bt_value *array_obj, int64_t val);
-
-extern bt_value_status bt_value_array_append_real_element(
- bt_value *array_obj, double val);
-
-extern bt_value_status bt_value_array_append_string_element(
- bt_value *array_obj, const char *val);
-
-extern bt_value_status bt_value_array_append_empty_array_element(
- bt_value *array_obj);
-
-extern bt_value_status bt_value_array_append_empty_map_element(
- bt_value *array_obj);
-
-extern bt_value_status bt_value_array_set_element_by_index(
- bt_value *array_obj, uint64_t index,
- bt_value *element_obj);
-
-extern bt_value *bt_value_map_create(void);
-
-extern bt_value *bt_value_map_borrow_entry_value(
- bt_value *map_obj, const char *key);
-
-typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key,
- bt_value *object, void *data);
-
-extern bt_value_status bt_value_map_foreach_entry(
- bt_value *map_obj,
- bt_value_map_foreach_entry_func func, void *data);
-
-extern bt_value_status bt_value_map_insert_entry(
- bt_value *map_obj, const char *key,
- bt_value *element_obj);
-
-extern bt_value_status bt_value_map_insert_bool_entry(
- bt_value *map_obj, const char *key, bt_bool val);
-
-extern bt_value_status bt_value_map_insert_unsigned_integer_entry(
- bt_value *map_obj, const char *key, uint64_t val);
-
-extern bt_value_status bt_value_map_insert_signed_integer_entry(
- bt_value *map_obj, const char *key, int64_t val);
-
-extern bt_value_status bt_value_map_insert_real_entry(
- bt_value *map_obj, const char *key, double val);
-
-extern bt_value_status bt_value_map_insert_string_entry(
- bt_value *map_obj, const char *key,
- const char *val);
-
-extern bt_value_status bt_value_map_insert_empty_array_entry(
- bt_value *map_obj, const char *key);
-
-extern bt_value_status bt_value_map_insert_empty_map_entry(
- bt_value *map_obj, const char *key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_VALUES_H */
+++ /dev/null
-#ifndef BABELTRACE_VERSION_H
-#define BABELTRACE_VERSION_H
-
-/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * 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.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int bt_version_get_major(void);
-extern int bt_version_get_minor(void);
-extern int bt_version_get_patch(void);
-extern const char *bt_version_get_extra(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_VERSION_H */
--- /dev/null
+#ifndef _BABELTRACE_ALIGN_H
+#define _BABELTRACE_ALIGN_H
+
+/*
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <babeltrace2/compiler-internal.h>
+#include <babeltrace2/compat/limits-internal.h>
+
+#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a))
+#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
+#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask))
+#define PTR_ALIGN_FLOOR(p, a) \
+ ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
+#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0)
+
+/*
+ * Align pointer on natural object alignment.
+ */
+#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
+#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
+
+/**
+ * offset_align - Calculate the offset needed to align an object on its natural
+ * alignment towards higher addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define offset_align(align_drift, alignment) \
+ ({ \
+ MAYBE_BUILD_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((alignment) - (align_drift)) & ((alignment) - 1)); \
+ })
+
+/**
+ * offset_align_floor - Calculate the offset needed to align an object
+ * on its natural alignment towards lower addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define offset_align_floor(align_drift, alignment) \
+ ({ \
+ MAYBE_BUILD_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((align_drift) - (alignment)) & ((alignment) - 1)); \
+ })
+
+#endif /* _BABELTRACE_ALIGN_H */
--- /dev/null
+#ifndef BABELTRACE_ASSERT_INTERNAL_H
+#define BABELTRACE_ASSERT_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <assert.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+#ifdef BT_DEBUG_MODE
+
+extern void bt_common_assert_failed(const char *file, int line,
+ const char *func, const char *assertion) __attribute__((noreturn));
+
+/*
+ * Internal assertion (to detect logic errors on which the library user
+ * has no influence). Use BT_ASSERT_PRE() to check a precondition which
+ * must be directly or indirectly satisfied by the library user.
+ */
+#define BT_ASSERT(_cond) \
+ do { \
+ if (!(_cond)) { \
+ bt_common_assert_failed(__FILE__, __LINE__, __func__, \
+ TOSTRING(_cond)); \
+ } \
+ } while (0)
+
+/*
+ * Marks a function as being only used within a BT_ASSERT() context.
+ */
+# define BT_ASSERT_FUNC
+#else
+/*
+ * When BT_DEBUG_MODE is not defined, define BT_ASSERT() macro to the following
+ * to trick the compiler into thinking that the variable passed as condition to
+ * the assertion is used. This is to prevent set-but-not-used warnings from the
+ * compiler when assertions are disabled. The `sizeof` operator also makes sure
+ * that the `_cond` expression is not evaluated, thus preventing unwanted side
+ * effects.
+ *
+ * In-depth explanation: https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551
+ */
+# define BT_ASSERT(_cond) ((void) sizeof((void) (_cond), 0))
+# define BT_ASSERT_FUNC BT_UNUSED
+#endif /* BT_DEBUG_MODE */
+
+#endif /* BABELTRACE_ASSERT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_ASSERT_PRE_INTERNAL_H
+#define BABELTRACE_ASSERT_PRE_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+/*
+ * The macros in this header use macros defined in
+ * <babeltrace2/lib-logging-internal.h>. We don't want this header to
+ * automatically include <babeltrace2/lib-logging-internal.h> because you
+ * need to manually define BT_LOG_TAG before including
+ * <babeltrace2/lib-logging-internal.h> and it is unexpected that you
+ * also need to define it before including this header.
+ *
+ * This is a reminder that in order to use
+ * <babeltrace2/assert-pre-internal.h>, you also need to use logging
+ * explicitly.
+ */
+
+#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
+# error Include <babeltrace2/lib-logging-internal.h> before this header.
+#endif
+
+#include <stdlib.h>
+#include <inttypes.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+#ifdef BT_DEV_MODE
+/*
+ * Asserts that the library precondition _cond is satisfied.
+ *
+ * If _cond is false, log a fatal statement using _fmt and the optional
+ * arguments using BT_LIB_LOGF(), and abort.
+ *
+ * To assert that a postcondition is satisfied or that some internal
+ * object/context/value is in the expected state, use BT_ASSERT().
+ */
+# define BT_ASSERT_PRE(_cond, _fmt, ...) \
+ do { \
+ if (!(_cond)) { \
+ BT_LOGF_STR("Library precondition not satisfied; error is:"); \
+ BT_LIB_LOGF((_fmt), ##__VA_ARGS__); \
+ BT_LOGF_STR("Aborting..."); \
+ abort(); \
+ } \
+ } while (0)
+
+/*
+ * Marks a function as being only used within a BT_ASSERT_PRE() context.
+ */
+# define BT_ASSERT_PRE_FUNC
+
+/*
+ * Prints the details of an unsatisfied precondition without immediately
+ * aborting. You should use this within a function which checks
+ * preconditions, but which is called from a BT_ASSERT_PRE() context, so
+ * that the function can still return its result for BT_ASSERT_PRE() to
+ * evaluate it.
+ *
+ * Example:
+ *
+ * BT_ASSERT_PRE_FUNC
+ * static inline bool check_complex_precond(...)
+ * {
+ * ...
+ *
+ * if (...) {
+ * BT_ASSERT_PRE_MSG("Invalid object: ...", ...);
+ * return false;
+ * }
+ *
+ * ...
+ * }
+ *
+ * ...
+ *
+ * BT_ASSERT_PRE(check_complex_precond(...),
+ * "Precondition is not satisfied: ...", ...);
+ */
+# define BT_ASSERT_PRE_MSG BT_LIB_LOGF
+#else
+# define BT_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0))
+# define BT_ASSERT_PRE_FUNC BT_UNUSED
+# define BT_ASSERT_PRE_MSG(_fmt, ...)
+#endif /* BT_DEV_MODE */
+
+/*
+ * Developer mode: asserts that a given variable is not NULL.
+ */
+#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \
+ BT_ASSERT_PRE((_obj) != NULL, "%s is NULL: ", _obj_name)
+
+/*
+ * Developer mode: asserts that a given object is NOT frozen. This macro
+ * checks the `frozen` field of _obj.
+ */
+#define BT_ASSERT_PRE_HOT(_obj, _obj_name, _fmt, ...) \
+ BT_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name, \
+ ##__VA_ARGS__)
+
+/*
+ * Developer mode: asserts that a given index is less than a given size.
+ */
+#define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
+ BT_ASSERT_PRE((_index) < (_length), \
+ "Index is out of bounds: index=%" PRIu64 ", " \
+ "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
+
+#endif /* BABELTRACE_ASSERT_PRE_INTERNAL_H */
--- /dev/null
+#ifndef _BABELTRACE_INTERNAL_H
+#define _BABELTRACE_INTERNAL_H
+
+/*
+ * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <stdio.h>
+#include <glib.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <babeltrace2/compat/string-internal.h>
+#include <babeltrace2/types.h>
+
+#define PERROR_BUFLEN 200
+
+#ifndef likely
+# ifdef __GNUC__
+# define likely(x) __builtin_expect(!!(x), 1)
+# else
+# define likely(x) (!!(x))
+# endif
+#endif
+
+#ifndef unlikely
+# ifdef __GNUC__
+# define unlikely(x) __builtin_expect(!!(x), 0)
+# else
+# define unlikely(x) (!!(x))
+# endif
+#endif
+
+#ifndef min
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef max
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef max_t
+#define max_t(type, a, b) \
+ ((type) (a) > (type) (b) ? (type) (a) : (type) (b))
+#endif
+
+static inline
+bool bt_safe_to_mul_int64(int64_t a, int64_t b)
+{
+ if (a == 0 || b == 0) {
+ return true;
+ }
+
+ return a < INT64_MAX / b;
+}
+
+static inline
+bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b)
+{
+ if (a == 0 || b == 0) {
+ return true;
+ }
+
+ return a < UINT64_MAX / b;
+}
+
+static inline
+bool bt_safe_to_add_int64(int64_t a, int64_t b)
+{
+ return a <= INT64_MAX - b;
+}
+
+static inline
+bool bt_safe_to_add_uint64(uint64_t a, uint64_t b)
+{
+ return a <= UINT64_MAX - b;
+}
+
+/*
+ * Memory allocation zeroed
+ */
+#define zmalloc(x) calloc(1, x)
+
+/*
+ * BT_HIDDEN: set the hidden attribute for internal functions
+ * On Windows, symbols are local unless explicitly exported,
+ * see https://gcc.gnu.org/wiki/Visibility
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define BT_HIDDEN
+#else
+#define BT_HIDDEN __attribute__((visibility("hidden")))
+#endif
+
+#ifndef __STRINGIFY
+#define __STRINGIFY(x) #x
+#endif
+
+#define TOSTRING(x) __STRINGIFY(x)
+
+#define BT_UNUSED __attribute__((unused))
+
+#endif
--- /dev/null
+#ifndef BABELTRACE_BABELTRACE_H
+#define BABELTRACE_BABELTRACE_H
+
+/*
+ * Babeltrace API
+ *
+ * Copyright 2010-2018 EfficiOS Inc. <http://www.efficios.com/>
+ *
+ * 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.
+ */
+
+/* Core API */
+#include <babeltrace2/logging.h>
+#include <babeltrace2/property.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/util.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/version.h>
+
+/* Legacy API (for CTF writer) */
+#include <babeltrace2/ctf/events.h>
+
+/* CTF writer API */
+#include <babeltrace2/ctf-writer/clock-class.h>
+#include <babeltrace2/ctf-writer/clock.h>
+#include <babeltrace2/ctf-writer/event-fields.h>
+#include <babeltrace2/ctf-writer/event-types.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/visitor.h>
+#include <babeltrace2/ctf-writer/writer.h>
+
+/* Legacy API (for CTF writer) */
+#include <babeltrace2/ctf-ir/clock.h>
+#include <babeltrace2/ctf-ir/event-fields.h>
+#include <babeltrace2/ctf-ir/event-types.h>
+#include <babeltrace2/ctf-ir/event.h>
+#include <babeltrace2/ctf-ir/field-types.h>
+#include <babeltrace2/ctf-ir/fields.h>
+#include <babeltrace2/ctf-ir/stream-class.h>
+#include <babeltrace2/ctf-ir/stream.h>
+#include <babeltrace2/ctf-ir/trace.h>
+#include <babeltrace2/ctf-ir/utils.h>
+
+/* Trace IR API */
+#include <babeltrace2/trace-ir/clock-class-const.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-snapshot-const.h>
+#include <babeltrace2/trace-ir/event-class-const.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event-const.h>
+#include <babeltrace2/trace-ir/event.h>
+#include <babeltrace2/trace-ir/field-class-const.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field-const.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/packet-const.h>
+#include <babeltrace2/trace-ir/packet-context-field.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/stream-class-const.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream-const.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/trace-class-const.h>
+#include <babeltrace2/trace-ir/trace-class.h>
+#include <babeltrace2/trace-ir/trace-const.h>
+#include <babeltrace2/trace-ir/trace.h>
+
+/* Plugin and plugin development API */
+#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-dev.h>
+#include <babeltrace2/plugin/plugin-set-const.h>
+
+/* Graph, component, and message API */
+#include <babeltrace2/graph/component-class-const.h>
+#include <babeltrace2/graph/component-class-filter-const.h>
+#include <babeltrace2/graph/component-class-filter.h>
+#include <babeltrace2/graph/component-class-sink-const.h>
+#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/graph/component-class-source-const.h>
+#include <babeltrace2/graph/component-class-source.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-const.h>
+#include <babeltrace2/graph/component-filter-const.h>
+#include <babeltrace2/graph/component-sink-const.h>
+#include <babeltrace2/graph/component-source-const.h>
+#include <babeltrace2/graph/connection-const.h>
+#include <babeltrace2/graph/graph-const.h>
+#include <babeltrace2/graph/graph.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message-discarded-events-const.h>
+#include <babeltrace2/graph/message-discarded-events.h>
+#include <babeltrace2/graph/message-discarded-packets-const.h>
+#include <babeltrace2/graph/message-discarded-packets.h>
+#include <babeltrace2/graph/message-event-const.h>
+#include <babeltrace2/graph/message-event.h>
+#include <babeltrace2/graph/message-iterator-const.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity-const.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity.h>
+#include <babeltrace2/graph/message-packet-beginning-const.h>
+#include <babeltrace2/graph/message-packet-beginning.h>
+#include <babeltrace2/graph/message-packet-end-const.h>
+#include <babeltrace2/graph/message-packet-end.h>
+#include <babeltrace2/graph/message-stream-activity-beginning-const.h>
+#include <babeltrace2/graph/message-stream-activity-beginning.h>
+#include <babeltrace2/graph/message-stream-activity-const.h>
+#include <babeltrace2/graph/message-stream-activity-end-const.h>
+#include <babeltrace2/graph/message-stream-activity-end.h>
+#include <babeltrace2/graph/message-stream-beginning-const.h>
+#include <babeltrace2/graph/message-stream-beginning.h>
+#include <babeltrace2/graph/message-stream-end-const.h>
+#include <babeltrace2/graph/message-stream-end.h>
+#include <babeltrace2/graph/port-const.h>
+#include <babeltrace2/graph/port-input-const.h>
+#include <babeltrace2/graph/port-output-const.h>
+#include <babeltrace2/graph/port-output-message-iterator.h>
+#include <babeltrace2/graph/query-executor-const.h>
+#include <babeltrace2/graph/query-executor.h>
+#include <babeltrace2/graph/self-component-class-filter.h>
+#include <babeltrace2/graph/self-component-class-sink.h>
+#include <babeltrace2/graph/self-component-class-source.h>
+#include <babeltrace2/graph/self-component-filter.h>
+#include <babeltrace2/graph/self-component-port-input-message-iterator.h>
+#include <babeltrace2/graph/self-component-port-input.h>
+#include <babeltrace2/graph/self-component-port-output.h>
+#include <babeltrace2/graph/self-component-port.h>
+#include <babeltrace2/graph/self-component-sink.h>
+#include <babeltrace2/graph/self-component-source.h>
+#include <babeltrace2/graph/self-component.h>
+#include <babeltrace2/graph/self-message-iterator.h>
+
+#endif /* BABELTRACE_BABELTRACE_H */
--- /dev/null
+#ifndef _BABELTRACE_BITFIELD_H
+#define _BABELTRACE_BITFIELD_H
+
+/*
+ * Copyright 2010-2019 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <stdint.h> /* C99 5.2.4.2 Numerical limits */
+#include <stdbool.h> /* C99 7.16 bool type */
+#include <babeltrace2/compat/limits-internal.h> /* C99 5.2.4.2 Numerical limits */
+#include <babeltrace2/endian-internal.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
+
+/*
+ * This header strictly follows the C99 standard, except for use of the
+ * compiler-specific __typeof__.
+ */
+
+/*
+ * This bitfield header requires the compiler representation of signed
+ * integers to be two's complement.
+ */
+#if (-1 != ~0)
+#error "bitfield.h requires the compiler representation of signed integers to be two's complement."
+#endif
+
+/*
+ * _bt_is_signed_type() willingly generates comparison of unsigned
+ * expression < 0, which is always false. Silence compiler warnings.
+ */
+#ifdef __GNUC__
+# define _BT_DIAG_PUSH _Pragma("GCC diagnostic push")
+# define _BT_DIAG_POP _Pragma("GCC diagnostic pop")
+
+# define _BT_DIAG_STRINGIFY_1(x) #x
+# define _BT_DIAG_STRINGIFY(x) _BT_DIAG_STRINGIFY_1(x)
+
+# define _BT_DIAG_IGNORE(option) \
+ _Pragma(_BT_DIAG_STRINGIFY(GCC diagnostic ignored option))
+# define _BT_DIAG_IGNORE_TYPE_LIMITS _BT_DIAG_IGNORE("-Wtype-limits")
+#else
+# define _BT_DIAG_PUSH
+# define _BT_DIAG_POP
+# define _BT_DIAG_IGNORE
+#endif
+
+#define _bt_is_signed_type(type) ((type) -1 < (type) 0)
+
+/*
+ * Produce a build-time error if the condition `cond` is non-zero.
+ * Evaluates as a size_t expression.
+ */
+#define _BT_BUILD_ASSERT(cond) \
+ sizeof(struct { int f:(2 * !!(cond) - 1); })
+
+/*
+ * Cast value `v` to an unsigned integer of the same size as `v`.
+ */
+#define _bt_cast_value_to_unsigned(v) \
+ (sizeof(v) == sizeof(uint8_t) ? (uint8_t) (v) : \
+ sizeof(v) == sizeof(uint16_t) ? (uint16_t) (v) : \
+ sizeof(v) == sizeof(uint32_t) ? (uint32_t) (v) : \
+ sizeof(v) == sizeof(uint64_t) ? (uint64_t) (v) : \
+ _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * Cast value `v` to an unsigned integer type of the size of type `type`
+ * *without* sign-extension.
+ *
+ * The unsigned cast ensures that we're not shifting a negative value,
+ * which is undefined in C. However, this limits the maximum type size
+ * of `type` to 64-bit. Generate a compile-time error if the size of
+ * `type` is larger than 64-bit.
+ */
+#define _bt_cast_value_to_unsigned_type(type, v) \
+ (sizeof(type) == sizeof(uint8_t) ? \
+ (uint8_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint16_t) ? \
+ (uint16_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint32_t) ? \
+ (uint32_t) _bt_cast_value_to_unsigned(v) : \
+ sizeof(type) == sizeof(uint64_t) ? \
+ (uint64_t) _bt_cast_value_to_unsigned(v) : \
+ _BT_BUILD_ASSERT(sizeof(v) <= sizeof(uint64_t)))
+
+/*
+ * _bt_fill_mask evaluates to a "type" integer with all bits set.
+ */
+#define _bt_fill_mask(type) ((type) ~(type) 0)
+
+/*
+ * Left shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, left shift of a left hand-side signed
+ * type is undefined if it has a negative value or if the result cannot
+ * be represented in the result type. This bitfield header discards the
+ * bits that are left-shifted beyond the result type representation,
+ * which is the behavior of an unsigned type left shift operation.
+ * Therefore, always perform left shift on an unsigned type.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_lshift`.
+ */
+#define _bt_lshift(v, shift) \
+ ((__typeof__(v)) (_bt_cast_value_to_unsigned(v) << (shift)))
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * cleared, and the most significant bits set.
+ */
+#define _bt_make_mask_complement(type, length) \
+ _bt_lshift(_bt_fill_mask(type), length)
+
+/*
+ * Generate a mask of type `type` with the `length` least significant bits
+ * set, and the most significant bits cleared.
+ */
+#define _bt_make_mask(type, length) \
+ ((type) ~_bt_make_mask_complement(type, length))
+
+/*
+ * Right shift a value `v` of `shift` bits.
+ *
+ * The type of `v` can be signed or unsigned integer.
+ * The value of `shift` must be less than the size of `v` (in bits),
+ * otherwise the behavior is undefined.
+ * Evaluates to the result of the shift operation.
+ *
+ * According to the C99 standard, right shift of a left hand-side signed
+ * type which has a negative value is implementation defined. This
+ * bitfield header relies on the right shift implementation carrying the
+ * sign bit. If the compiler implementation has a different behavior,
+ * emulate carrying the sign bit.
+ *
+ * This macro should not be used if `shift` can be greater or equal than
+ * the bitwidth of `v`. See `_bt_safe_rshift`.
+ */
+#if ((-1 >> 1) == -1)
+#define _bt_rshift(v, shift) ((v) >> (shift))
+#else
+#define _bt_rshift(v, shift) \
+ ((__typeof__(v)) ((_bt_cast_value_to_unsigned(v) >> (shift)) | \
+ ((v) < 0 ? _bt_make_mask_complement(__typeof__(v), \
+ sizeof(v) * CHAR_BIT - (shift)) : 0)))
+#endif
+
+/*
+ * Right shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_rshift(v, shift) \
+do { \
+ unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+ unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+ \
+ for (; _nr_partial_shifts; _nr_partial_shifts--) \
+ (v) = _bt_rshift(v, sizeof(v) * CHAR_BIT - 1); \
+ (v) = _bt_rshift(v, _leftover_bits); \
+} while (0)
+
+/*
+ * Left shift a signed or unsigned integer with `shift` value being an
+ * arbitrary number of bits. `v` is modified by this macro. The shift
+ * is transformed into a sequence of `_nr_partial_shifts` consecutive
+ * shift operations, each of a number of bits smaller than the bitwidth
+ * of `v`, ending with a shift of the number of left over bits.
+ */
+#define _bt_safe_lshift(v, shift) \
+do { \
+ unsigned long _nr_partial_shifts = (shift) / (sizeof(v) * CHAR_BIT - 1); \
+ unsigned long _leftover_bits = (shift) % (sizeof(v) * CHAR_BIT - 1); \
+ \
+ for (; _nr_partial_shifts; _nr_partial_shifts--) \
+ (v) = _bt_lshift(v, sizeof(v) * CHAR_BIT - 1); \
+ (v) = _bt_lshift(v, _leftover_bits); \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ *
+ * Save integer to the bitfield, which starts at the "start" bit, has "len"
+ * bits.
+ * The inside of a bitfield is from high bits to low bits.
+ * Uses native endianness.
+ * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
+ * For signed "v", sign-extend v if bitfield is larger than v.
+ *
+ * On little endian, bytes are placed from the less significant to the most
+ * significant. Also, consecutive bitfields are placed from lower bits to higher
+ * bits.
+ *
+ * On big endian, bytes are places from most significant to less significant.
+ * Also, consecutive bitfields are placed from higher to lower bits.
+ */
+
+#define _bt_bitfield_write_le(ptr, type, start, length, v) \
+do { \
+ __typeof__(v) _v = (v); \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) \
+ break; \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ /* Trim v high bits */ \
+ if (_length < sizeof(_v) * CHAR_BIT) \
+ _v &= _bt_make_mask(__typeof__(_v), _length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ _this_unit = _start_unit; \
+ if (_start_unit == _end_unit - 1) { \
+ _mask = _bt_make_mask(type, _start % _ts); \
+ if (_end % _ts) \
+ _mask |= _bt_make_mask_complement(type, _end % _ts); \
+ _cmask = _bt_lshift((type) (_v), _start % _ts); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ break; \
+ } \
+ if (_start % _ts) { \
+ _cshift = _start % _ts; \
+ _mask = _bt_make_mask(type, _cshift); \
+ _cmask = _bt_lshift((type) (_v), _cshift); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ _bt_safe_rshift(_v, _ts - _cshift); \
+ _start += _ts - _cshift; \
+ _this_unit++; \
+ } \
+ for (; _this_unit < _end_unit - 1; _this_unit++) { \
+ _ptr[_this_unit] = (type) _v; \
+ _bt_safe_rshift(_v, _ts); \
+ _start += _ts; \
+ } \
+ if (_end % _ts) { \
+ _mask = _bt_make_mask_complement(type, _end % _ts); \
+ _cmask = (type) _v; \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ } else \
+ _ptr[_this_unit] = (type) _v; \
+} while (0)
+
+#define _bt_bitfield_write_be(ptr, type, start, length, v) \
+do { \
+ __typeof__(v) _v = (v); \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ \
+ if (!_length) \
+ break; \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ /* Trim v high bits */ \
+ if (_length < sizeof(_v) * CHAR_BIT) \
+ _v &= _bt_make_mask(__typeof__(_v), _length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ _this_unit = _end_unit - 1; \
+ if (_start_unit == _end_unit - 1) { \
+ _mask = _bt_make_mask(type, (_ts - (_end % _ts)) % _ts); \
+ if (_start % _ts) \
+ _mask |= _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+ _cmask = _bt_lshift((type) (_v), (_ts - (_end % _ts)) % _ts); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ break; \
+ } \
+ if (_end % _ts) { \
+ _cshift = _end % _ts; \
+ _mask = _bt_make_mask(type, _ts - _cshift); \
+ _cmask = _bt_lshift((type) (_v), _ts - _cshift); \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ _bt_safe_rshift(_v, _cshift); \
+ _end -= _cshift; \
+ _this_unit--; \
+ } \
+ for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+ _ptr[_this_unit] = (type) _v; \
+ _bt_safe_rshift(_v, _ts); \
+ _end -= _ts; \
+ } \
+ if (_start % _ts) { \
+ _mask = _bt_make_mask_complement(type, _ts - (_start % _ts)); \
+ _cmask = (type) _v; \
+ _cmask &= ~_mask; \
+ _ptr[_this_unit] &= _mask; \
+ _ptr[_this_unit] |= _cmask; \
+ } else \
+ _ptr[_this_unit] = (type) _v; \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ * bt_bitfield_write_le - write integer to a bitfield in little endian
+ * bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, type, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, unsigned char, start, length, v)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#define bt_bitfield_write_le(ptr, type, start, length, v) \
+ _bt_bitfield_write_le(ptr, unsigned char, start, length, v)
+
+#define bt_bitfield_write_be(ptr, type, start, length, v) \
+ _bt_bitfield_write_be(ptr, type, start, length, v)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#define _bt_bitfield_read_le(ptr, type, start, length, vptr) \
+do { \
+ __typeof__(*(vptr)) *_vptr = (vptr); \
+ __typeof__(*_vptr) _v; \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ bool _is_signed_type; \
+ \
+ if (!_length) { \
+ *_vptr = 0; \
+ break; \
+ } \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ _this_unit = _end_unit - 1; \
+ _BT_DIAG_PUSH \
+ _BT_DIAG_IGNORE_TYPE_LIMITS \
+ _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \
+ _BT_DIAG_POP \
+ if (_is_signed_type \
+ && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \
+ _v = ~(__typeof__(_v)) 0; \
+ else \
+ _v = 0; \
+ if (_start_unit == _end_unit - 1) { \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _start % _ts); \
+ if ((_end - _start) % _ts) { \
+ _mask = _bt_make_mask(type, _end - _start); \
+ _cmask &= _mask; \
+ } \
+ _bt_safe_lshift(_v, _end - _start); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ *_vptr = _v; \
+ break; \
+ } \
+ if (_end % _ts) { \
+ _cshift = _end % _ts; \
+ _mask = _bt_make_mask(type, _cshift); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _cshift); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ _end -= _cshift; \
+ _this_unit--; \
+ } \
+ for (; (long) _this_unit >= (long) _start_unit + 1; _this_unit--) { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ _end -= _ts; \
+ } \
+ if (_start % _ts) { \
+ _mask = _bt_make_mask(type, _ts - (_start % _ts)); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _start % _ts); \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _ts - (_start % _ts)); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ } else { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ } \
+ *_vptr = _v; \
+} while (0)
+
+#define _bt_bitfield_read_be(ptr, type, start, length, vptr) \
+do { \
+ __typeof__(*(vptr)) *_vptr = (vptr); \
+ __typeof__(*_vptr) _v; \
+ type *_ptr = (void *) (ptr); \
+ unsigned long _start = (start), _length = (length); \
+ type _mask, _cmask; \
+ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long _start_unit, _end_unit, _this_unit; \
+ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \
+ bool _is_signed_type; \
+ \
+ if (!_length) { \
+ *_vptr = 0; \
+ break; \
+ } \
+ \
+ _end = _start + _length; \
+ _start_unit = _start / _ts; \
+ _end_unit = (_end + (_ts - 1)) / _ts; \
+ \
+ _this_unit = _start_unit; \
+ _BT_DIAG_PUSH \
+ _BT_DIAG_IGNORE_TYPE_LIMITS \
+ _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \
+ _BT_DIAG_POP \
+ if (_is_signed_type \
+ && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \
+ _v = ~(__typeof__(_v)) 0; \
+ else \
+ _v = 0; \
+ if (_start_unit == _end_unit - 1) { \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, (_ts - (_end % _ts)) % _ts); \
+ if ((_end - _start) % _ts) { \
+ _mask = _bt_make_mask(type, _end - _start); \
+ _cmask &= _mask; \
+ } \
+ _bt_safe_lshift(_v, _end - _start); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ *_vptr = _v; \
+ break; \
+ } \
+ if (_start % _ts) { \
+ _cshift = _start % _ts; \
+ _mask = _bt_make_mask(type, _ts - _cshift); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _ts - _cshift); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ _start += _ts - _cshift; \
+ _this_unit++; \
+ } \
+ for (; _this_unit < _end_unit - 1; _this_unit++) { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ _start += _ts; \
+ } \
+ if (_end % _ts) { \
+ _mask = _bt_make_mask(type, _end % _ts); \
+ _cmask = _ptr[_this_unit]; \
+ _cmask = _bt_rshift(_cmask, _ts - (_end % _ts)); \
+ _cmask &= _mask; \
+ _bt_safe_lshift(_v, _end % _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _cmask); \
+ } else { \
+ _bt_safe_lshift(_v, _ts); \
+ _v |= _bt_cast_value_to_unsigned_type(__typeof__(_v), _ptr[_this_unit]); \
+ } \
+ *_vptr = _v; \
+} while (0)
+
+/*
+ * bt_bitfield_read - read integer from a bitfield in native endianness
+ * bt_bitfield_read_le - read integer from a bitfield in little endian
+ * bt_bitfield_read_be - read integer from a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, unsigned char, start, length, vptr)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_read(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#define bt_bitfield_read_le(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_le(ptr, unsigned char, start, length, vptr)
+
+#define bt_bitfield_read_be(ptr, type, start, length, vptr) \
+ _bt_bitfield_read_be(ptr, type, start, length, vptr)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BABELTRACE_BITFIELD_H */
--- /dev/null
+#ifndef BABELTRACE_COMMON_INTERNAL_H
+#define BABELTRACE_COMMON_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdbool.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/trace-ir/field-class-const.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
+#include <babeltrace2/trace-ir/event-class-const.h>
+#include <babeltrace2/graph/self-message-iterator.h>
+#include <babeltrace2/value.h>
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <glib.h>
+
+#define BT_COMMON_COLOR_RESET "\033[0m"
+#define BT_COMMON_COLOR_BOLD "\033[1m"
+#define BT_COMMON_COLOR_FG_DEFAULT "\033[39m"
+#define BT_COMMON_COLOR_FG_RED "\033[31m"
+#define BT_COMMON_COLOR_FG_GREEN "\033[32m"
+#define BT_COMMON_COLOR_FG_YELLOW "\033[33m"
+#define BT_COMMON_COLOR_FG_BLUE "\033[34m"
+#define BT_COMMON_COLOR_FG_MAGENTA "\033[35m"
+#define BT_COMMON_COLOR_FG_CYAN "\033[36m"
+#define BT_COMMON_COLOR_FG_LIGHT_GRAY "\033[37m"
+#define BT_COMMON_COLOR_BG_DEFAULT "\033[49m"
+#define BT_COMMON_COLOR_BG_RED "\033[41m"
+#define BT_COMMON_COLOR_BG_GREEN "\033[42m"
+#define BT_COMMON_COLOR_BG_YELLOW "\033[43m"
+#define BT_COMMON_COLOR_BG_BLUE "\033[44m"
+#define BT_COMMON_COLOR_BG_MAGENTA "\033[45m"
+#define BT_COMMON_COLOR_BG_CYAN "\033[46m"
+#define BT_COMMON_COLOR_BG_LIGHT_GRAY "\033[47m"
+
+struct bt_common_lttng_live_url_parts {
+ GString *proto;
+ GString *hostname;
+ GString *target_hostname;
+ GString *session_name;
+
+ /* -1 means default port */
+ int port;
+};
+
+/*
+ * Checks if the current process has setuid or setgid access rights.
+ * Returns `true` if so.
+ */
+BT_HIDDEN
+bool bt_common_is_setuid_setgid(void);
+
+/*
+ * Returns the system-wide plugin path, e.g.
+ * `/usr/lib/babeltrace/plugins`. Do not free the return value.
+ */
+BT_HIDDEN
+const char *bt_common_get_system_plugin_path(void);
+
+/*
+ * Returns the user plugin path, e.g.
+ * `/home/user/.local/lib/babeltrace/plugins`. You need to free the
+ * return value.
+ */
+BT_HIDDEN
+char *bt_common_get_home_plugin_path(void);
+
+/*
+ * Appends the list of directories in `paths` to the array `dirs`.
+ * `paths` is a list of directories separated by `:`. Returns 0 on
+ * success.
+ */
+BT_HIDDEN
+int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs);
+
+/*
+ * Returns `true` if terminal color codes are supported for this
+ * process.
+ */
+BT_HIDDEN
+bool bt_common_colors_supported(void);
+
+BT_HIDDEN
+const char *bt_common_color_reset(void);
+
+BT_HIDDEN
+const char *bt_common_color_bold(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_default(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_red(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_green(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_yellow(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_blue(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_magenta(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_cyan(void);
+
+BT_HIDDEN
+const char *bt_common_color_fg_light_gray(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_default(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_red(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_green(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_yellow(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_blue(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_magenta(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_cyan(void);
+
+BT_HIDDEN
+const char *bt_common_color_bg_light_gray(void);
+
+/*
+ * Returns the substring from `input` to the first character found
+ * in the list of characters `end_chars`, unescaping any character
+ * found in `escapable_chars`, and sets `*end_pos` to the position of
+ * the end (from `input`). The caller owns the returned GString.
+ */
+BT_HIDDEN
+GString *bt_common_string_until(const char *input, const char *escapable_chars,
+ const char *end_chars, size_t *end_pos);
+
+/*
+ * Returns the quoted version of `input` for a shell. If
+ * `with_single_quotes` is `true`, prepends and appends the `'` prefix
+ * and suffix to the returned string; otherwise the caller should
+ * prepend and append them manually, although they are not always
+ * required. The caller owns the returned GString.
+ */
+BT_HIDDEN
+GString *bt_common_shell_quote(const char *input, bool with_single_quotes);
+
+/*
+ * Returns `true` if `input` is a string made only of printable
+ * characters.
+ */
+BT_HIDDEN
+bool bt_common_string_is_printable(const char *input);
+
+/*
+ * Destroys the parts of an LTTng live URL as returned by
+ * bt_common_parse_lttng_live_url().
+ */
+BT_HIDDEN
+void bt_common_destroy_lttng_live_url_parts(
+ struct bt_common_lttng_live_url_parts *parts);
+
+/*
+ * Parses the LTTng live URL `url` and returns its different parts.
+ * If there's an error, writes the error message into `*error_buf`
+ * up to `error_buf_size` bytes. You must destroy the returned value
+ * with bt_common_destroy_lttng_live_url_parts().
+ */
+BT_HIDDEN
+struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url(
+ const char *url, char *error_buf, size_t error_buf_size);
+
+/*
+ * Normalizes (in place) a star globbing pattern to be used with
+ * bt_common_star_glob_match(). This function always succeeds.
+ */
+BT_HIDDEN
+void bt_common_normalize_star_glob_pattern(char *pattern);
+
+/*
+ * Returns `true` if `candidate` (of size `candidate_len`) matches
+ * the star globbing pattern `pattern` (of size `pattern_len`).
+ */
+BT_HIDDEN
+bool bt_common_star_glob_match(const char *pattern, size_t pattern_len,
+ const char *candidate, size_t candidate_len);
+
+/*
+ * Normalizes the path `path`:
+ *
+ * * If it's a relative path, converts it to an absolute path using
+ * `wd` as the working directory (or the current working directory
+ * if `wd` is NULL).
+ * * Removes consecutive and trailing slashes.
+ * * Resolves `..` and `.` in the path (both in `path` and in `wd`).
+ * * Does NOT resolve symbolic links.
+ *
+ * The caller owns the returned GString.
+ */
+BT_HIDDEN
+GString *bt_common_normalize_path(const char *path, const char *wd);
+
+typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data,
+ char **buf, size_t avail_size, const char **fmt, va_list *args);
+
+/*
+ * This is a custom vsnprintf() which handles the standard conversion
+ * specifier as well as custom ones.
+ *
+ * `fmt` is a typical printf()-style format string, with the following
+ * limitations:
+ *
+ * * The `*` width specifier is not accepted.
+ * * The `*` precision specifier is not accepted.
+ * * The `j` and `t` length modifiers are not accepted.
+ * * The `n` format specifier is not accepted.
+ * * The format specifiers defined in <inttypes.h> are not accepted
+ * except for `PRId64`, `PRIu64`, `PRIx64`, `PRIX64`, `PRIo64`, and
+ * `PRIi64`.
+ *
+ * `intro` specifies which special character immediately following an
+ * introductory `%` character in `fmt` is used to indicate a custom
+ * conversion specifier. For example, if `intro` is '@', then any `%@`
+ * sequence in `fmt` is the beginning of a custom conversion specifier.
+ *
+ * When a custom conversion specifier is encountered in `fmt`,
+ * the function calls `handle_specifier`. This callback receives:
+ *
+ * `priv_data`:
+ * Custom, private data.
+ *
+ * `buf`:
+ * Address of the current buffer pointer. `*buf` is the position to
+ * append new data. The callback must update `*buf` when appending
+ * new data. The callback must ensure not to write passed the whole
+ * buffer passed to bt_common_custom_vsnprintf().
+ *
+ * `avail_size`:
+ * Number of bytes left in whole buffer from the `*buf` point.
+ *
+ * `fmt`:
+ * Address of the current format string pointer. `*fmt` points to
+ * the introductory `%` character, which is followed by the
+ * character `intro`. The callback must update `*fmt` so that it
+ * points after the whole custom conversion specifier.
+ *
+ * `args`:
+ * Variable argument list. Use va_arg() to get new arguments from
+ * this list and update it at the same time.
+ *
+ * Because this is an internal utility, this function and its callback
+ * do not return error codes: they abort when there's any error (bad
+ * format string, for example).
+ */
+BT_HIDDEN
+void bt_common_custom_vsnprintf(char *buf, size_t buf_size,
+ char intro,
+ bt_common_handle_custom_specifier_func handle_specifier,
+ void *priv_data, const char *fmt, va_list *args);
+
+/*
+ * Variadic form of bt_common_custom_vsnprintf().
+ */
+BT_HIDDEN
+void bt_common_custom_snprintf(char *buf, size_t buf_size,
+ char intro,
+ bt_common_handle_custom_specifier_func handle_specifier,
+ void *priv_data, const char *fmt, ...);
+
+/*
+ * Returns the system page size.
+ */
+BT_HIDDEN
+size_t bt_common_get_page_size(void);
+
+/*
+ * Wraps read() function to handle EINTR and partial reads.
+ * On success, it returns `count` received as parameter. On error, it returns a
+ * value smaller than the requested `count`.
+ */
+static inline
+ssize_t bt_common_read(int fd, void *buf, size_t count)
+{
+ size_t i = 0;
+ ssize_t ret;
+
+ BT_ASSERT(buf);
+
+ /* Never return an overflow value. */
+ BT_ASSERT(count <= SSIZE_MAX);
+
+ do {
+ ret = read(fd, buf + i, count - i);
+ if (ret < 0) {
+ if (errno == EINTR) {
+#ifdef BT_LOGD_STR
+ BT_LOGD_STR("read() call interrupted. Retrying...");
+#endif
+ /* retry operation */
+ continue;
+ } else {
+#ifdef BT_LOGE_ERRNO
+ BT_LOGE_ERRNO("Error while reading", ": fd=%d",
+ fd);
+#endif
+ goto end;
+ }
+ }
+ i += ret;
+ BT_ASSERT(i <= count);
+ } while (count - i > 0 && ret > 0);
+
+end:
+ if (ret >= 0) {
+ if (i == 0) {
+ ret = -1;
+ } else {
+ ret = i;
+ }
+ }
+
+ return ret;
+}
+
+static inline
+const char *bt_common_field_class_type_string(enum bt_field_class_type class_type)
+{
+ switch (class_type) {
+ case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
+ return "BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER";
+ case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
+ return "BT_FIELD_CLASS_TYPE_SIGNED_INTEGER";
+ case BT_FIELD_CLASS_TYPE_REAL:
+ return "BT_FIELD_CLASS_TYPE_REAL";
+ case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
+ return "BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION";
+ case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION:
+ return "BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION";
+ case BT_FIELD_CLASS_TYPE_STRING:
+ return "BT_FIELD_CLASS_TYPE_STRING";
+ case BT_FIELD_CLASS_TYPE_STRUCTURE:
+ return "BT_FIELD_CLASS_TYPE_STRUCTURE";
+ case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
+ return "BT_FIELD_CLASS_TYPE_STATIC_ARRAY";
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ return "BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY";
+ case BT_FIELD_CLASS_TYPE_VARIANT:
+ return "BT_FIELD_CLASS_TYPE_VARIANT";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+const char *bt_common_field_class_integer_preferred_display_base_string(enum bt_field_class_integer_preferred_display_base base)
+{
+ switch (base) {
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL";
+ case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL:
+ return "BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_common_scope_string(enum bt_scope scope)
+{
+ switch (scope) {
+ case BT_SCOPE_PACKET_CONTEXT:
+ return "BT_SCOPE_PACKET_CONTEXT";
+ case BT_SCOPE_EVENT_COMMON_CONTEXT:
+ return "BT_SCOPE_EVENT_COMMON_CONTEXT";
+ case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
+ return "BT_SCOPE_EVENT_SPECIFIC_CONTEXT";
+ case BT_SCOPE_EVENT_PAYLOAD:
+ return "BT_SCOPE_EVENT_PAYLOAD";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_common_event_class_log_level_string(
+ enum bt_event_class_log_level level)
+{
+ switch (level) {
+ case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
+ return "BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY";
+ case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
+ return "BT_EVENT_CLASS_LOG_LEVEL_ALERT";
+ case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
+ return "BT_EVENT_CLASS_LOG_LEVEL_CRITICAL";
+ case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
+ return "BT_EVENT_CLASS_LOG_LEVEL_ERROR";
+ case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
+ return "BT_EVENT_CLASS_LOG_LEVEL_WARNING";
+ case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
+ return "BT_EVENT_CLASS_LOG_LEVEL_NOTICE";
+ case BT_EVENT_CLASS_LOG_LEVEL_INFO:
+ return "BT_EVENT_CLASS_LOG_LEVEL_INFO";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE";
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
+ return "BT_EVENT_CLASS_LOG_LEVEL_DEBUG";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+const char *bt_common_value_type_string(enum bt_value_type type)
+{
+ switch (type) {
+ case BT_VALUE_TYPE_NULL:
+ return "BT_VALUE_TYPE_NULL";
+ case BT_VALUE_TYPE_BOOL:
+ return "BT_VALUE_TYPE_BOOL";
+ case BT_VALUE_TYPE_UNSIGNED_INTEGER:
+ return "BT_VALUE_TYPE_UNSIGNED_INTEGER";
+ case BT_VALUE_TYPE_SIGNED_INTEGER:
+ return "BT_VALUE_TYPE_SIGNED_INTEGER";
+ case BT_VALUE_TYPE_REAL:
+ return "BT_VALUE_TYPE_REAL";
+ case BT_VALUE_TYPE_STRING:
+ return "BT_VALUE_TYPE_STRING";
+ case BT_VALUE_TYPE_ARRAY:
+ return "BT_VALUE_TYPE_ARRAY";
+ case BT_VALUE_TYPE_MAP:
+ return "BT_VALUE_TYPE_MAP";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+GString *bt_common_field_path_string(struct bt_field_path *path)
+{
+ GString *str = g_string_new(NULL);
+ uint64_t i;
+
+ BT_ASSERT(path);
+
+ if (!str) {
+ goto end;
+ }
+
+ g_string_append_printf(str, "[%s", bt_common_scope_string(
+ bt_field_path_get_root_scope(path)));
+
+ for (i = 0; i < bt_field_path_get_item_count(path); i++) {
+ const struct bt_field_path_item *fp_item =
+ bt_field_path_borrow_item_by_index_const(path, i);
+
+ switch (bt_field_path_item_get_type(fp_item)) {
+ case BT_FIELD_PATH_ITEM_TYPE_INDEX:
+ g_string_append_printf(str, ", %" PRIu64,
+ bt_field_path_item_index_get_index(fp_item));
+ break;
+ case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
+ g_string_append(str, ", <CUR>");
+ break;
+ default:
+ abort();
+ }
+ }
+
+ g_string_append(str, "]");
+
+end:
+ return str;
+}
+
+static inline
+const char *bt_common_self_message_iterator_status_string(
+ enum bt_self_message_iterator_status status)
+{
+ switch (status) {
+ case BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN:
+ return "BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN";
+ case BT_SELF_MESSAGE_ITERATOR_STATUS_END:
+ return "BT_SELF_MESSAGE_ITERATOR_STATUS_END";
+ case BT_SELF_MESSAGE_ITERATOR_STATUS_OK:
+ return "BT_SELF_MESSAGE_ITERATOR_STATUS_OK";
+ case BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR:
+ return "BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR";
+ case BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM:
+ return "BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+};
+
+#define NS_PER_S_I INT64_C(1000000000)
+#define NS_PER_S_U UINT64_C(1000000000)
+
+static inline
+int bt_common_clock_value_from_ns_from_origin(
+ int64_t cc_offset_seconds, uint64_t cc_offset_cycles,
+ uint64_t cc_freq, int64_t ns_from_origin,
+ uint64_t *raw_value)
+{
+ int ret = 0;
+ int64_t offset_in_ns;
+ uint64_t value_in_ns;
+ uint64_t rem_value_in_ns;
+ uint64_t value_periods;
+ uint64_t value_period_cycles;
+ int64_t ns_to_add;
+
+ BT_ASSERT(raw_value);
+
+ /* Compute offset part of requested value, in nanoseconds */
+ if (!bt_safe_to_mul_int64(cc_offset_seconds, NS_PER_S_I)) {
+ ret = -1;
+ goto end;
+ }
+
+ offset_in_ns = cc_offset_seconds * NS_PER_S_I;
+
+ if (cc_freq == NS_PER_S_U) {
+ ns_to_add = (int64_t) cc_offset_cycles;
+ } else {
+ if (!bt_safe_to_mul_int64((int64_t) cc_offset_cycles,
+ NS_PER_S_I)) {
+ ret = -1;
+ goto end;
+ }
+
+ ns_to_add = ((int64_t) cc_offset_cycles * NS_PER_S_I) /
+ (int64_t) cc_freq;
+ }
+
+ if (!bt_safe_to_add_int64(offset_in_ns, ns_to_add)) {
+ ret = -1;
+ goto end;
+ }
+
+ offset_in_ns += ns_to_add;
+
+ /* Value part in nanoseconds */
+ if (ns_from_origin < offset_in_ns) {
+ ret = -1;
+ goto end;
+ }
+
+ value_in_ns = (uint64_t) (ns_from_origin - offset_in_ns);
+
+ /* Number of whole clock periods in `value_in_ns` */
+ value_periods = value_in_ns / NS_PER_S_U;
+
+ /* Remaining nanoseconds in cycles + whole clock periods in cycles */
+ rem_value_in_ns = value_in_ns - value_periods * NS_PER_S_U;
+
+ if (value_periods > UINT64_MAX / cc_freq) {
+ ret = -1;
+ goto end;
+ }
+
+ if (!bt_safe_to_mul_uint64(value_periods, cc_freq)) {
+ ret = -1;
+ goto end;
+ }
+
+ value_period_cycles = value_periods * cc_freq;
+
+ if (!bt_safe_to_mul_uint64(cc_freq, rem_value_in_ns)) {
+ ret = -1;
+ goto end;
+ }
+
+ if (!bt_safe_to_add_uint64(cc_freq * rem_value_in_ns / NS_PER_S_U,
+ value_period_cycles)) {
+ ret = -1;
+ goto end;
+ }
+
+ *raw_value = cc_freq * rem_value_in_ns / NS_PER_S_U +
+ value_period_cycles;
+
+end:
+ return ret;
+}
+
+static inline
+enum bt_self_message_iterator_status bt_common_message_iterator_status_to_self(
+ enum bt_message_iterator_status status)
+{
+ return (int) status;
+}
+#endif /* BABELTRACE_COMMON_INTERNAL_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_FCNTL_H
+#define _BABELTRACE_COMPAT_FCNTL_H
+
+/*
+ * Copyright 2015 (c) - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * fcntl compatibility layer.
+ *
+ * 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.
+ */
+
+#ifdef BABELTRACE_HAVE_POSIX_FALLOCATE
+
+#include <fcntl.h>
+
+static inline
+int bt_posix_fallocate(int fd, off_t offset, off_t len)
+{
+ return posix_fallocate(fd, offset, len);
+}
+
+#elif defined(__MINGW32__) /* #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
+
+#include <stdlib.h>
+#include <windows.h>
+#include <fcntl.h>
+
+static inline
+int bt_posix_fallocate(int fd, off_t offset, off_t len)
+{
+ HANDLE handle;
+ LARGE_INTEGER pos, file_pos, orig_end_offset, range_end;
+ int ret = 0;
+ char zero = 0;
+ DWORD byteswritten;
+
+ if (offset < 0 || len <= 0) {
+ ret = EINVAL;
+ goto end;
+ }
+
+ range_end.QuadPart = (__int64) offset + (__int64) len;
+
+ /* Get a handle from the fd */
+ handle = (HANDLE) _get_osfhandle(fd);
+ if (handle == INVALID_HANDLE_VALUE) {
+ ret = EBADF;
+ goto end;
+ }
+
+ /* Get the file original end offset */
+ ret = GetFileSizeEx(handle, &orig_end_offset);
+ if (ret == 0) {
+ ret = EBADF;
+ goto end;
+ }
+
+ /* Make sure we don't truncate the file */
+ if (orig_end_offset.QuadPart >= range_end.QuadPart) {
+ ret = 0;
+ goto end;
+ }
+
+ /* Get the current file pointer position */
+ pos.QuadPart = 0;
+ ret = SetFilePointerEx(handle, pos, &file_pos, FILE_CURRENT);
+ if (ret == 0) {
+ ret = EBADF;
+ goto end;
+ }
+
+ /* Move the file pointer to the new end offset */
+ ret = SetFilePointerEx(handle, range_end, NULL, FILE_BEGIN);
+ if (ret == 0) {
+ ret = EBADF;
+ goto end;
+ }
+
+ /* Sets the physical file size to the current position */
+ ret = SetEndOfFile(handle);
+ if (ret == 0) {
+ ret = EINVAL;
+ goto restore;
+ }
+
+ /*
+ * Move the file pointer back 1 byte, and write a single 0 at the
+ * last byte of the new end offset, the operating system will zero
+ * fill the file.
+ */
+ pos.QuadPart = -1;
+ ret = SetFilePointerEx(handle, pos, NULL, FILE_END);
+ if (ret == 0) {
+ ret = EBADF;
+ goto end;
+ }
+
+ ret = WriteFile(handle, &zero, 1, &byteswritten, NULL);
+ if (ret == 0 || byteswritten != 1) {
+ ret = ENOSPC;
+ } else {
+ ret = 0;
+ }
+
+restore:
+ /* Restore the original file pointer position */
+ if (!SetFilePointerEx(handle, file_pos, NULL, FILE_BEGIN)) {
+ /* We moved the file pointer but failed to restore it. */
+ abort();
+ }
+
+end:
+ return ret;
+}
+
+#else
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#define BABELTRACE_FALLOCATE_BUFLEN 256
+
+#ifndef min_t
+#define min_t(type, a, b) \
+ ((type) (a) < (type) (b) ? (type) (a) : (type) (b))
+#endif
+
+static inline
+int bt_posix_fallocate(int fd, off_t offset, off_t len)
+{
+ int ret = 0;
+ ssize_t copy_len;
+ char buf[BABELTRACE_FALLOCATE_BUFLEN];
+ off_t i, file_pos, orig_end_offset, range_end;
+
+ if (offset < 0 || len < 0) {
+ ret = EINVAL;
+ goto end;
+ }
+
+ range_end = offset + len;
+ if (range_end < 0) {
+ ret = EFBIG;
+ goto end;
+ }
+
+ file_pos = lseek(fd, 0, SEEK_CUR);
+ if (file_pos < 0) {
+ ret = errno;
+ goto end;
+ }
+
+ orig_end_offset = lseek(fd, 0, SEEK_END);
+ if (orig_end_offset < 0) {
+ ret = errno;
+ goto end;
+ }
+
+ /* Seek back to original position. */
+ ret = lseek(fd, file_pos, SEEK_SET);
+ if (ret) {
+ ret = errno;
+ goto end;
+ }
+
+ /*
+ * The file may not need to grow, but we want to ensure the
+ * space has actually been reserved by the file system. First, copy
+ * the "existing" region of the file, then grow the file if needed.
+ */
+ for (i = file_pos; i < min_t(off_t, range_end, orig_end_offset);
+ i += copy_len) {
+ ssize_t copy_ret;
+
+ copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
+ min_t(off_t, range_end - i,
+ orig_end_offset - i));
+ copy_ret = pread(fd, &buf, copy_len, i);
+ if (copy_ret < copy_len) {
+ /*
+ * The caller must handle any EINTR.
+ * POSIX_FALLOCATE(3) does not mention EINTR.
+ * However, glibc does forward to fallocate()
+ * directly on Linux, which may be interrupted.
+ */
+ ret = errno;
+ goto end;
+ }
+
+ copy_ret = pwrite(fd, &buf, copy_len, i);
+ if (copy_ret < copy_len) {
+ /* Same caveat as noted at pread() */
+ ret = errno;
+ goto end;
+ }
+ }
+
+ /* Grow file, as necessary. */
+ memset(&buf, 0, BABELTRACE_FALLOCATE_BUFLEN);
+ for (i = orig_end_offset; i < range_end; i += copy_len) {
+ ssize_t write_ret;
+
+ copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
+ range_end - i);
+ write_ret = pwrite(fd, &buf, copy_len, i);
+ if (write_ret < copy_len) {
+ ret = errno;
+ goto end;
+ }
+ }
+end:
+ return ret;
+}
+#endif /* #else #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
+
+#endif /* _BABELTRACE_COMPAT_FCNTL_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_GLIB_H
+#define _BABELTRACE_COMPAT_GLIB_H
+
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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 <glib.h>
+
+#if GLIB_CHECK_VERSION(2,31,8)
+
+static inline gboolean
+bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
+{
+ return g_hash_table_contains(hash_table, key);
+}
+
+#else
+
+static inline gboolean
+bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
+{
+ gpointer orig_key;
+ gpointer value;
+
+ return g_hash_table_lookup_extended(hash_table, key, &orig_key,
+ &value);
+}
+
+#endif
+
+
+#if GLIB_CHECK_VERSION(2,29,16)
+
+static inline GPtrArray *
+bt_g_ptr_array_new_full(guint reserved_size,
+ GDestroyNotify element_free_func)
+{
+ return g_ptr_array_new_full(reserved_size, element_free_func);
+}
+
+#else
+
+static inline GPtrArray *
+bt_g_ptr_array_new_full(guint reserved_size,
+ GDestroyNotify element_free_func)
+{
+ GPtrArray *array;
+
+ array = g_ptr_array_sized_new(reserved_size);
+ if (!array) {
+ goto end;
+ }
+ g_ptr_array_set_free_func(array, element_free_func);
+end:
+ return array;
+}
+#endif
+
+#endif /* _BABELTRACE_COMPAT_GLIB_H */
--- /dev/null
+#ifndef _BABELTRACE_LIMITS_H
+#define _BABELTRACE_LIMITS_H
+
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <limits.h>
+
+#ifdef __linux__
+
+#define BABELTRACE_HOST_NAME_MAX HOST_NAME_MAX
+
+#elif defined(__FreeBSD__)
+
+#define BABELTRACE_HOST_NAME_MAX MAXHOSTNAMELEN
+
+#elif defined(_POSIX_HOST_NAME_MAX)
+
+#define BABELTRACE_HOST_NAME_MAX _POSIX_HOST_NAME_MAX
+
+#else
+
+#define BABELTRACE_HOST_NAME_MAX 256
+
+#endif /* __linux__, __FreeBSD__, _POSIX_HOST_NAME_MAX */
+
+#endif /* _BABELTRACE_LIMITS_H */
--- /dev/null
+#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+
+/*
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * memstream compatibility layer.
+ *
+ * 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.
+ */
+
+#ifdef BABELTRACE_HAVE_FMEMOPEN
+#include <stdio.h>
+
+static inline
+FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
+{
+ return fmemopen(buf, size, mode);
+}
+
+#else /* BABELTRACE_HAVE_FMEMOPEN */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <babeltrace2/endian-internal.h>
+
+#ifdef __MINGW32__
+
+#include <io.h>
+#include <glib.h>
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
+{
+ char *tmpname;
+ size_t len;
+ FILE *fp;
+ int ret;
+
+ /*
+ * Support reading only.
+ */
+ if (strcmp(mode, "rb") != 0) {
+ return NULL;
+ }
+
+ /* Build a temporary filename */
+ tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
+ if (_mktemp(tmpname) == NULL) {
+ goto error_free;
+ }
+
+ /*
+ * Open as a read/write binary temporary deleted on close file.
+ * Will be deleted when the last file pointer is closed.
+ */
+ fp = fopen(tmpname, "w+bTD");
+ if (!fp) {
+ goto error_free;
+ }
+
+ /* Copy the entire buffer to the file */
+ len = fwrite(buf, sizeof(char), size, fp);
+ if (len != size) {
+ goto error_close;
+ }
+
+ /* Set the file pointer to the start of file */
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ perror("fseek");
+ goto error_close;
+ }
+
+ g_free(tmpname);
+ return fp;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("close");
+ }
+error_free:
+ g_free(tmpname);
+ return NULL;
+}
+
+#else /* __MINGW32__ */
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
+{
+ char *tmpname;
+ size_t len;
+ FILE *fp;
+ int ret;
+
+ /*
+ * Support reading only.
+ */
+ if (strcmp(mode, "rb") != 0) {
+ return NULL;
+ }
+
+ tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
+ ret = mkstemp(tmpname);
+ if (ret < 0) {
+ g_free(tmpname);
+ return NULL;
+ }
+ /*
+ * We need to write to the file.
+ */
+ fp = fdopen(ret, "wb+");
+ if (!fp) {
+ goto error_unlink;
+ }
+ /* Copy the entire buffer to the file */
+ len = fwrite(buf, sizeof(char), size, fp);
+ if (len != size) {
+ goto error_close;
+ }
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ perror("fseek");
+ goto error_close;
+ }
+ /* We keep the handle open, but can unlink the file on the VFS. */
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ g_free(tmpname);
+ return fp;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("close");
+ }
+error_unlink:
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ g_free(tmpname);
+ return NULL;
+}
+
+#endif /* __MINGW32__ */
+
+#endif /* BABELTRACE_HAVE_FMEMOPEN */
+
+
+#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
+
+#include <stdio.h>
+
+static inline
+FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
+{
+ return open_memstream(ptr, sizeloc);
+}
+
+static inline
+int bt_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+ return fclose(fp);
+}
+
+#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+
+#ifdef __MINGW32__
+
+/*
+ * Fallback for systems which don't have open_memstream. Create FILE *
+ * with bt_open_memstream, but require call to
+ * bt_close_memstream to flush all data written to the FILE *
+ * into the buffer (which we allocate).
+ */
+static inline
+FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
+{
+ char *tmpname;
+ FILE *fp;
+
+ tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
+
+ if (_mktemp(tmpname) == NULL) {
+ goto error_free;
+ }
+
+ /*
+ * Open as a read/write binary temporary deleted on close file.
+ * Will be deleted when the last file pointer is closed.
+ */
+ fp = fopen(tmpname, "w+bTD");
+ if (!fp) {
+ goto error_free;
+ }
+
+ g_free(tmpname);
+ return fp;
+
+error_free:
+ g_free(tmpname);
+ return NULL;
+}
+
+#else /* __MINGW32__ */
+
+/*
+ * Fallback for systems which don't have open_memstream. Create FILE *
+ * with bt_open_memstream, but require call to
+ * bt_close_memstream to flush all data written to the FILE *
+ * into the buffer (which we allocate).
+ */
+static inline
+FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
+{
+ char *tmpname;
+ int ret;
+ FILE *fp;
+
+ tmpname = g_build_filename(g_get_tmp_dir(), "babeltrace-tmp-XXXXXX", NULL);
+
+ ret = mkstemp(tmpname);
+ if (ret < 0) {
+ perror("mkstemp");
+ g_free(tmpname);
+ return NULL;
+ }
+ fp = fdopen(ret, "wb+");
+ if (!fp) {
+ goto error_unlink;
+ }
+ /*
+ * babeltrace_flush_memstream will update the buffer content
+ * with read from fp. No need to keep the file around, just the
+ * handle.
+ */
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ g_free(tmpname);
+ return fp;
+
+error_unlink:
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ g_free(tmpname);
+ return NULL;
+}
+
+#endif /* __MINGW32__ */
+
+/* Get file size, allocate buffer, copy. */
+static inline
+int bt_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+ size_t len, n;
+ long pos;
+ int ret;
+
+ ret = fflush(fp);
+ if (ret < 0) {
+ perror("fflush");
+ return ret;
+ }
+ ret = fseek(fp, 0L, SEEK_END);
+ if (ret < 0) {
+ perror("fseek");
+ return ret;
+ }
+ pos = ftell(fp);
+ if (ret < 0) {
+ perror("ftell");
+ return ret;
+ }
+ *size = pos;
+ /* add final \0 */
+ *buf = calloc(pos + 1, sizeof(char));
+ if (!*buf) {
+ return -ENOMEM;
+ }
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ perror("fseek");
+ goto error_free;
+ }
+ /* Copy the entire file into the buffer */
+ n = 0;
+ clearerr(fp);
+ while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
+ len = fread(*buf, sizeof(char), *size - n, fp);
+ n += len;
+ }
+ if (n != *size) {
+ ret = -1;
+ goto error_close;
+ }
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("fclose");
+ return ret;
+ }
+ return 0;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("fclose");
+ }
+error_free:
+ free(*buf);
+ *buf = NULL;
+ return ret;
+}
+
+#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_MMAN_H
+#define _BABELTRACE_COMPAT_MMAN_H
+
+/*
+ * Copyright (C) 2015-2016 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __MINGW32__
+
+#include <sys/types.h>
+
+#define PROT_NONE 0x0
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+#define PROT_EXEC 0x4
+
+#define MAP_FILE 0
+#define MAP_SHARED 1
+#define MAP_PRIVATE 2
+#define MAP_TYPE 0xF
+#define MAP_FIXED 0x10
+#define MAP_ANONYMOUS 0x20
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FAILED ((void *) -1)
+
+/*
+ * Note that some platforms (e.g. Windows) do not allow read-only
+ * mappings to exceed the file's size (even within a page).
+ */
+void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
+ off_t offset);
+
+int bt_munmap(void *addr, size_t length);
+
+#else /* __MINGW32__ */
+
+#include <sys/mman.h>
+
+static inline
+void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
+ off_t offset)
+{
+ return (void *) mmap(addr, length, prot, flags, fd, offset);
+}
+
+static inline
+int bt_munmap(void *addr, size_t length)
+{
+ return munmap(addr, length);
+}
+#endif /* __MINGW32__ */
+
+#ifndef MAP_ANONYMOUS
+# ifdef MAP_ANON
+# define MAP_ANONYMOUS MAP_ANON
+# endif
+#endif
+
+#endif /* _BABELTRACE_COMPAT_MMAN_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_SOCKET_H
+#define _BABELTRACE_COMPAT_SOCKET_H
+
+/*
+ * Copyright (C) 2015-2017 Michael Jeanson <mjeanson@efficios.com>
+ * 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __MINGW32__
+
+#include <winsock2.h>
+
+#define BT_INVALID_SOCKET INVALID_SOCKET
+#define BT_SOCKET_ERROR SOCKET_ERROR
+#define BT_SOCKET SOCKET
+
+static inline
+int bt_socket_init(void)
+{
+ WORD verreq;
+ WSADATA wsa;
+ int ret;
+
+ /* Request winsock 2.2 support */
+ verreq = MAKEWORD(2, 2);
+
+ ret = WSAStartup(verreq, &wsa);
+ if (ret != 0) {
+#ifdef BT_LOGE
+ BT_LOGE("Winsock init failed with error: %d", ret);
+#endif
+ goto end;
+ }
+
+ if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wVersion) != 2) {
+#ifdef BT_LOGE_STR
+ BT_LOGE_STR("Could not init winsock 2.2 support");
+#endif
+ WSACleanup();
+ ret = -1;
+ }
+
+end:
+ return ret;
+}
+
+static inline
+int bt_socket_fini(void)
+{
+ return WSACleanup();
+}
+
+static inline
+int bt_socket_send(int sockfd, const void *buf, size_t len, int flags)
+{
+ return send(sockfd, buf, len, flags);
+}
+
+static inline
+int bt_socket_recv(int sockfd, void *buf, size_t len, int flags)
+{
+ return recv(sockfd, buf, len, flags);
+}
+
+static inline
+int bt_socket_close(int fd)
+{
+ return closesocket(fd);
+}
+
+static inline
+bool bt_socket_interrupted(void)
+{
+ /* There is no equivalent to EINTR in winsock 2.2 */
+ return false;
+}
+
+static inline
+const char *bt_socket_errormsg(void)
+{
+ const char *errstr;
+ int error = WSAGetLastError();
+
+ switch (error) {
+ case WSAEINTR:
+ errstr = "Call interrupted";
+ break;
+ case WSAEBADF:
+ errstr = "Bad file";
+ break;
+ case WSAEACCES:
+ errstr = "Bad access";
+ break;
+ case WSAEFAULT:
+ errstr = "Bad argument";
+ break;
+ case WSAEINVAL:
+ errstr = "Invalid arguments";
+ break;
+ case WSAEMFILE:
+ errstr = "Out of file descriptors";
+ break;
+ case WSAEWOULDBLOCK:
+ errstr = "Call would block";
+ break;
+ case WSAEINPROGRESS:
+ case WSAEALREADY:
+ errstr = "Blocking call in progress";
+ break;
+ case WSAENOTSOCK:
+ errstr = "Descriptor is not a socket";
+ break;
+ case WSAEDESTADDRREQ:
+ errstr = "Need destination address";
+ break;
+ case WSAEMSGSIZE:
+ errstr = "Bad message size";
+ break;
+ case WSAEPROTOTYPE:
+ errstr = "Bad protocol";
+ break;
+ case WSAENOPROTOOPT:
+ errstr = "Protocol option is unsupported";
+ break;
+ case WSAEPROTONOSUPPORT:
+ errstr = "Protocol is unsupported";
+ break;
+ case WSAESOCKTNOSUPPORT:
+ errstr = "Socket is unsupported";
+ break;
+ case WSAEOPNOTSUPP:
+ errstr = "Operation not supported";
+ break;
+ case WSAEAFNOSUPPORT:
+ errstr = "Address family not supported";
+ break;
+ case WSAEPFNOSUPPORT:
+ errstr = "Protocol family not supported";
+ break;
+ case WSAEADDRINUSE:
+ errstr = "Address already in use";
+ break;
+ case WSAEADDRNOTAVAIL:
+ errstr = "Address not available";
+ break;
+ case WSAENETDOWN:
+ errstr = "Network down";
+ break;
+ case WSAENETUNREACH:
+ errstr = "Network unreachable";
+ break;
+ case WSAENETRESET:
+ errstr = "Network has been reset";
+ break;
+ case WSAECONNABORTED:
+ errstr = "Connection was aborted";
+ break;
+ case WSAECONNRESET:
+ errstr = "Connection was reset";
+ break;
+ case WSAENOBUFS:
+ errstr = "No buffer space";
+ break;
+ case WSAEISCONN:
+ errstr = "Socket is already connected";
+ break;
+ case WSAENOTCONN:
+ errstr = "Socket is not connected";
+ break;
+ case WSAESHUTDOWN:
+ errstr = "Socket has been shut down";
+ break;
+ case WSAETOOMANYREFS:
+ errstr = "Too many references";
+ break;
+ case WSAETIMEDOUT:
+ errstr = "Timed out";
+ break;
+ case WSAECONNREFUSED:
+ errstr = "Connection refused";
+ break;
+ case WSAELOOP:
+ errstr = "Loop??";
+ break;
+ case WSAENAMETOOLONG:
+ errstr = "Name too long";
+ break;
+ case WSAEHOSTDOWN:
+ errstr = "Host down";
+ break;
+ case WSAEHOSTUNREACH:
+ errstr = "Host unreachable";
+ break;
+ case WSAENOTEMPTY:
+ errstr = "Not empty";
+ break;
+ case WSAEPROCLIM:
+ errstr = "Process limit reached";
+ break;
+ case WSAEUSERS:
+ errstr = "Too many users";
+ break;
+ case WSAEDQUOT:
+ errstr = "Bad quota";
+ break;
+ case WSAESTALE:
+ errstr = "Something is stale";
+ break;
+ case WSAEREMOTE:
+ errstr = "Remote error";
+ break;
+ case WSAEDISCON:
+ errstr = "Disconnected";
+ break;
+
+ /* Extended Winsock errors */
+ case WSASYSNOTREADY:
+ errstr = "Winsock library is not ready";
+ break;
+ case WSANOTINITIALISED:
+ errstr = "Winsock library not initialised";
+ break;
+ case WSAVERNOTSUPPORTED:
+ errstr = "Winsock version not supported";
+ break;
+
+ /* getXbyY() errors (already handled in herrmsg):
+ * Authoritative Answer: Host not found */
+ case WSAHOST_NOT_FOUND:
+ errstr = "Host not found";
+ break;
+
+ /* Non-Authoritative: Host not found, or SERVERFAIL */
+ case WSATRY_AGAIN:
+ errstr = "Host not found, try again";
+ break;
+
+ /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+ case WSANO_RECOVERY:
+ errstr = "Unrecoverable error in call to nameserver";
+ break;
+
+ /* Valid name, no data record of requested type */
+ case WSANO_DATA:
+ errstr = "No data record of requested type";
+ break;
+
+ default:
+ errstr = "Unknown error";
+ }
+
+ return errstr;
+}
+
+#else /* __MINGW32__ */
+
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#define BT_INVALID_SOCKET -1
+#define BT_SOCKET_ERROR -1
+#define BT_SOCKET int
+
+static inline
+int bt_socket_init(void)
+{
+ return 0;
+}
+
+static inline
+int bt_socket_fini(void)
+{
+ return 0;
+}
+
+static inline
+int bt_socket_send(int sockfd, const void *buf, size_t len, int flags)
+{
+ return send(sockfd, buf, len, flags);
+}
+
+static inline
+int bt_socket_recv(int sockfd, void *buf, size_t len, int flags)
+{
+ return recv(sockfd, buf, len, flags);
+}
+
+static inline
+int bt_socket_close(int fd)
+{
+ return close(fd);
+}
+
+static inline
+bool bt_socket_interrupted(void)
+{
+ return (errno == EINTR);
+}
+
+static inline
+const char *bt_socket_errormsg(void)
+{
+ return g_strerror(errno);
+}
+#endif
+
+
+/*
+ * This wrapper is used on platforms that have no way of ignoring SIGPIPE
+ * during a send().
+ */
+
+#ifndef MSG_NOSIGNAL
+# ifdef SO_NOSIGPIPE
+# define MSG_NOSIGNAL SO_NOSIGPIPE
+# elif defined(__MINGW32__)
+# define MSG_NOSIGNAL 0
+# endif
+#endif
+
+#if defined(MSG_NOSIGNAL)
+static inline
+ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size)
+{
+ return bt_socket_send(fd, buffer, size, MSG_NOSIGNAL);
+}
+#else
+
+#include <signal.h>
+
+static inline
+ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size)
+{
+ ssize_t sent;
+ int saved_err;
+ sigset_t sigpipe_set, pending_set, old_set;
+ int sigpipe_was_pending;
+
+ /*
+ * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
+ * that might be already pending. If a bogus SIGPIPE is sent to
+ * the entire process concurrently by a malicious user, it may
+ * be simply discarded.
+ */
+ if (sigemptyset(&pending_set)) {
+ return -1;
+ }
+ /*
+ * sigpending returns the mask of signals that are _both_
+ * blocked for the thread _and_ pending for either the thread or
+ * the entire process.
+ */
+ if (sigpending(&pending_set)) {
+ return -1;
+ }
+ sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
+ /*
+ * If sigpipe was pending, it means it was already blocked, so
+ * no need to block it.
+ */
+ if (!sigpipe_was_pending) {
+ if (sigemptyset(&sigpipe_set)) {
+ return -1;
+ }
+ if (sigaddset(&sigpipe_set, SIGPIPE)) {
+ return -1;
+ }
+ if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
+ return -1;
+ }
+ }
+
+ /* Send and save errno. */
+ sent = bt_socket_send(fd, buffer, size, 0);
+ saved_err = errno;
+
+ if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) {
+ struct timespec timeout = { 0, 0 };
+ int ret;
+
+ do {
+ ret = sigtimedwait(&sigpipe_set, NULL,
+ &timeout);
+ } while (ret == -1 && errno == EINTR);
+ }
+ if (!sigpipe_was_pending) {
+ if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
+ return -1;
+ }
+ }
+ /* Restore send() errno */
+ errno = saved_err;
+
+ return sent;
+}
+#endif
+
+
+#endif /* _BABELTRACE_COMPAT_SOCKET_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STDIO_H
+#define _BABELTRACE_COMPAT_STDIO_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <babeltrace2/assert-internal.h>
+
+#define BT_GETLINE_MINBUFLEN 64
+
+static inline
+char * _bt_getline_bufalloc(char **lineptr, size_t *n, size_t linelen)
+{
+ size_t buflen = *n;
+ char *buf = *lineptr;
+
+ if (buflen >= linelen && buf != NULL) {
+ return buf;
+ }
+ if (buf == NULL) {
+ buflen = BT_GETLINE_MINBUFLEN;
+ } else {
+ buflen = buflen << 1;
+ if (buflen < BT_GETLINE_MINBUFLEN) {
+ buflen = BT_GETLINE_MINBUFLEN;
+ }
+ }
+ /* Check below not strictly needed, extra safety. */
+ if (buflen < linelen) {
+ buflen = linelen;
+ }
+ buf = realloc(buf, buflen);
+ if (!buf) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ *n = buflen;
+ *lineptr = buf;
+ return buf;
+}
+
+/*
+ * Returns line length (including possible final \n, excluding final
+ * \0). On end of file, returns -1 with nonzero feof(stream) and errno
+ * set to 0. On error, returns -1 with errno set.
+ *
+ * This interface is similar to the getline(3) man page part of the
+ * Linux man-pages project, release 3.74. One major difference from the
+ * Open Group POSIX specification is that this implementation does not
+ * necessarily set the ferror() flag on error (because it is internal to
+ * libc).
+ */
+static inline
+ssize_t bt_getline(char **lineptr, size_t *n, FILE *stream)
+{
+ size_t linelen = 0;
+ char *buf;
+ int found_eof = 0;
+
+ if (lineptr == NULL || n == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ for (;;) {
+ char c;
+ int ret;
+
+ ret = fgetc(stream);
+ if (ret == EOF) {
+ if (ferror(stream)) {
+ /* ferror() is set, errno set by fgetc(). */
+ return -1;
+ }
+ BT_ASSERT(feof(stream));
+ found_eof = 1;
+ break;
+ }
+ c = (char) ret;
+ if (linelen == SSIZE_MAX) {
+ errno = EOVERFLOW;
+ return -1;
+ }
+ buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
+ if (!buf) {
+ return -1;
+ }
+ buf[linelen - 1] = c;
+ if (c == '\n') {
+ break;
+ }
+ }
+ if (!linelen && found_eof) {
+ /* feof() is set. */
+ errno = 0;
+ return -1;
+ }
+ buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
+ if (!buf) {
+ return -1;
+ }
+ buf[linelen - 1] = '\0';
+ return linelen - 1; /* Count don't include final \0. */
+}
+
+#endif /* _BABELTRACE_COMPAT_STDIO_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STDLIB_H
+#define _BABELTRACE_COMPAT_STDLIB_H
+
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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.
+ */
+
+/*
+ * This compat wrapper can be removed and replaced by g_mkdtemp() when we bump
+ * the requirement on glib to version 2.30.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <glib.h>
+
+#ifdef HAVE_MKDTEMP
+
+static inline
+char *bt_mkdtemp(char *template)
+{
+ return mkdtemp(template);
+}
+
+#elif GLIB_CHECK_VERSION(2,30,0)
+
+#include <glib/gstdio.h>
+static inline
+char *bt_mkdtemp(char *template)
+{
+ return g_mkdtemp(template);
+}
+
+#else
+
+static inline
+char *bt_mkdtemp(char *template)
+{
+ char *ret;
+
+ ret = mktemp(template);
+ if (!ret) {
+ goto end;
+ }
+
+ if(mkdir(template, 0700)) {
+ ret = NULL;
+ goto end;
+ }
+
+ ret = template;
+end:
+ return ret;
+}
+
+#endif
+
+#endif /* _BABELTRACE_COMPAT_STDLIB_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STRING_H
+#define _BABELTRACE_COMPAT_STRING_H
+
+/*
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+
+#ifdef HAVE_STRNLEN
+static inline
+size_t bt_strnlen(const char *str, size_t max)
+{
+ return strnlen(str, max);
+}
+#else
+static inline
+size_t bt_strnlen(const char *str, size_t max)
+{
+ size_t ret;
+ const char *end;
+
+ end = memchr(str, 0, max);
+
+ if (end) {
+ ret = (size_t) (end - str);
+ } else {
+ ret = max;
+ }
+
+ return ret;
+}
+#endif /* HAVE_STRNLEN */
+
+#ifdef HAVE_STRNDUP
+static inline
+char *bt_strndup(const char *s, size_t n)
+{
+ return strndup(s, n);
+}
+#else
+static inline
+char *bt_strndup(const char *s, size_t n)
+{
+ char *ret;
+ size_t navail;
+
+ if (!s) {
+ ret = NULL;
+ goto end;
+ }
+
+ /* min() */
+ navail = strlen(s) + 1;
+ if ((n + 1) < navail) {
+ navail = n + 1;
+ }
+
+ ret = malloc(navail);
+ if (!ret) {
+ goto end;
+ }
+
+ memcpy(ret, s, navail);
+ ret[navail - 1] = '\0';
+end:
+ return ret;
+}
+#endif /* HAVE_STRNDUP */
+
+#endif /* _BABELTRACE_COMPAT_STRING_H */
--- /dev/null
+#ifndef _BABELTRACE_INCLUDE_COMPAT_TIME_H
+#define _BABELTRACE_INCLUDE_COMPAT_TIME_H
+
+/*
+ * Copyright (C) 2013 JP Ikaheimonen <jp_ikaheimonen@mentor.com>
+ * 2016 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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 <time.h>
+#include <stdlib.h>
+
+#ifdef __MINGW32__
+
+#include <string.h>
+
+/*
+ * The Windows version of the time functions use one common tm structure per
+ * thread which makes them thread-safe. Implement the POSIX _r variants by
+ * copying this to a user supplied struct.
+ */
+
+static inline
+struct tm *bt_gmtime_r(const time_t *timep, struct tm *result)
+{
+ struct tm *local_res;
+
+ if (!result) {
+ goto error;
+ }
+
+ local_res = gmtime(timep);
+ if (!local_res) {
+ result = NULL;
+ goto error;
+ }
+
+ memcpy(result, local_res, sizeof(struct tm));
+
+error:
+ return result;
+}
+
+static inline
+struct tm *bt_localtime_r(const time_t *timep, struct tm *result)
+{
+ struct tm *local_res;
+
+ if (!result) {
+ goto error;
+ }
+
+ local_res = localtime(timep);
+ if (!local_res) {
+ result = NULL;
+ goto error;
+ }
+
+ memcpy(result, local_res, sizeof(struct tm));
+
+error:
+ return result;
+}
+
+#else /* __MINGW32__ */
+
+static inline
+struct tm *bt_gmtime_r(const time_t *timep, struct tm *result)
+{
+ return gmtime_r(timep, result);
+}
+
+static inline
+struct tm *bt_localtime_r(const time_t *timep, struct tm *result)
+{
+ return localtime_r(timep, result);
+}
+
+#endif /* __MINGW32__ */
+#endif /* _BABELTRACE_INCLUDE_COMPAT_TIME_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_UNISTD_H
+#define _BABELTRACE_COMPAT_UNISTD_H
+
+/*
+ * (C) Copyright 2016 - Michael Jeanson <mjeanson@efficios.com>
+ *
+ * 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 <unistd.h>
+
+#ifdef __MINGW32__
+#include <windows.h>
+#include <errno.h>
+
+#define _SC_PAGESIZE 30
+
+static inline
+long bt_sysconf(int name)
+{
+ SYSTEM_INFO si;
+
+ switch(name) {
+ case _SC_PAGESIZE:
+ GetNativeSystemInfo(&si);
+ return si.dwPageSize;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
+
+#else
+
+static inline
+long bt_sysconf(int name)
+{
+ return sysconf(name);
+}
+
+#endif
+#endif /* _BABELTRACE_COMPAT_UNISTD_H */
--- /dev/null
+#ifndef _BABELTRACE_UTC_H
+#define _BABELTRACE_UTC_H
+
+/*
+ * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <time.h>
+
+/* If set, use GNU or BSD timegm(3) */
+#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+
+static inline
+time_t bt_timegm(struct tm *tm)
+{
+ return timegm(tm);
+}
+
+#elif defined(__MINGW32__)
+
+static inline
+time_t bt_timegm(struct tm *tm)
+{
+ return _mkgmtime(tm);
+}
+
+#else
+
+#include <errno.h>
+
+/*
+ * This is a simple implementation of timegm() it just turns the "struct tm" into
+ * a GMT time_t. It does not normalize any of the fields of the "struct tm", nor
+ * does it set tm_wday or tm_yday.
+ */
+
+static inline
+int bt_leapyear(int year)
+{
+ return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));
+}
+
+static inline
+time_t bt_timegm(struct tm *tm)
+{
+ int year, month, total_days;
+
+ int monthlen[2][12] = {
+ /* Days per month for a regular year */
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ /* Days per month for a leap year */
+ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ };
+
+ if ((tm->tm_mon >= 12) ||
+ (tm->tm_mday >= 32) ||
+ (tm->tm_hour >= 24) ||
+ (tm->tm_min >= 60) ||
+ (tm->tm_sec >= 61)) {
+ errno = EOVERFLOW;
+ return (time_t) -1;
+ }
+
+ /* Add 365 days for each year since 1970 */
+ total_days = 365 * (tm->tm_year - 70);
+
+ /* Add one day for each leap year since 1970 */
+ for (year = 70; year < tm->tm_year; year++) {
+ if (bt_leapyear(1900 + year)) {
+ total_days++;
+ }
+ }
+
+ /* Add days for each remaining month */
+ for (month = 0; month < tm->tm_mon; month++) {
+ total_days += monthlen[bt_leapyear(1900 + year)][month];
+ }
+
+ /* Add remaining days */
+ total_days += tm->tm_mday - 1;
+
+ return ((((total_days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);
+}
+
+#endif
+
+#endif /* _BABELTRACE_UTC_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_UUID_H
+#define _BABELTRACE_COMPAT_UUID_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ */
+
+/* Includes final \0. */
+#define BABELTRACE_UUID_STR_LEN 37
+#define BABELTRACE_UUID_LEN 16
+
+#ifdef BABELTRACE_HAVE_LIBUUID
+#include <uuid/uuid.h>
+
+static inline
+int bt_uuid_generate(unsigned char *uuid_out)
+{
+ uuid_generate(uuid_out);
+ return 0;
+}
+
+/* Sun's libuuid lacks const qualifiers */
+#if defined(__sun__)
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uuid_unparse((unsigned char *) uuid_in, str_out);
+ return 0;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ return uuid_parse((char *) str_in, uuid_out);
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ return uuid_compare((unsigned char *) uuid_a,
+ (unsigned char *) uuid_b);
+}
+#else
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uuid_unparse(uuid_in, str_out);
+ return 0;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ return uuid_parse(str_in, uuid_out);
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ return uuid_compare(uuid_a, uuid_b);
+}
+#endif
+
+#elif defined(BABELTRACE_HAVE_LIBC_UUID)
+#include <uuid.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+static inline
+int bt_uuid_generate(unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_create((uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uint32_t status;
+ char *alloc_str;
+ int ret;
+
+ uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
+ if (status == uuid_s_ok) {
+ strcpy(str_out, alloc_str);
+ ret = 0;
+ } else {
+ ret = -1;
+ }
+ free(alloc_str);
+ return ret;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ uint32_t status;
+
+ uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+#elif defined(__MINGW32__)
+
+int bt_uuid_generate(unsigned char *uuid_out);
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out);
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out);
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b);
+
+#else
+#error "Babeltrace needs to have a UUID generator configured."
+#endif
+
+#endif /* _BABELTRACE_COMPAT_UUID_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPILER_H
+#define _BABELTRACE_COMPILER_H
+
+/*
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <stddef.h> /* for offsetof */
+
+#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)NULL)->member) * __ptr = (ptr); \
+ (type *)((char *)__ptr - offsetof(type, member)); \
+ })
+#endif
+
+#define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+#endif /* _BABELTRACE_COMPILER_H */
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/clock.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/event-fields.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/event-types.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/event.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/field-types.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/fields.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/stream-class.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/stream.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/trace.h>
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/utils.h>
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_ATTRIBUTES_H
+#define BABELTRACE_CTF_WRITER_ATTRIBUTES_H
+
+/*
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_attributes_create(void);
+
+BT_HIDDEN
+void bt_ctf_attributes_destroy(struct bt_ctf_private_value *attr_obj);
+
+BT_HIDDEN
+int64_t bt_ctf_attributes_get_count(struct bt_ctf_private_value *attr_obj);
+
+BT_HIDDEN
+const char *bt_ctf_attributes_get_field_name(struct bt_ctf_private_value *attr_obj,
+ uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value(struct bt_ctf_private_value *attr_obj,
+ uint64_t index);
+
+BT_HIDDEN
+int bt_ctf_attributes_set_field_value(struct bt_ctf_private_value *attr_obj,
+ const char *name, struct bt_ctf_private_value *value_obj);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_attributes_borrow_field_value_by_name(
+ struct bt_ctf_private_value *attr_obj, const char *name);
+
+BT_HIDDEN
+int bt_ctf_attributes_freeze(struct bt_ctf_private_value *attr_obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_ATTRIBUTES_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/types.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <glib.h>
+
+struct bt_ctf_clock_class {
+ struct bt_ctf_object base;
+ GString *name;
+ GString *description;
+ uint64_t frequency;
+ uint64_t precision;
+ int64_t offset_s; /* Offset in seconds */
+ int64_t offset; /* Offset in ticks */
+ unsigned char uuid[BABELTRACE_UUID_LEN];
+ int uuid_set;
+ int absolute;
+
+ /*
+ * A clock's properties can't be modified once it is added to a stream
+ * class.
+ */
+ int frozen;
+};
+
+BT_HIDDEN
+void bt_ctf_clock_class_freeze(struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a,
+ struct bt_ctf_clock_class *clock_class_b);
+
+BT_HIDDEN
+struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
+ uint64_t freq);
+BT_HIDDEN
+const char *bt_ctf_clock_class_get_name(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class,
+ const char *name);
+BT_HIDDEN
+const char *bt_ctf_clock_class_get_description(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_description(
+ struct bt_ctf_clock_class *clock_class,
+ const char *desc);
+BT_HIDDEN
+uint64_t bt_ctf_clock_class_get_frequency(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_frequency(
+ struct bt_ctf_clock_class *clock_class, uint64_t freq);
+BT_HIDDEN
+uint64_t bt_ctf_clock_class_get_precision(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_precision(
+ struct bt_ctf_clock_class *clock_class, uint64_t precision);
+BT_HIDDEN
+int bt_ctf_clock_class_get_offset_s(
+ struct bt_ctf_clock_class *clock_class, int64_t *seconds);
+BT_HIDDEN
+int bt_ctf_clock_class_set_offset_s(
+ struct bt_ctf_clock_class *clock_class, int64_t seconds);
+BT_HIDDEN
+int bt_ctf_clock_class_get_offset_cycles(
+ struct bt_ctf_clock_class *clock_class, int64_t *cycles);
+BT_HIDDEN
+int bt_ctf_clock_class_set_offset_cycles(
+ struct bt_ctf_clock_class *clock_class, int64_t cycles);
+BT_HIDDEN
+bt_bool bt_ctf_clock_class_is_absolute(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_is_absolute(
+ struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
+BT_HIDDEN
+const unsigned char *bt_ctf_clock_class_get_uuid(
+ struct bt_ctf_clock_class *clock_class);
+BT_HIDDEN
+int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
+ const unsigned char *uuid);
+
+#endif /* BABELTRACE_CTF_WRITER_CLOCK_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_CLOCK_CLASS_H
+#define BABELTRACE_CTF_WRITER_CLOCK_CLASS_H
+
+/*
+ * BabelTrace - CTF Writer: Clock Class
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_clock_class;
+
+extern struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
+ uint64_t freq);
+
+extern const char *bt_ctf_clock_class_get_name(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class,
+ const char *name);
+
+extern const char *bt_ctf_clock_class_get_description(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_description(
+ struct bt_ctf_clock_class *clock_class,
+ const char *desc);
+
+extern uint64_t bt_ctf_clock_class_get_frequency(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_frequency(
+ struct bt_ctf_clock_class *clock_class, uint64_t freq);
+
+extern uint64_t bt_ctf_clock_class_get_precision(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_precision(
+ struct bt_ctf_clock_class *clock_class, uint64_t precision);
+
+extern int bt_ctf_clock_class_get_offset_s(
+ struct bt_ctf_clock_class *clock_class, int64_t *seconds);
+
+extern int bt_ctf_clock_class_set_offset_s(
+ struct bt_ctf_clock_class *clock_class, int64_t seconds);
+
+extern int bt_ctf_clock_class_get_offset_cycles(
+ struct bt_ctf_clock_class *clock_class, int64_t *cycles);
+
+extern int bt_ctf_clock_class_set_offset_cycles(
+ struct bt_ctf_clock_class *clock_class, int64_t cycles);
+
+extern bt_bool bt_ctf_clock_class_is_absolute(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_is_absolute(
+ struct bt_ctf_clock_class *clock_class, bt_bool is_absolute);
+
+extern const unsigned char *bt_ctf_clock_class_get_uuid(
+ struct bt_ctf_clock_class *clock_class);
+
+extern int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class,
+ const unsigned char *uuid);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_CLOCK_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/clock.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <glib.h>
+#include <babeltrace2/compat/uuid-internal.h>
+
+struct bt_ctf_clock {
+ struct bt_ctf_object base;
+ struct bt_ctf_clock_class *clock_class;
+ uint64_t value; /* Current clock value */
+};
+
+struct metadata_context;
+
+BT_HIDDEN
+int bt_ctf_clock_get_value(struct bt_ctf_clock *clock, uint64_t *value);
+
+BT_HIDDEN
+void bt_ctf_clock_class_serialize(struct bt_ctf_clock_class *clock_class,
+ struct metadata_context *context);
+
+#endif /* BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_CLOCK_H
+#define BABELTRACE_CTF_WRITER_CLOCK_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_clock;
+struct bt_ctf_clock_class;
+
+/*
+ * bt_ctf_clock_create: create a clock.
+ *
+ * Allocate a new clock setting its reference count to 1.
+ *
+ * @param name Name of the clock (will be copied); can be set to NULL
+ * for nameless clocks.
+ *
+ * Returns an allocated clock on success, NULL on error.
+ */
+extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
+
+/*
+ * bt_ctf_clock_get_name: get a clock's name.
+ *
+ * Get the clock's name.
+ *
+ * @param clock Clock instance.
+ *
+ * Returns the clock's name, NULL on error.
+ */
+extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_get_description: get a clock's description.
+ *
+ * Get the clock's description.
+ *
+ * @param clock Clock instance.
+ *
+ * Returns the clock's description, NULL if unset.
+ */
+extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_set_description: set a clock's description.
+ *
+ * Set the clock's description. The description appears in the clock's TSDL
+ * meta-data.
+ *
+ * @param clock Clock instance.
+ * @param desc Description of the clock.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
+ const char *desc);
+
+/*
+ * bt_ctf_clock_get_frequency: get a clock's frequency.
+ *
+ * Get the clock's frequency (Hz).
+ *
+ * @param clock Clock instance.
+ *
+ * Returns the clock's frequency, -1ULL on error.
+ */
+extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_set_frequency: set a clock's frequency.
+ *
+ * Set the clock's frequency (Hz).
+ *
+ * @param clock Clock instance.
+ * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
+ uint64_t freq);
+
+/*
+ * bt_ctf_clock_get_precision: get a clock's precision.
+ *
+ * Get the clock's precision (in clock ticks).
+ *
+ * @param clock Clock instance.
+ *
+ * Returns the clock's precision, -1ULL on error.
+ */
+extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_set_precision: set a clock's precision.
+ *
+ * Set the clock's precision.
+ *
+ * @param clock Clock instance.
+ * @param precision Clock's precision in clock ticks, defaults to 1.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
+ uint64_t precision);
+
+/*
+ * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
+ *
+ * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
+ *
+ * @param clock Clock instance.
+ * @param offset_s Pointer to clock offset in seconds (output).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock,
+ int64_t *offset_s);
+
+/*
+ * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
+ *
+ * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
+ * defaults to 0.
+ *
+ * @param clock Clock instance.
+ * @param offset_s Clock's offset in seconds, defaults to 0.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
+ int64_t offset_s);
+
+/*
+ * bt_ctf_clock_get_offset: get a clock's offset in ticks.
+ *
+ * Get the clock's offset in ticks from Epoch + offset_t.
+ *
+ * @param clock Clock instance.
+ * @param offset Clock offset in ticks from Epoch + offset_s (output).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_get_offset(struct bt_ctf_clock *clock,
+ int64_t *offset);
+
+/*
+ * bt_ctf_clock_set_offset: set a clock's offset in ticks.
+ *
+ * Set the clock's offset in ticks from Epoch + offset_s.
+ *
+ * @param clock Clock instance.
+ * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
+ int64_t offset);
+
+/*
+ * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
+ *
+ * Get the clock's absolute attribute. A clock is absolute if the clock is a
+ * global reference across the trace's other clocks.
+ *
+ * @param clock Clock instance.
+ *
+ * Returns the clock's absolute attribute, a negative value on error.
+ */
+extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
+ *
+ * Set the clock's absolute attribute. A clock is absolute if the clock is a
+ * global reference across the trace's other clocks.
+ *
+ * @param clock Clock instance.
+ * @param is_absolute Clock's absolute attribute, defaults to FALSE.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
+ int is_absolute);
+
+/*
+ * bt_ctf_clock_get_uuid: get a clock's UUID.
+ *
+ * Get the clock's UUID.
+ *
+ * @param clock Clock instance.
+ *
+ * Returns a pointer to the clock's UUID (16 byte array) on success,
+ * NULL on error.
+ */
+extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_clock_set_uuid: set a clock's UUID.
+ *
+ * Set a clock's UUID.
+ *
+ * @param clock Clock instance.
+ * @param uuid A 16-byte array containing a UUID.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock,
+ const unsigned char *uuid);
+
+/*
+ * bt_ctf_clock_set_time: set a clock's current time value.
+ *
+ * Set the current time in nanoseconds since the clock's origin (offset and
+ * offset_s attributes). Defaults to 0.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock,
+ int64_t time);
+
+/*
+ * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
+ * refcount of the clock
+ *
+ * You may also use bt_ctf_get() and bt_ctf_put() with clock objects.
+ *
+ * These functions ensure that the clock won't be destroyed when it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) has to be done to
+ * destroy a clock.
+ *
+ * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
+ * the clock is freed.
+ *
+ * @param clock Clock instance.
+ */
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_clock_get(struct bt_ctf_clock *clock)
+{
+ bt_ctf_object_get_ref(clock);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_clock_put(struct bt_ctf_clock *clock)
+{
+ bt_ctf_object_put_ref(clock);
+}
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_CLOCK_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <glib.h>
+
+struct bt_ctf_event_class_common {
+ struct bt_ctf_object base;
+ struct bt_ctf_field_type_common *context_field_type;
+ struct bt_ctf_field_type_common *payload_field_type;
+ int frozen;
+
+ /*
+ * This flag indicates if the event class is valid. A valid
+ * event class is _always_ frozen. However, an event class
+ * may be frozen, but not valid yet. This is okay, as long as
+ * no events are created out of this event class.
+ */
+ int valid;
+
+ /* Attributes */
+ GString *name;
+ int64_t id;
+ int log_level;
+ GString *emf_uri;
+};
+
+BT_HIDDEN
+void bt_ctf_event_class_common_freeze(struct bt_ctf_event_class_common *event_class);
+
+BT_HIDDEN
+void bt_ctf_event_class_common_set_native_byte_order(
+ struct bt_ctf_event_class_common *event_class, int byte_order);
+
+static inline
+struct bt_ctf_stream_class_common *bt_ctf_event_class_common_borrow_stream_class(
+ struct bt_ctf_event_class_common *event_class)
+{
+ BT_ASSERT(event_class);
+ return (void *) bt_ctf_object_borrow_parent(&event_class->base);
+}
+
+typedef struct bt_ctf_field_type_common *(*bt_ctf_field_type_structure_create_func)();
+
+BT_HIDDEN
+int bt_ctf_event_class_common_initialize(struct bt_ctf_event_class_common *event_class,
+ const char *name, bt_ctf_object_release_func release_func,
+ bt_ctf_field_type_structure_create_func ft_struct_create_func);
+
+BT_HIDDEN
+void bt_ctf_event_class_common_finalize(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+int bt_ctf_event_class_common_validate_single_clock_class(
+ struct bt_ctf_event_class_common *event_class,
+ struct bt_ctf_clock_class **expected_clock_class);
+
+static inline
+const char *bt_ctf_event_class_common_get_name(
+ struct bt_ctf_event_class_common *event_class)
+{
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ BT_ASSERT(event_class->name);
+ return event_class->name->str;
+}
+
+static inline
+int64_t bt_ctf_event_class_common_get_id(
+ struct bt_ctf_event_class_common *event_class)
+{
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->id;
+}
+
+static inline
+int bt_ctf_event_class_common_set_id(
+ struct bt_ctf_event_class_common *event_class, uint64_t id_param)
+{
+ int ret = 0;
+ int64_t id = (int64_t) id_param;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class,
+ bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (id < 0) {
+ BT_LOGW("Invalid parameter: invalid event class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRIu64,
+ event_class,
+ bt_ctf_event_class_common_get_name(event_class),
+ id_param);
+ ret = -1;
+ goto end;
+ }
+
+ event_class->id = id;
+ BT_LOGV("Set event class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_ctf_event_class_common_get_name(event_class), id);
+
+end:
+ return ret;
+}
+
+static inline
+int bt_ctf_event_class_common_get_log_level(
+ struct bt_ctf_event_class_common *event_class)
+{
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->log_level;
+}
+
+static inline
+int bt_ctf_event_class_common_set_log_level(
+ struct bt_ctf_event_class_common *event_class, int log_level)
+{
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class,
+ bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ switch (log_level) {
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG:
+ break;
+ default:
+ BT_LOGW("Invalid parameter: unknown event class log level: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class), log_level);
+ ret = -1;
+ goto end;
+ }
+
+ event_class->log_level = log_level;
+ BT_LOGV("Set event class's log level: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class),
+ bt_ctf_event_class_log_level_string(log_level));
+
+end:
+ return ret;
+}
+
+static inline
+const char *bt_ctf_event_class_common_get_emf_uri(
+ struct bt_ctf_event_class_common *event_class)
+{
+ const char *emf_uri = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+ if (event_class->emf_uri->len > 0) {
+ emf_uri = event_class->emf_uri->str;
+ }
+
+ return emf_uri;
+}
+
+static inline
+int bt_ctf_event_class_common_set_emf_uri(
+ struct bt_ctf_event_class_common *event_class,
+ const char *emf_uri)
+{
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (emf_uri && strlen(emf_uri) == 0) {
+ BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (emf_uri) {
+ g_string_assign(event_class->emf_uri, emf_uri);
+ BT_LOGV("Set event class's EMF URI: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class), emf_uri);
+ } else {
+ g_string_assign(event_class->emf_uri, "");
+ BT_LOGV("Reset event class's EMF URI: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ }
+
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_context_field_type(
+ struct bt_ctf_event_class_common *event_class)
+{
+ struct bt_ctf_field_type_common *context_ft = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+ if (!event_class->context_field_type) {
+ BT_LOGV("Event class has no context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ goto end;
+ }
+
+ context_ft = event_class->context_field_type;
+
+end:
+ return context_ft;
+}
+
+static inline
+int bt_ctf_event_class_common_set_context_field_type(
+ struct bt_ctf_event_class_common *event_class,
+ struct bt_ctf_field_type_common *context_ft)
+{
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (context_ft && bt_ctf_field_type_common_get_type_id(context_ft) !=
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
+ BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "context-ft-id=%s",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class),
+ bt_ctf_field_type_id_string(
+ bt_ctf_field_type_common_get_type_id(context_ft)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_object_put_ref(event_class->context_field_type);
+ event_class->context_field_type = context_ft;
+ bt_ctf_object_get_ref(event_class->context_field_type);
+ BT_LOGV("Set event class's context field type: "
+ "event-class-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", context-ft-addr=%p",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class), context_ft);
+
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_type_common *bt_ctf_event_class_common_borrow_payload_field_type(
+ struct bt_ctf_event_class_common *event_class)
+{
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->payload_field_type;
+}
+
+static inline
+int bt_ctf_event_class_common_set_payload_field_type(
+ struct bt_ctf_event_class_common *event_class,
+ struct bt_ctf_field_type_common *payload_ft)
+{
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (payload_ft && bt_ctf_field_type_common_get_type_id(payload_ft) !=
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
+ BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "payload-ft-addr=%p, payload-ft-id=%s",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class), payload_ft,
+ bt_ctf_field_type_id_string(
+ bt_ctf_field_type_common_get_type_id(payload_ft)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_object_put_ref(event_class->payload_field_type);
+ event_class->payload_field_type = payload_ft;
+ bt_ctf_object_get_ref(event_class->payload_field_type);
+ BT_LOGV("Set event class's payload field type: "
+ "event-class-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", payload-ft-addr=%p",
+ event_class, bt_ctf_event_class_common_get_name(event_class),
+ bt_ctf_event_class_common_get_id(event_class), payload_ft);
+end:
+ return ret;
+}
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
+#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
+ * field's reference count.
+ *
+ * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field objects.
+ *
+ * These functions ensure that the field won't be destroyed when it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) have to be done to
+ * destroy a field.
+ *
+ * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
+ * the field is freed.
+ *
+ * @param field Field instance.
+ */
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_field_get(struct bt_ctf_field *field)
+{
+ bt_ctf_object_get_ref(field);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_field_put(struct bt_ctf_field *field)
+{
+ bt_ctf_object_put_ref(field);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/field-wrapper-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/ctfser-internal.h>
+
+struct bt_ctf_stream_class;
+struct bt_ctf_stream_pos;
+struct metadata_context;
+
+struct bt_ctf_event_common {
+ struct bt_ctf_object base;
+ struct bt_ctf_event_class_common *class;
+ struct bt_ctf_field_wrapper *header_field;
+ struct bt_ctf_field_common *stream_event_context_field;
+ struct bt_ctf_field_common *context_field;
+ struct bt_ctf_field_common *payload_field;
+ int frozen;
+};
+
+BT_HIDDEN
+int _bt_ctf_event_common_validate(struct bt_ctf_event_common *event);
+
+BT_HIDDEN
+void _bt_ctf_event_common_set_is_frozen(struct bt_ctf_event_common *event,
+ bool is_frozen);
+
+#ifdef BT_DEV_MODE
+# define bt_ctf_event_common_validate _bt_ctf_event_common_validate
+# define bt_ctf_event_common_set_is_frozen _bt_ctf_event_common_set_is_frozen
+#else
+# define bt_ctf_event_common_validate(_event) 0
+# define bt_ctf_event_common_set_is_frozen(_event, _is_frozen)
+#endif
+
+#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \
+ BT_ASSERT_PRE_HOT((_event), (_name), ": event-addr=%p", (_event))
+
+static inline
+struct bt_ctf_event_class_common *bt_ctf_event_common_borrow_class(
+ struct bt_ctf_event_common *event)
+{
+ BT_ASSERT(event);
+ return event->class;
+}
+
+typedef void *(*create_field_func)(void *);
+typedef void (*release_field_func)(void *);
+typedef void *(*create_header_field_func)(void *, void *);
+typedef void (*release_header_field_func)(void *, void *);
+
+BT_HIDDEN
+int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event,
+ struct bt_ctf_event_class_common *event_class,
+ struct bt_ctf_clock_class *init_expected_clock_class,
+ bool is_shared_with_parent, bt_ctf_object_release_func release_func,
+ bt_ctf_validation_flag_copy_field_type_func field_type_copy_func,
+ bool must_be_in_trace,
+ int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_field_type_common *packet_context_field_type,
+ struct bt_ctf_field_type_common *event_header_field_type),
+ create_field_func create_field_func,
+ release_field_func release_field_func,
+ create_header_field_func create_header_field_func,
+ release_header_field_func release_header_field_func);
+
+static inline
+struct bt_ctf_field_common *bt_ctf_event_common_borrow_payload(
+ struct bt_ctf_event_common *event)
+{
+ struct bt_ctf_field_common *payload = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->payload_field) {
+ BT_LOGV("Event has no current payload field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_ctf_event_class_common_get_name(event->class),
+ bt_ctf_event_class_common_get_id(event->class));
+ goto end;
+ }
+
+ payload = event->payload_field;
+
+end:
+ return payload;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_event_common_borrow_header(
+ struct bt_ctf_event_common *event)
+{
+ struct bt_ctf_field_common *header = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->header_field) {
+ BT_LOGV("Event has no current header field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_ctf_event_class_common_get_name(event->class),
+ bt_ctf_event_class_common_get_id(event->class));
+ goto end;
+ }
+
+ header = event->header_field->field;
+
+end:
+ return header;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_event_common_borrow_context(
+ struct bt_ctf_event_common *event)
+{
+ struct bt_ctf_field_common *context = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->context_field) {
+ BT_LOGV("Event has no current context field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_ctf_event_class_common_get_name(event->class),
+ bt_ctf_event_class_common_get_id(event->class));
+ goto end;
+ }
+
+ context = event->context_field;
+
+end:
+ return context;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_event_common_borrow_stream_event_context(
+ struct bt_ctf_event_common *event)
+{
+ struct bt_ctf_field_common *stream_event_context = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->stream_event_context_field) {
+ BT_LOGV("Event has no current stream event context field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_ctf_event_class_common_get_name(event->class),
+ bt_ctf_event_class_common_get_id(event->class));
+ goto end;
+ }
+
+ stream_event_context = event->stream_event_context_field;
+
+end:
+ return stream_event_context;
+}
+
+static inline
+void bt_ctf_event_common_finalize(struct bt_ctf_object *obj,
+ void (*field_release_func)(void *),
+ void (*header_field_release_func)(void *, struct bt_ctf_event_common *))
+{
+ struct bt_ctf_event_common *event = (void *) obj;
+
+ BT_LOGD("Destroying event: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event,
+ event->class ? bt_ctf_event_class_common_get_name(event->class) : NULL,
+ event->class ? bt_ctf_event_class_common_get_id(event->class) : INT64_C(-1));
+
+ if (event->header_field) {
+ BT_LOGD_STR("Releasing event's header field.");
+ header_field_release_func(event->header_field, event);
+ }
+
+ if (event->stream_event_context_field) {
+ BT_LOGD_STR("Releasing event's stream event context field.");
+ field_release_func(event->stream_event_context_field);
+ }
+
+ if (event->context_field) {
+ BT_LOGD_STR("Releasing event's context field.");
+ field_release_func(event->context_field);
+ }
+
+ if (event->payload_field) {
+ BT_LOGD_STR("Releasing event's payload field.");
+ field_release_func(event->payload_field);
+ }
+
+ /*
+ * Leave this after calling header_field_release_func() because
+ * this function receives the event object and could need its
+ * class to perform some cleanup.
+ */
+ if (!event->base.parent) {
+ /*
+ * Event was keeping a reference to its class since it shared no
+ * common ancestor with it to guarantee they would both have the
+ * same lifetime.
+ */
+ bt_ctf_object_put_ref(event->class);
+ }
+}
+
+struct bt_ctf_event {
+ struct bt_ctf_event_common common;
+};
+
+struct bt_ctf_event_class {
+ struct bt_ctf_event_class_common common;
+};
+
+BT_HIDDEN
+int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
+ struct metadata_context *context);
+
+BT_HIDDEN
+int bt_ctf_event_serialize(struct bt_ctf_event *event,
+ struct bt_ctfser *pos,
+ enum bt_ctf_byte_order native_byte_order);
+
+static inline
+struct bt_ctf_stream_class *bt_ctf_event_class_borrow_stream_class(
+ struct bt_ctf_event_class *event_class)
+{
+ return BT_CTF_FROM_COMMON(bt_ctf_event_class_common_borrow_stream_class(
+ BT_CTF_TO_COMMON(event_class)));
+}
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_EVENT_TYPES_H
+#define BABELTRACE_CTF_WRITER_EVENT_TYPES_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
+ * the field type's reference count.
+ *
+ * You may also use bt_ctf_object_get_ref() and bt_ctf_object_put_ref() with field type objects.
+ *
+ * These functions ensure that the field type won't be destroyed while it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) have to be done to
+ * destroy a field type.
+ *
+ * When the field type's reference count is decremented to 0 by a
+ * bt_ctf_field_type_put, the field type is freed.
+ *
+ * @param type Field type.
+ */
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
+{
+ bt_ctf_object_get_ref(type);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_field_type_put(struct bt_ctf_field_type *type)
+{
+ bt_ctf_object_put_ref(type);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_TYPES_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_EVENT_H
+#define BABELTRACE_CTF_WRITER_EVENT_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/ctf-writer/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event;
+struct bt_ctf_event_class;
+struct bt_ctf_stream;
+struct bt_ctf_field;
+struct bt_ctf_field_type;
+
+enum bt_ctf_event_class_log_level {
+ /// Unknown, used for errors.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN = -1,
+
+ /// Unspecified log level.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED = 255,
+
+ /// System is unusable.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY = 0,
+
+ /// Action must be taken immediately.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT = 1,
+
+ /// Critical conditions.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL = 2,
+
+ /// Error conditions.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR = 3,
+
+ /// Warning conditions.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING = 4,
+
+ /// Normal, but significant, condition.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE = 5,
+
+ /// Informational message.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO = 6,
+
+ /// Debug information with system-level scope (set of programs).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM = 7,
+
+ /// Debug information with program-level scope (set of processes).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM = 8,
+
+ /// Debug information with process-level scope (set of modules).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS = 9,
+
+ /// Debug information with module (executable/library) scope (set of units).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE = 10,
+
+ /// Debug information with compilation unit scope (set of functions).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT = 11,
+
+ /// Debug information with function-level scope.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION = 12,
+
+ /// Debug information with line-level scope (default log level).
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE = 13,
+
+ /// Debug-level message.
+ BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG = 14,
+};
+
+extern struct bt_ctf_event *bt_ctf_event_create(
+ struct bt_ctf_event_class *event_class);
+
+extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
+ const char *name);
+
+extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
+ const char *name, struct bt_ctf_field *field);
+
+extern struct bt_ctf_field *bt_ctf_event_get_payload_field(
+ struct bt_ctf_event *event);
+
+extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event,
+ struct bt_ctf_field *field);
+
+extern int bt_ctf_event_set_context(struct bt_ctf_event *event,
+ struct bt_ctf_field *field);
+
+extern struct bt_ctf_field *bt_ctf_event_get_context(
+ struct bt_ctf_event *event);
+
+extern int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event,
+ struct bt_ctf_field *field);
+
+extern struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
+ struct bt_ctf_event *event);
+
+extern int bt_ctf_event_set_header(struct bt_ctf_event *event,
+ struct bt_ctf_field *field);
+
+extern struct bt_ctf_field *bt_ctf_event_get_header(
+ struct bt_ctf_event *event);
+
+extern struct bt_ctf_stream *bt_ctf_event_get_stream(
+ struct bt_ctf_event *event);
+
+extern struct bt_ctf_event_class *bt_ctf_event_get_class(
+ struct bt_ctf_event *event);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_event_get(struct bt_ctf_event *event)
+{
+ bt_ctf_object_get_ref(event);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_event_put(struct bt_ctf_event *event)
+{
+ bt_ctf_object_put_ref(event);
+}
+
+extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
+
+extern struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class(
+ struct bt_ctf_event_class *event_class);
+
+extern const char *bt_ctf_event_class_get_name(
+ struct bt_ctf_event_class *event_class);
+
+extern int64_t bt_ctf_event_class_get_id(
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_event_class_set_id(
+ struct bt_ctf_event_class *event_class, uint64_t id);
+
+extern enum bt_ctf_event_class_log_level bt_ctf_event_class_get_log_level(
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_event_class_set_log_level(
+ struct bt_ctf_event_class *event_class,
+ enum bt_ctf_event_class_log_level log_level);
+
+extern const char *bt_ctf_event_class_get_emf_uri(
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_event_class_set_emf_uri(
+ struct bt_ctf_event_class *event_class,
+ const char *emf_uri);
+
+extern struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type(
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_event_class_set_context_field_type(
+ struct bt_ctf_event_class *event_class,
+ struct bt_ctf_field_type *context_type);
+
+extern struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type(
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_event_class_set_payload_field_type(
+ struct bt_ctf_event_class *event_class,
+ struct bt_ctf_field_type *payload_type);
+
+extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class,
+ struct bt_ctf_field_type *field_type,
+ const char *name);
+
+extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name(
+ struct bt_ctf_event_class *event_class, const char *name);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class)
+{
+ bt_ctf_object_get_ref(event_class);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class)
+{
+ bt_ctf_object_put_ref(event_class);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL
+#define BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL
+
+/*
+ * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <glib.h>
+
+struct bt_ctf_field_path {
+ struct bt_ctf_object base;
+ enum bt_ctf_scope root;
+
+ /*
+ * Array of integers (int) indicating the index in either
+ * structures, variants, arrays, or sequences that make up
+ * the path to a field type. -1 means the "current element
+ * of an array or sequence type".
+ */
+ GArray *indexes;
+};
+
+BT_HIDDEN
+struct bt_ctf_field_path *bt_ctf_field_path_create(void);
+
+BT_HIDDEN
+void bt_ctf_field_path_clear(struct bt_ctf_field_path *field_path);
+
+BT_HIDDEN
+struct bt_ctf_field_path *bt_ctf_field_path_copy(
+ struct bt_ctf_field_path *path);
+
+BT_HIDDEN enum bt_ctf_scope bt_ctf_field_path_get_root_scope(
+ const struct bt_ctf_field_path *field_path);
+
+BT_HIDDEN int64_t bt_ctf_field_path_get_index_count(
+ const struct bt_ctf_field_path *field_path);
+
+BT_HIDDEN int bt_ctf_field_path_get_index(
+ const struct bt_ctf_field_path *field_path, uint64_t index);
+
+#endif /* BABELTRACE_CTF_WRITER_FIELD_PATH_INTERNAL */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/types.h>
+
+#define BT_ASSERT_PRE_CTF_FT_COMMON_HAS_ID(_ft, _type_id, _name) \
+ BT_ASSERT_PRE(((struct bt_ctf_field_type_common *) (_ft))->id == (_type_id), \
+ _name " has the wrong type ID: expected-type-id=%s, " \
+ "ft-addr=%p", bt_ctf_field_type_id_string(_type_id), (_ft))
+
+#define BT_ASSERT_PRE_CTF_FT_HOT(_ft, _name) \
+ BT_ASSERT_PRE_HOT((_ft), (_name), ": ft-addr=%p", (_ft))
+
+#define BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
+ (&g_array_index(((struct bt_ctf_field_type_common_structure *) (_ft))->fields, \
+ struct bt_ctf_field_type_common_structure_field, (_index)))
+
+#define BT_CTF_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index) \
+ (&g_array_index(((struct bt_ctf_field_type_common_variant *) (_ft))->choices, \
+ struct bt_ctf_field_type_common_variant_choice, (_index)))
+
+struct bt_ctf_field_common;
+struct bt_ctf_field_type_common;
+
+typedef void (*bt_ctf_field_type_common_method_freeze)(
+ struct bt_ctf_field_type_common *);
+typedef int (*bt_ctf_field_type_common_method_validate)(
+ struct bt_ctf_field_type_common *);
+typedef void (*bt_ctf_field_type_common_method_set_byte_order)(
+ struct bt_ctf_field_type_common *, enum bt_ctf_byte_order);
+typedef struct bt_ctf_field_type_common *(*bt_ctf_field_type_common_method_copy)(
+ struct bt_ctf_field_type_common *);
+typedef int (*bt_ctf_field_type_common_method_compare)(
+ struct bt_ctf_field_type_common *,
+ struct bt_ctf_field_type_common *);
+
+struct bt_ctf_field_type_common_methods {
+ bt_ctf_field_type_common_method_freeze freeze;
+ bt_ctf_field_type_common_method_validate validate;
+ bt_ctf_field_type_common_method_set_byte_order set_byte_order;
+ bt_ctf_field_type_common_method_copy copy;
+ bt_ctf_field_type_common_method_compare compare;
+};
+
+struct bt_ctf_field_type_common {
+ struct bt_ctf_object base;
+ enum bt_ctf_field_type_id id;
+ unsigned int alignment;
+
+ /* Virtual table */
+ struct bt_ctf_field_type_common_methods *methods;
+
+ /*
+ * A type can't be modified once it is added to an event or after a
+ * a field has been instanciated from it.
+ */
+ int frozen;
+
+ /*
+ * This flag indicates if the field type is valid. A valid
+ * field type is _always_ frozen. All the nested field types of
+ * a valid field type are also valid (and thus frozen).
+ */
+ int valid;
+
+ /*
+ * Specialized data for either CTF IR or CTF writer APIs.
+ * Having this here ensures that:
+ *
+ * * The type-specific common data is always found at the same
+ * offset when the common API has a `struct
+ * bt_ctf_field_type_common *` so that you can cast it to `struct
+ * bt_ctf_field_type_common_integer *` for example and access the
+ * common integer field type fields.
+ *
+ * * The specific CTF IR and CTF writer APIs can access their
+ * specific field type fields in this union at an offset known
+ * at build time. This avoids a pointer to specific data so
+ * that all the fields, common or specific, of a CTF IR
+ * integer field type or of a CTF writer integer field type,
+ * for example, are contained within the same contiguous block
+ * of memory.
+ */
+ union {
+ struct {
+ } ir;
+ struct {
+ void *serialize_func;
+ } writer;
+ } spec;
+};
+
+struct bt_ctf_field_type_common_integer {
+ struct bt_ctf_field_type_common common;
+
+ /* Owned by this */
+ struct bt_ctf_clock_class *mapped_clock_class;
+
+ enum bt_ctf_byte_order user_byte_order;
+ bt_bool is_signed;
+ unsigned int size;
+ enum bt_ctf_integer_base base;
+ enum bt_ctf_string_encoding encoding;
+};
+
+struct bt_ctf_enumeration_mapping {
+ union {
+ uint64_t _unsigned;
+ int64_t _signed;
+ } range_start;
+ union {
+ uint64_t _unsigned;
+ int64_t _signed;
+ } range_end;
+ GQuark string;
+};
+
+struct bt_ctf_field_type_common_enumeration {
+ struct bt_ctf_field_type_common common;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common_integer *container_ft;
+
+ /* Array of `struct bt_ctf_enumeration_mapping *`, owned by this */
+ GPtrArray *entries;
+
+ /* Only set during validation */
+ bt_bool has_overlapping_ranges;
+};
+
+enum bt_ctf_field_type_enumeration_mapping_iterator_type {
+ CTF_ITERATOR_BY_NAME,
+ CTF_ITERATOR_BY_SIGNED_VALUE,
+ CTF_ITERATOR_BY_UNSIGNED_VALUE,
+};
+
+struct bt_ctf_field_type_enumeration_mapping_iterator {
+ struct bt_ctf_object base;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common_enumeration *enumeration_ft;
+
+ enum bt_ctf_field_type_enumeration_mapping_iterator_type type;
+ int index;
+ union {
+ GQuark name_quark;
+ int64_t signed_value;
+ uint64_t unsigned_value;
+ } u;
+};
+
+struct bt_ctf_field_type_common_floating_point {
+ struct bt_ctf_field_type_common common;
+ enum bt_ctf_byte_order user_byte_order;
+ unsigned int exp_dig;
+ unsigned int mant_dig;
+};
+
+struct bt_ctf_field_type_common_structure_field {
+ GQuark name;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common *type;
+};
+
+struct bt_ctf_field_type_common_structure {
+ struct bt_ctf_field_type_common common;
+ GHashTable *field_name_to_index;
+
+ /*
+ * Array of `struct bt_ctf_field_type_common_structure_field`,
+ * owned by this
+ */
+ GArray *fields;
+};
+
+struct bt_ctf_field_type_common_variant_choice_range {
+ union {
+ int64_t i;
+ uint64_t u;
+ } lower;
+ union {
+ int64_t i;
+ uint64_t u;
+ } upper;
+};
+
+struct bt_ctf_field_type_common_variant_choice {
+ GQuark name;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common *type;
+
+ /* Array of `struct bt_ctf_field_type_common_variant_choice_range` */
+ GArray *ranges;
+};
+
+struct bt_ctf_field_type_common_variant {
+ struct bt_ctf_field_type_common common;
+ GString *tag_name;
+ bool choices_up_to_date;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common_enumeration *tag_ft;
+
+ /* Owned by this */
+ struct bt_ctf_field_path *tag_field_path;
+
+ GHashTable *choice_name_to_index;
+
+ /*
+ * Array of `struct bt_ctf_field_type_common_variant_choice`,
+ * owned by this */
+ GArray *choices;
+};
+
+struct bt_ctf_field_type_common_array {
+ struct bt_ctf_field_type_common common;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common *element_ft;
+
+ unsigned int length;
+};
+
+struct bt_ctf_field_type_common_sequence {
+ struct bt_ctf_field_type_common common;
+
+ /* Owned by this */
+ struct bt_ctf_field_type_common *element_ft;
+
+ GString *length_field_name;
+
+ /* Owned by this */
+ struct bt_ctf_field_path *length_field_path;
+};
+
+struct bt_ctf_field_type_common_string {
+ struct bt_ctf_field_type_common common;
+ enum bt_ctf_string_encoding encoding;
+};
+
+typedef struct bt_ctf_field_common *(* bt_ctf_field_common_create_func)(
+ struct bt_ctf_field_type_common *);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_initialize(struct bt_ctf_field_type_common *ft,
+ bool init_bo, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_integer_initialize(
+ struct bt_ctf_field_type_common *ft,
+ unsigned int size, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_floating_point_initialize(
+ struct bt_ctf_field_type_common *ft,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_enumeration_initialize(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *container_ft,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_string_initialize(
+ struct bt_ctf_field_type_common *ft,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_structure_initialize(
+ struct bt_ctf_field_type_common *ft,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_array_initialize(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *element_ft,
+ unsigned int length, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_sequence_initialize(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *element_ft,
+ const char *length_field_name,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_variant_initialize(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *tag_ft,
+ const char *tag_name,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_type_common_methods *methods);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_integer_destroy(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_floating_point_destroy(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_string_destroy(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_structure_destroy_recursive(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_array_destroy_recursive(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_ctf_object *obj);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_validate(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_validate_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_sequence_validate_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_array_validate_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_validate_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_validate_recursive(
+ struct bt_ctf_field_type_common *type);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_validate(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_get_size(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_type_common_integer_is_signed(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_is_signed(struct bt_ctf_field_type_common *ft,
+ bt_bool is_signed);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_size(struct bt_ctf_field_type_common *ft,
+ unsigned int size);
+
+BT_HIDDEN
+enum bt_ctf_integer_base bt_ctf_field_type_common_integer_get_base(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_base(struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_integer_base base);
+
+BT_HIDDEN
+enum bt_ctf_string_encoding bt_ctf_field_type_common_integer_get_encoding(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_encoding(struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_string_encoding encoding);
+
+BT_HIDDEN
+struct bt_ctf_clock_class *bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_set_mapped_clock_class(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+struct bt_ctf_field_type_enumeration_mapping_iterator *
+bt_ctf_field_type_common_enumeration_find_mappings_by_name(
+ struct bt_ctf_field_type_common *ft, const char *name);
+
+BT_HIDDEN
+struct bt_ctf_field_type_enumeration_mapping_iterator *
+bt_ctf_field_type_common_enumeration_signed_find_mappings_by_value(
+ struct bt_ctf_field_type_common *ft, int64_t value);
+
+BT_HIDDEN
+struct bt_ctf_field_type_enumeration_mapping_iterator *
+bt_ctf_field_type_common_enumeration_unsigned_find_mappings_by_value(
+ struct bt_ctf_field_type_common *ft, uint64_t value);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_signed_get_mapping_by_index(
+ struct bt_ctf_field_type_common *ft, uint64_t index,
+ const char **mapping_name, int64_t *range_begin,
+ int64_t *range_end);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_unsigned_get_mapping_by_index(
+ struct bt_ctf_field_type_common *ft, uint64_t index,
+ const char **mapping_name, uint64_t *range_begin,
+ uint64_t *range_end);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_enumeration_borrow_container_field_type(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_signed_add_mapping(
+ struct bt_ctf_field_type_common *ft, const char *string,
+ int64_t range_start, int64_t range_end);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_unsigned_add_mapping(
+ struct bt_ctf_field_type_common *ft, const char *string,
+ uint64_t range_start, uint64_t range_end);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_enumeration_get_mapping_count(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_floating_point_get_exponent_digits(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_floating_point_set_exponent_digits(
+ struct bt_ctf_field_type_common *ft,
+ unsigned int exponent_digits);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_floating_point_get_mantissa_digits(
+ struct bt_ctf_field_type_common *type);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_floating_point_set_mantissa_digits(
+ struct bt_ctf_field_type_common *ft, unsigned int mantissa_digits);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_replace_field(
+ struct bt_ctf_field_type_common *ft,
+ const char *field_name,
+ struct bt_ctf_field_type_common *field_type);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_add_field(struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *field_type,
+ const char *field_name);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_structure_get_field_count(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_borrow_field_by_index(
+ struct bt_ctf_field_type_common *ft,
+ const char **field_name,
+ struct bt_ctf_field_type_common **field_type, uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_structure_borrow_field_type_by_name(
+ struct bt_ctf_field_type_common *ft, const char *name);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_variant_borrow_tag_field_type(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+const char *bt_ctf_field_type_common_variant_get_tag_name(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_set_tag_name(
+ struct bt_ctf_field_type_common *ft, const char *name);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_add_field(struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *field_type,
+ const char *field_name);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_update_choices(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_variant_borrow_field_type_by_name(
+ struct bt_ctf_field_type_common *ft,
+ const char *field_name);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_variant_get_field_count(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_borrow_field_by_index(
+ struct bt_ctf_field_type_common *ft,
+ const char **field_name,
+ struct bt_ctf_field_type_common **field_type, uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_array_borrow_element_field_type(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_array_set_element_field_type(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *element_ft);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_array_get_length(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_sequence_borrow_element_field_type(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_sequence_set_element_field_type(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *element_ft);
+
+BT_HIDDEN
+const char *bt_ctf_field_type_common_sequence_get_length_field_name(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+enum bt_ctf_string_encoding bt_ctf_field_type_common_string_get_encoding(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_string_set_encoding(struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_string_encoding encoding);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_get_alignment(struct bt_ctf_field_type_common *type);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_set_alignment(struct bt_ctf_field_type_common *ft,
+ unsigned int alignment);
+
+BT_HIDDEN
+enum bt_ctf_byte_order bt_ctf_field_type_common_get_byte_order(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_set_byte_order(struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+enum bt_ctf_field_type_id bt_ctf_field_type_common_get_type_id(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_freeze(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_variant_borrow_field_type_signed(
+ struct bt_ctf_field_type_common_variant *var_ft,
+ int64_t tag_value);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *
+bt_ctf_field_type_common_variant_borrow_field_type_unsigned(
+ struct bt_ctf_field_type_common_variant *var_ft,
+ uint64_t tag_value);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *bt_ctf_field_type_common_copy(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_get_field_name_index(
+ struct bt_ctf_field_type_common *ft, const char *name);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_get_field_name_index(
+ struct bt_ctf_field_type_common *ft, const char *name);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_sequence_set_length_field_path(
+ struct bt_ctf_field_type_common *ft, struct bt_ctf_field_path *path);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_set_tag_field_path(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_path *path);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_set_tag_field_type(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_field_type_common *tag_ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_generic_freeze(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_enumeration_freeze_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_structure_freeze_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_variant_freeze_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_array_freeze_recursive(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_sequence_freeze_recursive(
+ struct bt_ctf_field_type_common *type);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_integer_set_byte_order(
+ struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_enumeration_set_byte_order_recursive(
+ struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_floating_point_set_byte_order(
+ struct bt_ctf_field_type_common *ft, enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_structure_set_byte_order_recursive(
+ struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_variant_set_byte_order_recursive(
+ struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_array_set_byte_order_recursive(
+ struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_field_type_common_sequence_set_byte_order_recursive(
+ struct bt_ctf_field_type_common *ft,
+ enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_integer_compare(struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_floating_point_compare(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_enumeration_compare_recursive(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_string_compare(struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_structure_compare_recursive(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_variant_compare_recursive(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_array_compare_recursive(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_sequence_compare_recursive(
+ struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_compare(struct bt_ctf_field_type_common *ft_a,
+ struct bt_ctf_field_type_common *ft_b);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_get_field_count(struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+struct bt_ctf_field_type_common *bt_ctf_field_type_common_borrow_field_at_index(
+ struct bt_ctf_field_type_common *ft, int index);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_get_field_index(struct bt_ctf_field_type_common *ft,
+ const char *name);
+
+BT_HIDDEN
+struct bt_ctf_field_path *bt_ctf_field_type_common_variant_borrow_tag_field_path(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+struct bt_ctf_field_path *bt_ctf_field_type_common_sequence_borrow_length_field_path(
+ struct bt_ctf_field_type_common *ft);
+
+BT_HIDDEN
+int bt_ctf_field_type_common_validate_single_clock_class(
+ struct bt_ctf_field_type_common *ft,
+ struct bt_ctf_clock_class **expected_clock_class);
+
+BT_HIDDEN
+int64_t bt_ctf_field_type_common_variant_find_choice_index(
+ struct bt_ctf_field_type_common *ft, uint64_t uval,
+ bool is_signed);
+
+BT_HIDDEN
+int bt_ctf_field_type_serialize_recursive(struct bt_ctf_field_type *type,
+ struct metadata_context *context);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_copy(struct bt_ctf_field_type *ft);
+
+#endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_H
+#define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_field;
+struct bt_ctf_field_type;
+
+enum bt_ctf_scope {
+ /// Unknown, used for errors.
+ BT_CTF_SCOPE_UNKNOWN = -1,
+
+ /// Trace packet header.
+ BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1,
+
+ /// Stream packet context.
+ BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2,
+
+ /// Stream event header.
+ BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3,
+
+ /// Stream event context.
+ BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4,
+
+ /// Event context.
+ BT_CTF_SCOPE_EVENT_CONTEXT = 5,
+
+ /// Event payload.
+ BT_CTF_SCOPE_EVENT_PAYLOAD = 6,
+
+ /// @cond DOCUMENT
+ BT_CTF_SCOPE_ENV = 0,
+ BT_CTF_SCOPE_EVENT_FIELDS = 6,
+ /// @endcond
+};
+
+enum bt_ctf_field_type_id {
+ BT_CTF_FIELD_TYPE_ID_UNKNOWN = -1,
+ BT_CTF_FIELD_TYPE_ID_INTEGER = 0,
+ BT_CTF_FIELD_TYPE_ID_FLOAT = 1,
+ BT_CTF_FIELD_TYPE_ID_ENUM = 2,
+ BT_CTF_FIELD_TYPE_ID_STRING = 3,
+ BT_CTF_FIELD_TYPE_ID_STRUCT = 4,
+ BT_CTF_FIELD_TYPE_ID_ARRAY = 5,
+ BT_CTF_FIELD_TYPE_ID_SEQUENCE = 6,
+ BT_CTF_FIELD_TYPE_ID_VARIANT = 7,
+ BT_CTF_FIELD_TYPE_ID_NR,
+};
+
+extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
+ struct bt_ctf_field_type *field_type);
+
+enum bt_ctf_byte_order {
+ BT_CTF_BYTE_ORDER_UNKNOWN = -1,
+ BT_CTF_BYTE_ORDER_NATIVE = 0,
+ BT_CTF_BYTE_ORDER_UNSPECIFIED,
+ BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
+ BT_CTF_BYTE_ORDER_BIG_ENDIAN,
+ BT_CTF_BYTE_ORDER_NETWORK,
+};
+
+enum bt_ctf_string_encoding {
+ BT_CTF_STRING_ENCODING_UNKNOWN = -1,
+ BT_CTF_STRING_ENCODING_NONE,
+ BT_CTF_STRING_ENCODING_UTF8,
+ BT_CTF_STRING_ENCODING_ASCII,
+};
+
+/* Pre-2.0 CTF writer compatibility */
+#define ctf_string_encoding bt_ctf_string_encoding
+
+extern int bt_ctf_field_type_get_alignment(
+ struct bt_ctf_field_type *field_type);
+
+extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type,
+ unsigned int alignment);
+
+extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
+ struct bt_ctf_field_type *field_type);
+
+extern int bt_ctf_field_type_set_byte_order(
+ struct bt_ctf_field_type *field_type,
+ enum bt_ctf_byte_order byte_order);
+
+enum bt_ctf_integer_base {
+ /// Unknown, used for errors.
+ BT_CTF_INTEGER_BASE_UNKNOWN = -1,
+
+ /// Unspecified by the tracer.
+ BT_CTF_INTEGER_BASE_UNSPECIFIED = 0,
+
+ /// Binary.
+ BT_CTF_INTEGER_BASE_BINARY = 2,
+
+ /// Octal.
+ BT_CTF_INTEGER_BASE_OCTAL = 8,
+
+ /// Decimal.
+ BT_CTF_INTEGER_BASE_DECIMAL = 10,
+
+ /// Hexadecimal.
+ BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
+};
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
+ unsigned int size);
+
+extern int bt_ctf_field_type_integer_get_size(
+ struct bt_ctf_field_type *int_field_type);
+
+extern int bt_ctf_field_type_integer_set_size(
+ struct bt_ctf_field_type *int_field_type, unsigned int size);
+
+extern bt_bool bt_ctf_field_type_integer_is_signed(
+ struct bt_ctf_field_type *int_field_type);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_type_integer_get_signed(
+ struct bt_ctf_field_type *int_field_type)
+{
+ return bt_ctf_field_type_integer_is_signed(int_field_type) ? 1 : 0;
+}
+
+extern int bt_ctf_field_type_integer_set_is_signed(
+ struct bt_ctf_field_type *int_field_type, bt_bool is_signed);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_type_integer_set_signed(
+ struct bt_ctf_field_type *int_field_type, int is_signed)
+{
+ return bt_ctf_field_type_integer_set_is_signed(int_field_type,
+ is_signed ? BT_TRUE : BT_FALSE);
+}
+
+extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
+ struct bt_ctf_field_type *int_field_type);
+
+extern int bt_ctf_field_type_integer_set_base(
+ struct bt_ctf_field_type *int_field_type,
+ enum bt_ctf_integer_base base);
+
+extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
+ struct bt_ctf_field_type *int_field_type);
+
+extern int bt_ctf_field_type_integer_set_encoding(
+ struct bt_ctf_field_type *int_field_type,
+ enum bt_ctf_string_encoding encoding);
+
+extern struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
+ struct bt_ctf_field_type *int_field_type);
+
+extern int bt_ctf_field_type_integer_set_mapped_clock_class(
+ struct bt_ctf_field_type *int_field_type,
+ struct bt_ctf_clock_class *clock_class);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
+
+extern int bt_ctf_field_type_floating_point_get_exponent_digits(
+ struct bt_ctf_field_type *float_field_type);
+
+extern int bt_ctf_field_type_floating_point_set_exponent_digits(
+ struct bt_ctf_field_type *float_field_type,
+ unsigned int exponent_size);
+
+extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
+ struct bt_ctf_field_type *float_field_type);
+
+extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
+ struct bt_ctf_field_type *float_field_type,
+ unsigned int mantissa_sign_size);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
+ struct bt_ctf_field_type *int_field_type);
+
+extern
+struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
+ struct bt_ctf_field_type *enum_field_type);
+
+extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
+ struct bt_ctf_field_type *enum_field_type);
+
+extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
+ struct bt_ctf_field_type *enum_field_type, uint64_t index,
+ const char **name, int64_t *range_begin, int64_t *range_end);
+
+extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
+ struct bt_ctf_field_type *enum_field_type, uint64_t index,
+ const char **name, uint64_t *range_begin,
+ uint64_t *range_end);
+
+extern int bt_ctf_field_type_enumeration_signed_add_mapping(
+ struct bt_ctf_field_type *enum_field_type,
+ const char *name, int64_t range_begin, int64_t range_end);
+
+extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
+ struct bt_ctf_field_type *enum_field_type,
+ const char *name, uint64_t range_begin, uint64_t range_end);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_type_enumeration_add_mapping(
+ struct bt_ctf_field_type *enumeration, const char *name,
+ int64_t range_start, int64_t range_end)
+{
+ return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration,
+ name, range_start, range_end);
+}
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
+
+extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
+ struct bt_ctf_field_type *string_field_type);
+
+extern int bt_ctf_field_type_string_set_encoding(
+ struct bt_ctf_field_type *string_field_type,
+ enum bt_ctf_string_encoding encoding);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
+
+extern int64_t bt_ctf_field_type_structure_get_field_count(
+ struct bt_ctf_field_type *struct_field_type);
+
+extern int bt_ctf_field_type_structure_get_field_by_index(
+ struct bt_ctf_field_type *struct_field_type,
+ const char **field_name, struct bt_ctf_field_type **field_type,
+ uint64_t index);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure,
+ const char **field_name, struct bt_ctf_field_type **field_type,
+ int index)
+{
+ return bt_ctf_field_type_structure_get_field_by_index(structure,
+ field_name, field_type, (uint64_t) index);
+}
+
+extern
+struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
+ struct bt_ctf_field_type *struct_field_type,
+ const char *field_name);
+
+extern int bt_ctf_field_type_structure_add_field(
+ struct bt_ctf_field_type *struct_field_type,
+ struct bt_ctf_field_type *field_type,
+ const char *field_name);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
+ struct bt_ctf_field_type *element_field_type,
+ unsigned int length);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
+ struct bt_ctf_field_type *array_field_type);
+
+extern int64_t bt_ctf_field_type_array_get_length(
+ struct bt_ctf_field_type *array_field_type);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
+ struct bt_ctf_field_type *element_field_type,
+ const char *length_name);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
+ struct bt_ctf_field_type *sequence_field_type);
+
+extern const char *bt_ctf_field_type_sequence_get_length_field_name(
+ struct bt_ctf_field_type *sequence_field_type);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
+ struct bt_ctf_field_type *tag_field_type,
+ const char *tag_name);
+
+extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
+ struct bt_ctf_field_type *variant_field_type);
+
+extern const char *bt_ctf_field_type_variant_get_tag_name(
+ struct bt_ctf_field_type *variant_field_type);
+
+extern int bt_ctf_field_type_variant_set_tag_name(
+ struct bt_ctf_field_type *variant_field_type,
+ const char *tag_name);
+
+extern int64_t bt_ctf_field_type_variant_get_field_count(
+ struct bt_ctf_field_type *variant_field_type);
+
+extern int bt_ctf_field_type_variant_get_field_by_index(
+ struct bt_ctf_field_type *variant_field_type,
+ const char **field_name,
+ struct bt_ctf_field_type **field_type, uint64_t index);
+
+extern
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
+ struct bt_ctf_field_type *variant_field_type,
+ const char *field_name);
+
+extern
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
+ struct bt_ctf_field_type *variant_field_type,
+ struct bt_ctf_field *tag_field);
+
+extern int bt_ctf_field_type_variant_add_field(
+ struct bt_ctf_field_type *variant_field_type,
+ struct bt_ctf_field_type *field_type,
+ const char *field_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H
+
+/*
+ * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/object-pool-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+
+struct bt_ctf_field_wrapper {
+ struct bt_ctf_object base;
+
+ /* Owned by this */
+ struct bt_ctf_field_common *field;
+};
+
+BT_HIDDEN
+struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_new(void *data);
+
+BT_HIDDEN
+void bt_ctf_field_wrapper_destroy(struct bt_ctf_field_wrapper *field);
+
+BT_HIDDEN
+struct bt_ctf_field_wrapper *bt_ctf_field_wrapper_create(
+ struct bt_ctf_object_pool *pool, struct bt_ctf_field_type *ft);
+
+#endif /* BABELTRACE_CTF_WRITER_FIELD_WRAPPER_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctfser-internal.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name) \
+ BT_ASSERT_PRE((_field)->type->id == ((int) (_type_id)), \
+ _name " has the wrong type ID: expected-type-id=%s, " \
+ "field-addr=%p", \
+ bt_ctf_field_type_id_string((int) (_type_id)), (_field))
+
+#define BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(_field, _name) \
+ BT_ASSERT_PRE(bt_ctf_field_common_is_set_recursive(_field), \
+ _name " is not set: field-addr=%p", (_field))
+
+#define BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(_field, _name) \
+ BT_ASSERT_PRE_HOT((_field), (_name), ": field-addr=%p", (_field))
+
+struct bt_ctf_field_common;
+
+typedef void (*bt_ctf_field_common_method_set_is_frozen)(struct bt_ctf_field_common *,
+ bool);
+typedef int (*bt_ctf_field_common_method_validate)(struct bt_ctf_field_common *);
+typedef struct bt_ctf_field_common *(*bt_ctf_field_common_method_copy)(
+ struct bt_ctf_field_common *);
+typedef bt_bool (*bt_ctf_field_common_method_is_set)(struct bt_ctf_field_common *);
+typedef void (*bt_ctf_field_common_method_reset)(struct bt_ctf_field_common *);
+
+struct bt_ctf_field_common_methods {
+ bt_ctf_field_common_method_set_is_frozen set_is_frozen;
+ bt_ctf_field_common_method_validate validate;
+ bt_ctf_field_common_method_copy copy;
+ bt_ctf_field_common_method_is_set is_set;
+ bt_ctf_field_common_method_reset reset;
+};
+
+struct bt_ctf_field_common {
+ struct bt_ctf_object base;
+ struct bt_ctf_field_type_common *type;
+ struct bt_ctf_field_common_methods *methods;
+ bool payload_set;
+ bool frozen;
+
+ /*
+ * Specialized data for either CTF IR or CTF writer APIs.
+ * See comment in `field-types-internal.h` for more details.
+ */
+ union {
+ struct {
+ } ir;
+ struct {
+ void *serialize_func;
+ } writer;
+ } spec;
+};
+
+struct bt_ctf_field_common_integer {
+ struct bt_ctf_field_common common;
+ union {
+ int64_t signd;
+ uint64_t unsignd;
+ } payload;
+};
+
+struct bt_ctf_field_common_floating_point {
+ struct bt_ctf_field_common common;
+ double payload;
+};
+
+struct bt_ctf_field_common_structure {
+ struct bt_ctf_field_common common;
+
+ /* Array of `struct bt_ctf_field_common *`, owned by this */
+ GPtrArray *fields;
+};
+
+struct bt_ctf_field_common_variant {
+ struct bt_ctf_field_common common;
+
+ union {
+ uint64_t u;
+ int64_t i;
+ } tag_value;
+
+ /* Weak: belongs to `choices` below */
+ struct bt_ctf_field_common *current_field;
+
+ /* Array of `struct bt_ctf_field_common *`, owned by this */
+ GPtrArray *fields;
+};
+
+struct bt_ctf_field_common_array {
+ struct bt_ctf_field_common common;
+
+ /* Array of `struct bt_ctf_field_common *`, owned by this */
+ GPtrArray *elements;
+};
+
+struct bt_ctf_field_common_sequence {
+ struct bt_ctf_field_common common;
+
+ /*
+ * This is the true sequence field's length: its value can be
+ * less than `elements->len` below because we never shrink the
+ * array of elements to avoid reallocation.
+ */
+ uint64_t length;
+
+ /* Array of `struct bt_ctf_field_common *`, owned by this */
+ GPtrArray *elements;
+};
+
+struct bt_ctf_field_common_string {
+ struct bt_ctf_field_common common;
+ GArray *buf;
+ size_t size;
+};
+
+BT_HIDDEN
+struct bt_ctf_field_common *bt_ctf_field_common_copy(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *type,
+ bool is_shared, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods,
+ bt_ctf_field_common_create_func field_create_func,
+ GDestroyNotify field_release_func);
+
+BT_HIDDEN
+int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *type,
+ bool is_shared, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods,
+ bt_ctf_field_common_create_func field_create_func,
+ GDestroyNotify field_destroy_func);
+
+BT_HIDDEN
+int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *type,
+ bool is_shared, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods,
+ GDestroyNotify field_destroy_func);
+
+BT_HIDDEN
+int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *type,
+ bool is_shared, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods,
+ bt_ctf_field_common_create_func field_create_func,
+ GDestroyNotify field_release_func);
+
+BT_HIDDEN
+int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *type,
+ bool is_shared, bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods);
+
+BT_HIDDEN
+int bt_ctf_field_common_generic_validate(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+int bt_ctf_field_common_structure_validate_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+int bt_ctf_field_common_variant_validate_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+int bt_ctf_field_common_array_validate_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+int bt_ctf_field_common_sequence_validate_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_generic_reset(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_structure_reset_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_variant_reset_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_array_reset_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_sequence_reset_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+void bt_ctf_field_common_generic_set_is_frozen(struct bt_ctf_field_common *field,
+ bool is_frozen);
+
+BT_HIDDEN
+void bt_ctf_field_common_structure_set_is_frozen_recursive(
+ struct bt_ctf_field_common *field, bool is_frozen);
+
+BT_HIDDEN
+void bt_ctf_field_common_variant_set_is_frozen_recursive(
+ struct bt_ctf_field_common *field, bool is_frozen);
+
+BT_HIDDEN
+void bt_ctf_field_common_array_set_is_frozen_recursive(
+ struct bt_ctf_field_common *field, bool is_frozen);
+
+BT_HIDDEN
+void bt_ctf_field_common_sequence_set_is_frozen_recursive(
+ struct bt_ctf_field_common *field, bool is_frozen);
+
+BT_HIDDEN
+void _bt_ctf_field_common_set_is_frozen_recursive(struct bt_ctf_field_common *field,
+ bool is_frozen);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_common_generic_is_set(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_common_structure_is_set_recursive(
+ struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_common_variant_is_set_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_common_array_is_set_recursive(struct bt_ctf_field_common *field);
+
+BT_HIDDEN
+bt_bool bt_ctf_field_common_sequence_is_set_recursive(struct bt_ctf_field_common *field);
+
+#ifdef BT_DEV_MODE
+# define bt_ctf_field_common_validate_recursive _bt_ctf_field_common_validate_recursive
+# define bt_ctf_field_common_set_is_frozen_recursive _bt_ctf_field_common_set_is_frozen_recursive
+# define bt_ctf_field_common_is_set_recursive _bt_ctf_field_common_is_set_recursive
+# define bt_ctf_field_common_reset_recursive _bt_ctf_field_common_reset_recursive
+# define bt_ctf_field_common_set _bt_ctf_field_common_set
+#else
+# define bt_ctf_field_common_validate_recursive(_field) (-1)
+# define bt_ctf_field_common_set_is_frozen_recursive(_field, _is_frozen)
+# define bt_ctf_field_common_is_set_recursive(_field) (BT_FALSE)
+# define bt_ctf_field_common_reset_recursive(_field)
+# define bt_ctf_field_common_set(_field, _val)
+#endif
+
+BT_ASSERT_FUNC
+static inline bool field_type_common_has_known_id(
+ struct bt_ctf_field_type_common *ft)
+{
+ return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN ||
+ (int) ft->id < BT_CTF_FIELD_TYPE_ID_NR;
+}
+
+static inline
+int _bt_ctf_field_common_validate_recursive(struct bt_ctf_field_common *field)
+{
+ int ret = 0;
+
+ if (!field) {
+ BT_ASSERT_PRE_MSG("%s", "Invalid field: field is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ BT_ASSERT(field_type_common_has_known_id(field->type));
+
+ if (field->methods->validate) {
+ ret = field->methods->validate(field);
+ }
+
+end:
+ return ret;
+}
+
+static inline
+void _bt_ctf_field_common_reset_recursive(struct bt_ctf_field_common *field)
+{
+ BT_ASSERT(field);
+ BT_ASSERT(field->methods->reset);
+ field->methods->reset(field);
+}
+
+static inline
+void _bt_ctf_field_common_set(struct bt_ctf_field_common *field, bool value)
+{
+ BT_ASSERT(field);
+ field->payload_set = value;
+}
+
+static inline
+bt_bool _bt_ctf_field_common_is_set_recursive(struct bt_ctf_field_common *field)
+{
+ bt_bool is_set = BT_FALSE;
+
+ if (!field) {
+ goto end;
+ }
+
+ BT_ASSERT(field_type_common_has_known_id(field->type));
+ BT_ASSERT(field->methods->is_set);
+ is_set = field->methods->is_set(field);
+
+end:
+ return is_set;
+}
+
+static inline
+void bt_ctf_field_common_initialize(struct bt_ctf_field_common *field,
+ struct bt_ctf_field_type_common *ft, bool is_shared,
+ bt_ctf_object_release_func release_func,
+ struct bt_ctf_field_common_methods *methods)
+{
+ BT_ASSERT(field);
+ BT_ASSERT(ft);
+ bt_ctf_object_init(&field->base, is_shared, release_func);
+ field->methods = methods;
+ field->type = (void *) bt_ctf_object_get_ref(ft);
+}
+
+static inline
+struct bt_ctf_field_type_common *bt_ctf_field_common_borrow_type(
+ struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_type_common *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Field");
+ ret = field->type;
+ return ret;
+}
+
+static inline
+int64_t bt_ctf_field_common_sequence_get_length(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE,
+ "Field");
+ return (int64_t) sequence->length;
+}
+
+static inline
+int bt_ctf_field_common_sequence_set_length(struct bt_ctf_field_common *field,
+ uint64_t length, bt_ctf_field_common_create_func field_create_func)
+{
+ int ret = 0;
+ struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE(((int64_t) length) >= 0,
+ "Invalid sequence length (too large): length=%" PRId64,
+ length);
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Sequence field");
+
+ if (unlikely(length > sequence->elements->len)) {
+ /* Make more room */
+ struct bt_ctf_field_type_common_sequence *sequence_ft;
+ uint64_t cur_len = sequence->elements->len;
+ uint64_t i;
+
+ g_ptr_array_set_size(sequence->elements, length);
+ sequence_ft = BT_CTF_FROM_COMMON(sequence->common.type);
+
+ for (i = cur_len; i < sequence->elements->len; i++) {
+ struct bt_ctf_field_common *elem_field =
+ field_create_func(sequence_ft->element_ft);
+
+ if (!elem_field) {
+ ret = -1;
+ goto end;
+ }
+
+ BT_ASSERT(!sequence->elements->pdata[i]);
+ sequence->elements->pdata[i] = elem_field;
+ }
+ }
+
+ sequence->length = length;
+
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_name(
+ struct bt_ctf_field_common *field, const char *name)
+{
+ struct bt_ctf_field_common *ret = NULL;
+ GQuark field_quark;
+ struct bt_ctf_field_type_common_structure *structure_ft;
+ struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
+ size_t index;
+ GHashTable *field_name_to_index;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+ BT_ASSERT_PRE_NON_NULL(name, "Field name");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRUCT, "Field");
+ structure_ft = BT_CTF_FROM_COMMON(field->type);
+ field_name_to_index = structure_ft->field_name_to_index;
+ field_quark = g_quark_from_string(name);
+ if (!g_hash_table_lookup_extended(field_name_to_index,
+ GUINT_TO_POINTER(field_quark),
+ NULL, (gpointer *) &index)) {
+ BT_LOGV("Invalid parameter: no such field in structure field's type: "
+ "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
+ field, field->type, name);
+ goto error;
+ }
+
+ ret = structure->fields->pdata[index];
+ BT_ASSERT(ret);
+
+error:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_index(
+ struct bt_ctf_field_common *field, uint64_t index)
+{
+ struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRUCT, "Field");
+ BT_ASSERT_PRE(index < structure->fields->len,
+ "Index is out of bound: struct-field-addr=%p, "
+ "index=%" PRIu64 ", count=%u", field, index,
+ structure->fields->len);
+ return structure->fields->pdata[index];
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_field_common_array_borrow_field(
+ struct bt_ctf_field_common *field, uint64_t index)
+{
+ struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Array field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_ARRAY,
+ "Field");
+ BT_ASSERT_PRE(index < array->elements->len,
+ "Index is out of bound: array-field-addr=%p, "
+ "index=%" PRIu64 ", count=%u", field,
+ index, array->elements->len);
+ return array->elements->pdata[(size_t) index];
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_field_common_sequence_borrow_field(
+ struct bt_ctf_field_common *field, uint64_t index)
+{
+ struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field, BT_CTF_FIELD_TYPE_ID_SEQUENCE,
+ "Field");
+ BT_ASSERT_PRE(index < sequence->length,
+ "Index is out of bound: seq-field-addr=%p, "
+ "index=%" PRIu64 ", count=%u", field, index,
+ sequence->elements->len);
+ return sequence->elements->pdata[(size_t) index];
+}
+
+static inline
+int bt_ctf_field_common_variant_set_tag(struct bt_ctf_field_common *variant_field,
+ uint64_t tag_uval, bool is_signed)
+{
+ int ret = 0;
+ int64_t choice_index;
+ struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
+
+ BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
+ BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
+
+ /* Find matching index in variant field's type */
+ choice_index = bt_ctf_field_type_common_variant_find_choice_index(
+ variant_field->type, tag_uval, is_signed);
+ if (choice_index < 0) {
+ ret = -1;
+ goto end;
+ }
+
+ /* Select corresponding field */
+ BT_ASSERT(choice_index < variant->fields->len);
+ variant->current_field = variant->fields->pdata[choice_index];
+ variant->tag_value.u = tag_uval;
+
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_common *bt_ctf_field_common_variant_borrow_current_field(
+ struct bt_ctf_field_common *variant_field)
+{
+ struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
+
+ BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
+ BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: field-addr=%p", variant_field);
+ return variant->current_field;
+}
+
+static inline
+int bt_ctf_field_common_variant_get_tag_signed(struct bt_ctf_field_common *variant_field,
+ int64_t *tag)
+{
+ struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
+
+ BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
+ BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: field-addr=%p", variant_field);
+ *tag = variant->tag_value.i;
+ return 0;
+}
+
+static inline
+int bt_ctf_field_common_variant_get_tag_unsigned(struct bt_ctf_field_common *variant_field,
+ uint64_t *tag)
+{
+ struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(variant_field);
+
+ BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(variant_field,
+ BT_CTF_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: field-addr=%p", variant_field);
+ *tag = variant->tag_value.u;
+ return 0;
+}
+
+static inline
+int bt_ctf_field_common_floating_point_get_value(struct bt_ctf_field_common *field,
+ double *value)
+{
+ struct bt_ctf_field_common_floating_point *floating_point =
+ BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_FLOAT, "Field");
+ *value = floating_point->payload;
+ return 0;
+}
+
+static inline
+int bt_ctf_field_common_floating_point_set_value(struct bt_ctf_field_common *field,
+ double value)
+{
+ struct bt_ctf_field_common_floating_point *floating_point =
+ BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Floating point number field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_FLOAT, "Field");
+ floating_point->payload = value;
+ bt_ctf_field_common_set(field, true);
+ return 0;
+}
+
+static inline
+const char *bt_ctf_field_common_string_get_value(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRING, "Field");
+ return (const char *) string->buf->data;
+}
+
+static inline
+int bt_ctf_field_common_string_clear(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_string *string_field = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRING, "Field");
+ string_field->size = 0;
+ bt_ctf_field_common_set(field, true);
+ return 0;
+}
+
+static inline
+int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field,
+ const char *value, unsigned int length)
+{
+ struct bt_ctf_field_common_string *string_field = BT_CTF_FROM_COMMON(field);
+ char *data;
+ size_t new_size;
+
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRING, "Field");
+
+ /* Make sure no null bytes are appended */
+ BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+ "String value to append contains a null character: "
+ "partial-value=\"%.32s\", length=%u", value, length);
+
+ new_size = string_field->size + length;
+
+ if (unlikely(new_size + 1 > string_field->buf->len)) {
+ g_array_set_size(string_field->buf, new_size + 1);
+ }
+
+ data = string_field->buf->data;
+ memcpy(data + string_field->size, value, length);
+ ((char *) string_field->buf->data)[new_size] = '\0';
+ string_field->size = new_size;
+ bt_ctf_field_common_set(field, true);
+ return 0;
+}
+
+static inline
+int bt_ctf_field_common_string_append(struct bt_ctf_field_common *field,
+ const char *value)
+{
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ return bt_ctf_field_common_string_append_len(field, value,
+ strlen(value));
+}
+
+static inline
+int bt_ctf_field_common_string_set_value(struct bt_ctf_field_common *field,
+ const char *value)
+{
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "String field");
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_HAS_TYPE_ID(field,
+ BT_CTF_FIELD_TYPE_ID_STRING, "Field");
+ bt_ctf_field_common_string_clear(field);
+ return bt_ctf_field_common_string_append_len(field,
+ value, strlen(value));
+}
+
+static inline
+void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field)
+{
+ BT_ASSERT(field);
+ BT_LOGD_STR("Putting field's type.");
+ bt_ctf_object_put_ref(field->type);
+}
+
+static inline
+void bt_ctf_field_common_integer_finalize(struct bt_ctf_field_common *field)
+{
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common integer field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+}
+
+static inline
+void bt_ctf_field_common_floating_point_finalize(struct bt_ctf_field_common *field)
+{
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+}
+
+static inline
+void bt_ctf_field_common_structure_finalize_recursive(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common structure field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+
+ if (structure->fields) {
+ g_ptr_array_free(structure->fields, TRUE);
+ }
+}
+
+static inline
+void bt_ctf_field_common_variant_finalize_recursive(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common variant field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+
+ if (variant->fields) {
+ g_ptr_array_free(variant->fields, TRUE);
+ }
+}
+
+static inline
+void bt_ctf_field_common_array_finalize_recursive(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common array field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+
+ if (array->elements) {
+ g_ptr_array_free(array->elements, TRUE);
+ }
+}
+
+static inline
+void bt_ctf_field_common_sequence_finalize_recursive(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common sequence field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+
+ if (sequence->elements) {
+ g_ptr_array_free(sequence->elements, TRUE);
+ }
+}
+
+static inline
+void bt_ctf_field_common_string_finalize(struct bt_ctf_field_common *field)
+{
+ struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
+
+ BT_ASSERT(field);
+ BT_LOGD("Finalizing common string field object: addr=%p", field);
+ bt_ctf_field_common_finalize(field);
+
+ if (string->buf) {
+ g_array_free(string->buf, TRUE);
+ }
+}
+
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
+{
+ bool ret = true;
+ int64_t min_value, max_value;
+
+ min_value = -(1ULL << (size - 1));
+ max_value = (1ULL << (size - 1)) - 1;
+ if (value < min_value || value > max_value) {
+ BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
+ "min-value=%" PRId64 ", max-value=%" PRId64,
+ value, min_value, max_value);
+ ret = false;
+ }
+
+ return ret;
+}
+
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
+{
+ bool ret = true;
+ int64_t max_value;
+
+ max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
+ if (value > max_value) {
+ BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
+ "max-value=%" PRIu64,
+ value, max_value);
+ ret = false;
+ }
+
+ return ret;
+}
+
+struct bt_ctf_field_enumeration {
+ struct bt_ctf_field_common common;
+ struct bt_ctf_field_common_integer *container;
+};
+
+struct bt_ctf_field_variant {
+ struct bt_ctf_field_common_variant common;
+ struct bt_ctf_field_enumeration *tag;
+};
+
+BT_HIDDEN
+int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field,
+ struct bt_ctfser *ctfser,
+ enum bt_ctf_byte_order native_byte_order);
+
+BT_HIDDEN
+int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field,
+ const char *name, struct bt_ctf_field *value);
+
+BT_HIDDEN
+struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container(
+ struct bt_ctf_field *field);
+
+static inline
+bt_bool bt_ctf_field_is_set_recursive(struct bt_ctf_field *field)
+{
+ return bt_ctf_field_common_is_set_recursive((void *) field);
+}
+
+#endif /* BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FIELDS_H
+#define BABELTRACE_CTF_WRITER_FIELDS_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_field;
+struct bt_ctf_event_class;
+struct bt_ctf_event;
+struct bt_ctf_field_type;
+struct bt_ctf_field_type_enumeration_mapping_iterator;
+
+extern struct bt_ctf_field *bt_ctf_field_create(
+ struct bt_ctf_field_type *field_type);
+
+extern struct bt_ctf_field_type *bt_ctf_field_get_type(
+ struct bt_ctf_field *field);
+
+extern enum bt_ctf_field_type_id bt_ctf_field_get_type_id(
+ struct bt_ctf_field *field);
+
+extern struct bt_ctf_field *bt_ctf_field_copy(struct bt_ctf_field *field);
+
+extern int bt_ctf_field_integer_signed_get_value(
+ struct bt_ctf_field *integer_field, int64_t *value);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_signed_integer_set_value(
+ struct bt_ctf_field *integer_field, int64_t *value)
+{
+ return bt_ctf_field_integer_signed_get_value(integer_field, value);
+}
+
+extern int bt_ctf_field_integer_signed_set_value(
+ struct bt_ctf_field *integer_field, int64_t value);
+
+extern int bt_ctf_field_integer_unsigned_get_value(
+ struct bt_ctf_field *integer_field, uint64_t *value);
+
+extern int bt_ctf_field_integer_unsigned_set_value(
+ struct bt_ctf_field *integer_field, uint64_t value);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+int bt_ctf_field_unsigned_integer_set_value(
+ struct bt_ctf_field *integer_field, uint64_t *value)
+{
+ return bt_ctf_field_integer_unsigned_get_value(integer_field, value);
+}
+
+extern int bt_ctf_field_floating_point_get_value(
+ struct bt_ctf_field *float_field, double *value);
+
+extern int bt_ctf_field_floating_point_set_value(
+ struct bt_ctf_field *float_field, double value);
+
+extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
+ struct bt_ctf_field *enum_field);
+
+extern const char *bt_ctf_field_string_get_value(
+ struct bt_ctf_field *string_field);
+
+extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field,
+ const char *value);
+
+extern int bt_ctf_field_string_append(struct bt_ctf_field *string_field,
+ const char *value);
+
+extern int bt_ctf_field_string_append_len(
+ struct bt_ctf_field *string_field, const char *value,
+ unsigned int length);
+
+extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
+ struct bt_ctf_field *struct_field, const char *name);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+struct bt_ctf_field *bt_ctf_field_structure_get_field(
+ struct bt_ctf_field *structure, const char *name)
+{
+ return bt_ctf_field_structure_get_field_by_name(structure, name);
+}
+
+extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
+ struct bt_ctf_field *struct_field, uint64_t index);
+
+extern struct bt_ctf_field *bt_ctf_field_array_get_field(
+ struct bt_ctf_field *array_field, uint64_t index);
+
+extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
+ struct bt_ctf_field *sequence_field, uint64_t index);
+
+extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence_field,
+ struct bt_ctf_field *length_field);
+
+extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
+ struct bt_ctf_field *variant_field,
+ struct bt_ctf_field *tag_field);
+
+extern struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
+ struct bt_ctf_field *variant_field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_FIELDS_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <glib.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+BT_HIDDEN
+void value_exists(gpointer element, gpointer search_query);
+
+#endif /* BABELTRACE_CTF_WRITER_FUNCTOR_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H
+
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdbool.h>
+
+struct bt_ctf_object;
+
+typedef void (*bt_ctf_object_release_func)(struct bt_ctf_object *);
+typedef void (*bt_ctf_object_parent_is_owner_listener_func)(
+ struct bt_ctf_object *);
+
+static inline
+void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj);
+
+static inline
+void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj);
+
+/*
+ * Babeltrace object base.
+ *
+ * All objects publicly exposed by Babeltrace APIs must contain this
+ * object as their first member.
+ */
+struct bt_ctf_object {
+ /*
+ * True if this object is shared, that is, it has a reference
+ * count.
+ */
+ bool is_shared;
+
+ /*
+ * Current reference count.
+ */
+ unsigned long long ref_count;
+
+ /*
+ * Release function called when the object's reference count
+ * falls to zero. For an object with a parent, this function is
+ * bt_ctf_object_with_parent_release_func(), which calls
+ * `spec_release_func` below if there's no current parent.
+ */
+ bt_ctf_object_release_func release_func;
+
+ /*
+ * Specific release function called by
+ * bt_ctf_object_with_parent_release_func() or directly by a
+ * parent object.
+ */
+ bt_ctf_object_release_func spec_release_func;
+
+ /*
+ * Optional callback for an object with a parent, called by
+ * bt_ctf_object_with_parent_release_func() to indicate to the
+ * object that its parent is its owner.
+ */
+ bt_ctf_object_parent_is_owner_listener_func
+ parent_is_owner_listener_func;
+
+ /*
+ * Optional parent object.
+ */
+ struct bt_ctf_object *parent;
+};
+
+static inline
+unsigned long long bt_ctf_object_get_ref_count(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->ref_count;
+}
+
+static inline
+struct bt_ctf_object *bt_ctf_object_borrow_parent(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->parent;
+}
+
+static inline
+struct bt_ctf_object *bt_ctf_object_get_parent(struct bt_ctf_object *obj)
+{
+ struct bt_ctf_object *parent = bt_ctf_object_borrow_parent(obj);
+
+ if (parent) {
+ bt_ctf_object_get_no_null_check(parent);
+ }
+
+ return parent;
+}
+
+static inline
+void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object *parent)
+{
+ BT_ASSERT(child);
+ BT_ASSERT(child->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p",
+ child, parent);
+#endif
+
+ /*
+ * It is assumed that a "child" having a parent is publicly
+ * reachable. Therefore, a reference to its parent must be
+ * taken. The reference to the parent will be released once the
+ * object's reference count falls to zero.
+ */
+ if (parent) {
+ BT_ASSERT(!child->parent);
+ child->parent = parent;
+ bt_ctf_object_get_no_null_check(parent);
+ } else {
+ if (child->parent) {
+ bt_ctf_object_put_no_null_check(child->parent);
+ }
+
+ child->parent = NULL;
+ }
+}
+
+static inline
+void bt_ctf_object_try_spec_release(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+
+ if (bt_ctf_object_get_ref_count(obj) == 0) {
+ obj->spec_release_func(obj);
+ }
+}
+
+static inline
+void bt_ctf_object_with_parent_release_func(struct bt_ctf_object *obj)
+{
+ if (obj->parent) {
+ /*
+ * Keep our own copy of the parent address because `obj`
+ * could be destroyed in
+ * obj->parent_is_owner_listener_func().
+ */
+ struct bt_ctf_object *parent = obj->parent;
+
+#ifdef BT_LOGV
+ BT_LOGV("Releasing parented object: addr=%p, ref-count=%llu, "
+ "parent-addr=%p, parent-ref-count=%llu",
+ obj, obj->ref_count,
+ parent, parent->ref_count);
+#endif
+
+ if (obj->parent_is_owner_listener_func) {
+ /*
+ * Object has a chance to destroy itself here
+ * under certain conditions and notify its
+ * parent. At this point the parent is
+ * guaranteed to exist because it's not put yet.
+ */
+ obj->parent_is_owner_listener_func(obj);
+ }
+
+ /* The release function will be invoked by the parent. */
+ bt_ctf_object_put_no_null_check(parent);
+ } else {
+ bt_ctf_object_try_spec_release(obj);
+ }
+}
+
+static inline
+void bt_ctf_object_init(struct bt_ctf_object *obj, bool is_shared,
+ bt_ctf_object_release_func release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(!is_shared || release_func);
+ obj->is_shared = is_shared;
+ obj->release_func = release_func;
+ obj->parent_is_owner_listener_func = NULL;
+ obj->spec_release_func = NULL;
+ obj->parent = NULL;
+ obj->ref_count = 1;
+}
+
+static inline
+void bt_ctf_object_init_shared(struct bt_ctf_object *obj,
+ bt_ctf_object_release_func release_func)
+{
+ bt_ctf_object_init(obj, true, release_func);
+}
+
+static inline
+void bt_ctf_object_init_unique(struct bt_ctf_object *obj)
+{
+ bt_ctf_object_init(obj, false, NULL);
+}
+
+static inline
+void bt_ctf_object_init_shared_with_parent(struct bt_ctf_object *obj,
+ bt_ctf_object_release_func spec_release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(spec_release_func);
+ bt_ctf_object_init_shared(obj, bt_ctf_object_with_parent_release_func);
+ obj->spec_release_func = spec_release_func;
+}
+
+static inline
+void bt_ctf_object_set_parent_is_owner_listener_func(struct bt_ctf_object *obj,
+ bt_ctf_object_parent_is_owner_listener_func func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+ ((struct bt_ctf_object *) obj)->parent_is_owner_listener_func = func;
+}
+
+static inline
+void bt_ctf_object_inc_ref_count(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ obj->ref_count++;
+ BT_ASSERT(obj->ref_count != 0);
+}
+
+static inline
+void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_ctf_object_inc_ref_count(obj);
+ return obj;
+}
+
+static inline
+void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+ if (unlikely(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) {
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's parent's reference count: "
+ "addr=%p, parent-addr=%p", obj, obj->parent);
+#endif
+
+ bt_ctf_object_get_no_null_check(obj->parent);
+ }
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_ctf_object_inc_ref_count(obj);
+ return obj;
+}
+
+static inline
+void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->ref_count > 0);
+
+#ifdef BT_LOGV
+ BT_LOGV("Decrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count - 1,
+ obj, obj->ref_count, obj->ref_count - 1);
+#endif
+
+ obj->ref_count--;
+
+ if (obj->ref_count == 0) {
+ BT_ASSERT(obj->release_func);
+ obj->release_func(obj);
+ }
+}
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+/*
+ * This is a generic object pool to avoid memory allocation/deallocation
+ * for objects of which the lifespan is typically short, but which are
+ * created a lot.
+ *
+ * The object pool, thanks to two user functions, knows how to allocate
+ * a brand new object in memory when the pool is empty and how to
+ * destroy an object when we destroy the pool.
+ *
+ * The object pool's user is responsible for:
+ *
+ * * Setting whatever references the object needs to keep and reset some
+ * properties _after_ calling bt_ctf_object_pool_create_object(). This is
+ * typically done in the bt_*_create() function which calls
+ * bt_ctf_object_pool_create_object() (which could call the user-provided
+ * allocation function if the pool is empty) and then sets the
+ * appropriate properties on the possibly recycled object.
+ *
+ * * Releasing whatever references the object keeps _before_ calling
+ * bt_ctf_object_pool_recycle_object(). This is typically done in a custom
+ * bt_*_recycle() function which does the necessary before calling
+ * bt_ctf_object_pool_recycle_object() with an object ready to be reused
+ * at any time.
+ */
+
+#include <glib.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+
+typedef void *(*bt_ctf_object_pool_new_object_func)(void *data);
+typedef void *(*bt_ctf_object_pool_destroy_object_func)(void *obj, void *data);
+
+struct bt_ctf_object_pool {
+ /*
+ * Container of recycled objects, owned by this. The array's size
+ * is the pool's capacity.
+ */
+ GPtrArray *objects;
+
+ /*
+ * Pool's size, that is, number of elements in the array above,
+ * starting at index 0, which exist as recycled objects.
+ */
+ size_t size;
+
+ /* User functions */
+ struct {
+ /* Allocate a new object in memory */
+ bt_ctf_object_pool_new_object_func new_object;
+
+ /* Free direct and indirect memory occupied by object */
+ bt_ctf_object_pool_destroy_object_func destroy_object;
+ } funcs;
+
+ /* User data passed to user functions */
+ void *data;
+};
+
+/*
+ * Initializes an object pool which is already allocated.
+ */
+int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool,
+ bt_ctf_object_pool_new_object_func new_object_func,
+ bt_ctf_object_pool_destroy_object_func destroy_object_func,
+ void *data);
+
+/*
+ * Finalizes an object pool without deallocating it.
+ */
+void bt_ctf_object_pool_finalize(struct bt_ctf_object_pool *pool);
+
+/*
+ * Creates an object from an object pool. If the pool is empty, this
+ * function calls the "new" user function to allocate a new object
+ * before returning it. Otherwise this function returns a recycled
+ * object, removing it from the pool.
+ *
+ * The returned object is owned by the caller.
+ */
+static inline
+void *bt_ctf_object_pool_create_object(struct bt_ctf_object_pool *pool)
+{
+ struct bt_ctf_object *obj;
+
+ BT_ASSERT(pool);
+
+#ifdef BT_LOGV
+ BT_LOGV("Creating object from pool: pool-addr=%p, pool-size=%zu, pool-cap=%u",
+ pool, pool->size, pool->objects->len);
+#endif
+
+ if (pool->size > 0) {
+ /* Pick one from the pool */
+ pool->size--;
+ obj = pool->objects->pdata[pool->size];
+ pool->objects->pdata[pool->size] = NULL;
+ goto end;
+ }
+
+ /* Pool is empty: create a brand new object */
+#ifdef BT_LOGV
+ BT_LOGV("Pool is empty: allocating new object: pool-addr=%p",
+ pool);
+#endif
+
+ obj = pool->funcs.new_object(pool->data);
+
+end:
+#ifdef BT_LOGV
+ BT_LOGV("Created one object from pool: pool-addr=%p, obj-addr=%p",
+ pool, obj);
+#endif
+
+ return obj;
+}
+
+/*
+ * Recycles an object, that is, puts it back into the pool.
+ *
+ * The pool becomes the sole owner of the object to recycle.
+ */
+static inline
+void bt_ctf_object_pool_recycle_object(struct bt_ctf_object_pool *pool, void *obj)
+{
+ struct bt_ctf_object *bt_obj = obj;
+
+ BT_ASSERT(pool);
+ BT_ASSERT(obj);
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycling object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+
+ if (pool->size == pool->objects->len) {
+ /* Backing array is full: make place for recycled object */
+#ifdef BT_LOGV
+ BT_LOGV("Object pool is full: increasing object pool capacity: "
+ "pool-addr=%p, old-pool-cap=%u, new-pool-cap=%u",
+ pool, pool->objects->len, pool->objects->len + 1);
+#endif
+ g_ptr_array_set_size(pool->objects, pool->size + 1);
+ }
+
+ /* Reset reference count to 1 since it could be 0 now */
+ bt_obj->ref_count = 1;
+
+ /* Back to the pool */
+ pool->objects->pdata[pool->size] = obj;
+ pool->size++;
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycled object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+}
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_POOL_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_OBJECT_H
+#define BABELTRACE_CTF_WRITER_OBJECT_H
+
+/*
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
+ * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup refs Reference counting management
+@ingroup apiref
+@brief Common reference counting management for all Babeltrace objects.
+
+@code
+#include <babeltrace2/ctf-writer/object.h>
+@endcode
+
+The macros and functions of this module are everything that is needed
+to handle the <strong><em>reference counting</em></strong> of
+Babeltrace objects.
+
+Any Babeltrace object can be shared by multiple owners thanks to
+<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
+counting</a>.
+
+The Babeltrace C API complies with the following key principles:
+
+1. When you call an API function which accepts a Babeltrace object
+ pointer as a parameter, the API function <strong>borrows the
+ reference</strong> for the <strong>duration of the function</strong>.
+
+ @image html ref-count-user-calls.png
+
+ The API function can also get a new reference if the system needs a
+ more persistent reference, but the ownership is <strong>never
+ transferred</strong> from the caller to the API function.
+
+ In other words, the caller still owns the object after calling any
+ API function: no function "steals" the user's reference (except
+ bt_ctf_object_put_ref()).
+
+2. An API function which \em returns a Babeltrace object pointer to the
+ user returns a <strong>new reference</strong>. The caller becomes an
+ owner of the object.
+
+ @image html ref-count-api-returns.png
+
+ It is your responsibility to discard the object when you don't
+ need it anymore with bt_ctf_object_put_ref().
+
+ For example, see bt_ctf_value_array_get().
+
+3. A Babeltrace object pointer received as a parameter in a user
+ function called back from an API function is a
+ <strong>borrowed</strong>, or <strong>weak reference</strong>: if you
+ need a reference which is more persistent than the duration of the
+ user function, call bt_ctf_object_get_ref() on the pointer.
+
+ @image html ref-count-callback.png
+
+ For example, see bt_ctf_value_map_foreach_entry().
+
+The two macros BT_CTF_OBJECT_PUT_REF_AND_RESET() and BT_CTF_OBJECT_MOVE_REF() operate on \em variables rather
+than pointer values. You should use BT_CTF_OBJECT_PUT_REF_AND_RESET() instead of bt_ctf_object_put_ref() when
+possible to avoid "double puts". For the same reason, you should use use
+BT_CTF_OBJECT_MOVE_REF() instead of performing manual reference moves between
+variables.
+
+@file
+@brief Reference counting management macros and functions.
+@sa refs
+
+@addtogroup refs
+@{
+*/
+
+/**
+@brief Calls bt_ctf_object_put_ref() on a variable named \p _var, then
+ sets \p _var to \c NULL.
+
+Using this macro is considered safer than calling bt_ctf_object_put_ref() because it
+makes sure that the variable which used to contain a reference to a
+Babeltrace object is set to \c NULL so that a future BT_CTF_OBJECT_PUT_REF_AND_RESET() or
+bt_ctf_object_put_ref() call will not cause another, unwanted reference decrementation.
+
+@param[in,out] _var Name of a variable containing a
+ Babeltrace object's address (this address
+ can be \c NULL).
+
+@post <strong>If \p _var does not contain \p NULL</strong>,
+ its reference count is decremented.
+@post \p _var contains \c NULL.
+
+@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
+ variable to another.
+*/
+#define BT_CTF_OBJECT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_ctf_object_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+/**
+@brief Transfers the ownership of a Babeltrace object from a variable
+ named \p _var_src to a variable named \p _var_dst.
+
+This macro implements the following common pattern:
+
+ 1. Call bt_ctf_object_put_ref() on \p _var_dst to make sure the previous reference
+ held by \p _var_dst is discarded.
+ 2. Assign \p _var_src to \p _var_dst.
+ 3. Set \p _var_src to \c NULL to avoid future, unwanted reference
+ decrementation of \p _var_src.
+
+@warning
+You must \em not use this macro when both \p _var_dst and
+\p _var_src contain the same Babeltrace object address and the reference
+count of this object is 1. The initial call to bt_ctf_object_put_ref() on \p _var_dst
+would destroy the object and leave a dangling pointer in \p _var_dst.
+
+@param[in,out] _var_dst Name of the destination variable, containing
+ either the address of a Babeltrace object to
+ put first, or \c NULL.
+@param[in,out] _var_src Name of the source variable, containing
+ either the address of a Babeltrace object to
+ move, or \c NULL.
+
+@pre <strong>If \p _var_dst and \p _var_src contain the same
+ value which is not \c NULL</strong>, this object's reference
+ count is greater than 1.
+@post <strong>If \c _var_dst is not \c NULL</strong>, its reference
+ count is decremented.
+@post \p _var_dst is equal to the value of \p _var_src \em before
+ you called this macro.
+@post \p _var_src is \c NULL.
+
+@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
+*/
+#define BT_CTF_OBJECT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_ctf_object_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+/**
+@brief Increments the reference count of the Babeltrace object \p obj.
+
+@param[in] obj Babeltrace object of which to get a new reference
+ (can be \c NULL).
+@returns \p obj
+
+@post <strong>If \c obj is not \c NULL</strong>, its reference
+ count is incremented.
+
+@sa bt_ctf_object_put_ref(): Decrements the reference count of a Babeltrace object.
+*/
+void *bt_ctf_object_get_ref(void *obj);
+
+/**
+@brief Decrements the reference count of the Babeltrace object
+ \p obj.
+
+When the object's reference count reaches 0, the object can no longer
+be accessed and is considered \em destroyed.
+
+@remarks
+You should use the BT_CTF_OBJECT_PUT_REF_AND_RESET() macro instead of calling bt_ctf_object_put_ref() since the
+former is generally safer.
+
+@param[in] obj Babeltrace object of which to drop a reference
+ (can be \c NULL).
+
+@post <strong>If \c obj is not \c NULL</strong>, its reference
+ count is decremented.
+
+@sa BT_CTF_OBJECT_PUT_REF_AND_RESET(): Calls bt_ctf_object_put_ref() on a variable, then sets it to \c NULL.
+@sa BT_CTF_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a
+ variable to another.
+@sa bt_ctf_object_get_ref(): Increments the reference count of a Babeltrace object.
+*/
+void bt_ctf_object_put_ref(void *obj);
+
+/**
+@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_OBJECT_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H
+
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Authors: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <glib.h>
+
+enum bt_ctf_resolve_flag {
+ BT_CTF_RESOLVE_FLAG_PACKET_HEADER = 0x01,
+ BT_CTF_RESOLVE_FLAG_PACKET_CONTEXT = 0x02,
+ BT_CTF_RESOLVE_FLAG_EVENT_HEADER = 0x04,
+ BT_CTF_RESOLVE_FLAG_STREAM_EVENT_CTX = 0x08,
+ BT_CTF_RESOLVE_FLAG_EVENT_CONTEXT = 0x10,
+ BT_CTF_RESOLVE_FLAG_EVENT_PAYLOAD = 0x20,
+};
+
+/*
+ * Resolves CTF IR field types: recursively locates the tag and length
+ * field types of resp. variant and sequence field types.
+ *
+ * All `*_type` parameters may be resolved, and may as well serve as
+ * resolving targets.
+ *
+ * Resolving is performed based on the flags in `flags`.
+ *
+ * It is expected that, amongst all the provided types, no common
+ * references to sequence variant field types exist. In other words,
+ * this function does not copy field types.
+ *
+ * All parameters are owned by the caller.
+ */
+BT_HIDDEN
+int bt_ctf_resolve_types(struct bt_ctf_private_value *environment,
+ struct bt_ctf_field_type_common *packet_header_type,
+ struct bt_ctf_field_type_common *packet_context_type,
+ struct bt_ctf_field_type_common *event_header_type,
+ struct bt_ctf_field_type_common *stream_event_ctx_type,
+ struct bt_ctf_field_type_common *event_context_type,
+ struct bt_ctf_field_type_common *event_payload_type,
+ enum bt_ctf_resolve_flag flags);
+
+#endif /* BABELTRACE_CTF_WRITER_RESOLVE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2014 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/visitor.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <inttypes.h>
+
+struct bt_ctf_stream_class_common {
+ struct bt_ctf_object base;
+ GString *name;
+
+ /* Array of pointers to event class addresses */
+ GPtrArray *event_classes;
+
+ /* event class id (int64_t) to event class address */
+ GHashTable *event_classes_ht;
+ int id_set;
+ int64_t id;
+ int64_t next_event_id;
+ struct bt_ctf_field_type_common *packet_context_field_type;
+ struct bt_ctf_field_type_common *event_header_field_type;
+ struct bt_ctf_field_type_common *event_context_field_type;
+ int frozen;
+ int byte_order;
+
+ /*
+ * This flag indicates if the stream class is valid. A valid
+ * stream class is _always_ frozen.
+ */
+ int valid;
+
+ /*
+ * Unique clock class mapped to any field type within this
+ * stream class, including all the stream class's event class
+ * field types. This is only set if the stream class is frozen.
+ *
+ * If the stream class is frozen and this is still NULL, it is
+ * still possible that it becomes non-NULL because
+ * bt_ctf_stream_class_add_event_class() can add an event class
+ * containing a field type mapped to some clock class. In this
+ * case, this is the mapped clock class, and at this point, both
+ * the new event class and the stream class are frozen, so the
+ * next added event classes are expected to contain field types
+ * which only map to this specific clock class.
+ *
+ * If this is a CTF writer stream class, then this is the
+ * backing clock class of the `clock` member above.
+ */
+ struct bt_ctf_clock_class *clock_class;
+};
+
+struct bt_ctf_event_class_common;
+
+BT_HIDDEN
+int bt_ctf_stream_class_common_initialize(struct bt_ctf_stream_class_common *stream_class,
+ const char *name, bt_ctf_object_release_func release_func);
+
+BT_HIDDEN
+void bt_ctf_stream_class_common_finalize(struct bt_ctf_stream_class_common *stream_class);
+
+BT_HIDDEN
+void bt_ctf_stream_class_common_freeze(struct bt_ctf_stream_class_common *stream_class);
+
+static inline
+const char *bt_ctf_stream_class_common_get_name(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return stream_class->name->len > 0 ? stream_class->name->str : NULL;
+}
+
+static inline
+int64_t bt_ctf_stream_class_common_get_id(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->id_set) {
+ BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class));
+ ret = (int64_t) -1;
+ goto end;
+ }
+
+ ret = stream_class->id;
+
+end:
+ return ret;
+}
+
+BT_HIDDEN
+void bt_ctf_stream_class_common_set_byte_order(
+ struct bt_ctf_stream_class_common *stream_class, int byte_order);
+
+BT_HIDDEN
+int bt_ctf_stream_class_common_validate_single_clock_class(
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_clock_class **expected_clock_class);
+
+BT_HIDDEN
+int bt_ctf_stream_class_common_add_event_class(
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_event_class_common *event_class,
+ bt_ctf_validation_flag_copy_field_type_func copy_field_type_func);
+
+BT_HIDDEN
+int bt_ctf_stream_class_common_visit(struct bt_ctf_stream_class_common *stream_class,
+ bt_ctf_visitor visitor, void *data);
+
+BT_HIDDEN
+int bt_ctf_stream_class_visit(struct bt_ctf_stream_class *stream_class,
+ bt_ctf_visitor visitor, void *data);
+
+static inline
+struct bt_ctf_trace_common *bt_ctf_stream_class_common_borrow_trace(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ BT_ASSERT(stream_class);
+ return (void *) bt_ctf_object_borrow_parent(&stream_class->base);
+}
+
+static inline
+int bt_ctf_stream_class_common_set_name(struct bt_ctf_stream_class_common *stream_class,
+ const char *name)
+{
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (!name) {
+ g_string_assign(stream_class->name, "");
+ } else {
+ if (strlen(name) == 0) {
+ BT_LOGW("Invalid parameter: name is empty.");
+ ret = -1;
+ goto end;
+ }
+
+ g_string_assign(stream_class->name, name);
+ }
+
+ BT_LOGV("Set stream class's name: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+end:
+ return ret;
+}
+
+static inline
+void _bt_ctf_stream_class_common_set_id(
+ struct bt_ctf_stream_class_common *stream_class, int64_t id)
+{
+ BT_ASSERT(stream_class);
+ stream_class->id = id;
+ stream_class->id_set = 1;
+ BT_LOGV("Set stream class's ID (internal): "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+}
+
+static inline
+int bt_ctf_stream_class_common_set_id_no_check(
+ struct bt_ctf_stream_class_common *stream_class, int64_t id)
+{
+ _bt_ctf_stream_class_common_set_id(stream_class, id);
+ return 0;
+}
+
+static inline
+int bt_ctf_stream_class_common_set_id(struct bt_ctf_stream_class_common *stream_class,
+ uint64_t id_param)
+{
+ int ret = 0;
+ int64_t id = (int64_t) id_param;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (id < 0) {
+ BT_LOGW("Invalid parameter: invalid stream class's ID: "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64 ", id=%" PRIu64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ id_param);
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_stream_class_common_set_id_no_check(stream_class, id);
+ if (ret == 0) {
+ BT_LOGV("Set stream class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ }
+end:
+ return ret;
+}
+
+static inline
+int64_t bt_ctf_stream_class_common_get_event_class_count(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ int64_t ret;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = (int64_t) -1;
+ goto end;
+ }
+
+ ret = (int64_t) stream_class->event_classes->len;
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_by_index(
+ struct bt_ctf_stream_class_common *stream_class, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(index < stream_class->event_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, stream_class->event_classes->len);
+ return g_ptr_array_index(stream_class->event_classes, index);
+}
+
+static inline
+struct bt_ctf_event_class_common *bt_ctf_stream_class_common_borrow_event_class_by_id(
+ struct bt_ctf_stream_class_common *stream_class, uint64_t id)
+{
+ int64_t id_key = (int64_t) id;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(id_key >= 0,
+ "Invalid event class ID: %" PRIu64, id);
+ return g_hash_table_lookup(stream_class->event_classes_ht,
+ &id_key);
+}
+
+static inline
+struct bt_ctf_field_type_common *
+bt_ctf_stream_class_common_borrow_packet_context_field_type(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return stream_class->packet_context_field_type;
+}
+
+static inline
+int bt_ctf_stream_class_common_set_packet_context_field_type(
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_field_type_common *packet_context_type)
+{
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (packet_context_type &&
+ bt_ctf_field_type_common_get_type_id(packet_context_type) !=
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p, packet-context-ft-id=%s",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ packet_context_type,
+ bt_ctf_field_type_id_string(
+ bt_ctf_field_type_common_get_type_id(packet_context_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_object_put_ref(stream_class->packet_context_field_type);
+ stream_class->packet_context_field_type = packet_context_type;
+ bt_ctf_object_get_ref(stream_class->packet_context_field_type);
+ BT_LOGV("Set stream class's packet context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ packet_context_type);
+
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_type_common *
+bt_ctf_stream_class_common_borrow_event_header_field_type(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ struct bt_ctf_field_type_common *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->event_header_field_type) {
+ BT_LOGV("Stream class has no event header field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ goto end;
+ }
+
+ ret = stream_class->event_header_field_type;
+
+end:
+ return ret;
+}
+
+static inline
+int bt_ctf_stream_class_common_set_event_header_field_type(
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_field_type_common *event_header_type)
+{
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (event_header_type &&
+ bt_ctf_field_type_common_get_type_id(event_header_type) !=
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
+ /* An event header must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-header-ft-addr=%p, event-header-ft-id=%s",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ event_header_type,
+ bt_ctf_field_type_id_string(
+ bt_ctf_field_type_common_get_type_id(event_header_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_object_put_ref(stream_class->event_header_field_type);
+ stream_class->event_header_field_type = event_header_type;
+ bt_ctf_object_get_ref(stream_class->event_header_field_type);
+ BT_LOGV("Set stream class's event header field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-header-ft-addr=%p",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ event_header_type);
+end:
+ return ret;
+}
+
+static inline
+struct bt_ctf_field_type_common *
+bt_ctf_stream_class_common_borrow_event_context_field_type(
+ struct bt_ctf_stream_class_common *stream_class)
+{
+ struct bt_ctf_field_type_common *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->event_context_field_type) {
+ goto end;
+ }
+
+ ret = stream_class->event_context_field_type;
+
+end:
+ return ret;
+}
+
+static inline
+int bt_ctf_stream_class_common_set_event_context_field_type(
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_field_type_common *event_context_type)
+{
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (event_context_type &&
+ bt_ctf_field_type_common_get_type_id(event_context_type) !=
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-context-ft-addr=%p, event-context-ft-id=%s",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ event_context_type,
+ bt_ctf_field_type_id_string(
+ bt_ctf_field_type_common_get_type_id(event_context_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_ctf_object_put_ref(stream_class->event_context_field_type);
+ stream_class->event_context_field_type = event_context_type;
+ bt_ctf_object_get_ref(stream_class->event_context_field_type);
+ BT_LOGV("Set stream class's event context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-context-ft-addr=%p",
+ stream_class, bt_ctf_stream_class_common_get_name(stream_class),
+ bt_ctf_stream_class_common_get_id(stream_class),
+ event_context_type);
+end:
+ return ret;
+}
+
+struct bt_ctf_stream_class {
+ struct bt_ctf_stream_class_common common;
+ struct bt_ctf_clock *clock;
+ int64_t next_stream_id;
+};
+
+struct metadata_context;
+
+BT_HIDDEN
+int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
+ struct metadata_context *context);
+
+BT_HIDDEN
+int bt_ctf_stream_class_map_clock_class(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *packet_context_type,
+ struct bt_ctf_field_type *event_header_type);
+
+#endif /* BABELTRACE_CTF_WRITER_STREAM_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_STREAM_CLASS_H
+#define BABELTRACE_CTF_WRITER_STREAM_CLASS_H
+
+/*
+ * Copyright 2014 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/ctf-writer/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_stream_class;
+struct bt_ctf_trace;
+struct bt_ctf_event_class;
+struct bt_ctf_field_type;
+struct bt_ctf_clock;
+
+extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(
+ const char *name);
+
+extern struct bt_ctf_trace *bt_ctf_stream_class_get_trace(
+ struct bt_ctf_stream_class *stream_class);
+
+extern const char *bt_ctf_stream_class_get_name(
+ struct bt_ctf_stream_class *stream_class);
+
+extern int bt_ctf_stream_class_set_name(
+ struct bt_ctf_stream_class *stream_class, const char *name);
+
+extern int64_t bt_ctf_stream_class_get_id(
+ struct bt_ctf_stream_class *stream_class);
+
+extern int bt_ctf_stream_class_set_id(
+ struct bt_ctf_stream_class *stream_class, uint64_t id);
+
+extern struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
+ struct bt_ctf_stream_class *stream_class);
+
+extern int bt_ctf_stream_class_set_packet_context_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *packet_context_type);
+
+extern struct bt_ctf_field_type *
+bt_ctf_stream_class_get_event_header_type(
+ struct bt_ctf_stream_class *stream_class);
+
+extern int bt_ctf_stream_class_set_event_header_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *event_header_type);
+
+extern struct bt_ctf_field_type *
+bt_ctf_stream_class_get_event_context_type(
+ struct bt_ctf_stream_class *stream_class);
+
+extern int bt_ctf_stream_class_set_event_context_type(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_field_type *event_context_type);
+
+extern int64_t bt_ctf_stream_class_get_event_class_count(
+ struct bt_ctf_stream_class *stream_class);
+
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
+ struct bt_ctf_stream_class *stream_class, uint64_t index);
+
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
+ struct bt_ctf_stream_class *stream_class, uint64_t id);
+
+extern int bt_ctf_stream_class_add_event_class(
+ struct bt_ctf_stream_class *stream_class,
+ struct bt_ctf_event_class *event_class);
+
+extern int bt_ctf_stream_class_set_clock(
+ struct bt_ctf_stream_class *ctf_stream_class,
+ struct bt_ctf_clock *clock);
+
+extern struct bt_ctf_clock *bt_ctf_stream_class_get_clock(
+ struct bt_ctf_stream_class *stream_class);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
+{
+ bt_ctf_object_get_ref(stream_class);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
+{
+ bt_ctf_object_put_ref(stream_class);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_STREAM_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctfser-internal.h>
+#include <stdint.h>
+
+struct bt_ctf_stream_common;
+
+struct bt_ctf_stream_common {
+ struct bt_ctf_object base;
+ int64_t id;
+ struct bt_ctf_stream_class_common *stream_class;
+ GString *name;
+};
+
+BT_HIDDEN
+int bt_ctf_stream_common_initialize(
+ struct bt_ctf_stream_common *stream,
+ struct bt_ctf_stream_class_common *stream_class, const char *name,
+ uint64_t id, bt_ctf_object_release_func release_func);
+
+BT_HIDDEN
+void bt_ctf_stream_common_finalize(struct bt_ctf_stream_common *stream);
+
+static inline
+struct bt_ctf_stream_class_common *bt_ctf_stream_common_borrow_class(
+ struct bt_ctf_stream_common *stream)
+{
+ BT_ASSERT(stream);
+ return stream->stream_class;
+}
+
+static inline
+const char *bt_ctf_stream_common_get_name(struct bt_ctf_stream_common *stream)
+{
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+ return stream->name ? stream->name->str : NULL;
+}
+
+static inline
+int64_t bt_ctf_stream_common_get_id(struct bt_ctf_stream_common *stream)
+{
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+ ret = stream->id;
+ if (ret < 0) {
+ BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
+ stream, bt_ctf_stream_common_get_name(stream));
+ }
+
+ return ret;
+}
+
+struct bt_ctf_stream {
+ struct bt_ctf_stream_common common;
+ struct bt_ctf_field *packet_header;
+ struct bt_ctf_field *packet_context;
+
+ /* Array of pointers to bt_ctf_event for the current packet */
+ GPtrArray *events;
+ struct bt_ctfser ctfser;
+ unsigned int flushed_packet_count;
+ uint64_t discarded_events;
+ uint64_t last_ts_end;
+};
+
+BT_HIDDEN
+struct bt_ctf_stream *bt_ctf_stream_create_with_id(
+ struct bt_ctf_stream_class *stream_class,
+ const char *name, uint64_t id);
+
+#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_STREAM_H
+#define BABELTRACE_CTF_WRITER_STREAM_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_stream;
+struct bt_ctf_event;
+
+/*
+ * bt_ctf_stream_get_discarded_events_count: get the number of discarded
+ * events associated with this stream.
+ *
+ * Note that discarded events are not stored if the stream's packet
+ * context has no "events_discarded" field. An error will be returned
+ * in that case.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns the number of discarded events, a negative value on error.
+ */
+extern int bt_ctf_stream_get_discarded_events_count(
+ struct bt_ctf_stream *stream, uint64_t *count);
+
+/*
+ * bt_ctf_stream_append_discarded_events: increment discarded events count.
+ *
+ * Increase the current packet's discarded event count. Has no effect if the
+ * stream class' packet context has no "events_discarded" field.
+ *
+ * @param stream Stream instance.
+ * @param event_count Number of discarded events to add to the stream's current
+ * packet.
+ */
+extern void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
+ uint64_t event_count);
+
+/*
+ * bt_ctf_stream_append_event: append an event to the stream.
+ *
+ * Append "event" to the stream's current packet. The stream's associated clock
+ * will be sampled during this call. The event shall not be modified after
+ * being appended to a stream. The stream will share the event's ownership by
+ * incrementing its reference count. The current packet is not flushed to disk
+ * until the next call to bt_ctf_stream_flush.
+ *
+ * The stream event context will be sampled for every appended event if
+ * a stream event context was defined.
+ *
+ * @param stream Stream instance.
+ * @param event Event instance to append to the stream's current packet.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
+ struct bt_ctf_event *event);
+
+/*
+ * bt_ctf_stream_get_packet_header: get a stream's packet header.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_stream_get_packet_header(
+ struct bt_ctf_stream *stream);
+
+/*
+ * bt_ctf_stream_set_packet_header: set a stream's packet header.
+ *
+ * The packet header's type must match the trace's packet header
+ * type.
+ *
+ * @param stream Stream instance.
+ * @param packet_header Packet header instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern int bt_ctf_stream_set_packet_header(
+ struct bt_ctf_stream *stream,
+ struct bt_ctf_field *packet_header);
+
+/*
+ * bt_ctf_stream_get_packet_context: get a stream's packet context.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_stream_get_packet_context(
+ struct bt_ctf_stream *stream);
+
+/*
+ * bt_ctf_stream_set_packet_context: set a stream's packet context.
+ *
+ * The packet context's type must match the stream class' packet
+ * context type.
+ *
+ * @param stream Stream instance.
+ * @param packet_context Packet context field instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern int bt_ctf_stream_set_packet_context(
+ struct bt_ctf_stream *stream,
+ struct bt_ctf_field *packet_context);
+
+/*
+ * bt_ctf_stream_flush: flush a stream.
+ *
+ * The stream's current packet's events will be flushed, thus closing the
+ * current packet. Events subsequently appended to the stream will be
+ * added to a new packet.
+ *
+ * Flushing will also set the packet context's default attributes if
+ * they remained unset while populating the current packet. These default
+ * attributes, along with their expected types, are detailed in stream-class.h.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
+
+extern int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream);
+
+extern
+struct bt_ctf_stream *bt_ctf_stream_create(
+ struct bt_ctf_stream_class *stream_class,
+ const char *name, uint64_t id);
+
+extern struct bt_ctf_stream_class *bt_ctf_stream_get_class(
+ struct bt_ctf_stream *stream);
+
+extern const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream);
+
+extern int64_t bt_ctf_stream_get_id(struct bt_ctf_stream *stream);
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_stream_get(struct bt_ctf_stream *stream)
+{
+ bt_ctf_object_get_ref(stream);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_stream_put(struct bt_ctf_stream *stream)
+{
+ bt_ctf_object_put_ref(stream);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_STREAM_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H
+
+/*
+ * Copyright 2014 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/ctf-writer/attributes-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+#include <sys/types.h>
+
+struct bt_ctf_trace_common {
+ struct bt_ctf_object base;
+ GString *name;
+ int frozen;
+ unsigned char uuid[BABELTRACE_UUID_LEN];
+ bt_bool uuid_set;
+ enum bt_ctf_byte_order native_byte_order;
+ struct bt_ctf_private_value *environment;
+ GPtrArray *clock_classes; /* Array of pointers to bt_ctf_clock_class */
+ GPtrArray *stream_classes; /* Array of ptrs to bt_ctf_stream_class_common */
+ GPtrArray *streams; /* Array of ptrs to bt_ctf_stream_common */
+ struct bt_ctf_field_type_common *packet_header_field_type;
+ int64_t next_stream_id;
+
+ /*
+ * This flag indicates if the trace is valid. A valid
+ * trace is _always_ frozen.
+ */
+ int valid;
+};
+
+BT_HIDDEN
+bt_bool bt_ctf_trace_common_has_clock_class(struct bt_ctf_trace_common *trace,
+ struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace,
+ bt_ctf_object_release_func release_func);
+
+BT_HIDDEN
+void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace);
+
+static inline
+const char *bt_ctf_trace_common_get_name(struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->name ? trace->name->str : NULL;
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_name(struct bt_ctf_trace_common *trace, const char *name);
+
+static inline
+const unsigned char *bt_ctf_trace_common_get_uuid(struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->uuid_set ? trace->uuid : NULL;
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace, const unsigned char *uuid);
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
+ const char *name, struct bt_ctf_private_value *value);
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common *trace,
+ const char *name, const char *value);
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_environment_field_integer(struct bt_ctf_trace_common *trace,
+ const char *name, int64_t value);
+
+static inline
+int64_t bt_ctf_trace_common_get_environment_field_count(
+ struct bt_ctf_trace_common *trace)
+{
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ ret = bt_ctf_attributes_get_count(trace->environment);
+ BT_ASSERT(ret >= 0);
+ return ret;
+}
+
+static inline
+const char *
+bt_ctf_trace_common_get_environment_field_name_by_index(
+ struct bt_ctf_trace_common *trace, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return bt_ctf_attributes_get_field_name(trace->environment, index);
+}
+
+static inline
+struct bt_ctf_private_value *
+bt_ctf_trace_common_borrow_environment_field_value_by_index(
+ struct bt_ctf_trace_common *trace, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return bt_ctf_attributes_borrow_field_value(trace->environment, index);
+}
+
+static inline
+struct bt_ctf_private_value *
+bt_ctf_trace_common_borrow_environment_field_value_by_name(
+ struct bt_ctf_trace_common *trace, const char *name)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ return bt_ctf_attributes_borrow_field_value_by_name(trace->environment,
+ name);
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_add_clock_class(struct bt_ctf_trace_common *trace,
+ struct bt_ctf_clock_class *clock_class);
+
+static inline
+int64_t bt_ctf_trace_common_get_clock_class_count(struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->clock_classes->len;
+}
+
+static inline
+struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_index(
+ struct bt_ctf_trace_common *trace, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->clock_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->clock_classes->len);
+ return g_ptr_array_index(trace->clock_classes, index);
+}
+
+static inline
+int64_t bt_ctf_trace_common_get_stream_count(struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return (int64_t) trace->streams->len;
+}
+
+static inline
+struct bt_ctf_stream_common *bt_ctf_trace_common_borrow_stream_by_index(
+ struct bt_ctf_trace_common *trace,
+ uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->streams->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->streams->len);
+ return g_ptr_array_index(trace->streams, index);
+}
+
+static inline
+int64_t bt_ctf_trace_common_get_stream_class_count(struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return (int64_t) trace->stream_classes->len;
+}
+
+static inline
+struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_index(
+ struct bt_ctf_trace_common *trace, uint64_t index)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->stream_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->stream_classes->len);
+ return g_ptr_array_index(trace->stream_classes, index);
+}
+
+static inline
+struct bt_ctf_stream_class_common *bt_ctf_trace_common_borrow_stream_class_by_id(
+ struct bt_ctf_trace_common *trace, uint64_t id_param)
+{
+ int i;
+ struct bt_ctf_stream_class_common *stream_class = NULL;
+ int64_t id = (int64_t) id_param;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(id >= 0,
+ "Invalid stream class ID: %" PRIu64, id_param);
+
+ for (i = 0; i < trace->stream_classes->len; i++) {
+ struct bt_ctf_stream_class_common *stream_class_candidate;
+
+ stream_class_candidate =
+ g_ptr_array_index(trace->stream_classes, i);
+
+ if (bt_ctf_stream_class_common_get_id(stream_class_candidate) ==
+ (int64_t) id) {
+ stream_class = stream_class_candidate;
+ goto end;
+ }
+ }
+
+end:
+ return stream_class;
+}
+
+static inline
+struct bt_ctf_clock_class *bt_ctf_trace_common_borrow_clock_class_by_name(
+ struct bt_ctf_trace_common *trace, const char *name)
+{
+ size_t i;
+ struct bt_ctf_clock_class *clock_class = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+
+ for (i = 0; i < trace->clock_classes->len; i++) {
+ struct bt_ctf_clock_class *cur_clk =
+ g_ptr_array_index(trace->clock_classes, i);
+ const char *cur_clk_name = bt_ctf_clock_class_get_name(cur_clk);
+
+ if (!cur_clk_name) {
+ goto end;
+ }
+
+ if (!strcmp(cur_clk_name, name)) {
+ clock_class = cur_clk;
+ goto end;
+ }
+ }
+
+end:
+ return clock_class;
+}
+
+static inline
+enum bt_ctf_byte_order bt_ctf_trace_common_get_native_byte_order(
+ struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->native_byte_order;
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_native_byte_order(struct bt_ctf_trace_common *trace,
+ enum bt_ctf_byte_order byte_order, bool allow_unspecified);
+
+static inline
+struct bt_ctf_field_type_common *bt_ctf_trace_common_borrow_packet_header_field_type(
+ struct bt_ctf_trace_common *trace)
+{
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->packet_header_field_type;
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_set_packet_header_field_type(struct bt_ctf_trace_common *trace,
+ struct bt_ctf_field_type_common *packet_header_field_type);
+
+static inline
+void bt_ctf_trace_common_freeze(struct bt_ctf_trace_common *trace)
+{
+ int i;
+
+ if (trace->frozen) {
+ return;
+ }
+
+ BT_LOGD("Freezing trace: addr=%p, name=\"%s\"",
+ trace, bt_ctf_trace_common_get_name(trace));
+ BT_LOGD_STR("Freezing packet header field type.");
+ bt_ctf_field_type_common_freeze(trace->packet_header_field_type);
+ BT_LOGD_STR("Freezing environment attributes.");
+ bt_ctf_attributes_freeze(trace->environment);
+
+ if (trace->clock_classes->len > 0) {
+ BT_LOGD_STR("Freezing clock classes.");
+ }
+
+ for (i = 0; i < trace->clock_classes->len; i++) {
+ struct bt_ctf_clock_class *clock_class =
+ g_ptr_array_index(trace->clock_classes, i);
+
+ bt_ctf_clock_class_freeze(clock_class);
+ }
+
+ trace->frozen = 1;
+}
+
+BT_HIDDEN
+int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace,
+ struct bt_ctf_stream_class_common *stream_class,
+ bt_ctf_validation_flag_copy_field_type_func copy_field_type_func,
+ struct bt_ctf_clock_class *init_expected_clock_class,
+ int (*map_clock_classes_func)(struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_field_type_common *packet_context_field_type,
+ struct bt_ctf_field_type_common *event_header_field_type),
+ bool check_ts_begin_end_mapped);
+
+struct bt_ctf_trace {
+ struct bt_ctf_trace_common common;
+};
+
+/*
+ * bt_ctf_trace_get_metadata_string: get metadata string.
+ *
+ * Get the trace's TSDL metadata. The caller assumes the ownership of the
+ * returned string.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the metadata string on success, NULL on error.
+ */
+BT_HIDDEN
+char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
+
+BT_HIDDEN
+struct bt_ctf_trace *bt_ctf_trace_create(void);
+
+BT_HIDDEN
+int64_t bt_ctf_trace_get_clock_class_count(
+ struct bt_ctf_trace *trace);
+
+BT_HIDDEN
+struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
+ struct bt_ctf_trace *trace, uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
+ struct bt_ctf_trace *trace, const char *name);
+
+BT_HIDDEN
+int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace,
+ struct bt_ctf_clock_class *clock_class);
+
+BT_HIDDEN
+int64_t bt_ctf_trace_get_environment_field_count(
+ struct bt_ctf_trace *trace);
+
+BT_HIDDEN
+const char *bt_ctf_trace_get_environment_field_name_by_index(
+ struct bt_ctf_trace *trace, uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_value *
+bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace,
+ uint64_t index);
+
+BT_HIDDEN
+struct bt_ctf_value *
+bt_ctf_trace_get_environment_field_value_by_name(
+ struct bt_ctf_trace *trace, const char *name);
+
+#endif /* BABELTRACE_CTF_WRITER_TRACE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_TRACE_H
+#define BABELTRACE_CTF_WRITER_TRACE_H
+
+/*
+ * Copyright 2014 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_trace;
+struct bt_ctf_stream_class;
+struct bt_ctf_stream;
+
+extern enum bt_ctf_byte_order bt_ctf_trace_get_native_byte_order(
+ struct bt_ctf_trace *trace);
+
+extern int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace,
+ enum bt_ctf_byte_order native_byte_order);
+
+extern const unsigned char *bt_ctf_trace_get_uuid(
+ struct bt_ctf_trace *trace);
+
+extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
+ const unsigned char *uuid);
+
+extern int bt_ctf_trace_set_environment_field_integer(
+ struct bt_ctf_trace *trace, const char *name,
+ int64_t value);
+
+extern int bt_ctf_trace_set_environment_field_string(
+ struct bt_ctf_trace *trace, const char *name,
+ const char *value);
+
+extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
+ struct bt_ctf_trace *trace);
+
+extern int bt_ctf_trace_set_packet_header_field_type(struct bt_ctf_trace *trace,
+ struct bt_ctf_field_type *packet_header_type);
+
+extern int64_t bt_ctf_trace_get_stream_class_count(
+ struct bt_ctf_trace *trace);
+
+extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
+ struct bt_ctf_trace *trace, uint64_t index);
+
+extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
+ struct bt_ctf_trace *trace, uint64_t id);
+
+extern int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
+ struct bt_ctf_stream_class *stream_class);
+
+extern int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace);
+
+extern struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
+ struct bt_ctf_trace *trace, uint64_t index);
+
+extern const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_TRACE_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H
+
+/*
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/field-path-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <stdint.h>
+
+#define BT_CTF_TO_COMMON(_obj) (&(_obj)->common)
+#define BT_CTF_FROM_COMMON(_obj) ((void *) _obj)
+
+struct bt_ctf_search_query {
+ gpointer value;
+ int found;
+};
+
+BT_HIDDEN
+const char *bt_ctf_get_byte_order_string(enum bt_ctf_byte_order byte_order);
+
+static inline
+const char *bt_ctf_field_type_id_string(enum bt_ctf_field_type_id type_id)
+{
+ switch (type_id) {
+ case BT_CTF_FIELD_TYPE_ID_UNKNOWN:
+ return "BT_CTF_FIELD_TYPE_ID_UNKNOWN";
+ case BT_CTF_FIELD_TYPE_ID_INTEGER:
+ return "BT_CTF_FIELD_TYPE_ID_INTEGER";
+ case BT_CTF_FIELD_TYPE_ID_FLOAT:
+ return "BT_CTF_FIELD_TYPE_ID_FLOAT";
+ case BT_CTF_FIELD_TYPE_ID_ENUM:
+ return "BT_CTF_FIELD_TYPE_ID_ENUM";
+ case BT_CTF_FIELD_TYPE_ID_STRING:
+ return "BT_CTF_FIELD_TYPE_ID_STRING";
+ case BT_CTF_FIELD_TYPE_ID_STRUCT:
+ return "BT_CTF_FIELD_TYPE_ID_STRUCT";
+ case BT_CTF_FIELD_TYPE_ID_ARRAY:
+ return "BT_CTF_FIELD_TYPE_ID_ARRAY";
+ case BT_CTF_FIELD_TYPE_ID_SEQUENCE:
+ return "BT_CTF_FIELD_TYPE_ID_SEQUENCE";
+ case BT_CTF_FIELD_TYPE_ID_VARIANT:
+ return "BT_CTF_FIELD_TYPE_ID_VARIANT";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+const char *bt_ctf_byte_order_string(enum bt_ctf_byte_order bo)
+{
+ switch (bo) {
+ case BT_CTF_BYTE_ORDER_UNKNOWN:
+ return "BT_CTF_BYTE_ORDER_UNKNOWN";
+ case BT_CTF_BYTE_ORDER_UNSPECIFIED:
+ return "BT_CTF_BYTE_ORDER_UNSPECIFIED";
+ case BT_CTF_BYTE_ORDER_NATIVE:
+ return "BT_CTF_BYTE_ORDER_NATIVE";
+ case BT_CTF_BYTE_ORDER_LITTLE_ENDIAN:
+ return "BT_CTF_BYTE_ORDER_LITTLE_ENDIAN";
+ case BT_CTF_BYTE_ORDER_BIG_ENDIAN:
+ return "BT_CTF_BYTE_ORDER_BIG_ENDIAN";
+ case BT_CTF_BYTE_ORDER_NETWORK:
+ return "BT_CTF_BYTE_ORDER_NETWORK";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+const char *bt_ctf_string_encoding_string(enum bt_ctf_string_encoding encoding)
+{
+ switch (encoding) {
+ case BT_CTF_STRING_ENCODING_UNKNOWN:
+ return "BT_CTF_STRING_ENCODING_UNKNOWN";
+ case BT_CTF_STRING_ENCODING_NONE:
+ return "BT_CTF_STRING_ENCODING_NONE";
+ case BT_CTF_STRING_ENCODING_UTF8:
+ return "BT_CTF_STRING_ENCODING_UTF8";
+ case BT_CTF_STRING_ENCODING_ASCII:
+ return "BT_CTF_STRING_ENCODING_ASCII";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+const char *bt_ctf_integer_base_string(enum bt_ctf_integer_base base)
+{
+ switch (base) {
+ case BT_CTF_INTEGER_BASE_UNKNOWN:
+ return "BT_CTF_INTEGER_BASE_UNKNOWN";
+ case BT_CTF_INTEGER_BASE_UNSPECIFIED:
+ return "BT_CTF_INTEGER_BASE_UNSPECIFIED";
+ case BT_CTF_INTEGER_BASE_BINARY:
+ return "BT_CTF_INTEGER_BASE_BINARY";
+ case BT_CTF_INTEGER_BASE_OCTAL:
+ return "BT_CTF_INTEGER_BASE_OCTAL";
+ case BT_CTF_INTEGER_BASE_DECIMAL:
+ return "BT_CTF_INTEGER_BASE_DECIMAL";
+ case BT_CTF_INTEGER_BASE_HEXADECIMAL:
+ return "BT_CTF_INTEGER_BASE_HEXADECIMAL";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_ctf_scope_string(enum bt_ctf_scope scope)
+{
+ switch (scope) {
+ case BT_CTF_SCOPE_UNKNOWN:
+ return "BT_CTF_SCOPE_UNKNOWN";
+ case BT_CTF_SCOPE_TRACE_PACKET_HEADER:
+ return "BT_CTF_SCOPE_TRACE_PACKET_HEADER";
+ case BT_CTF_SCOPE_STREAM_PACKET_CONTEXT:
+ return "BT_CTF_SCOPE_STREAM_PACKET_CONTEXT";
+ case BT_CTF_SCOPE_STREAM_EVENT_HEADER:
+ return "BT_CTF_SCOPE_STREAM_EVENT_HEADER";
+ case BT_CTF_SCOPE_STREAM_EVENT_CONTEXT:
+ return "BT_CTF_SCOPE_STREAM_EVENT_CONTEXT";
+ case BT_CTF_SCOPE_EVENT_CONTEXT:
+ return "BT_CTF_SCOPE_EVENT_CONTEXT";
+ case BT_CTF_SCOPE_EVENT_PAYLOAD:
+ return "BT_CTF_SCOPE_EVENT_PAYLOAD";
+ case BT_CTF_SCOPE_ENV:
+ return "BT_CTF_SCOPE_ENV";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_ctf_event_class_log_level_string(
+ enum bt_ctf_event_class_log_level level)
+{
+ switch (level) {
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE";
+ case BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG:
+ return "BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline
+GString *bt_ctf_field_path_string(struct bt_ctf_field_path *path)
+{
+ GString *str = g_string_new(NULL);
+ size_t i;
+
+ BT_ASSERT(path);
+
+ if (!str) {
+ goto end;
+ }
+
+ g_string_append_printf(str, "[%s", bt_common_scope_string(
+ bt_ctf_field_path_get_root_scope(path)));
+
+ for (i = 0; i < bt_ctf_field_path_get_index_count(path); i++) {
+ int index = bt_ctf_field_path_get_index(path, i);
+
+ g_string_append_printf(str, ", %d", index);
+ }
+
+ g_string_append(str, "]");
+
+end:
+ return str;
+}
+
+#endif /* BABELTRACE_CTF_WRITER_UTILS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_UTILS_H
+#define BABELTRACE_CTF_WRITER_UTILS_H
+
+/*
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_bool */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_bool bt_ctf_identifier_is_valid(const char *identifier);
+
+static inline
+int bt_ctf_validate_identifier(const char *identifier)
+{
+ return bt_ctf_identifier_is_valid(identifier) ? 1 : 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_UTILS_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
+
+/*
+ * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+
+struct bt_ctf_trace_common;
+struct bt_ctf_stream_class_common;
+struct bt_ctf_event_class_common;
+struct bt_ctf_field_type_common;
+
+typedef struct bt_ctf_field_type_common *(*bt_ctf_validation_flag_copy_field_type_func)(
+ struct bt_ctf_field_type_common *);
+
+enum bt_ctf_validation_flag {
+ BT_CTF_VALIDATION_FLAG_TRACE = 1,
+ BT_CTF_VALIDATION_FLAG_STREAM = 2,
+ BT_CTF_VALIDATION_FLAG_EVENT = 4,
+};
+
+/*
+ * Validation output structure.
+ *
+ * This is where the results of the validation function go. The field
+ * types are the validated ones which should replace the original field
+ * types of a trace, a stream class, and an event class.
+ *
+ * `valid_flags` contains the results of the validation.
+ */
+struct bt_ctf_validation_output {
+ struct bt_ctf_field_type_common *packet_header_type;
+ struct bt_ctf_field_type_common *packet_context_type;
+ struct bt_ctf_field_type_common *event_header_type;
+ struct bt_ctf_field_type_common *stream_event_ctx_type;
+ struct bt_ctf_field_type_common *event_context_type;
+ struct bt_ctf_field_type_common *event_payload_type;
+ enum bt_ctf_validation_flag valid_flags;
+};
+
+/*
+ * This function resolves and validates the field types of an event
+ * class, a stream class, and a trace. Copies are created if needed
+ * and the resulting field types to use are placed in the `output`
+ * validation structure, which also contains the results of the
+ * validation. Copies can replace the original field types of a trace,
+ * a stream class, and an event class using
+ * bt_ctf_validation_replace_types().
+ *
+ * The current known validity of the field types of the trace,
+ * stream class, and event class must be indicated with the
+ * `trace_valid`, `stream_class_valid`, and `event_class_valid`
+ * parameters. If a class is valid, its field types are not copied,
+ * validated, or resolved during this call.
+ *
+ * The validation flags `validate_flags` indicate which classes should
+ * have their field types validated.
+ *
+ * All parameters are owned by the caller.
+ */
+BT_HIDDEN
+int bt_ctf_validate_class_types(struct bt_ctf_private_value *environment,
+ struct bt_ctf_field_type_common *packet_header_type,
+ struct bt_ctf_field_type_common *packet_context_type,
+ struct bt_ctf_field_type_common *event_header_type,
+ struct bt_ctf_field_type_common *stream_event_ctx_type,
+ struct bt_ctf_field_type_common *event_context_type,
+ struct bt_ctf_field_type_common *event_payload_type,
+ int trace_valid, int stream_class_valid, int event_class_valid,
+ struct bt_ctf_validation_output *output,
+ enum bt_ctf_validation_flag validate_flags,
+ bt_ctf_validation_flag_copy_field_type_func copy_field_type_func);
+
+/*
+ * This function replaces the actual field types of a trace, a stream
+ * class, and an event class with the appropriate field types contained
+ * in a validation output structure.
+ *
+ * The replace flags `replace_flags` indicate which classes should have
+ * their field types replaced.
+ *
+ * Note that the field types that are not used in the validation output
+ * structure are still owned by it at the end of this call.
+ * bt_ctf_validation_output_put_types() should be called to clean the
+ * structure.
+ *
+ * All parameters are owned by the caller.
+ */
+BT_HIDDEN
+void bt_ctf_validation_replace_types(struct bt_ctf_trace_common *trace,
+ struct bt_ctf_stream_class_common *stream_class,
+ struct bt_ctf_event_class_common *event_class,
+ struct bt_ctf_validation_output *output,
+ enum bt_ctf_validation_flag replace_flags);
+
+/*
+ * This function puts all the field types contained in a given
+ * validation output structure.
+ *
+ * `output` is owned by the caller and is not freed here.
+ */
+BT_HIDDEN
+void bt_ctf_validation_output_put_types(
+ struct bt_ctf_validation_output *output);
+
+#endif /* BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H
+
+/*
+ * Copyright (c) 2015-2017 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015-2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+
+struct bt_ctf_value;
+struct bt_ctf_private_value;
+
+/**
+@brief Status codes.
+*/
+enum bt_ctf_value_status {
+ /// Operation canceled.
+ BT_CTF_VALUE_STATUS_CANCELED = 125,
+
+ /// Cannot allocate memory.
+ BT_CTF_VALUE_STATUS_NOMEM = -12,
+
+ /// Okay, no error.
+ BT_CTF_VALUE_STATUS_OK = 0,
+};
+
+BT_HIDDEN
+enum bt_ctf_value_status _bt_ctf_value_freeze(struct bt_ctf_value *object);
+
+#ifdef BT_DEV_MODE
+# define bt_ctf_value_freeze _bt_ctf_value_freeze
+#else
+# define bt_ctf_value_freeze(_value)
+#endif /* BT_DEV_MODE */
+
+extern struct bt_ctf_value *const bt_ctf_value_null;
+
+enum bt_ctf_value_type {
+ /// Null value object.
+ BT_CTF_VALUE_TYPE_NULL = 0,
+
+ /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
+ BT_CTF_VALUE_TYPE_BOOL = 1,
+
+ /// Integer value object (holds a signed 64-bit integer raw value).
+ BT_CTF_VALUE_TYPE_INTEGER = 2,
+
+ /// Floating point number value object (holds a \c double raw value).
+ BT_CTF_VALUE_TYPE_REAL = 3,
+
+ /// String value object.
+ BT_CTF_VALUE_TYPE_STRING = 4,
+
+ /// Array value object.
+ BT_CTF_VALUE_TYPE_ARRAY = 5,
+
+ /// Map value object.
+ BT_CTF_VALUE_TYPE_MAP = 6,
+};
+
+BT_HIDDEN
+enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object);
+
+static inline
+bt_bool bt_ctf_value_is_null(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_NULL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_bool(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_BOOL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_integer(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_INTEGER;
+}
+
+static inline
+bt_bool bt_ctf_value_is_real(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_REAL;
+}
+
+static inline
+bt_bool bt_ctf_value_is_string(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_STRING;
+}
+
+static inline
+bt_bool bt_ctf_value_is_array(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_ARRAY;
+}
+
+static inline
+bt_bool bt_ctf_value_is_map(const struct bt_ctf_value *object)
+{
+ return bt_ctf_value_get_type(object) == BT_CTF_VALUE_TYPE_MAP;
+}
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy,
+ const struct bt_ctf_value *object);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a,
+ const struct bt_ctf_value *object_b);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj);
+
+BT_HIDDEN
+int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj);
+
+BT_HIDDEN
+double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj);
+
+BT_HIDDEN
+const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj);
+
+BT_HIDDEN
+uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj);
+
+static inline
+bt_bool bt_ctf_value_array_is_empty(const struct bt_ctf_value *array_obj)
+{
+ return bt_ctf_value_array_get_size(array_obj) == 0;
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
+ const struct bt_ctf_value *array_obj, uint64_t index);
+
+BT_HIDDEN
+uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj);
+
+static inline
+bt_bool bt_ctf_value_map_is_empty(const struct bt_ctf_value *map_obj)
+{
+ return bt_ctf_value_map_get_size(map_obj) == 0;
+}
+
+BT_HIDDEN
+struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(
+ const struct bt_ctf_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_ctf_value_map_foreach_entry_cb)(const char *key,
+ struct bt_ctf_value *object, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(
+ const struct bt_ctf_value *map_obj,
+ bt_ctf_value_map_foreach_entry_cb cb, void *data);
+
+BT_HIDDEN
+bt_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj,
+ const char *key);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_value_map_extend(
+ struct bt_ctf_private_value **extended_map_obj,
+ const struct bt_ctf_value *base_map_obj,
+ const struct bt_ctf_value *extension_map_obj);
+
+
+struct bt_ctf_value;
+struct bt_ctf_private_value;
+
+extern struct bt_ctf_private_value *const bt_ctf_private_value_null;
+
+static inline
+struct bt_ctf_value *bt_ctf_private_value_as_value(
+ struct bt_ctf_private_value *priv_value)
+{
+ return (void *) priv_value;
+}
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_bool_create_init(bt_bool val);
+
+BT_HIDDEN
+void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj,
+ bt_bool val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_integer_create_init(
+ int64_t val);
+
+BT_HIDDEN
+void bt_ctf_private_value_integer_set(
+ struct bt_ctf_private_value *integer_obj, int64_t val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_real_create_init(double val);
+
+BT_HIDDEN
+void bt_ctf_private_value_real_set(
+ struct bt_ctf_private_value *real_obj, double val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_string_create_init(
+ const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_string_set(
+ struct bt_ctf_private_value *string_obj,
+ const char *val);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
+ const struct bt_ctf_private_value *array_obj, uint64_t index);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
+ struct bt_ctf_private_value *array_obj,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
+ struct bt_ctf_private_value *array_obj,
+ bt_bool val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
+ struct bt_ctf_private_value *array_obj,
+ int64_t val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
+ struct bt_ctf_private_value *array_obj,
+ double val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
+ struct bt_ctf_private_value *array_obj, const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
+ struct bt_ctf_private_value *array_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
+ struct bt_ctf_private_value *array_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
+ struct bt_ctf_private_value *array_obj, uint64_t index,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_create(void);
+
+BT_HIDDEN
+struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value(
+ const struct bt_ctf_private_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_ctf_private_value_map_foreach_entry_cb)(const char *key,
+ struct bt_ctf_private_value *object, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_foreach_entry(
+ const struct bt_ctf_private_value *map_obj,
+ bt_ctf_private_value_map_foreach_entry_cb cb, void *data);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
+ struct bt_ctf_private_value *map_obj, const char *key,
+ struct bt_ctf_value *element_obj);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, bt_bool val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, int64_t val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
+ struct bt_ctf_private_value *map_obj, const char *key, double val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
+ struct bt_ctf_private_value *map_obj, const char *key,
+ const char *val);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
+ struct bt_ctf_private_value *map_obj, const char *key);
+
+BT_HIDDEN
+enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
+ struct bt_ctf_private_value *map_obj, const char *key);
+
+static inline
+const char *bt_ctf_value_type_string(enum bt_ctf_value_type type)
+{
+ switch (type) {
+ case BT_CTF_VALUE_TYPE_NULL:
+ return "BT_CTF_VALUE_TYPE_NULL";
+ case BT_CTF_VALUE_TYPE_BOOL:
+ return "BT_CTF_VALUE_TYPE_BOOL";
+ case BT_CTF_VALUE_TYPE_INTEGER:
+ return "BT_CTF_VALUE_TYPE_INTEGER";
+ case BT_CTF_VALUE_TYPE_REAL:
+ return "BT_CTF_VALUE_TYPE_REAL";
+ case BT_CTF_VALUE_TYPE_STRING:
+ return "BT_CTF_VALUE_TYPE_STRING";
+ case BT_CTF_VALUE_TYPE_ARRAY:
+ return "BT_CTF_VALUE_TYPE_ARRAY";
+ case BT_CTF_VALUE_TYPE_MAP:
+ return "BT_CTF_VALUE_TYPE_MAP";
+ default:
+ return "(unknown)";
+ }
+};
+
+#endif /* BABELTRACE_CTF_WRITER_VALUES_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/visitor.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+typedef void *(*bt_ctf_child_accessor)(void *object, int index);
+typedef int64_t (*bt_ctf_child_count_accessor)(void *object);
+typedef int (*bt_ctf_child_visitor)(void *object, bt_ctf_visitor visitor,
+ void *data);
+
+struct bt_ctf_visitor_object {
+ enum bt_ctf_visitor_object_type type;
+ void *object;
+};
+
+BT_HIDDEN
+int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root,
+ bt_ctf_child_count_accessor child_counter,
+ bt_ctf_child_accessor child_accessor,
+ bt_ctf_child_visitor child_visitor,
+ bt_ctf_visitor visitor,
+ void *data);
+
+#endif /* BABELTRACE_CTF_WRITER_VISITOR_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_VISITOR_H
+#define BABELTRACE_CTF_WRITER_VISITOR_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup ctfirvisitor CTF IR visitor
+@ingroup ctfir
+@brief CTF IR visitor.
+
+@code
+#include <babeltrace2/trace-ir/visitor.h>
+@endcode
+
+A CTF IR <strong><em>visitor</em></strong> is a function that you
+can use to visit the hierarchy of a
+\link ctfirtraceclass CTF IR trace class\endlink with
+bt_ctf_trace_visit() or of a
+\link ctfirstreamclass CTF IR stream class\endlink with
+bt_ctf_stream_class_visit().
+
+The traversal of the object's hierarchy is always done in a
+pre-order fashion.
+
+@sa ctfirstreamclass
+@sa ctfirtraceclass
+
+@file
+@brief CTF IR visitor types and functions.
+@sa ctfirvisitor
+
+@addtogroup ctfirvisitor
+@{
+*/
+
+/**
+@struct bt_ctf_object
+@brief A CTF IR object wrapper.
+
+This structure wraps both a CTF IR object and its type
+(see #bt_ctf_object_type). It is used in the visiting function.
+
+You can use the bt_ctf_object_get_type() and
+bt_ctf_object_get_object() accessors to get the type and wrapped
+CTF IR object of a CTF IR object wrapper.
+
+A CTF IR object wrapper has <strong>no reference count</strong>: do \em
+not use bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
+
+@sa ctfirvisitor
+*/
+struct bt_ctf_visitor_object;
+
+/**
+@brief CTF IR object wrapper type.
+*/
+enum bt_ctf_visitor_object_type {
+ /// Unknown (used for errors).
+ BT_CTF_VISITOR_OBJECT_TYPE_UNKNOWN = -1,
+
+ /// \ref ctfirtraceclass.
+ BT_CTF_VISITOR_OBJECT_TYPE_TRACE = 0,
+
+ /// \ref ctfirstreamclass.
+ BT_CTF_VISITOR_OBJECT_TYPE_STREAM_CLASS = 1,
+
+ /// \ref ctfirstream.
+ BT_CTF_VISITOR_OBJECT_TYPE_STREAM = 2,
+
+ /// \ref ctfireventclass.
+ BT_CTF_VISITOR_OBJECT_TYPE_EVENT_CLASS = 3,
+
+ /// \ref ctfirevent.
+ BT_CTF_VISITOR_OBJECT_TYPE_EVENT = 4,
+
+ /// Number of entries in this enumeration.
+ BT_CTF_VISITOR_OBJECT_TYPE_NR,
+};
+
+/**
+@brief Visting function type.
+
+A function of this type is called by bt_ctf_trace_visit() or
+bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper
+\p object.
+
+\p object has <strong>no reference count</strong>: do \em not use
+bt_ctf_object_put_ref() or bt_ctf_object_get_ref() on it.
+
+@param[in] object Currently visited CTF IR object wrapper.
+@param[in] data User data.
+@returns 0 on success, or a negative value on error.
+
+@prenotnull{object}
+
+@sa bt_ctf_trace_visit(): Accepts a visitor to visit a trace class.
+@sa bt_ctf_stream_class_visit(): Accepts a visitor to visit a stream
+ class.
+*/
+typedef int (*bt_ctf_visitor)(struct bt_ctf_visitor_object *object,
+ void *data);
+
+/**
+@brief Returns the type of the CTF IR object wrapped by the CTF IR
+ object wrapper \p object.
+
+@param[in] object Object wrapper of which to get the type.
+@returns Type of \p object.
+
+@prenotnull{object}
+
+@sa bt_ctf_visitor_object_get_object(): Returns the object wrapped by a given
+ CTF IR object wrapper.
+*/
+enum bt_ctf_visitor_object_type bt_ctf_visitor_object_get_type(
+ struct bt_ctf_visitor_object *object);
+
+/**
+@brief Returns the CTF IR object wrapped by the CTF IR object
+ wrapper \p object.
+
+The reference count of \p object is \em not incremented by this
+function. On success, you must call bt_ctf_object_get_ref() on the return value to
+have your own reference.
+
+@param[in] object Object wrapper of which to get the wrapped
+ CTF IR object.
+@returns CTF IR object wrapped by \p object.
+
+@prenotnull{object}
+@post The reference count of the returned object is not modified.
+
+@sa bt_ctf_visitor_object_get_type(): Returns the type of a given
+ CTF IR object wrapper.
+*/
+void *bt_ctf_visitor_object_get_object(struct bt_ctf_visitor_object *object);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_VISITOR_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/ctf-writer/writer.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <glib.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+
+struct metadata_context {
+ GString *string;
+ GString *field_name;
+ unsigned int current_indentation_level;
+};
+
+struct bt_ctf_writer {
+ struct bt_ctf_object base;
+ int frozen; /* Protects attributes that can't be changed mid-trace */
+ struct bt_ctf_trace *trace;
+ GString *path;
+ int metadata_fd;
+};
+
+enum field_type_alias {
+ FIELD_TYPE_ALIAS_UINT5_T = 0,
+ FIELD_TYPE_ALIAS_UINT8_T,
+ FIELD_TYPE_ALIAS_UINT16_T,
+ FIELD_TYPE_ALIAS_UINT27_T,
+ FIELD_TYPE_ALIAS_UINT32_T,
+ FIELD_TYPE_ALIAS_UINT64_T,
+ NR_FIELD_TYPE_ALIAS,
+};
+
+BT_HIDDEN
+struct bt_ctf_field_type *get_field_type(enum field_type_alias alias);
+
+BT_HIDDEN
+const char *bt_ctf_get_byte_order_string(enum bt_ctf_byte_order byte_order);
+
+BT_HIDDEN
+void bt_ctf_writer_freeze(struct bt_ctf_writer *writer);
+
+#endif /* BABELTRACE_CTF_WRITER_WRITER_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_WRITER_H
+#define BABELTRACE_CTF_WRITER_WRITER_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/trace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_writer;
+struct bt_ctf_stream;
+struct bt_ctf_stream_class;
+struct bt_ctf_clock;
+
+/*
+ * bt_ctf_writer_create: create a writer instance.
+ *
+ * Allocate a new writer that will produce a trace in the given path.
+ * The creation of a writer sets its reference count to 1.
+ *
+ * @param path Path to the trace's containing folder (string is copied).
+ *
+ * Returns an allocated writer on success, NULL on error.
+ */
+extern struct bt_ctf_writer *bt_ctf_writer_create(const char *path);
+
+/*
+ * bt_ctf_writer_get_trace: Get a writer's associated trace.
+ *
+ * @param writer Writer instance.
+ *
+ * Return the writer's associated instance, NULL on error.
+ */
+extern struct bt_ctf_trace *bt_ctf_writer_get_trace(
+ struct bt_ctf_writer *writer);
+
+/*
+ * bt_ctf_writer_create_stream: create a stream instance.
+ *
+ * Allocate a new stream instance and register it to the writer. The creation of
+ * a stream sets its reference count to 1.
+ *
+ * @param writer Writer instance.
+ * @param stream_class Stream class to instantiate.
+ *
+ * Returns an allocated stream on success, NULL on error.
+ */
+extern struct bt_ctf_stream *bt_ctf_writer_create_stream(
+ struct bt_ctf_writer *writer,
+ struct bt_ctf_stream_class *stream_class);
+
+/*
+ * bt_ctf_writer_add_environment_field: add an environment field to the trace.
+ *
+ * Add an environment field to the trace. The name and value parameters are
+ * copied.
+ *
+ * @param writer Writer instance.
+ * @param name Name of the environment field (will be copied).
+ * @param value Value of the environment field (will be copied).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer,
+ const char *name,
+ const char *value);
+
+/*
+ * bt_ctf_writer_add_environment_field_int64: add an environment field to the trace.
+ *
+ * Add an environment field to the trace. The name and value parameters are
+ * copied.
+ *
+ * @param writer Writer instance.
+ * @param name Name of the environment field (will be copied).
+ * @param value Value of the environment field.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_writer_add_environment_field_int64(
+ struct bt_ctf_writer *writer,
+ const char *name,
+ int64_t value);
+
+/*
+ * bt_ctf_writer_add_clock: add a clock to the trace.
+ *
+ * Add a clock to the trace. Clocks assigned to stream classes must be
+ * registered to the writer.
+ *
+ * @param writer Writer instance.
+ * @param clock Clock to add to the trace.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer,
+ struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_writer_get_metadata_string: get meta-data string.
+ *
+ * Get the trace's TSDL meta-data. The caller assumes the ownership of the
+ * returned string.
+ *
+ * @param writer Writer instance.
+ *
+ * Returns the metadata string on success, NULL on error.
+ */
+extern char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
+
+/*
+ * bt_ctf_writer_flush_metadata: flush the trace's metadata to disk.
+ *
+ * Flush the trace's metadata to the metadata file. Note that the metadata will
+ * be flushed automatically when the Writer instance is released (last call to
+ * bt_ctf_writer_put).
+ *
+ * @param writer Writer instance.
+ */
+extern void bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
+
+/*
+ * bt_ctf_writer_set_byte_order: set a field type's byte order.
+ *
+ * Set the trace's byte order. Defaults to the host machine's endianness.
+ *
+ * @param writer Writer instance.
+ * @param byte_order Trace's byte order.
+ *
+ * Returns 0 on success, a negative value on error.
+ *
+ * Note: byte_order must not be BT_CTF_BYTE_ORDER_NATIVE since, according
+ * to the CTF specification, is defined as "the byte order described in the
+ * trace description".
+ */
+extern int bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer,
+ enum bt_ctf_byte_order byte_order);
+
+/*
+ * bt_ctf_writer_get and bt_ctf_writer_put: increment and decrement the
+ * writer's reference count.
+ *
+ * You may also use bt_ctf_get() and bt_ctf_put() with writer objects.
+ *
+ * These functions ensure that the writer won't be destroyed while it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) have to be done to
+ * destroy a writer.
+ *
+ * When the writer's reference count is decremented to 0 by a
+ * bt_ctf_writer_put, the writer is freed.
+ *
+ * @param writer Writer instance.
+ */
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_writer_get(struct bt_ctf_writer *writer)
+{
+ bt_ctf_object_get_ref(writer);
+}
+
+/* Pre-2.0 CTF writer compatibility */
+static inline
+void bt_ctf_writer_put(struct bt_ctf_writer *writer)
+{
+ bt_ctf_object_put_ref(writer);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_WRITER_WRITER_H */
--- /dev/null
+/* Pre-2.0 CTF writer backward compatibility */
+#include <babeltrace2/ctf-writer/clock.h>
+#include <babeltrace2/ctf-writer/event-fields.h>
+#include <babeltrace2/ctf-writer/event-types.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/writer.h>
--- /dev/null
+#ifndef BABELTRACE_CTFSER_INTERNAL_H
+#define BABELTRACE_CTFSER_INTERNAL_H
+
+/*
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2017-2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <limits.h>
+#include <babeltrace2/compat/mman-internal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/mmap-align-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/bitfield-internal.h>
+#include <glib.h>
+
+struct bt_ctfser {
+ /* Stream file's descriptor */
+ int fd;
+
+ /* Offset (bytes) of memory map (current packet) in the stream file */
+ off_t mmap_offset;
+
+ /* Offset (bytes) of packet's first byte in the memory map */
+ off_t mmap_base_offset;
+
+ /* Current offset (bits) within current packet */
+ uint64_t offset_in_cur_packet_bits;
+
+ /* Current packet size (bytes) */
+ uint64_t cur_packet_size_bytes;
+
+ /* Previous packet size (bytes) */
+ uint64_t prev_packet_size_bytes;
+
+ /* Current stream size (bytes) */
+ uint64_t stream_size_bytes;
+
+ /* Memory map base address */
+ struct mmap_align *base_mma;
+
+ /* Stream file's path (for debugging) */
+ GString *path;
+};
+
+/*
+ * Initializes a CTF serializer.
+ *
+ * This function opens the file `path` for writing.
+ */
+BT_HIDDEN
+int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path);
+
+/*
+ * Finalizes a CTF serializer.
+ *
+ * This function truncates the stream file so that there's no extra
+ * padding after the last packet, and then closes the file.
+ */
+BT_HIDDEN
+int bt_ctfser_fini(struct bt_ctfser *ctfser);
+
+/*
+ * Opens a new packet.
+ *
+ * All the next writing functions are performed within this new packet.
+ */
+BT_HIDDEN
+int bt_ctfser_open_packet(struct bt_ctfser *ctfser);
+
+/*
+ * Closes the current packet, making its size `packet_size_bytes`.
+ */
+BT_HIDDEN
+void bt_ctfser_close_current_packet(struct bt_ctfser *ctfser,
+ uint64_t packet_size_bytes);
+
+BT_HIDDEN
+int _bt_ctfser_increase_cur_packet_size(struct bt_ctfser *ctfser);
+
+static inline
+uint64_t _bt_ctfser_cur_packet_size_bits(struct bt_ctfser *ctfser)
+{
+ return ctfser->cur_packet_size_bytes * 8;
+}
+
+static inline
+uint64_t _bt_ctfser_prev_packet_size_bits(struct bt_ctfser *ctfser)
+{
+ return ctfser->prev_packet_size_bytes * 8;
+}
+
+static inline
+uint64_t _bt_ctfser_offset_bytes(struct bt_ctfser *ctfser)
+{
+ return ctfser->offset_in_cur_packet_bits / 8;
+}
+
+static inline
+uint8_t *_bt_ctfser_get_addr(struct bt_ctfser *ctfser)
+{
+ /* Only makes sense to get the address after aligning on byte */
+ BT_ASSERT(ctfser->offset_in_cur_packet_bits % 8 == 0);
+ return ((uint8_t *) mmap_align_addr(ctfser->base_mma)) +
+ ctfser->mmap_base_offset + _bt_ctfser_offset_bytes(ctfser);
+}
+
+static inline
+bool _bt_ctfser_has_space_left(struct bt_ctfser *ctfser, uint64_t size_bits)
+{
+ bool has_space_left = true;
+
+ if (unlikely((ctfser->offset_in_cur_packet_bits + size_bits >
+ _bt_ctfser_cur_packet_size_bits(ctfser)))) {
+ has_space_left = false;
+ goto end;
+ }
+
+ if (unlikely(size_bits > UINT64_MAX - ctfser->offset_in_cur_packet_bits)) {
+ has_space_left = false;
+ goto end;
+ }
+
+end:
+ return has_space_left;
+}
+
+static inline
+void _bt_ctfser_incr_offset(struct bt_ctfser *ctfser, uint64_t size_bits)
+{
+ BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
+ ctfser->offset_in_cur_packet_bits += size_bits;
+}
+
+/*
+ * Aligns the current offset within the current packet to
+ * `alignment_bits` bits (power of two, > 0).
+ */
+static inline
+int bt_ctfser_align_offset_in_current_packet(struct bt_ctfser *ctfser,
+ uint64_t alignment_bits)
+{
+ int ret = 0;
+ uint64_t align_size_bits;
+
+ BT_ASSERT(alignment_bits > 0);
+ align_size_bits = ALIGN(ctfser->offset_in_cur_packet_bits,
+ alignment_bits) - ctfser->offset_in_cur_packet_bits;
+
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, align_size_bits))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ _bt_ctfser_incr_offset(ctfser, align_size_bits);
+
+end:
+ return ret;
+}
+
+static inline
+int _bt_ctfser_write_byte_aligned_unsigned_int_no_align(
+ struct bt_ctfser *ctfser, uint64_t value,
+ unsigned int size_bits, int byte_order)
+{
+ int ret = 0;
+
+ /* Reverse byte order? */
+ bool rbo = byte_order != BYTE_ORDER;
+
+ BT_ASSERT(size_bits % 8 == 0);
+ BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
+
+ switch (size_bits) {
+ case 8:
+ {
+ uint8_t v = (uint8_t) value;
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 16:
+ {
+ uint16_t v = (uint16_t) value;
+
+ if (rbo) {
+ v = GUINT16_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 32:
+ {
+ uint32_t v = (uint32_t) value;
+
+ if (rbo) {
+ v = GUINT32_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 64:
+ {
+ uint64_t v = (uint64_t) value;
+
+ if (rbo) {
+ v = GUINT64_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ default:
+ abort();
+ }
+
+ _bt_ctfser_incr_offset(ctfser, size_bits);
+ return ret;
+}
+
+static inline
+int _bt_ctfser_write_byte_aligned_signed_int_no_align(
+ struct bt_ctfser *ctfser, int64_t value,
+ unsigned int size_bits, int byte_order)
+{
+ int ret = 0;
+
+ /* Reverse byte order? */
+ bool rbo = byte_order != BYTE_ORDER;
+
+ BT_ASSERT(size_bits % 8 == 0);
+ BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits));
+
+ switch (size_bits) {
+ case 8:
+ {
+ int8_t v = (int8_t) value;
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 16:
+ {
+ int16_t v = (int16_t) value;
+
+ if (rbo) {
+ v = GUINT16_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 32:
+ {
+ int32_t v = (int32_t) value;
+
+ if (rbo) {
+ v = GUINT32_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ case 64:
+ {
+ int64_t v = (int64_t) value;
+
+ if (rbo) {
+ v = GUINT64_SWAP_LE_BE(v);
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), &v, sizeof(v));
+ break;
+ }
+ default:
+ abort();
+ }
+
+ _bt_ctfser_incr_offset(ctfser, size_bits);
+ return ret;
+}
+
+/*
+ * Writes an unsigned integer known to have a size that is a multiple of
+ * 8 and an alignment that is >= 8 at the current offset within the
+ * current packet.
+ */
+static inline
+int bt_ctfser_write_byte_aligned_unsigned_int(struct bt_ctfser *ctfser,
+ uint64_t value, unsigned int alignment_bits,
+ unsigned int size_bits, int byte_order)
+{
+ int ret;
+
+ BT_ASSERT(alignment_bits % 8 == 0);
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ ret = _bt_ctfser_write_byte_aligned_unsigned_int_no_align(ctfser, value,
+ size_bits, byte_order);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+end:
+ return ret;
+}
+
+/*
+ * Writes a signed integer known to have a size that is a multiple of 8
+ * and an alignment that is >= 8 at the current offset within the
+ * current packet.
+ */
+static inline
+int bt_ctfser_write_byte_aligned_signed_int(struct bt_ctfser *ctfser,
+ int64_t value, unsigned int alignment_bits,
+ unsigned int size_bits, int byte_order)
+{
+ int ret;
+
+ BT_ASSERT(alignment_bits % 8 == 0);
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ ret = _bt_ctfser_write_byte_aligned_signed_int_no_align(ctfser, value,
+ size_bits, byte_order);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+end:
+ return ret;
+}
+
+/*
+ * Writes an unsigned integer at the current offset within the current
+ * packet.
+ */
+static inline
+int bt_ctfser_write_unsigned_int(struct bt_ctfser *ctfser, uint64_t value,
+ unsigned int alignment_bits, unsigned int size_bits,
+ int byte_order)
+{
+ int ret = 0;
+
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ if (alignment_bits % 8 == 0 && size_bits % 8 == 0) {
+ ret = _bt_ctfser_write_byte_aligned_unsigned_int_no_align(
+ ctfser, value, size_bits, byte_order);
+ goto end;
+ }
+
+ if (byte_order == LITTLE_ENDIAN) {
+ bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) +
+ ctfser->mmap_base_offset, uint8_t,
+ ctfser->offset_in_cur_packet_bits, size_bits, value);
+ } else {
+ bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) +
+ ctfser->mmap_base_offset, uint8_t,
+ ctfser->offset_in_cur_packet_bits, size_bits, value);
+ }
+
+ _bt_ctfser_incr_offset(ctfser, size_bits);
+
+end:
+ return ret;
+}
+
+/*
+ * Writes a signed integer at the current offset within the current
+ * packet.
+ */
+static inline
+int bt_ctfser_write_signed_int(struct bt_ctfser *ctfser, int64_t value,
+ unsigned int alignment_bits, unsigned int size_bits,
+ int byte_order)
+{
+ int ret = 0;
+
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ if (alignment_bits % 8 == 0 && size_bits % 8 == 0) {
+ ret = _bt_ctfser_write_byte_aligned_signed_int_no_align(
+ ctfser, value, size_bits, byte_order);
+ goto end;
+ }
+
+ if (byte_order == LITTLE_ENDIAN) {
+ bt_bitfield_write_le(mmap_align_addr(ctfser->base_mma) +
+ ctfser->mmap_base_offset, uint8_t,
+ ctfser->offset_in_cur_packet_bits, size_bits, value);
+ } else {
+ bt_bitfield_write_be(mmap_align_addr(ctfser->base_mma) +
+ ctfser->mmap_base_offset, uint8_t,
+ ctfser->offset_in_cur_packet_bits, size_bits, value);
+ }
+
+ _bt_ctfser_incr_offset(ctfser, size_bits);
+
+end:
+ return ret;
+}
+
+/*
+ * Writes a 32-bit floating point number at the current offset within
+ * the current packet.
+ */
+static inline
+int bt_ctfser_write_float32(struct bt_ctfser *ctfser, double value,
+ unsigned int alignment_bits, int byte_order)
+{
+ union u32f {
+ uint32_t u;
+ float f;
+ } u32f;
+
+ u32f.f = (float) value;
+ return bt_ctfser_write_unsigned_int(ctfser, (uint64_t) u32f.u,
+ alignment_bits, 32, byte_order);
+}
+
+/*
+ * Writes a 64-bit floating point number at the current offset within
+ * the current packet.
+ */
+static inline
+int bt_ctfser_write_float64(struct bt_ctfser *ctfser, double value,
+ unsigned int alignment_bits, int byte_order)
+{
+ union u64f {
+ uint64_t u;
+ float f;
+ } u64f;
+
+ u64f.f = value;
+ return bt_ctfser_write_unsigned_int(ctfser, u64f.u, alignment_bits,
+ 64, byte_order);
+}
+
+/*
+ * Writes a C string, including the terminating null character, at the
+ * current offset within the current packet.
+ */
+static inline
+int bt_ctfser_write_string(struct bt_ctfser *ctfser, const char *value)
+{
+ int ret = 0;
+ const char *at = value;
+
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser, 8);
+ if (unlikely(ret)) {
+ goto end;
+ }
+
+ while (true) {
+ if (unlikely(!_bt_ctfser_has_space_left(ctfser, 8))) {
+ ret = _bt_ctfser_increase_cur_packet_size(ctfser);
+ if (unlikely(ret)) {
+ goto end;
+ }
+ }
+
+ memcpy(_bt_ctfser_get_addr(ctfser), at, sizeof(*at));
+ _bt_ctfser_incr_offset(ctfser, 8);
+
+ if (unlikely(*at == '\0')) {
+ break;
+ }
+
+ at++;
+ }
+
+end:
+ return ret;
+}
+
+/*
+ * Returns the current offset within the current packet (bits).
+ */
+static inline
+uint64_t bt_ctfser_get_offset_in_current_packet_bits(struct bt_ctfser *ctfser)
+{
+ return ctfser->offset_in_cur_packet_bits;
+}
+
+/*
+ * Sets the current offset within the current packet (bits).
+ */
+static inline
+void bt_ctfser_set_offset_in_current_packet_bits(struct bt_ctfser *ctfser,
+ uint64_t offset_bits)
+{
+ BT_ASSERT(offset_bits <= _bt_ctfser_cur_packet_size_bits(ctfser));
+ ctfser->offset_in_cur_packet_bits = offset_bits;
+}
+
+static inline
+const char *bt_ctfser_get_file_path(struct bt_ctfser *ctfser)
+{
+ return ctfser->path->str;
+}
+
+#endif /* BABELTRACE_CTFSER_INTERNAL_H */
--- /dev/null
+#ifndef _BABELTRACE_ENDIAN_H
+#define _BABELTRACE_ENDIAN_H
+
+/*
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * endian.h compatibility layer.
+ *
+ * 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.
+ */
+
+#ifdef __FreeBSD__
+#include <machine/endian.h>
+
+#elif defined(__sun__)
+#include <sys/byteorder.h>
+
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifdef _LITTLE_ENDIAN
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#define betoh16(x) BE_16(x)
+#define letoh16(x) LE_16(x)
+#define betoh32(x) BE_32(x)
+#define letoh32(x) LE_32(x)
+#define betoh64(x) BE_64(x)
+#define letoh64(x) LE_64(x)
+#define htobe16(x) BE_16(x)
+#define be16toh(x) BE_16(x)
+#define htobe32(x) BE_32(x)
+#define be32toh(x) BE_32(x)
+#define htobe64(x) BE_64(x)
+#define be64toh(x) BE_64(x)
+
+#elif defined(__MINGW32__)
+#include <stdint.h>
+
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#define htobe16(x) (uint16_t) _byteswap_ushort(x)
+#define htole16(x) (x)
+#define be16toh(x) (uint16_t) _byteswap_ushort(x)
+#define le16toh(x) (x)
+
+#define htobe32(x) (uint32_t) _byteswap_ulong(x)
+#define htole32(x) (x)
+#define be32toh(x) (uint32_t) _byteswap_ulong(x)
+#define le32toh(x) (x)
+
+#define htobe64(x) (uint64_t) _byteswap_uint64(x)
+#define htole64(x) (x)
+#define be64toh(x) (uint64_t) _byteswap_uint64(x)
+#define le64toh(x) (x)
+
+#elif defined(__APPLE__)
+# include <machine/endian.h>
+# include <libkern/OSByteOrder.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define htobe16(x) OSSwapConstInt16(x)
+# define htole16(x) (x)
+# define be16toh(x) OSSwapConstInt16(x)
+# define le16toh(x) (x)
+
+# define htobe32(x) OSSwapConstInt32(x)
+# define htole32(x) (x)
+# define be32toh(x) OSSwapConstInt32(x)
+# define le32toh(x) (x)
+
+# define htobe64(x) OSSwapConstInt64(x)
+# define htole64(x) (x)
+# define be64toh(x) OSSwapConstInt64(x)
+# define le64toh(x) (x)
+
+# else /* BYTE_ORDER == LITTLE_ENDIAN */
+# define htobe16(x) (x)
+# define htole16(x) OSSwapConstInt16(x)
+# define be16toh(x) (x)
+# define le16toh(x) OSSwapConstInt16(x)
+
+# define htobe32(x) (x)
+# define htole32(x) OSSwapConstInt32(x)
+# define be32toh(x) (x)
+# define le32toh(x) OSSwapConstInt32(x)
+
+# define htobe64(x) (x)
+# define htole64(x) OSSwapConstInt64(x)
+# define be64toh(x) (x)
+# define le64toh(x) OSSwapConstInt64(x)
+# endif
+
+#else
+#include <endian.h>
+
+/*
+ * htobe/betoh are not defined for glibc < 2.9, so add them explicitly
+ * if they are missing.
+ */
+# ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef htobe16
+# define htobe16(x) __bswap_16(x)
+# endif
+# ifndef htole16
+# define htole16(x) (x)
+# endif
+# ifndef be16toh
+# define be16toh(x) __bswap_16(x)
+# endif
+# ifndef le16toh
+# define le16toh(x) (x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) __bswap_32(x)
+# endif
+# ifndef htole32
+# define htole32(x) (x)
+# endif
+# ifndef be32toh
+# define be32toh(x) __bswap_32(x)
+# endif
+# ifndef le32toh
+# define le32toh(x) (x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) __bswap_64(x)
+# endif
+# ifndef htole64
+# define htole64(x) (x)
+# endif
+# ifndef be64toh
+# define be64toh(x) __bswap_64(x)
+# endif
+# ifndef le64toh
+# define le64toh(x) (x)
+# endif
+
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+# ifndef htobe16
+# define htobe16(x) (x)
+# endif
+# ifndef htole16
+# define htole16(x) __bswap_16(x)
+# endif
+# ifndef be16toh
+# define be16toh(x) (x)
+# endif
+# ifndef le16toh
+# define le16toh(x) __bswap_16(x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) (x)
+# endif
+# ifndef htole32
+# define htole32(x) __bswap_32(x)
+# endif
+# ifndef be32toh
+# define be32toh(x) (x)
+# endif
+# ifndef le32toh
+# define le32toh(x) __bswap_32(x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) (x)
+# endif
+# ifndef htole64
+# define htole64(x) __bswap_64(x)
+# endif
+# ifndef be64toh
+# define be64toh(x) (x)
+# endif
+# ifndef le64toh
+# define le64toh(x) __bswap_64(x)
+# endif
+
+# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+# endif /* __USE_BSD */
+#endif /* else -- __FreeBSD__ */
+
+#ifndef FLOAT_WORD_ORDER
+#ifdef __FLOAT_WORD_ORDER
+#define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
+#else /* __FLOAT_WORD_ORDER */
+#define FLOAT_WORD_ORDER BYTE_ORDER
+#endif /* __FLOAT_WORD_ORDER */
+#endif /* FLOAT_WORD_ORDER */
+
+#endif /* _BABELTRACE_ENDIAN_H */
--- /dev/null
+#ifndef BABELTRACE_FD_CACHE_INTERNAL_H
+#define BABELTRACE_FD_CACHE_INTERNAL_H
+/*
+ * fd-cache-internal.h
+ *
+ * Babeltrace - File descriptor cache
+ *
+ * Copyright 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * Author: Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+
+struct bt_fd_cache_handle {
+ int fd;
+};
+
+struct bt_fd_cache {
+ GHashTable *cache;
+};
+
+static inline
+int bt_fd_cache_handle_get_fd(struct bt_fd_cache_handle *handle)
+{
+ return handle->fd;
+}
+
+BT_HIDDEN
+int bt_fd_cache_init(struct bt_fd_cache *fdc);
+
+BT_HIDDEN
+void bt_fd_cache_fini(struct bt_fd_cache *fdc);
+
+BT_HIDDEN
+struct bt_fd_cache_handle *bt_fd_cache_get_handle(struct bt_fd_cache *fdc,
+ const char *path);
+
+BT_HIDDEN
+void bt_fd_cache_put_handle(struct bt_fd_cache *fdc,
+ struct bt_fd_cache_handle *handle);
+
+#endif /* BABELTRACE_FD_CACHE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_bool, bt_component_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_component_class_status {
+ BT_COMPONENT_CLASS_STATUS_OK = 0,
+ BT_COMPONENT_CLASS_STATUS_NOMEM = -12,
+} bt_component_class_status;
+
+typedef enum bt_component_class_type {
+ BT_COMPONENT_CLASS_TYPE_SOURCE = 0,
+ BT_COMPONENT_CLASS_TYPE_FILTER = 1,
+ BT_COMPONENT_CLASS_TYPE_SINK = 2,
+} bt_component_class_type;
+
+extern const char *bt_component_class_get_name(
+ const bt_component_class *component_class);
+
+extern const char *bt_component_class_get_description(
+ const bt_component_class *component_class);
+
+extern const char *bt_component_class_get_help(
+ const bt_component_class *component_class);
+
+extern bt_component_class_type bt_component_class_get_type(
+ const bt_component_class *component_class);
+
+static inline
+bt_bool bt_component_class_is_source(
+ const bt_component_class *component_class)
+{
+ return bt_component_class_get_type(component_class) ==
+ BT_COMPONENT_CLASS_TYPE_SOURCE;
+}
+
+static inline
+bt_bool bt_component_class_is_filter(
+ const bt_component_class *component_class)
+{
+ return bt_component_class_get_type(component_class) ==
+ BT_COMPONENT_CLASS_TYPE_FILTER;
+}
+
+static inline
+bt_bool bt_component_class_is_sink(
+ const bt_component_class *component_class)
+{
+ return bt_component_class_get_type(component_class) ==
+ BT_COMPONENT_CLASS_TYPE_SINK;
+}
+
+extern void bt_component_class_get_ref(
+ const bt_component_class *component_class);
+
+extern void bt_component_class_put_ref(
+ const bt_component_class *component_class);
+
+#define BT_COMPONENT_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class, bt_component_class_filter,
+ * __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class *
+bt_component_class_filter_as_component_class_const(
+ const bt_component_class_filter *comp_cls_filter)
+{
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_filter);
+}
+
+extern void bt_component_class_filter_get_ref(
+ const bt_component_class_filter *component_class_filter);
+
+extern void bt_component_class_filter_put_ref(
+ const bt_component_class_filter *component_class_filter);
+
+#define BT_COMPONENT_CLASS_FILTER_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_class_filter_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_CLASS_FILTER_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_class_filter_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/* For bt_self_message_iterator_status */
+#include <babeltrace2/graph/self-message-iterator.h>
+
+/* For bt_query_status */
+#include <babeltrace2/graph/component-class.h>
+
+/* For bt_component_class_status */
+#include <babeltrace2/graph/component-class-const.h>
+
+/*
+ * 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_message_array_const,
+ * bt_bool, bt_self_message_iterator, __BT_UPCAST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef bt_self_component_status
+(*bt_component_class_filter_init_method)(
+ bt_self_component_filter *self_component,
+ const bt_value *params, void *init_method_data);
+
+typedef void (*bt_component_class_filter_finalize_method)(
+ bt_self_component_filter *self_component);
+
+typedef 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_message_iterator_finalize_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef 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 bt_self_message_iterator_status
+(*bt_component_class_filter_message_iterator_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin);
+
+typedef bt_self_message_iterator_status
+(*bt_component_class_filter_message_iterator_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_bool
+(*bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin);
+
+typedef bt_bool
+(*bt_component_class_filter_message_iterator_can_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_query_status
+(*bt_component_class_filter_query_method)(
+ bt_self_component_class_filter *comp_class,
+ const bt_query_executor *query_executor,
+ const char *object, const bt_value *params,
+ const bt_value **result);
+
+typedef bt_self_component_status
+(*bt_component_class_filter_accept_input_port_connection_method)(
+ bt_self_component_filter *self_component,
+ bt_self_component_port_input *self_port,
+ const bt_port_output *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_filter_accept_output_port_connection_method)(
+ bt_self_component_filter *self_component,
+ bt_self_component_port_output *self_port,
+ const bt_port_input *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_filter_input_port_connected_method)(
+ bt_self_component_filter *self_component,
+ bt_self_component_port_input *self_port,
+ const bt_port_output *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_filter_output_port_connected_method)(
+ bt_self_component_filter *self_component,
+ bt_self_component_port_output *self_port,
+ const bt_port_input *other_port);
+
+static inline
+bt_component_class *bt_component_class_filter_as_component_class(
+ bt_component_class_filter *comp_cls_filter)
+{
+ return __BT_UPCAST(bt_component_class, comp_cls_filter);
+}
+
+extern
+bt_component_class_filter *bt_component_class_filter_create(
+ const char *name,
+ bt_component_class_filter_message_iterator_next_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_init_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_init_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_finalize_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_finalize_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_accept_input_port_connection_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_accept_input_port_connection_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_accept_output_port_connection_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_accept_output_port_connection_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_input_port_connected_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_input_port_connected_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_output_port_connected_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_output_port_connected_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_query_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_query_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_message_iterator_init_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_init_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_message_iterator_finalize_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_finalize_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_seek_ns_from_origin_method method);
+
+extern bt_component_class_status
+bt_component_class_filter_set_message_iterator_seek_beginning_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_seek_beginning_method method);
+
+extern bt_bool
+bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method);
+
+extern bt_bool
+bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
+ bt_component_class_filter *comp_class,
+ bt_component_class_filter_message_iterator_can_seek_beginning_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_FILTER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/graph/component-const.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-source.h>
+#include <babeltrace2/graph/component-class-filter.h>
+#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/list-internal.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+
+struct bt_component_class;
+struct bt_plugin_so_shared_lib_handle;
+
+typedef void (*bt_component_class_destroy_listener_func)(
+ struct bt_component_class *class, void *data);
+
+struct bt_component_class_destroy_listener {
+ bt_component_class_destroy_listener_func func;
+ void *data;
+};
+
+struct bt_component_class {
+ struct bt_object base;
+ enum bt_component_class_type type;
+ GString *name;
+ GString *description;
+ GString *help;
+
+ /* Array of struct bt_component_class_destroy_listener */
+ GArray *destroy_listeners;
+ bool frozen;
+ struct bt_list_head node;
+ struct bt_plugin_so_shared_lib_handle *so_handle;
+};
+
+struct bt_component_class_source {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_source_init_method init;
+ bt_component_class_source_finalize_method finalize;
+ 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_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
+ bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+ 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;
+ } methods;
+};
+
+struct bt_component_class_sink {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_sink_init_method init;
+ bt_component_class_sink_finalize_method finalize;
+ bt_component_class_sink_query_method query;
+ bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
+ bt_component_class_sink_input_port_connected_method input_port_connected;
+ bt_component_class_sink_graph_is_configured_method graph_is_configured;
+ bt_component_class_sink_consume_method consume;
+ } methods;
+};
+
+struct bt_component_class_filter {
+ struct bt_component_class parent;
+ struct {
+ bt_component_class_filter_init_method init;
+ bt_component_class_filter_finalize_method finalize;
+ 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_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+ bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
+ bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+ bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+ 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;
+ bt_component_class_filter_input_port_connected_method input_port_connected;
+ bt_component_class_filter_output_port_connected_method output_port_connected;
+ } methods;
+};
+
+BT_HIDDEN
+void bt_component_class_add_destroy_listener(struct bt_component_class *class,
+ bt_component_class_destroy_listener_func func, void *data);
+
+BT_HIDDEN
+void _bt_component_class_freeze(
+ const struct bt_component_class *component_class);
+
+#ifdef BT_DEV_MODE
+# define bt_component_class_freeze _bt_component_class_freeze
+#else
+# define bt_component_class_freeze(_cc)
+#endif
+
+static inline
+const char *bt_component_class_type_string(enum bt_component_class_type type)
+{
+ switch (type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ return "BT_COMPONENT_CLASS_TYPE_SOURCE";
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ return "BT_COMPONENT_CLASS_TYPE_SINK";
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ return "BT_COMPONENT_CLASS_TYPE_FILTER";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/graph/message-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_component_class_sink_colander_priv_data {
+ bt_message_array_const msgs;
+ uint64_t *count_addr;
+ struct bt_self_component_port_input_message_iterator *msg_iter;
+};
+
+struct bt_component_class_sink_colander_data {
+ bt_message_array_const msgs;
+ uint64_t *count_addr;
+};
+
+extern struct bt_component_class_sink *
+bt_component_class_sink_colander_get(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class, bt_component_class_sink, __BT_UPCAST_CONST */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class *
+bt_component_class_sink_as_component_class_const(
+ const bt_component_class_sink *comp_cls_sink)
+{
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_sink);
+}
+
+extern void bt_component_class_sink_get_ref(
+ const bt_component_class_sink *component_class_sink);
+
+extern void bt_component_class_sink_put_ref(
+ const bt_component_class_sink *component_class_sink);
+
+#define BT_COMPONENT_CLASS_SINK_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_class_sink_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_CLASS_SINK_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_class_sink_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/* For bt_query_status */
+#include <babeltrace2/graph/component-class.h>
+
+/* For bt_component_class_status */
+#include <babeltrace2/graph/component-class-const.h>
+
+/*
+ * For bt_component_class, bt_component_class_sink, bt_port_output,
+ * bt_query_executor, bt_self_component_class_sink,
+ * bt_self_component_sink, bt_self_component_port_input, bt_value,
+ * __BT_UPCAST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef bt_self_component_status (*bt_component_class_sink_init_method)(
+ bt_self_component_sink *self_component,
+ const bt_value *params, void *init_method_data);
+
+typedef void (*bt_component_class_sink_finalize_method)(
+ bt_self_component_sink *self_component);
+
+typedef bt_query_status
+(*bt_component_class_sink_query_method)(
+ bt_self_component_class_sink *comp_class,
+ const bt_query_executor *query_executor,
+ const char *object, const bt_value *params,
+ const bt_value **result);
+
+typedef bt_self_component_status
+(*bt_component_class_sink_accept_input_port_connection_method)(
+ bt_self_component_sink *self_component,
+ bt_self_component_port_input *self_port,
+ const bt_port_output *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_sink_input_port_connected_method)(
+ bt_self_component_sink *self_component,
+ bt_self_component_port_input *self_port,
+ const bt_port_output *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_sink_graph_is_configured_method)(
+ bt_self_component_sink *self_component);
+
+typedef bt_self_component_status (*bt_component_class_sink_consume_method)(
+ bt_self_component_sink *self_component);
+
+static inline
+bt_component_class *bt_component_class_sink_as_component_class(
+ bt_component_class_sink *comp_cls_sink)
+{
+ return __BT_UPCAST(bt_component_class, comp_cls_sink);
+}
+
+extern
+bt_component_class_sink *bt_component_class_sink_create(
+ const char *name,
+ bt_component_class_sink_consume_method method);
+
+extern bt_component_class_status bt_component_class_sink_set_init_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_init_method method);
+
+extern bt_component_class_status bt_component_class_sink_set_finalize_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_finalize_method method);
+
+extern bt_component_class_status
+bt_component_class_sink_set_accept_input_port_connection_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_accept_input_port_connection_method method);
+
+extern bt_component_class_status
+bt_component_class_sink_set_input_port_connected_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_input_port_connected_method method);
+
+extern bt_component_class_status
+bt_component_class_sink_set_graph_is_configured_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_graph_is_configured_method method);
+
+extern bt_component_class_status bt_component_class_sink_set_query_method(
+ bt_component_class_sink *comp_class,
+ bt_component_class_sink_query_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class, bt_component_class_source,
+ * __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class *
+bt_component_class_source_as_component_class_const(
+ const bt_component_class_source *comp_cls_source)
+{
+ return __BT_UPCAST_CONST(bt_component_class, comp_cls_source);
+}
+
+extern void bt_component_class_source_get_ref(
+ const bt_component_class_source *component_class_source);
+
+extern void bt_component_class_source_put_ref(
+ const bt_component_class_source *component_class_source);
+
+#define BT_COMPONENT_CLASS_SOURCE_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_class_source_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_CLASS_SOURCE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_class_source_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/* For bt_self_message_iterator_status */
+#include <babeltrace2/graph/self-message-iterator.h>
+
+/* For bt_query_status */
+#include <babeltrace2/graph/component-class.h>
+
+/* For bt_component_class_status */
+#include <babeltrace2/graph/component-class-const.h>
+
+/*
+ * 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_message_array_const, bt_bool, bt_self_message_iterator,
+ * __BT_UPCAST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef bt_self_component_status
+(*bt_component_class_source_init_method)(
+ bt_self_component_source *self_component,
+ const bt_value *params, void *init_method_data);
+
+typedef void (*bt_component_class_source_finalize_method)(
+ bt_self_component_source *self_component);
+
+typedef 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_message_iterator_finalize_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef 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 bt_self_message_iterator_status
+(*bt_component_class_source_message_iterator_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin);
+
+typedef bt_self_message_iterator_status
+(*bt_component_class_source_message_iterator_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_bool
+(*bt_component_class_source_message_iterator_can_seek_ns_from_origin_method)(
+ bt_self_message_iterator *message_iterator,
+ int64_t ns_from_origin);
+
+typedef bt_bool
+(*bt_component_class_source_message_iterator_can_seek_beginning_method)(
+ bt_self_message_iterator *message_iterator);
+
+typedef bt_query_status (*bt_component_class_source_query_method)(
+ bt_self_component_class_source *comp_class,
+ const bt_query_executor *query_executor,
+ const char *object, const bt_value *params,
+ const bt_value **result);
+
+typedef bt_self_component_status
+(*bt_component_class_source_accept_output_port_connection_method)(
+ bt_self_component_source *self_component,
+ bt_self_component_port_output *self_port,
+ const bt_port_input *other_port);
+
+typedef bt_self_component_status
+(*bt_component_class_source_output_port_connected_method)(
+ bt_self_component_source *self_component,
+ bt_self_component_port_output *self_port,
+ const bt_port_input *other_port);
+
+static inline
+bt_component_class *bt_component_class_source_as_component_class(
+ bt_component_class_source *comp_cls_source)
+{
+ return __BT_UPCAST(bt_component_class, comp_cls_source);
+}
+
+extern
+bt_component_class_source *bt_component_class_source_create(
+ const char *name,
+ bt_component_class_source_message_iterator_next_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_init_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_init_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_finalize_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_finalize_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_accept_output_port_connection_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_accept_output_port_connection_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_output_port_connected_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_output_port_connected_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_query_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_query_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_message_iterator_init_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_init_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_message_iterator_finalize_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_finalize_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_seek_ns_from_origin_method method);
+
+extern bt_component_class_status
+bt_component_class_source_set_message_iterator_seek_beginning_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_seek_beginning_method method);
+
+extern bt_bool
+bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method);
+
+extern bt_bool
+bt_component_class_source_set_message_iterator_can_seek_beginning_method(
+ bt_component_class_source *comp_class,
+ bt_component_class_source_message_iterator_can_seek_beginning_method method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_H
+#define BABELTRACE_GRAPH_COMPONENT_CLASS_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_QUERY_EXECUTOR_STATUS_* */
+#include <babeltrace2/graph/query-executor-const.h>
+
+/* For bt_component_class */
+#include <babeltrace2/types.h>
+
+/* For bt_component_class_status */
+#include <babeltrace2/graph/component-class-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_query_status {
+ BT_QUERY_STATUS_OK = BT_QUERY_EXECUTOR_STATUS_OK,
+ BT_QUERY_STATUS_AGAIN = BT_QUERY_EXECUTOR_STATUS_AGAIN,
+ BT_QUERY_STATUS_ERROR = BT_QUERY_EXECUTOR_STATUS_ERROR,
+ BT_QUERY_STATUS_NOMEM = BT_QUERY_EXECUTOR_STATUS_NOMEM,
+ BT_QUERY_STATUS_INVALID_OBJECT = BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT,
+ BT_QUERY_STATUS_INVALID_PARAMS = BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS,
+} bt_query_status;
+
+extern bt_component_class_status bt_component_class_set_description(
+ bt_component_class *component_class,
+ const char *description);
+
+extern bt_component_class_status bt_component_class_set_help(
+ bt_component_class *component_class,
+ const char *help);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class_type */
+#include <babeltrace2/graph/component-class-const.h>
+
+/*
+ * For bt_bool, bt_component_class, bt_component_graph, bt_component,
+ * bt_value, bt_port
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Get component's name.
+ *
+ * @param component Component instance of which to get the name
+ * @returns Returns a pointer to the component's name
+ */
+extern const char *bt_component_get_name(const bt_component *component);
+
+/**
+ * Get component's class.
+ *
+ * @param component Component instance of which to get the class
+ * @returns The component's class
+ */
+extern const bt_component_class *bt_component_borrow_class_const(
+ const bt_component *component);
+
+extern bt_component_class_type bt_component_get_class_type(
+ const bt_component *component);
+
+static inline
+bt_bool bt_component_is_source(const bt_component *component)
+{
+ return bt_component_get_class_type(component) ==
+ BT_COMPONENT_CLASS_TYPE_SOURCE;
+}
+
+static inline
+bt_bool bt_component_is_filter(const bt_component *component)
+{
+ return bt_component_get_class_type(component) ==
+ BT_COMPONENT_CLASS_TYPE_FILTER;
+}
+
+static inline
+bt_bool bt_component_is_sink(const bt_component *component)
+{
+ return bt_component_get_class_type(component) ==
+ BT_COMPONENT_CLASS_TYPE_SINK;
+}
+
+extern bt_bool bt_component_graph_is_canceled(
+ const bt_component *component);
+
+extern void bt_component_get_ref(const bt_component *component);
+
+extern void bt_component_put_ref(const bt_component *component);
+
+#define BT_COMPONENT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/*
+ * For bt_component, bt_component_filter, bt_port_input, bt_port_output,
+ * __BT_UPCAST_CONST, bt_component_class_filter
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component *bt_component_filter_as_component_const(
+ const bt_component_filter *component)
+{
+ return __BT_UPCAST_CONST(bt_component, component);
+}
+
+extern const bt_component_class_filter *
+bt_component_filter_borrow_class_const(
+ const bt_component_filter *component);
+
+extern uint64_t bt_component_filter_get_input_port_count(
+ const bt_component_filter *component);
+
+extern const bt_port_input *
+bt_component_filter_borrow_input_port_by_name_const(
+ const bt_component_filter *component, const char *name);
+
+extern const bt_port_input *
+bt_component_filter_borrow_input_port_by_index_const(
+ const bt_component_filter *component, uint64_t index);
+
+extern uint64_t bt_component_filter_get_output_port_count(
+ const bt_component_filter *component);
+
+extern const bt_port_output *
+bt_component_filter_borrow_output_port_by_name_const(
+ const bt_component_filter *component, const char *name);
+
+extern const bt_port_output *
+bt_component_filter_borrow_output_port_by_index_const(
+ const bt_component_filter *component, uint64_t index);
+
+extern void bt_component_filter_get_ref(
+ const bt_component_filter *component_filter);
+
+extern void bt_component_filter_put_ref(
+ const bt_component_filter *component_filter);
+
+#define BT_COMPONENT_FILTER_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_filter_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_FILTER_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_filter_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H
+#define BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/graph/component-filter-const.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+
+struct bt_component_filter {
+ struct bt_component parent;
+};
+
+BT_HIDDEN
+struct bt_component *bt_component_filter_create(
+ const struct bt_component_class *class);
+
+BT_HIDDEN
+void bt_component_filter_destroy(struct bt_component *component);
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_FILTER_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
+#define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/graph/component-const.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <glib.h>
+#include <stdio.h>
+
+typedef void (*bt_component_destroy_listener_func)(
+ struct bt_component *class, void *data);
+
+struct bt_component_destroy_listener {
+ bt_component_destroy_listener_func func;
+ void *data;
+};
+
+struct bt_graph;
+
+struct bt_component {
+ struct bt_object base;
+ struct bt_component_class *class;
+ GString *name;
+
+ /*
+ * Internal destroy function specific to a source, filter, or
+ * sink component object.
+ */
+ void (*destroy)(struct bt_component *);
+
+ /* User-defined data */
+ void *user_data;
+
+ /* Input and output ports (weak references) */
+ GPtrArray *input_ports;
+ GPtrArray *output_ports;
+
+ /* Array of struct bt_component_destroy_listener */
+ GArray *destroy_listeners;
+
+ bool initialized;
+};
+
+static inline
+struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
+{
+ BT_ASSERT(comp);
+ return (void *) bt_object_borrow_parent(&comp->base);
+}
+
+BT_HIDDEN
+int bt_component_create(struct bt_component_class *component_class,
+ const char *name, struct bt_component **component);
+
+BT_HIDDEN
+enum bt_self_component_status bt_component_accept_port_connection(
+ struct bt_component *component, struct bt_port *self_port,
+ struct bt_port *other_port);
+
+BT_HIDDEN
+enum bt_self_component_status bt_component_port_connected(
+ struct bt_component *comp,
+ struct bt_port *self_port, struct bt_port *other_port);
+
+BT_HIDDEN
+void bt_component_set_graph(struct bt_component *component,
+ struct bt_graph *graph);
+
+BT_HIDDEN
+uint64_t bt_component_get_input_port_count(const struct bt_component *comp);
+
+BT_HIDDEN
+uint64_t bt_component_get_output_port_count(const struct bt_component *comp);
+
+BT_HIDDEN
+struct bt_port_input *bt_component_borrow_input_port_by_index(
+ struct bt_component *comp, uint64_t index);
+
+BT_HIDDEN
+struct bt_port_output *bt_component_borrow_output_port_by_index(
+ struct bt_component *comp, uint64_t index);
+
+BT_HIDDEN
+struct bt_port_input *bt_component_borrow_input_port_by_name(
+ struct bt_component *comp, const char *name);
+
+BT_HIDDEN
+struct bt_port_output *bt_component_borrow_output_port_by_name(
+ struct bt_component *comp, const char *name);
+
+BT_HIDDEN
+enum bt_self_component_status bt_component_add_input_port(
+ struct bt_component *component, const char *name,
+ void *user_data, struct bt_port **port);
+
+BT_HIDDEN
+enum bt_self_component_status bt_component_add_output_port(
+ struct bt_component *component, const char *name,
+ void *user_data, struct bt_port **port);
+
+BT_HIDDEN
+void bt_component_remove_port(struct bt_component *component,
+ struct bt_port *port);
+
+BT_HIDDEN
+void bt_component_add_destroy_listener(struct bt_component *component,
+ bt_component_destroy_listener_func func, void *data);
+
+BT_HIDDEN
+void bt_component_remove_destroy_listener(struct bt_component *component,
+ bt_component_destroy_listener_func func, void *data);
+
+static inline
+const char *bt_self_component_status_string(
+ enum bt_self_component_status status)
+{
+ switch (status) {
+ case BT_SELF_COMPONENT_STATUS_OK:
+ return "BT_SELF_COMPONENT_STATUS_OK";
+ case BT_SELF_COMPONENT_STATUS_END:
+ return "BT_SELF_COMPONENT_STATUS_END";
+ case BT_SELF_COMPONENT_STATUS_AGAIN:
+ return "BT_SELF_COMPONENT_STATUS_AGAIN";
+ case BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION:
+ return "BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION";
+ case BT_SELF_COMPONENT_STATUS_ERROR:
+ return "BT_SELF_COMPONENT_STATUS_ERROR";
+ case BT_SELF_COMPONENT_STATUS_NOMEM:
+ return "BT_SELF_COMPONENT_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/*
+ * For bt_component, bt_component_filter, bt_port_input,
+ * __BT_UPCAST_CONST, bt_component_class_sink
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component *bt_component_sink_as_component_const(
+ const bt_component_sink *component)
+{
+ return __BT_UPCAST_CONST(bt_component, component);
+}
+
+extern const bt_component_class_sink *
+bt_component_sink_borrow_class_const(
+ const bt_component_sink *component);
+
+extern uint64_t bt_component_sink_get_input_port_count(
+ const bt_component_sink *component);
+
+extern const bt_port_input *
+bt_component_sink_borrow_input_port_by_name_const(
+ const bt_component_sink *component, const char *name);
+
+extern const bt_port_input *
+bt_component_sink_borrow_input_port_by_index_const(
+ const bt_component_sink *component, uint64_t index);
+
+extern void bt_component_sink_get_ref(
+ const bt_component_sink *component_sink);
+
+extern void bt_component_sink_put_ref(
+ const bt_component_sink *component_sink);
+
+#define BT_COMPONENT_SINK_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_sink_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_SINK_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_sink_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H
+#define BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/graph/component-sink-const.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+
+struct bt_component_sink {
+ struct bt_component parent;
+ bool graph_is_configured_method_called;
+};
+
+BT_HIDDEN
+struct bt_component *bt_component_sink_create(
+ const struct bt_component_class *class);
+
+BT_HIDDEN
+void bt_component_sink_destroy(struct bt_component *component);
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_SINK_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H
+#define BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/*
+ * For bt_component, bt_component_filter, bt_port_output,
+ * __BT_UPCAST_CONST, bt_component_class_source
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component *bt_component_source_as_component_const(
+ const bt_component_source *component)
+{
+ return __BT_UPCAST_CONST(bt_component, component);
+}
+
+extern const bt_component_class_source *
+bt_component_source_borrow_class_const(
+ const bt_component_source *component);
+
+extern uint64_t bt_component_source_get_output_port_count(
+ const bt_component_source *component);
+
+extern const bt_port_output *
+bt_component_source_borrow_output_port_by_name_const(
+ const bt_component_source *component, const char *name);
+
+extern const bt_port_output *
+bt_component_source_borrow_output_port_by_index_const(
+ const bt_component_source *component, uint64_t index);
+
+extern void bt_component_source_get_ref(
+ const bt_component_source *component_source);
+
+extern void bt_component_source_put_ref(
+ const bt_component_source *component_source);
+
+#define BT_COMPONENT_SOURCE_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_component_source_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_COMPONENT_SOURCE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_component_source_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H
+#define BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+
+struct bt_component_source {
+ struct bt_component parent;
+};
+
+BT_HIDDEN
+struct bt_component *bt_component_source_create(
+ const struct bt_component_class *class);
+
+BT_HIDDEN
+void bt_component_source_destroy(struct bt_component *component);
+
+#endif /* BABELTRACE_GRAPH_COMPONENT_SOURCE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_CONNECTION_CONST_H
+#define BABELTRACE_GRAPH_CONNECTION_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_bool, bt_port_input, bt_port_output, bt_connection */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_port_input *bt_connection_borrow_downstream_port_const(
+ const bt_connection *connection);
+
+extern const bt_port_output *bt_connection_borrow_upstream_port_const(
+ const bt_connection *connection);
+
+extern void bt_connection_get_ref(const bt_connection *connection);
+
+extern void bt_connection_put_ref(const bt_connection *connection);
+
+#define BT_CONNECTION_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_connection_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_CONNECTION_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_connection_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_CONNECTION_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
+#define BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/graph/connection-const.h>
+#include <babeltrace2/graph/message-iterator-const.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdbool.h>
+
+struct bt_graph;
+
+struct bt_connection {
+ /*
+ * The graph is a connection's parent and the connection is the parent
+ * of all iterators it has created.
+ */
+ struct bt_object base;
+ /*
+ * Weak references are held to both ports. Their existence is guaranteed
+ * by the existence of the graph and thus, of their respective
+ * components.
+ */
+ /* Downstream port. */
+ struct bt_port *downstream_port;
+ /* Upstream port. */
+ struct bt_port *upstream_port;
+
+ /*
+ * Weak references to all the message iterators that were
+ * created on this connection.
+ */
+ GPtrArray *iterators;
+
+ bool notified_upstream_port_connected;
+ bool notified_downstream_port_connected;
+ bool notified_graph_ports_connected;
+};
+
+BT_HIDDEN
+struct bt_connection *bt_connection_create(struct bt_graph *graph,
+ struct bt_port *upstream_port,
+ struct bt_port *downstream_port);
+
+BT_HIDDEN
+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_message_iterator *iterator);
+
+static inline
+struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn)
+{
+ BT_ASSERT(conn);
+ return (void *) conn->base.parent;
+}
+
+#endif /* BABELTRACE_GRAPH_CONNECTION_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_GRAPH_CONST_H
+#define BABELTRACE_GRAPH_GRAPH_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_bool, bt_graph */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_graph_status {
+ BT_GRAPH_STATUS_OK = 0,
+ BT_GRAPH_STATUS_END = 1,
+ BT_GRAPH_STATUS_AGAIN = 11,
+ BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION = 111,
+ BT_GRAPH_STATUS_CANCELED = 125,
+ BT_GRAPH_STATUS_ERROR = -1,
+ BT_GRAPH_STATUS_NOMEM = -12,
+} bt_graph_status;
+
+extern bt_bool bt_graph_is_canceled(const bt_graph *graph);
+
+extern void bt_graph_get_ref(const bt_graph *graph);
+
+extern void bt_graph_put_ref(const bt_graph *graph);
+
+#define BT_GRAPH_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_graph_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_GRAPH_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_graph_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_GRAPH_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_GRAPH_INTERNAL_H
+#define BABELTRACE_GRAPH_GRAPH_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/graph/graph.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdlib.h>
+#include <glib.h>
+
+struct bt_component;
+struct bt_port;
+
+enum bt_graph_configuration_state {
+ BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
+ BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED,
+ BT_GRAPH_CONFIGURATION_STATE_CONFIGURED,
+ BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+};
+
+struct bt_graph {
+ /**
+ * A component graph contains components and point-to-point connection
+ * between these components.
+ *
+ * In terms of ownership:
+ * 1) The graph is the components' parent,
+ * 2) The graph is the connnections' parent,
+ * 3) Components share the ownership of their connections,
+ * 4) A connection holds weak references to its two component endpoints.
+ */
+ struct bt_object base;
+
+ /* Array of pointers to bt_connection. */
+ GPtrArray *connections;
+ /* Array of pointers to bt_component. */
+ GPtrArray *components;
+ /* Queue of pointers (weak references) to sink bt_components. */
+ GQueue *sinks_to_consume;
+
+ bool canceled;
+ bool in_remove_listener;
+ bool has_sink;
+
+ /*
+ * If this is false, then the public API's consuming
+ * functions (bt_graph_consume() and bt_graph_run()) return
+ * BT_GRAPH_STATUS_CANNOT_CONSUME. The internal "no check"
+ * functions always work.
+ *
+ * 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.
+ */
+ bool can_consume;
+
+ enum bt_graph_configuration_state config_state;
+
+ struct {
+ GArray *source_output_port_added;
+ GArray *filter_output_port_added;
+ GArray *filter_input_port_added;
+ GArray *sink_input_port_added;
+ GArray *source_filter_ports_connected;
+ GArray *source_sink_ports_connected;
+ GArray *filter_filter_ports_connected;
+ GArray *filter_sink_ports_connected;
+ } listeners;
+
+ /* Pool of `struct bt_message_event *` */
+ struct bt_object_pool event_msg_pool;
+
+ /* Pool of `struct bt_message_packet_beginning *` */
+ struct bt_object_pool packet_begin_msg_pool;
+
+ /* Pool of `struct bt_message_packet_end *` */
+ struct bt_object_pool packet_end_msg_pool;
+
+ /*
+ * Array of `struct bt_message *` (weak).
+ *
+ * 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 message has a
+ * weak pointer to the graph containing its pool, we need to
+ * 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 message to remove itself from this
+ * array (on destruction).
+ */
+ GPtrArray *messages;
+};
+
+static inline
+void _bt_graph_set_can_consume(struct bt_graph *graph, bool can_consume)
+{
+ BT_ASSERT(graph);
+ graph->can_consume = can_consume;
+}
+
+#ifdef BT_DEV_MODE
+# define bt_graph_set_can_consume _bt_graph_set_can_consume
+#else
+# define bt_graph_set_can_consume(_graph, _can_consume)
+#endif
+
+BT_HIDDEN
+enum bt_graph_status bt_graph_consume_sink_no_check(struct bt_graph *graph,
+ struct bt_component_sink *sink);
+
+BT_HIDDEN
+enum bt_graph_listener_status bt_graph_notify_port_added(struct bt_graph *graph,
+ struct bt_port *port);
+
+BT_HIDDEN
+enum bt_graph_listener_status bt_graph_notify_ports_connected(
+ struct bt_graph *graph, struct bt_port *upstream_port,
+ struct bt_port *downstream_port);
+
+BT_HIDDEN
+void bt_graph_remove_connection(struct bt_graph *graph,
+ struct bt_connection *connection);
+
+/*
+ * This only works with a component which is not connected at this
+ * point.
+ *
+ * Also the reference count of `component` should be 0 when you call
+ * this function, which means only `graph` owns the component, so it
+ * is safe to destroy.
+ */
+BT_HIDDEN
+int bt_graph_remove_unconnected_component(struct bt_graph *graph,
+ struct bt_component *component);
+
+BT_HIDDEN
+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)
+{
+ switch (status) {
+ case BT_GRAPH_STATUS_CANCELED:
+ return "BT_GRAPH_STATUS_CANCELED";
+ case BT_GRAPH_STATUS_AGAIN:
+ return "BT_GRAPH_STATUS_AGAIN";
+ case BT_GRAPH_STATUS_END:
+ return "BT_GRAPH_STATUS_END";
+ case BT_GRAPH_STATUS_OK:
+ return "BT_GRAPH_STATUS_OK";
+ case BT_GRAPH_STATUS_ERROR:
+ return "BT_GRAPH_STATUS_ERROR";
+ case BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION:
+ return "BT_GRAPH_STATUS_COMPONENT_REFUSES_PORT_CONNECTION";
+ case BT_GRAPH_STATUS_NOMEM:
+ return "BT_GRAPH_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_graph_configuration_state_string(
+ enum bt_graph_configuration_state state)
+{
+ switch (state) {
+ case BT_GRAPH_CONFIGURATION_STATE_CONFIGURING:
+ return "BT_GRAPH_CONFIGURATION_STATE_CONFIGURING";
+ case BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED:
+ return "BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED";
+ case BT_GRAPH_CONFIGURATION_STATE_CONFIGURED:
+ return "BT_GRAPH_CONFIGURATION_STATE_CONFIGURED";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+enum bt_graph_status bt_graph_configure(struct bt_graph *graph)
+{
+ enum bt_graph_status status = BT_GRAPH_STATUS_OK;
+ uint64_t i;
+
+ BT_ASSERT(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY);
+
+ if (likely(graph->config_state ==
+ BT_GRAPH_CONFIGURATION_STATE_CONFIGURED)) {
+ goto end;
+ }
+
+#ifdef BT_ASSERT_PRE
+ BT_ASSERT_PRE(graph->has_sink, "Graph has no sink component: %!+g", graph);
+#endif
+
+ graph->config_state = BT_GRAPH_CONFIGURATION_STATE_PARTIALLY_CONFIGURED;
+
+ for (i = 0; i < graph->components->len; i++) {
+ struct bt_component *comp = graph->components->pdata[i];
+ struct bt_component_sink *comp_sink = (void *) comp;
+ struct bt_component_class_sink *comp_cls_sink =
+ (void *) comp->class;
+
+ if (comp->class->type != BT_COMPONENT_CLASS_TYPE_SINK) {
+ continue;
+ }
+
+ if (comp_sink->graph_is_configured_method_called) {
+ continue;
+ }
+
+ if (comp_cls_sink->methods.graph_is_configured) {
+ enum bt_self_component_status comp_status;
+
+#ifdef BT_LIB_LOGD
+ BT_LIB_LOGD("Calling user's \"graph is configured\" method: "
+ "%![graph-]+g, %![comp-]+c",
+ graph, comp);
+#endif
+
+ comp_status = comp_cls_sink->methods.graph_is_configured(
+ (void *) comp_sink);
+
+#ifdef BT_LIB_LOGD
+ BT_LIB_LOGD("User method returned: status=%s",
+ bt_self_component_status_string(comp_status));
+#endif
+
+#ifdef BT_ASSERT_PRE
+ BT_ASSERT_PRE(comp_status == BT_SELF_COMPONENT_STATUS_OK ||
+ comp_status == BT_SELF_COMPONENT_STATUS_ERROR ||
+ comp_status == BT_SELF_COMPONENT_STATUS_NOMEM,
+ "Unexpected returned status: status=%s",
+ bt_self_component_status_string(comp_status));
+#endif
+
+ if (comp_status != BT_SELF_COMPONENT_STATUS_OK) {
+ status = BT_GRAPH_STATUS_ERROR;
+#ifdef BT_LIB_LOGW
+ BT_LIB_LOGW("User's \"graph is configured\" method failed: "
+ "%![comp-]+c, status=%s",
+ comp,
+ bt_self_component_status_string(
+ comp_status));
+#endif
+
+ goto end;
+ }
+ }
+
+ comp_sink->graph_is_configured_method_called = true;
+ }
+
+ graph->config_state = BT_GRAPH_CONFIGURATION_STATE_CONFIGURED;
+
+end:
+ return status;
+}
+
+static inline
+void bt_graph_make_faulty(struct bt_graph *graph)
+{
+ graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
+#ifdef BT_LIB_LOGD
+ BT_LIB_LOGD("Set graph's state to faulty: %![graph-]+g", graph);
+#endif
+}
+
+#endif /* BABELTRACE_GRAPH_GRAPH_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_GRAPH_H
+#define BABELTRACE_GRAPH_GRAPH_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_bool, bt_component, bt_component_class,
+ * bt_component_class_filter, bt_component_class_sink,
+ * bt_component_class_source, bt_component_filter, bt_component_sink,
+ * bt_component_source, bt_connection, bt_graph, bt_port_input,
+ * bt_port_output, bt_value
+ */
+#include <babeltrace2/types.h>
+
+/* For bt_graph_status */
+#include <babeltrace2/graph/graph-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_graph_listener_status {
+ BT_GRAPH_LISTENER_STATUS_OK = 0,
+ BT_GRAPH_LISTENER_STATUS_ERROR = -1,
+ BT_GRAPH_LISTENER_STATUS_NOMEM = -12,
+} bt_graph_listener_status;
+
+typedef bt_graph_listener_status
+(*bt_graph_filter_component_input_port_added_listener_func)(
+ const bt_component_filter *component,
+ const bt_port_input *port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_sink_component_input_port_added_listener_func)(
+ const bt_component_sink *component,
+ const bt_port_input *port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_source_component_output_port_added_listener_func)(
+ const bt_component_source *component,
+ const bt_port_output *port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_filter_component_output_port_added_listener_func)(
+ const bt_component_filter *component,
+ const bt_port_output *port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_source_filter_component_ports_connected_listener_func)(
+ const bt_component_source *source_component,
+ const bt_component_filter *filter_component,
+ const bt_port_output *upstream_port,
+ const bt_port_input *downstream_port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_source_sink_component_ports_connected_listener_func)(
+ const bt_component_source *source_component,
+ const bt_component_sink *sink_component,
+ const bt_port_output *upstream_port,
+ const bt_port_input *downstream_port, void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_filter_filter_component_ports_connected_listener_func)(
+ const bt_component_filter *filter_component_upstream,
+ const bt_component_filter *filter_component_downstream,
+ const bt_port_output *upstream_port,
+ const bt_port_input *downstream_port,
+ void *data);
+
+typedef bt_graph_listener_status
+(*bt_graph_filter_sink_component_ports_connected_listener_func)(
+ const bt_component_filter *filter_component,
+ const bt_component_sink *sink_component,
+ const bt_port_output *upstream_port,
+ const bt_port_input *downstream_port, void *data);
+
+typedef void (* bt_graph_listener_removed_func)(void *data);
+
+extern bt_graph *bt_graph_create(void);
+
+extern bt_graph_status bt_graph_add_source_component(bt_graph *graph,
+ const bt_component_class_source *component_class,
+ const char *name, const bt_value *params,
+ const bt_component_source **component);
+
+extern bt_graph_status bt_graph_add_source_component_with_init_method_data(
+ bt_graph *graph,
+ const bt_component_class_source *component_class,
+ const char *name, const bt_value *params,
+ void *init_method_data,
+ const bt_component_source **component);
+
+extern bt_graph_status bt_graph_add_filter_component(bt_graph *graph,
+ const bt_component_class_filter *component_class,
+ const char *name, const bt_value *params,
+ const bt_component_filter **component);
+
+extern bt_graph_status bt_graph_add_filter_component_with_init_method_data(
+ bt_graph *graph,
+ const bt_component_class_filter *component_class,
+ const char *name, const bt_value *params,
+ void *init_method_data,
+ const bt_component_filter **component);
+
+extern bt_graph_status bt_graph_add_sink_component(
+ bt_graph *graph, const bt_component_class_sink *component_class,
+ const char *name, const bt_value *params,
+ const bt_component_sink **component);
+
+extern bt_graph_status bt_graph_add_sink_component_with_init_method_data(
+ bt_graph *graph, const bt_component_class_sink *component_class,
+ const char *name, const bt_value *params,
+ void *init_method_data,
+ const bt_component_sink **component);
+
+extern bt_graph_status bt_graph_connect_ports(bt_graph *graph,
+ const bt_port_output *upstream,
+ const bt_port_input *downstream,
+ const bt_connection **connection);
+
+extern bt_graph_status bt_graph_run(bt_graph *graph);
+
+extern bt_graph_status bt_graph_consume(bt_graph *graph);
+
+extern bt_graph_status bt_graph_add_filter_component_input_port_added_listener(
+ bt_graph *graph,
+ bt_graph_filter_component_input_port_added_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status bt_graph_add_sink_component_input_port_added_listener(
+ bt_graph *graph,
+ bt_graph_sink_component_input_port_added_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status bt_graph_add_source_component_output_port_added_listener(
+ bt_graph *graph,
+ bt_graph_source_component_output_port_added_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status bt_graph_add_filter_component_output_port_added_listener(
+ bt_graph *graph,
+ bt_graph_filter_component_output_port_added_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status
+bt_graph_add_source_filter_component_ports_connected_listener(
+ bt_graph *graph,
+ bt_graph_source_filter_component_ports_connected_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status
+bt_graph_add_filter_filter_component_ports_connected_listener(
+ bt_graph *graph,
+ bt_graph_filter_filter_component_ports_connected_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status
+bt_graph_add_source_sink_component_ports_connected_listener(
+ bt_graph *graph,
+ bt_graph_source_sink_component_ports_connected_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status
+bt_graph_add_filter_sink_component_ports_connected_listener(
+ bt_graph *graph,
+ bt_graph_filter_sink_component_ports_connected_listener_func listener,
+ bt_graph_listener_removed_func listener_removed, void *data,
+ int *listener_id);
+
+extern bt_graph_status bt_graph_cancel(bt_graph *graph);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_GRAPH_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Message types. Unhandled message types should be ignored.
+ */
+typedef enum bt_message_type {
+ BT_MESSAGE_TYPE_EVENT = 0,
+ BT_MESSAGE_TYPE_MESSAGE_ITERATOR_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,
+ BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING = 6,
+ BT_MESSAGE_TYPE_STREAM_ACTIVITY_END = 7,
+ BT_MESSAGE_TYPE_DISCARDED_EVENTS = 8,
+ BT_MESSAGE_TYPE_DISCARDED_PACKETS = 9,
+} bt_message_type;
+
+/**
+ * Get a message's type.
+ *
+ * @param message Message instance
+ * @returns One of #bt_message_type
+ */
+extern bt_message_type bt_message_get_type(const bt_message *message);
+
+extern void bt_message_get_ref(const bt_message *message);
+
+extern void bt_message_put_ref(const bt_message *message);
+
+#define BT_MESSAGE_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_message_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_MESSAGE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_message_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_clock_snapshot *
+bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_snapshot *
+bt_message_discarded_events_borrow_end_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_class *
+bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+extern const bt_stream *
+bt_message_discarded_events_borrow_stream_const(const bt_message *message);
+
+extern bt_property_availability bt_message_discarded_events_get_count(
+ const bt_message *message, uint64_t *count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message *bt_message_discarded_events_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream, uint64_t beginning_raw_value,
+ uint64_t end_raw_value);
+
+extern bt_stream *bt_message_discarded_events_borrow_stream(
+ bt_message *message);
+
+extern void bt_message_discarded_events_set_count(bt_message *message,
+ uint64_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_EVENTS_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <glib.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/property-internal.h>
+#include <babeltrace2/graph/message-const.h>
+
+struct bt_message_discarded_items {
+ struct bt_message parent;
+ struct bt_stream *stream;
+ struct bt_clock_snapshot *default_begin_cs;
+ struct bt_clock_snapshot *default_end_cs;
+ struct bt_property_uint count;
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_ITEMS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_clock_snapshot *
+bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_snapshot *
+bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_class *
+bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+extern const bt_stream *
+bt_message_discarded_packets_borrow_stream_const(const bt_message *message);
+
+extern bt_property_availability bt_message_discarded_packets_get_count(
+ const bt_message *message, uint64_t *count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H
+#define BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message *bt_message_discarded_packets_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern bt_message *bt_message_discarded_packets_create_with_default_clock_snapshots(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream, uint64_t beginning_raw_value,
+ uint64_t end_raw_value);
+
+extern bt_stream *bt_message_discarded_packets_borrow_stream(
+ bt_message *message);
+
+extern void bt_message_discarded_packets_set_count(bt_message *message,
+ uint64_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_DISCARDED_PACKETS_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_bool, bt_message, bt_event. bt_clock_class, bt_clock_snapshot */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_event *bt_message_event_borrow_event_const(
+ const bt_message *message);
+
+extern const bt_clock_snapshot *
+bt_message_event_borrow_default_clock_snapshot_const(const bt_message *msg);
+
+extern const bt_clock_class *
+bt_message_event_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/assert-internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_message_event {
+ struct bt_message parent;
+ struct bt_event *event;
+ struct bt_clock_snapshot *default_cs;
+};
+
+BT_HIDDEN
+struct bt_message *bt_message_event_new(struct bt_graph *graph);
+
+BT_HIDDEN
+void bt_message_event_recycle(struct bt_message *msg);
+
+BT_HIDDEN
+void bt_message_event_destroy(struct bt_message *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_EVENT_H
+#define BABELTRACE_GRAPH_MESSAGE_EVENT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/*
+ * For bt_self_message_iterator, bt_event, bt_packet,
+ * bt_event_class, bt_message
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_event_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_event_class *event_class,
+ const bt_packet *packet);
+
+extern
+bt_message *bt_message_event_create_with_default_clock_snapshot(
+ bt_self_message_iterator *message_iterator,
+ const bt_event_class *event_class,
+ const bt_packet *packet, uint64_t raw_clock_value);
+
+extern bt_event *bt_message_event_borrow_event(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_EVENT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/graph/graph.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/types.h>
+
+typedef struct bt_stream *(*get_stream_func)(
+ struct bt_message *message);
+
+struct bt_message {
+ struct bt_object base;
+ enum bt_message_type type;
+ 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;
+#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_MESSAGE_ITERATOR_INACTIVITY:
+ return "BT_MESSAGE_TYPE_MESSAGE_ITERATOR_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";
+ case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
+ return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING";
+ case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
+ return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_END";
+ case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+ return "BT_MESSAGE_TYPE_DISCARDED_EVENTS";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef 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_ERROR = -1,
+ BT_MESSAGE_ITERATOR_STATUS_NOMEM = -12,
+} bt_message_iterator_status;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/graph/connection-const.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message-iterator-const.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdbool.h>
+
+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 currently being finalized */
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING,
+
+ /* Iterator is finalized */
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED,
+
+ /* Iterator is seeking */
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING,
+
+ /* Iterator did seek, but returned `BT_MESSAGE_ITERATOR_STATUS_AGAIN` */
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN,
+
+ /* Iterator did seek, but returned error status */
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR,
+};
+
+struct bt_message_iterator {
+ struct bt_object base;
+ enum bt_message_iterator_type type;
+ GPtrArray *msgs;
+};
+
+typedef enum bt_self_message_iterator_status
+(*bt_self_component_port_input_message_iterator_next_method)(
+ void *, bt_message_array_const, uint64_t, uint64_t *);
+
+typedef enum bt_self_message_iterator_status
+(*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)(
+ void *, int64_t);
+
+typedef enum bt_self_message_iterator_status
+(*bt_self_component_port_input_message_iterator_seek_beginning_method)(
+ void *);
+
+typedef bt_bool
+(*bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)(
+ void *, int64_t);
+
+typedef bt_bool
+(*bt_self_component_port_input_message_iterator_can_seek_beginning_method)(
+ void *);
+
+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 */
+
+ struct {
+ bt_self_component_port_input_message_iterator_next_method next;
+ bt_self_component_port_input_message_iterator_seek_ns_from_origin_method seek_ns_from_origin;
+ bt_self_component_port_input_message_iterator_seek_beginning_method seek_beginning;
+ bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin;
+ bt_self_component_port_input_message_iterator_can_seek_beginning_method can_seek_beginning;
+ } methods;
+
+ enum bt_self_component_port_input_message_iterator_state state;
+ GQueue *auto_seek_msgs;
+ 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_try_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_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_FINALIZING:
+ return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING";
+ 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_SEEKING:
+ return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_SEEKING";
+ case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN:
+ return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN";
+ case BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR:
+ return "BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR";
+ default:
+ return "(unknown)";
+ }
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_clock_snapshot */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_clock_snapshot *
+bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
+ const bt_message *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <glib.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/graph/message-const.h>
+
+struct bt_message_message_iterator_inactivity {
+ struct bt_message parent;
+ struct bt_clock_snapshot *default_cs;
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H
+#define BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_message_iterator, bt_message, bt_clock_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_message_iterator_inactivity_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_clock_class *default_clock_class, uint64_t raw_value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_packet, bt_clock_snapshot, bt_clock_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_packet *bt_message_packet_beginning_borrow_packet_const(
+ const bt_message *message);
+
+extern const bt_clock_snapshot *
+bt_message_packet_beginning_borrow_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_class *
+bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H
+#define BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_packet */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_packet_beginning_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_packet *packet);
+
+extern
+bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot(
+ bt_self_message_iterator *message_iterator,
+ const bt_packet *packet, uint64_t raw_value);
+
+extern bt_packet *bt_message_packet_beginning_borrow_packet(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_BEGINNING_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_packet, bt_clock_snapshot, bt_clock_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_packet *bt_message_packet_end_borrow_packet_const(
+ const bt_message *message);
+
+extern const bt_clock_snapshot *
+bt_message_packet_end_borrow_default_clock_snapshot_const(
+ const bt_message *msg);
+
+extern const bt_clock_class *
+bt_message_packet_end_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_END_H
+#define BABELTRACE_GRAPH_MESSAGE_PACKET_END_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_packet */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_packet_end_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_packet *packet);
+
+extern
+bt_message *bt_message_packet_end_create_with_default_clock_snapshot(
+ bt_self_message_iterator *message_iterator,
+ const bt_packet *packet, uint64_t raw_value);
+
+extern bt_packet *bt_message_packet_end_borrow_packet(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_END_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/assert-internal.h>
+
+struct bt_message_packet {
+ struct bt_message parent;
+ struct bt_packet *packet;
+ struct bt_clock_snapshot *default_cs;
+};
+
+BT_HIDDEN
+void bt_message_packet_destroy(struct bt_message *msg);
+
+BT_HIDDEN
+struct bt_message *bt_message_packet_beginning_new(
+ struct bt_graph *graph);
+BT_HIDDEN
+void bt_message_packet_beginning_recycle(struct bt_message *msg);
+
+BT_HIDDEN
+struct bt_message *bt_message_packet_end_new(struct bt_graph *graph);
+
+BT_HIDDEN
+void bt_message_packet_end_recycle(struct bt_message *msg);
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_PACKET_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream, bt_clock_class */
+#include <babeltrace2/types.h>
+
+/* For bt_message_stream_activity_clock_snapshot_state */
+#include <babeltrace2/graph/message-stream-activity-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message_stream_activity_clock_snapshot_state
+bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const(
+ const bt_message *msg, const bt_clock_snapshot **snapshot);
+
+extern const bt_clock_class *
+bt_message_stream_activity_beginning_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+extern const bt_stream *
+bt_message_stream_activity_beginning_borrow_stream_const(
+ const bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_stream */
+#include <babeltrace2/types.h>
+
+/* For bt_message_stream_activity_clock_snapshot_state */
+#include <babeltrace2/graph/message-stream-activity-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message *bt_message_stream_activity_beginning_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern bt_stream *bt_message_stream_activity_beginning_borrow_stream(
+ bt_message *message);
+
+extern void bt_message_stream_activity_beginning_set_default_clock_snapshot_state(
+ bt_message *msg,
+ bt_message_stream_activity_clock_snapshot_state state);
+
+extern void bt_message_stream_activity_beginning_set_default_clock_snapshot(
+ bt_message *msg, uint64_t raw_value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_BEGINNING_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_message_stream_activity_clock_snapshot_state {
+ BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN,
+ BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN,
+ BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE,
+} bt_message_stream_activity_clock_snapshot_state;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream, bt_clock_class */
+#include <babeltrace2/types.h>
+
+/* For bt_message_stream_activity_clock_snapshot_state */
+#include <babeltrace2/graph/message-stream-activity-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message_stream_activity_clock_snapshot_state
+bt_message_stream_activity_end_borrow_default_clock_snapshot_const(
+ const bt_message *msg, const bt_clock_snapshot **snapshot);
+
+extern const bt_clock_class *
+bt_message_stream_activity_end_borrow_stream_class_default_clock_class_const(
+ const bt_message *msg);
+
+extern const bt_stream *
+bt_message_stream_activity_end_borrow_stream_const(
+ const bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message, bt_self_message_iterator, bt_stream */
+#include <babeltrace2/types.h>
+
+/* For bt_message_stream_activity_clock_snapshot_state */
+#include <babeltrace2/graph/message-stream-activity-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_message *bt_message_stream_activity_end_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern void bt_message_stream_activity_end_set_default_clock_snapshot_state(
+ bt_message *msg,
+ bt_message_stream_activity_clock_snapshot_state state);
+
+extern void bt_message_stream_activity_end_set_default_clock_snapshot(
+ bt_message *msg, uint64_t raw_value);
+
+extern bt_stream *bt_message_stream_activity_end_borrow_stream(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_END_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H
+
+/*
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <glib.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message-stream-activity-const.h>
+
+struct bt_message_stream_activity {
+ struct bt_message parent;
+ struct bt_stream *stream;
+ struct bt_clock_snapshot *default_cs;
+ enum bt_message_stream_activity_clock_snapshot_state default_cs_state;
+};
+
+static inline
+const char *bt_message_stream_activity_clock_snapshot_state_string(
+ enum bt_message_stream_activity_clock_snapshot_state state)
+{
+ switch (state) {
+ case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN:
+ return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN";
+ case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN:
+ return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_UNKNOWN";
+ case BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE:
+ return "BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_INFINITE";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_ACTIVITY_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_stream *bt_message_stream_beginning_borrow_stream_const(
+ const bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_stream_beginning_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern bt_stream *bt_message_stream_beginning_borrow_stream(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_clock_snapshot, bt_stream */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_stream *bt_message_stream_end_borrow_stream_const(
+ const bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_BEGINNING_END_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_END_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_END_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_message *bt_message_stream_end_create(
+ bt_self_message_iterator *message_iterator,
+ const bt_stream *stream);
+
+extern bt_stream *bt_message_stream_end_borrow_stream(
+ bt_message *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_END_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/assert-internal.h>
+
+struct bt_message_stream {
+ struct bt_message parent;
+ struct bt_stream *stream;
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_STREAM_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_CONST_H
+#define BABELTRACE_GRAPH_PORT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_bool, bt_port, bt_connection, bt_component */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_port_type {
+ BT_PORT_TYPE_INPUT = 0,
+ BT_PORT_TYPE_OUTPUT = 1,
+} bt_port_type;
+
+extern const char *bt_port_get_name(const bt_port *port);
+
+extern bt_port_type bt_port_get_type(const bt_port *port);
+
+extern const bt_connection *bt_port_borrow_connection_const(
+ const bt_port *port);
+
+extern const bt_component *bt_port_borrow_component_const(
+ const bt_port *port);
+
+extern bt_bool bt_port_is_connected(const bt_port *port);
+
+static inline
+bt_bool bt_port_is_input(const bt_port *port)
+{
+ return bt_port_get_type(port) == BT_PORT_TYPE_INPUT;
+}
+
+static inline
+bt_bool bt_port_is_output(const bt_port *port)
+{
+ return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT;
+}
+
+extern void bt_port_get_ref(const bt_port *port);
+
+extern void bt_port_put_ref(const bt_port *port);
+
+#define BT_PORT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_port_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PORT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_port_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_INPUT_CONST_H
+#define BABELTRACE_GRAPH_PORT_INPUT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_port, bt_port_input, __BT_UPCAST_CONST */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_port *bt_port_input_as_port_const(const bt_port_input *port_input)
+{
+ return __BT_UPCAST_CONST(bt_port, port_input);
+}
+
+extern void bt_port_input_get_ref(const bt_port_input *port_input);
+
+extern void bt_port_input_put_ref(const bt_port_input *port_input);
+
+#define BT_PORT_INPUT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_port_input_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PORT_INPUT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_port_input_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_INPUT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_INTERNAL_H
+#define BABELTRACE_GRAPH_PORT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/graph/port-const.h>
+
+struct bt_port {
+ struct bt_object base;
+ enum bt_port_type type;
+ GString *name;
+ struct bt_connection *connection;
+ void *user_data;
+};
+
+struct bt_component;
+
+BT_HIDDEN
+struct bt_port *bt_port_create(struct bt_component *parent_component,
+ enum bt_port_type type, const char *name, void *user_data);
+
+BT_HIDDEN
+void bt_port_set_connection(struct bt_port *port,
+ struct bt_connection *connection);
+
+static inline
+struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port)
+{
+ BT_ASSERT(port);
+ return (void *) bt_object_borrow_parent(&port->base);
+}
+
+static inline
+const char *bt_port_type_string(enum bt_port_type port_type)
+{
+ switch (port_type) {
+ case BT_PORT_TYPE_INPUT:
+ return "BT_PORT_TYPE_INPUT";
+ case BT_PORT_TYPE_OUTPUT:
+ return "BT_PORT_TYPE_OUTPUT";
+ default:
+ return "(unknown)";
+ }
+}
+
+#endif /* BABELTRACE_GRAPH_PORT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H
+#define BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_port, bt_port_output, __BT_UPCAST_CONST */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_port *bt_port_output_as_port_const(const bt_port_output *port_output)
+{
+ return __BT_UPCAST_CONST(bt_port, port_output);
+}
+
+extern void bt_port_output_get_ref(const bt_port_output *port_output);
+
+extern void bt_port_output_put_ref(const bt_port_output *port_output);
+
+#define BT_PORT_OUTPUT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_port_output_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PORT_OUTPUT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_port_output_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H
+#define BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message_iterator_status */
+#include <babeltrace2/graph/message-iterator-const.h>
+
+/*
+ * For bt_port, bt_message, bt_message_iterator,
+ * bt_port_output_message_iterator, bt_graph, bt_port_output,
+ * bt_message_array_const, bt_bool, __BT_UPCAST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_message_iterator *
+bt_port_output_message_iterator_as_message_iterator(
+ bt_port_output_message_iterator *iterator)
+{
+ return __BT_UPCAST(bt_message_iterator, iterator);
+}
+
+extern bt_port_output_message_iterator *
+bt_port_output_message_iterator_create(
+ bt_graph *graph,
+ const bt_port_output *output_port);
+
+extern 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 bt_bool bt_port_output_message_iterator_can_seek_ns_from_origin(
+ bt_port_output_message_iterator *iterator,
+ int64_t ns_from_origin);
+
+extern bt_bool bt_port_output_message_iterator_can_seek_beginning(
+ bt_port_output_message_iterator *iterator);
+
+extern bt_message_iterator_status
+bt_port_output_message_iterator_seek_ns_from_origin(
+ bt_port_output_message_iterator *iterator,
+ int64_t ns_from_origin);
+
+extern bt_message_iterator_status
+bt_port_output_message_iterator_seek_beginning(
+ bt_port_output_message_iterator *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_message_iterator_put_ref(
+ const bt_port_output_message_iterator *port_output_message_iterator);
+
+#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_port_output_message_iterator_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PORT_OUTPUT_MESSAGE_ITERATOR_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_port_output_message_iterator_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_PORT_OUTPUT_MESSAGE_ITERATOR_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H
+#define BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_bool, bt_query_executor */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_query_executor_status {
+ BT_QUERY_EXECUTOR_STATUS_OK = 0,
+ BT_QUERY_EXECUTOR_STATUS_AGAIN = 11,
+ BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED = 95,
+ BT_QUERY_EXECUTOR_STATUS_CANCELED = 125,
+ BT_QUERY_EXECUTOR_STATUS_ERROR = -1,
+ BT_QUERY_EXECUTOR_STATUS_NOMEM = -12,
+ BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT = -23,
+ BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS = -24,
+} bt_query_executor_status;
+
+extern
+bt_bool bt_query_executor_is_canceled(
+ const bt_query_executor *query_executor);
+
+extern void bt_query_executor_get_ref(
+ const bt_query_executor *query_executor);
+
+extern void bt_query_executor_put_ref(
+ const bt_query_executor *query_executor);
+
+#define BT_QUERY_EXECUTOR_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_query_executor_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_QUERY_EXECUTOR_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_query_executor_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H
+#define BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/types.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/graph/query-executor.h>
+#include <babeltrace2/graph/component-class.h>
+
+struct bt_query_executor {
+ struct bt_object base;
+ bool canceled;
+};
+
+static inline const char *bt_query_status_string(enum bt_query_status status)
+{
+ switch (status) {
+ case BT_QUERY_STATUS_OK:
+ return "BT_QUERY_STATUS_OK";
+ case BT_QUERY_STATUS_AGAIN:
+ return "BT_QUERY_STATUS_AGAIN";
+ case BT_QUERY_STATUS_ERROR:
+ return "BT_QUERY_STATUS_ERROR";
+ case BT_QUERY_STATUS_INVALID_OBJECT:
+ return "BT_QUERY_STATUS_INVALID_OBJECT";
+ case BT_QUERY_STATUS_INVALID_PARAMS:
+ return "BT_QUERY_STATUS_INVALID_PARAMS";
+ case BT_QUERY_STATUS_NOMEM:
+ return "BT_QUERY_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+};
+
+static inline const char *bt_query_executor_status_string(
+ enum bt_query_executor_status status)
+{
+ switch (status) {
+ case BT_QUERY_EXECUTOR_STATUS_OK:
+ return "BT_QUERY_EXECUTOR_STATUS_OK";
+ case BT_QUERY_EXECUTOR_STATUS_AGAIN:
+ return "BT_QUERY_EXECUTOR_STATUS_AGAIN";
+ case BT_QUERY_EXECUTOR_STATUS_CANCELED:
+ return "BT_QUERY_EXECUTOR_STATUS_CANCELED";
+ case BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED:
+ return "BT_QUERY_EXECUTOR_STATUS_UNSUPPORTED";
+ case BT_QUERY_EXECUTOR_STATUS_ERROR:
+ return "BT_QUERY_EXECUTOR_STATUS_ERROR";
+ case BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT:
+ return "BT_QUERY_EXECUTOR_STATUS_INVALID_OBJECT";
+ case BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS:
+ return "BT_QUERY_EXECUTOR_STATUS_INVALID_PARAMS";
+ case BT_QUERY_EXECUTOR_STATUS_NOMEM:
+ return "BT_QUERY_EXECUTOR_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+};
+
+#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_QUERY_EXECUTOR_H
+#define BABELTRACE_GRAPH_QUERY_EXECUTOR_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_query_executor_status */
+#include <babeltrace2/graph/query-executor.h>
+
+/* For bt_query_executor, bt_component_class, bt_value */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_query_executor *bt_query_executor_create(void);
+
+extern
+bt_query_executor_status bt_query_executor_query(
+ bt_query_executor *query_executor,
+ const bt_component_class *component_class,
+ const char *object, const bt_value *params,
+ const bt_value **result);
+
+extern
+bt_query_executor_status bt_query_executor_cancel(
+ bt_query_executor *query_executor);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_QUERY_EXECUTOR_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class_filter, bt_self_component_class_filter,
+ * __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class_filter *
+bt_self_component_class_filter_as_component_class_filter(
+ bt_self_component_class_filter *self_comp_cls_filter)
+{
+ return __BT_UPCAST_CONST(bt_component_class_filter,
+ self_comp_cls_filter);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_FILTER_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class_sink, bt_self_component_class_sink,
+ * __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class_sink *
+bt_self_component_class_sink_as_component_class_sink(
+ bt_self_component_class_sink *self_comp_cls_sink)
+{
+ return __BT_UPCAST_CONST(bt_component_class_sink, self_comp_cls_sink);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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_component_class_source, bt_self_component_class_source,
+ * __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+const bt_component_class_source *
+bt_self_component_class_source_as_component_class_source(
+ bt_self_component_class_source *self_comp_cls_source)
+{
+ return __BT_UPCAST_CONST(bt_component_class_source,
+ self_comp_cls_source);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_CLASS_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/*
+ * For bt_component_filter, bt_self_component, bt_self_component_filter,
+ * bt_self_component_port_input, bt_self_component_port_output,
+ * __BT_UPCAST, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_self_component *bt_self_component_filter_as_self_component(
+ bt_self_component_filter *self_comp_filter)
+{
+ return __BT_UPCAST(bt_self_component, self_comp_filter);
+}
+
+static inline
+const bt_component_filter *
+bt_self_component_filter_as_component_filter(
+ bt_self_component_filter *self_comp_filter)
+{
+ return __BT_UPCAST_CONST(bt_component_filter, self_comp_filter);
+}
+
+extern bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_name(
+ bt_self_component_filter *self_component,
+ const char *name);
+
+extern bt_self_component_port_output *
+bt_self_component_filter_borrow_output_port_by_index(
+ bt_self_component_filter *self_component,
+ uint64_t index);
+
+extern bt_self_component_status
+bt_self_component_filter_add_output_port(
+ bt_self_component_filter *self_component,
+ const char *name, void *data,
+ bt_self_component_port_output **self_component_port);
+
+extern bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_name(
+ bt_self_component_filter *self_component,
+ const char *name);
+
+extern bt_self_component_port_input *
+bt_self_component_filter_borrow_input_port_by_index(
+ bt_self_component_filter *self_component,
+ uint64_t index);
+
+extern bt_self_component_status
+bt_self_component_filter_add_input_port(
+ bt_self_component_filter *self_component,
+ const char *name, void *data,
+ bt_self_component_port_input **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_FILTER_H */
--- /dev/null
+#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 <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_message_iterator_status */
+#include <babeltrace2/graph/message-iterator-const.h>
+
+/*
+ * For bt_component, bt_message_iterator,
+ * bt_self_component_port_input_message_iterator,
+ * bt_self_component_port_input, bt_message_array_const, bt_bool,
+ * __BT_UPCAST
+ */
+#include <babeltrace2/types.h>
+
+#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 __BT_UPCAST(bt_message_iterator, 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 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 bt_bool
+bt_self_component_port_input_message_iterator_can_seek_ns_from_origin(
+ bt_self_component_port_input_message_iterator *iterator,
+ int64_t ns_from_origin);
+
+extern bt_bool bt_self_component_port_input_message_iterator_can_seek_beginning(
+ bt_self_component_port_input_message_iterator *iterator);
+
+extern bt_message_iterator_status
+bt_self_component_port_input_message_iterator_seek_ns_from_origin(
+ bt_self_component_port_input_message_iterator *iterator,
+ int64_t ns_from_origin);
+
+extern bt_message_iterator_status
+bt_self_component_port_input_message_iterator_seek_beginning(
+ bt_self_component_port_input_message_iterator *iterator);
+
+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 */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_port_input, bt_self_component_port,
+ * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_self_component_port *
+bt_self_component_port_input_as_self_component_port(
+ bt_self_component_port_input *self_component_port)
+{
+ return __BT_UPCAST(bt_self_component_port, self_component_port);
+}
+
+static inline
+const bt_port_input *bt_self_component_port_input_as_port_input(
+ const bt_self_component_port_input *self_component_port)
+{
+ return __BT_UPCAST_CONST(bt_port_input, self_component_port);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_INPUT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_port_output, bt_self_component_port,
+ * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_self_component_port *
+bt_self_component_port_output_as_self_component_port(
+ bt_self_component_port_output *self_component_port)
+{
+ return __BT_UPCAST(bt_self_component_port, self_component_port);
+}
+
+static inline
+const bt_port_output *bt_self_component_port_output_as_port_output(
+ bt_self_component_port_output *self_component_port)
+{
+ return __BT_UPCAST_CONST(bt_port_output, self_component_port);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_OUTPUT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_port, bt_self_component_port, bt_self_component,
+ * bt_connection, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_self_component_port_status {
+ BT_SELF_PORT_STATUS_OK = 0,
+} bt_self_component_port_status;
+
+static inline
+const bt_port *bt_self_component_port_as_port(
+ bt_self_component_port *self_port)
+{
+ return __BT_UPCAST_CONST(bt_port, self_port);
+}
+
+extern bt_self_component *bt_self_component_port_borrow_component(
+ bt_self_component_port *self_port);
+
+extern void *bt_self_component_port_get_data(
+ const bt_self_component_port *self_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_PORT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/*
+ * For bt_component_sink, bt_self_component, bt_self_component_sink,
+ * bt_self_component_port_input, __BT_UPCAST, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_self_component *bt_self_component_sink_as_self_component(
+ bt_self_component_sink *self_comp_sink)
+{
+ return __BT_UPCAST(bt_self_component, self_comp_sink);
+}
+
+static inline
+const bt_component_sink *
+bt_self_component_sink_as_component_sink(
+ bt_self_component_sink *self_comp_sink)
+{
+ return __BT_UPCAST_CONST(bt_component_sink, self_comp_sink);
+}
+
+extern bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_name(
+ bt_self_component_sink *self_component,
+ const char *name);
+
+extern bt_self_component_port_input *
+bt_self_component_sink_borrow_input_port_by_index(
+ bt_self_component_sink *self_component, uint64_t index);
+
+extern bt_self_component_status
+bt_self_component_sink_add_input_port(
+ bt_self_component_sink *self_component,
+ const char *name, void *user_data,
+ bt_self_component_port_input **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SINK_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_self_component_status */
+#include <babeltrace2/graph/self-component.h>
+
+/*
+ * For bt_component_source, bt_self_component, bt_self_component_source,
+ * bt_self_component_port_output, __BT_UPCAST, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline
+bt_self_component *bt_self_component_source_as_self_component(
+ bt_self_component_source *self_comp_source)
+{
+ return __BT_UPCAST(bt_self_component, self_comp_source);
+}
+
+static inline
+const bt_component_source *
+bt_self_component_source_as_component_source(
+ bt_self_component_source *self_comp_source)
+{
+ return __BT_UPCAST_CONST(bt_component_source, self_comp_source);
+}
+
+extern bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_name(
+ bt_self_component_source *self_component,
+ const char *name);
+
+extern bt_self_component_port_output *
+bt_self_component_source_borrow_output_port_by_index(
+ bt_self_component_source *self_component,
+ uint64_t index);
+
+extern bt_self_component_status
+bt_self_component_source_add_output_port(
+ bt_self_component_source *self_component,
+ const char *name, void *user_data,
+ bt_self_component_port_output **self_component_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_SOURCE_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_COMPONENT_H
+#define BABELTRACE_GRAPH_SELF_COMPONENT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_component, bt_self_component, __BT_UPCAST */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_self_component_status {
+ BT_SELF_COMPONENT_STATUS_OK = 0,
+ BT_SELF_COMPONENT_STATUS_END = 1,
+ BT_SELF_COMPONENT_STATUS_AGAIN = 11,
+ BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
+ BT_SELF_COMPONENT_STATUS_ERROR = -1,
+ BT_SELF_COMPONENT_STATUS_NOMEM = -12,
+} bt_self_component_status;
+
+static inline
+const bt_component *bt_self_component_as_component(
+ bt_self_component *self_component)
+{
+ return __BT_UPCAST(bt_component, self_component);
+}
+
+extern void *bt_self_component_get_data(
+ const bt_self_component *self_component);
+
+extern void bt_self_component_set_data(
+ bt_self_component *self_component, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_COMPONENT_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H
+#define BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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_ITERATOR_STATUS_* */
+#include <babeltrace2/graph/message-iterator-const.h>
+
+/* For bt_self_component, bt_self_message_iterator, bt_self_port_output */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef 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,
+} bt_self_message_iterator_status;
+
+extern bt_self_component *
+bt_self_message_iterator_borrow_component(
+ bt_self_message_iterator *message_iterator);
+
+extern bt_self_port_output *
+bt_self_message_iterator_borrow_port(
+ bt_self_message_iterator *message_iterator);
+
+extern void bt_self_message_iterator_set_data(
+ bt_self_message_iterator *message_iterator,
+ void *user_data);
+
+extern void *bt_self_message_iterator_get_data(
+ const bt_self_message_iterator *message_iterator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_GRAPH_SELF_MESSAGE_ITERATOR_H */
--- /dev/null
+#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
+#define BABELTRACE_LIB_LOGGING_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <stdarg.h>
+
+#ifndef BT_LOG_TAG
+# error Please define a tag with BT_LOG_TAG before including this file.
+#endif
+
+#define BT_LOG_OUTPUT_LEVEL bt_lib_log_level
+
+#include <babeltrace2/logging-internal.h>
+
+extern
+int bt_lib_log_level;
+
+#define BT_LIB_LOG(_lvl, _fmt, ...) \
+ do { \
+ if (BT_LOG_ON(_lvl)) { \
+ bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \
+ __LINE__, _lvl, _BT_LOG_TAG, \
+ (_fmt), ##__VA_ARGS__); \
+ } \
+ } while (0)
+
+/*
+ * The six macros below are logging statements which are specialized
+ * for the Babeltrace library.
+ *
+ * `_fmt` is a typical printf()-style format string, with the following
+ * limitations:
+ *
+ * * The `*` width specifier is not accepted.
+ * * The `*` precision specifier is not accepted.
+ * * The `j` and `t` length modifiers are not accepted.
+ * * The `n` format specifier is not accepted.
+ * * The format specifiers defined in <inttypes.h> are not accepted
+ * except for `PRId64`, `PRIu64`, `PRIx64`, `PRIX64`, `PRIo64`, and
+ * `PRIi64`.
+ *
+ * The Babeltrace extension conversion specifier is accepted. Its syntax
+ * is either `%!u` to format a UUID (`bt_uuid` type) or:
+ *
+ * 1. Introductory `%!` sequence.
+ *
+ * 2. Optional: `[` followed by a custom prefix for the printed fields
+ * of this specifier, followed by `]`. The standard form is to end
+ * this prefix with `-` so that, for example, with the prefix
+ * `prefix-`, the complete field name is `prefix-addr`.
+ *
+ * 3. Optional: `+` to print extended fields. This depends on the
+ * provided format specifier.
+ *
+ * 4. Format specifier (see below).
+ *
+ * The available format specifiers are:
+ *
+ * `F`:
+ * Trace IR field class. The parameter type is
+ * `struct bt_field_class *`.
+ *
+ * `f`:
+ * Trace IR field. The parameter type is `struct bt_field *`.
+ *
+ * `P`:
+ * Field path. The parameter type is `struct bt_field_path *`.
+ *
+ * `E`:
+ * Trace IR event class. The parameter type is
+ * `struct bt_event_class *`.
+ *
+ * `e`:
+ * Trace IR event. The parameter type is `struct bt_event *`.
+ *
+ * `S`:
+ * Trace IR stream class. The parameter type is
+ * `struct bt_stream_class *`.
+ *
+ * `s`:
+ * Trace IR stream. The parameter type is `struct bt_stream *`.
+ *
+ * `a`:
+ * Packet. The parameter type is `struct bt_packet *`.
+ *
+ * `T`:
+ * Trace IR trace class. The parameter type is `struct bt_trace_class *`.
+ *
+ * `t`:
+ * Trace IR trace. The parameter type is `struct bt_trace *`.
+ *
+ * `K`:
+ * Clock class. The parameter type is `struct bt_clock_class *`.
+ *
+ * `k`:
+ * Clock snapshot. The parameter type is `struct bt_clock_snapshot *`.
+ *
+ * `v`:
+ * Value. The parameter type is `struct bt_value *`.
+ *
+ * `n`:
+ * Message. The parameter type is `struct bt_message *`.
+ *
+ * `i`:
+ * Message iterator. The parameter type is
+ * `struct bt_message_iterator *`.
+ *
+ * `C`:
+ * Component class. The parameter type is
+ * `struct bt_component_class *`.
+ *
+ * `c`:
+ * Component. The parameter type is `struct bt_component *`.
+ *
+ * `p`:
+ * Port. The parameter type is `struct bt_port *`.
+ *
+ * `x`:
+ * Connection. The parameter type is `struct bt_connection *`.
+ *
+ * `g`:
+ * Graph. The parameter type is `struct bt_graph *`.
+ *
+ * `l`:
+ * Plugin. The parameter type is `const struct bt_plugin *`.
+ *
+ * `o`:
+ * Object pool. The parameter type is `struct bt_object_pool *`.
+ *
+ * `O`:
+ * Object. The parameter type is `struct bt_object *`.
+ *
+ * Conversion specifier examples:
+ *
+ * %!f
+ * %![my-event-]+e
+ * %!t
+ * %!+F
+ *
+ * The string `, ` is printed between individual fields, but not after
+ * the last one. Therefore you must put this separator in the format
+ * string between two conversion specifiers, e.g.:
+ *
+ * BT_LIB_LOGW("Message: count=%u, %!E, %!+K", count, event_class,
+ * clock_class);
+ *
+ * Example with a custom prefix:
+ *
+ * BT_LIB_LOGI("Some message: %![ec-a-]e, %![ec-b-]+e", ec_a, ec_b);
+ *
+ * It is safe to pass NULL as any Babeltrace object parameter: the
+ * macros only print its null address.
+ */
+#define BT_LIB_LOGF(_fmt, ...) BT_LIB_LOG(BT_LOG_FATAL, _fmt, ##__VA_ARGS__)
+#define BT_LIB_LOGE(_fmt, ...) BT_LIB_LOG(BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
+#define BT_LIB_LOGW(_fmt, ...) BT_LIB_LOG(BT_LOG_WARN, _fmt, ##__VA_ARGS__)
+#define BT_LIB_LOGI(_fmt, ...) BT_LIB_LOG(BT_LOG_INFO, _fmt, ##__VA_ARGS__)
+#define BT_LIB_LOGD(_fmt, ...) BT_LIB_LOG(BT_LOG_DEBUG, _fmt, ##__VA_ARGS__)
+#define BT_LIB_LOGV(_fmt, ...) BT_LIB_LOG(BT_LOG_VERBOSE, _fmt, ##__VA_ARGS__)
+
+/*
+ * Log statement, specialized for the Babeltrace library.
+ *
+ * Use one of the BT_LIB_LOGF*() macros above instead of calling this
+ * function directly.
+ */
+
+void bt_lib_log(const char *func, const char *file, unsigned line,
+ int lvl, const char *tag, const char *fmt, ...);
+
+#endif /* BABELTRACE_LIB_LOGGING_INTERNAL_H */
--- /dev/null
+/*
+ * Copyright (C) 2002 Free Software Foundation, Inc.
+ * This file is part of the GNU C Library.
+ * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _BT_LIST_H
+#define _BT_LIST_H 1
+
+/* The definitions of this file are adopted from those which can be
+ found in the Linux kernel headers to enable people familiar with
+ the latter find their way in these sources as well. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Basic type for the double-link list. */
+struct bt_list_head
+{
+ struct bt_list_head *next;
+ struct bt_list_head *prev;
+};
+
+
+/* Define a variable with the head and tail of the list. */
+#define BT_LIST_HEAD(name) \
+ struct bt_list_head name = { &(name), &(name) }
+
+/* Initialize a new list head. */
+#define BT_INIT_LIST_HEAD(ptr) \
+ (ptr)->next = (ptr)->prev = (ptr)
+
+#define BT_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
+
+/* Add new element at the head of the list. */
+static inline void
+bt_list_add (struct bt_list_head *newp, struct bt_list_head *head)
+{
+ head->next->prev = newp;
+ newp->next = head->next;
+ newp->prev = head;
+ head->next = newp;
+}
+
+
+/* Add new element at the tail of the list. */
+static inline void
+bt_list_add_tail (struct bt_list_head *newp, struct bt_list_head *head)
+{
+ head->prev->next = newp;
+ newp->next = head;
+ newp->prev = head->prev;
+ head->prev = newp;
+}
+
+
+/* Remove element from list. */
+static inline void
+__bt_list_del (struct bt_list_head *prev, struct bt_list_head *next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/* Remove element from list. */
+static inline void
+bt_list_del (struct bt_list_head *elem)
+{
+ __bt_list_del (elem->prev, elem->next);
+}
+
+/* delete from list, add to another list as head */
+static inline void
+bt_list_move (struct bt_list_head *elem, struct bt_list_head *head)
+{
+ __bt_list_del (elem->prev, elem->next);
+ bt_list_add (elem, head);
+}
+
+/* replace an old entry.
+ */
+static inline void
+bt_list_replace(struct bt_list_head *old, struct bt_list_head *_new)
+{
+ _new->next = old->next;
+ _new->prev = old->prev;
+ _new->prev->next = _new;
+ _new->next->prev = _new;
+}
+
+/* Join two lists. */
+static inline void
+bt_list_splice (struct bt_list_head *add, struct bt_list_head *head)
+{
+ /* Do nothing if the list which gets added is empty. */
+ if (add != add->next)
+ {
+ add->next->prev = head;
+ add->prev->next = head->next;
+ head->next->prev = add->prev;
+ head->next = add->next;
+ }
+}
+
+
+/* Get typed element from list at a given position. */
+#define bt_list_entry(ptr, type, member) \
+ ((type *) ((char *) (ptr) - (uintptr_t) (&((type *) 0)->member)))
+
+
+
+/* Iterate forward over the elements of the list. */
+#define bt_list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+
+/* Iterate forward over the elements of the list. */
+#define bt_list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); pos = pos->prev)
+
+
+/* Iterate backwards over the elements list. The list elements can be
+ removed from the list while doing this. */
+#define bt_list_for_each_prev_safe(pos, p, head) \
+ for (pos = (head)->prev, p = pos->prev; \
+ pos != (head); \
+ pos = p, p = pos->prev)
+
+#define bt_list_for_each_entry(pos, head, member) \
+ for (pos = bt_list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = bt_list_entry(pos->member.next, typeof(*pos), member))
+
+#define bt_list_for_each_entry_reverse(pos, head, member) \
+ for (pos = bt_list_entry((head)->prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = bt_list_entry(pos->member.prev, typeof(*pos), member))
+
+#define bt_list_for_each_entry_safe(pos, p, head, member) \
+ for (pos = bt_list_entry((head)->next, typeof(*pos), member), \
+ p = bt_list_entry(pos->member.next,typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = p, p = bt_list_entry(pos->member.next, typeof(*pos), member))
+
+static inline int bt_list_empty(struct bt_list_head *head)
+{
+ return head == head->next;
+}
+
+static inline void bt_list_replace_init(struct bt_list_head *old,
+ struct bt_list_head *_new)
+{
+ struct bt_list_head *head = old->next;
+ bt_list_del(old);
+ bt_list_add_tail(_new, head);
+ BT_INIT_LIST_HEAD(old);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BT_LIST_H */
--- /dev/null
+/*
+ * This is zf_log.h, modified with Babeltrace prefixes.
+ * See <https://github.com/wonder-mice/zf_log/>.
+ * See logging/LICENSE in the Babeltrace source tree.
+ */
+
+#pragma once
+
+#ifndef BABELTRACE_LOGGING_INTERNAL_H
+#define BABELTRACE_LOGGING_INTERNAL_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <babeltrace2/logging.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+/* To detect incompatible changes you can define BT_LOG_VERSION_REQUIRED to be
+ * the current value of BT_LOG_VERSION before including this file (or via
+ * compiler command line):
+ *
+ * #define BT_LOG_VERSION_REQUIRED 4
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * Compilation will fail when included file has different version.
+ */
+#define BT_LOG_VERSION 4
+#if defined(BT_LOG_VERSION_REQUIRED)
+ #if BT_LOG_VERSION_REQUIRED != BT_LOG_VERSION
+ #error different bt_log version required
+ #endif
+#endif
+
+/* Log level guideline:
+ * - BT_LOG_FATAL - happened something impossible and absolutely unexpected.
+ * Process can't continue and must be terminated.
+ * Example: division by zero, unexpected modifications from other thread.
+ * - BT_LOG_ERROR - happened something possible, but highly unexpected. The
+ * process is able to recover and continue execution.
+ * Example: out of memory (could also be FATAL if not handled properly).
+ * - BT_LOG_WARN - happened something that *usually* should not happen and
+ * significantly changes application behavior for some period of time.
+ * Example: configuration file not found, auth error.
+ * - BT_LOG_INFO - happened significant life cycle event or major state
+ * transition.
+ * Example: app started, user logged in.
+ * - BT_LOG_DEBUG - minimal set of events that could help to reconstruct the
+ * execution path. Usually disabled in release builds.
+ * - BT_LOG_VERBOSE - all other events. Usually disabled in release builds.
+ *
+ * *Ideally*, log file of debugged, well tested, production ready application
+ * should be empty or very small. Choosing a right log level is as important as
+ * providing short and self descriptive log message.
+ */
+#define BT_LOG_VERBOSE BT_LOGGING_LEVEL_VERBOSE
+#define BT_LOG_DEBUG BT_LOGGING_LEVEL_DEBUG
+#define BT_LOG_INFO BT_LOGGING_LEVEL_INFO
+#define BT_LOG_WARN BT_LOGGING_LEVEL_WARN
+#define BT_LOG_ERROR BT_LOGGING_LEVEL_ERROR
+#define BT_LOG_FATAL BT_LOGGING_LEVEL_FATAL
+#define BT_LOG_NONE BT_LOGGING_LEVEL_NONE
+
+/* "Current" log level is a compile time check and has no runtime overhead. Log
+ * level that is below current log level it said to be "disabled". Otherwise,
+ * it's "enabled". Log messages that are disabled has no runtime overhead - they
+ * are converted to no-op by preprocessor and then eliminated by compiler.
+ * Current log level is configured per compilation module (.c/.cpp/.m file) by
+ * defining BT_LOG_DEF_LEVEL or BT_LOG_LEVEL. BT_LOG_LEVEL has higer priority
+ * and when defined overrides value provided by BT_LOG_DEF_LEVEL.
+ *
+ * Common practice is to define default current log level with BT_LOG_DEF_LEVEL
+ * in build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
+ * project or target:
+ *
+ * CC_ARGS := -DBT_LOG_DEF_LEVEL=BT_LOG_INFO
+ *
+ * And when necessary to override it with BT_LOG_LEVEL in .c/.cpp/.m files
+ * before including bt_log.h:
+ *
+ * #define BT_LOG_LEVEL BT_LOG_VERBOSE
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * If both BT_LOG_DEF_LEVEL and BT_LOG_LEVEL are undefined, then BT_LOG_INFO
+ * will be used for release builds (NDEBUG is defined) and BT_LOG_DEBUG
+ * otherwise (NDEBUG is not defined).
+ */
+#if defined(BT_LOG_LEVEL)
+ #define _BT_LOG_LEVEL BT_LOG_LEVEL
+#elif defined(BT_LOG_DEF_LEVEL)
+ #define _BT_LOG_LEVEL BT_LOG_DEF_LEVEL
+#else
+ #ifdef NDEBUG
+ #define _BT_LOG_LEVEL BT_LOG_INFO
+ #else
+ #define _BT_LOG_LEVEL BT_LOG_DEBUG
+ #endif
+#endif
+
+/* "Output" log level is a runtime check. When log level is below output log
+ * level it said to be "turned off" (or just "off" for short). Otherwise it's
+ * "turned on" (or just "on"). Log levels that were "disabled" (see
+ * BT_LOG_LEVEL and BT_LOG_DEF_LEVEL) can't be "turned on", but "enabled" log
+ * levels could be "turned off". Only messages with log level which is
+ * "turned on" will reach output facility. All other messages will be ignored
+ * (and their arguments will not be evaluated). Output log level is a global
+ * property and configured per process using bt_log_set_output_level() function
+ * which can be called at any time.
+ *
+ * Though in some cases it could be useful to configure output log level per
+ * compilation module or per library. There are two ways to achieve that:
+ * - Define BT_LOG_OUTPUT_LEVEL to expresion that evaluates to desired output
+ * log level.
+ * - Copy bt_log.h and bt_log.c files into your library and build it with
+ * BT_LOG_LIBRARY_PREFIX defined to library specific prefix. See
+ * BT_LOG_LIBRARY_PREFIX for more details.
+ *
+ * When defined, BT_LOG_OUTPUT_LEVEL must evaluate to integral value that
+ * corresponds to desired output log level. Use it only when compilation module
+ * is required to have output log level which is different from global output
+ * log level set by bt_log_set_output_level() function. For other cases,
+ * consider defining BT_LOG_LEVEL or using bt_log_set_output_level() function.
+ *
+ * Example:
+ *
+ * #define BT_LOG_OUTPUT_LEVEL g_module_log_level
+ * #include <babeltrace2/logging-internal.h>
+ * static int g_module_log_level = BT_LOG_INFO;
+ * static void foo() {
+ * BT_LOGI("Will check g_module_log_level for output log level");
+ * }
+ * void debug_log(bool on) {
+ * g_module_log_level = on? BT_LOG_DEBUG: BT_LOG_INFO;
+ * }
+ *
+ * Note on performance. This expression will be evaluated each time message is
+ * logged (except when message log level is "disabled" - see BT_LOG_LEVEL for
+ * details). Keep this expression as simple as possible, otherwise it will not
+ * only add runtime overhead, but also will increase size of call site (which
+ * will result in larger executable). The prefered way is to use integer
+ * variable (as in example above). If structure must be used, log_level field
+ * must be the first field in this structure:
+ *
+ * #define BT_LOG_OUTPUT_LEVEL (g_config.log_level)
+ * #include <babeltrace2/logging-internal.h>
+ * struct config {
+ * int log_level;
+ * unsigned other_field;
+ * [...]
+ * };
+ * static config g_config = {BT_LOG_INFO, 0, ...};
+ *
+ * This allows compiler to generate more compact load instruction (no need to
+ * specify offset since it's zero). Calling a function to get output log level
+ * is generaly a bad idea, since it will increase call site size and runtime
+ * overhead even further.
+ */
+#if defined(BT_LOG_OUTPUT_LEVEL)
+ #define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
+#else
+ /*
+ * We disallow this to make sure Babeltrace modules always
+ * have their own local log level.
+ */
+ #error No log level symbol specified: please define BT_LOG_OUTPUT_LEVEL before including this header.
+#endif
+
+/* "Tag" is a compound string that could be associated with a log message. It
+ * consists of tag prefix and tag (both are optional).
+ *
+ * Tag prefix is a global property and configured per process using
+ * bt_log_set_tag_prefix() function. Tag prefix identifies context in which
+ * component or module is running (e.g. process name). For example, the same
+ * library could be used in both client and server processes that work on the
+ * same machine. Tag prefix could be used to easily distinguish between them.
+ * For more details about tag prefix see bt_log_set_tag_prefix() function. Tag
+ * prefix
+ *
+ * Tag identifies component or module. It is configured per compilation module
+ * (.c/.cpp/.m file) by defining BT_LOG_TAG or BT_LOG_DEF_TAG. BT_LOG_TAG has
+ * higer priority and when defined overrides value provided by BT_LOG_DEF_TAG.
+ * When defined, value must evaluate to (const char *), so for strings double
+ * quotes must be used.
+ *
+ * Default tag could be defined with BT_LOG_DEF_TAG in build script (e.g.
+ * Makefile, CMakeLists.txt, gyp, etc.) for the entire project or target:
+ *
+ * CC_ARGS := -DBT_LOG_DEF_TAG=\"MISC\"
+ *
+ * And when necessary could be overriden with BT_LOG_TAG in .c/.cpp/.m files
+ * before including bt_log.h:
+ *
+ * #define BT_LOG_TAG "MAIN"
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * If both BT_LOG_DEF_TAG and BT_LOG_TAG are undefined no tag will be added to
+ * the log message (tag prefix still could be added though).
+ *
+ * Output example:
+ *
+ * 04-29 22:43:20.244 40059 1299 I hello.MAIN Number of arguments: 1
+ * | |
+ * | +- tag (e.g. module)
+ * +- tag prefix (e.g. process name)
+ */
+#if defined(BT_LOG_TAG)
+ #define _BT_LOG_TAG BT_LOG_TAG
+#elif defined(BT_LOG_DEF_TAG)
+ #define _BT_LOG_TAG BT_LOG_DEF_TAG
+#else
+ #define _BT_LOG_TAG 0
+#endif
+
+/* Source location is part of a log line that describes location (function or
+ * method name, file name and line number, e.g. "runloop@main.cpp:68") of a
+ * log statement that produced it.
+ * Source location formats are:
+ * - BT_LOG_SRCLOC_NONE - don't add source location to log line.
+ * - BT_LOG_SRCLOC_SHORT - add source location in short form (file and line
+ * number, e.g. "@main.cpp:68").
+ * - BT_LOG_SRCLOC_LONG - add source location in long form (function or method
+ * name, file and line number, e.g. "runloop@main.cpp:68").
+ */
+#define BT_LOG_SRCLOC_NONE 0
+#define BT_LOG_SRCLOC_SHORT 1
+#define BT_LOG_SRCLOC_LONG 2
+
+/* Source location format is configured per compilation module (.c/.cpp/.m
+ * file) by defining BT_LOG_DEF_SRCLOC or BT_LOG_SRCLOC. BT_LOG_SRCLOC has
+ * higer priority and when defined overrides value provided by
+ * BT_LOG_DEF_SRCLOC.
+ *
+ * Common practice is to define default format with BT_LOG_DEF_SRCLOC in
+ * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
+ * project or target:
+ *
+ * CC_ARGS := -DBT_LOG_DEF_SRCLOC=BT_LOG_SRCLOC_LONG
+ *
+ * And when necessary to override it with BT_LOG_SRCLOC in .c/.cpp/.m files
+ * before including bt_log.h:
+ *
+ * #define BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * If both BT_LOG_DEF_SRCLOC and BT_LOG_SRCLOC are undefined, then
+ * BT_LOG_SRCLOC_NONE will be used for release builds (NDEBUG is defined) and
+ * BT_LOG_SRCLOC_LONG otherwise (NDEBUG is not defined).
+ */
+#if defined(BT_LOG_SRCLOC)
+ #define _BT_LOG_SRCLOC BT_LOG_SRCLOC
+#elif defined(BT_LOG_DEF_SRCLOC)
+ #define _BT_LOG_SRCLOC BT_LOG_DEF_SRCLOC
+#else
+ #ifdef NDEBUG
+ #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_NONE
+ #else
+ #define _BT_LOG_SRCLOC BT_LOG_SRCLOC_LONG
+ #endif
+#endif
+#if BT_LOG_SRCLOC_LONG == _BT_LOG_SRCLOC
+ #define _BT_LOG_SRCLOC_FUNCTION _BT_LOG_FUNCTION
+#else
+ #define _BT_LOG_SRCLOC_FUNCTION 0
+#endif
+
+/* Censoring provides conditional logging of secret information, also known as
+ * Personally Identifiable Information (PII) or Sensitive Personal Information
+ * (SPI). Censoring can be either enabled (BT_LOG_CENSORED) or disabled
+ * (BT_LOG_UNCENSORED). When censoring is enabled, log statements marked as
+ * "secrets" will be ignored and will have zero overhead (arguments also will
+ * not be evaluated).
+ */
+#define BT_LOG_CENSORED 1
+#define BT_LOG_UNCENSORED 0
+
+/* Censoring is configured per compilation module (.c/.cpp/.m file) by defining
+ * BT_LOG_DEF_CENSORING or BT_LOG_CENSORING. BT_LOG_CENSORING has higer priority
+ * and when defined overrides value provided by BT_LOG_DEF_CENSORING.
+ *
+ * Common practice is to define default censoring with BT_LOG_DEF_CENSORING in
+ * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
+ * project or target:
+ *
+ * CC_ARGS := -DBT_LOG_DEF_CENSORING=BT_LOG_CENSORED
+ *
+ * And when necessary to override it with BT_LOG_CENSORING in .c/.cpp/.m files
+ * before including bt_log.h (consider doing it only for debug purposes and be
+ * very careful not to push such temporary changes to source control):
+ *
+ * #define BT_LOG_CENSORING BT_LOG_UNCENSORED
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * If both BT_LOG_DEF_CENSORING and BT_LOG_CENSORING are undefined, then
+ * BT_LOG_CENSORED will be used for release builds (NDEBUG is defined) and
+ * BT_LOG_UNCENSORED otherwise (NDEBUG is not defined).
+ */
+#if defined(BT_LOG_CENSORING)
+ #define _BT_LOG_CENSORING BT_LOG_CENSORING
+#elif defined(BT_LOG_DEF_CENSORING)
+ #define _BT_LOG_CENSORING BT_LOG_DEF_CENSORING
+#else
+ #ifdef NDEBUG
+ #define _BT_LOG_CENSORING BT_LOG_CENSORED
+ #else
+ #define _BT_LOG_CENSORING BT_LOG_UNCENSORED
+ #endif
+#endif
+
+/* Check censoring at compile time. Evaluates to true when censoring is disabled
+ * (i.e. when secrets will be logged). For example:
+ *
+ * #if BT_LOG_SECRETS
+ * char ssn[16];
+ * getSocialSecurityNumber(ssn);
+ * BT_LOGI("Customer ssn: %s", ssn);
+ * #endif
+ *
+ * See BT_LOG_SECRET() macro for a more convenient way of guarding single log
+ * statement.
+ */
+#define BT_LOG_SECRETS (BT_LOG_UNCENSORED == _BT_LOG_CENSORING)
+
+/* Static (compile-time) initialization support allows to configure logging
+ * before entering main() function. This mostly useful in C++ where functions
+ * and methods could be called during initialization of global objects. Those
+ * functions and methods could record log messages too and for that reason
+ * static initialization of logging configuration is customizable.
+ *
+ * Macros below allow to specify values to use for initial configuration:
+ * - BT_LOG_EXTERN_TAG_PREFIX - tag prefix (default: none)
+ * - BT_LOG_EXTERN_GLOBAL_FORMAT - global format options (default: see
+ * BT_LOG_MEM_WIDTH in bt_log.c)
+ * - BT_LOG_EXTERN_GLOBAL_OUTPUT - global output facility (default: stderr or
+ * platform specific, see BT_LOG_USE_XXX macros in bt_log.c)
+ * - BT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL - global output log level (default: 0 -
+ * all levals are "turned on")
+ *
+ * For example, in log_config.c:
+ *
+ * #include <babeltrace2/logging-internal.h>
+ * BT_LOG_DEFINE_TAG_PREFIX = "MyApp";
+ * BT_LOG_DEFINE_GLOBAL_FORMAT = {CUSTOM_MEM_WIDTH};
+ * BT_LOG_DEFINE_GLOBAL_OUTPUT = {BT_LOG_PUT_STD, custom_output_callback, 0};
+ * BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = BT_LOG_INFO;
+ *
+ * However, to use any of those macros bt_log library must be compiled with
+ * following macros defined:
+ * - to use BT_LOG_DEFINE_TAG_PREFIX define BT_LOG_EXTERN_TAG_PREFIX
+ * - to use BT_LOG_DEFINE_GLOBAL_FORMAT define BT_LOG_EXTERN_GLOBAL_FORMAT
+ * - to use BT_LOG_DEFINE_GLOBAL_OUTPUT define BT_LOG_EXTERN_GLOBAL_OUTPUT
+ * - to use BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL define
+ * BT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL
+ *
+ * When bt_log library compiled with one of BT_LOG_EXTERN_XXX macros defined,
+ * corresponding BT_LOG_DEFINE_XXX macro MUST be used exactly once somewhere.
+ * Otherwise build will fail with link error (undefined symbol).
+ */
+#define BT_LOG_DEFINE_TAG_PREFIX BT_HIDDEN const char *_bt_log_tag_prefix
+#define BT_LOG_DEFINE_GLOBAL_FORMAT BT_HIDDEN bt_log_format _bt_log_global_format
+#define BT_LOG_DEFINE_GLOBAL_OUTPUT BT_HIDDEN bt_log_output _bt_log_global_output
+#define BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL BT_HIDDEN int _bt_log_global_output_lvl
+
+/* Pointer to global format options. Direct modification is not allowed. Use
+ * bt_log_set_mem_width() instead. Could be used to initialize bt_log_spec
+ * structure:
+ *
+ * const bt_log_output g_output = {BT_LOG_PUT_STD, output_callback, 0};
+ * const bt_log_spec g_spec = {BT_LOG_GLOBAL_FORMAT, &g_output};
+ * BT_LOGI_AUX(&g_spec, "Hello");
+ */
+#define BT_LOG_GLOBAL_FORMAT ((const bt_log_format *)&_bt_log_global_format)
+
+/* Pointer to global output variable. Direct modification is not allowed. Use
+ * bt_log_set_output_v() or bt_log_set_output_p() instead. Could be used to
+ * initialize bt_log_spec structure:
+ *
+ * const bt_log_format g_format = {40};
+ * const bt_log_spec g_spec = {g_format, BT_LOG_GLOBAL_OUTPUT};
+ * BT_LOGI_AUX(&g_spec, "Hello");
+ */
+#define BT_LOG_GLOBAL_OUTPUT ((const bt_log_output *)&_bt_log_global_output)
+
+/* When defined, all library symbols produced by linker will be prefixed with
+ * provided value. That allows to use bt_log library privately in another
+ * libraries without exposing bt_log symbols in their original form (to avoid
+ * possible conflicts with other libraries / components that also could use
+ * bt_log for logging). Value must be without quotes, for example:
+ *
+ * CC_ARGS := -DBT_LOG_LIBRARY_PREFIX=my_lib_
+ *
+ * Note, that in this mode BT_LOG_LIBRARY_PREFIX must be defined when building
+ * bt_log library AND it also must be defined to the same value when building
+ * a library that uses it. For example, consider fictional KittyHttp library
+ * that wants to use bt_log for logging. First approach that could be taken is
+ * to add bt_log.h and bt_log.c to the KittyHttp's source code tree directly.
+ * In that case it will be enough just to define BT_LOG_LIBRARY_PREFIX in
+ * KittyHttp's build script:
+ *
+ * // KittyHttp/CMakeLists.txt
+ * target_compile_definitions(KittyHttp PRIVATE
+ * "BT_LOG_LIBRARY_PREFIX=KittyHttp_")
+ *
+ * If KittyHttp doesn't want to include bt_log source code in its source tree
+ * and wants to build bt_log as a separate library than bt_log library must be
+ * built with BT_LOG_LIBRARY_PREFIX defined to KittyHttp_ AND KittyHttp library
+ * itself also needs to define BT_LOG_LIBRARY_PREFIX to KittyHttp_. It can do
+ * so either in its build script, as in example above, or by providing a
+ * wrapper header that KittyHttp library will need to use instead of bt_log.h:
+ *
+ * // KittyHttpLogging.h
+ * #define BT_LOG_LIBRARY_PREFIX KittyHttp_
+ * #include <babeltrace2/logging-internal.h>
+ *
+ * Regardless of the method chosen, the end result is that bt_log symbols will
+ * be prefixed with "KittyHttp_", so if a user of KittyHttp (say DogeBrowser)
+ * also uses bt_log for logging, they will not interferer with each other. Both
+ * will have their own log level, output facility, format options etc.
+ */
+#ifdef BT_LOG_LIBRARY_PREFIX
+ #define _BT_LOG_DECOR__(prefix, name) prefix ## name
+ #define _BT_LOG_DECOR_(prefix, name) _BT_LOG_DECOR__(prefix, name)
+ #define _BT_LOG_DECOR(name) _BT_LOG_DECOR_(BT_LOG_LIBRARY_PREFIX, name)
+
+ #define bt_log_set_tag_prefix _BT_LOG_DECOR(bt_log_set_tag_prefix)
+ #define bt_log_set_mem_width _BT_LOG_DECOR(bt_log_set_mem_width)
+ #define bt_log_set_output_level _BT_LOG_DECOR(bt_log_set_output_level)
+ #define bt_log_set_output_v _BT_LOG_DECOR(bt_log_set_output_v)
+ #define bt_log_set_output_p _BT_LOG_DECOR(bt_log_set_output_p)
+ #define bt_log_out_stderr_callback _BT_LOG_DECOR(bt_log_out_stderr_callback)
+ #define _bt_log_tag_prefix _BT_LOG_DECOR(_bt_log_tag_prefix)
+ #define _bt_log_global_format _BT_LOG_DECOR(_bt_log_global_format)
+ #define _bt_log_global_output _BT_LOG_DECOR(_bt_log_global_output)
+ #define _bt_log_global_output_lvl _BT_LOG_DECOR(_bt_log_global_output_lvl)
+ #define _bt_log_write_d _BT_LOG_DECOR(_bt_log_write_d)
+ #define _bt_log_write_aux_d _BT_LOG_DECOR(_bt_log_write_aux_d)
+ #define _bt_log_write _BT_LOG_DECOR(_bt_log_write)
+ #define _bt_log_write_aux _BT_LOG_DECOR(_bt_log_write_aux)
+ #define _bt_log_write_mem_d _BT_LOG_DECOR(_bt_log_write_mem_d)
+ #define _bt_log_write_mem_aux_d _BT_LOG_DECOR(_bt_log_write_mem_aux_d)
+ #define _bt_log_write_mem _BT_LOG_DECOR(_bt_log_write_mem)
+ #define _bt_log_write_mem_aux _BT_LOG_DECOR(_bt_log_write_mem_aux)
+ #define _bt_log_stderr_spec _BT_LOG_DECOR(_bt_log_stderr_spec)
+#endif
+
+#if defined(__printflike)
+ #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
+ __printflike(str_index, first_to_check)
+#elif defined(__MINGW_PRINTF_FORMAT)
+ #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
+ __attribute__((format(__MINGW_PRINTF_FORMAT, str_index, first_to_check)))
+#elif defined(__GNUC__)
+ #define _BT_LOG_PRINTFLIKE(str_index, first_to_check) \
+ __attribute__((format(__printf__, str_index, first_to_check)))
+#else
+ #define _BT_LOG_PRINTFLIKE(str_index, first_to_check)
+#endif
+
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__)
+ #define _BT_LOG_FUNCTION __FUNCTION__
+#else
+ #define _BT_LOG_FUNCTION __func__
+#endif
+
+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+ #define _BT_LOG_INLINE __inline
+ #define _BT_LOG_IF(cond) \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4127)) \
+ if(cond) \
+ __pragma(warning(pop))
+ #define _BT_LOG_WHILE(cond) \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4127)) \
+ while(cond) \
+ __pragma(warning(pop))
+#else
+ #define _BT_LOG_INLINE inline
+ #define _BT_LOG_IF(cond) if(cond)
+ #define _BT_LOG_WHILE(cond) while(cond)
+#endif
+#define _BT_LOG_NEVER _BT_LOG_IF(0)
+#define _BT_LOG_ONCE _BT_LOG_WHILE(0)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Set tag prefix. Prefix will be separated from the tag with dot ('.').
+ * Use 0 or empty string to disable (default). Common use is to set it to
+ * the process (or build target) name (e.g. to separate client and server
+ * processes). Function will NOT copy provided prefix string, but will store the
+ * pointer. Hence specified prefix string must remain valid. See
+ * BT_LOG_DEFINE_TAG_PREFIX for a way to set it before entering main() function.
+ * See BT_LOG_TAG for more information about tag and tag prefix.
+ */
+void bt_log_set_tag_prefix(const char *const prefix);
+
+/* Set number of bytes per log line in memory (ASCII-HEX) output. Example:
+ *
+ * I hello.MAIN 4c6f72656d20697073756d20646f6c6f Lorem ipsum dolo
+ * |<- w bytes ->| |<- w chars ->|
+ *
+ * See BT_LOGF_MEM and BT_LOGF_MEM_AUX for more details.
+ */
+void bt_log_set_mem_width(const unsigned w);
+
+/* Set "output" log level. See BT_LOG_LEVEL and BT_LOG_OUTPUT_LEVEL for more
+ * info about log levels.
+ */
+void bt_log_set_output_level(const int lvl);
+
+/* Put mask is a set of flags that define what fields will be added to each
+ * log message. Default value is BT_LOG_PUT_STD and other flags could be used to
+ * alter its behavior. See bt_log_set_output_v() for more details.
+ *
+ * Note about BT_LOG_PUT_SRC: it will be added only in debug builds (NDEBUG is
+ * not defined).
+ */
+enum
+{
+ BT_LOG_PUT_CTX = 1 << 0, /* context (time, pid, tid, log level) */
+ BT_LOG_PUT_TAG = 1 << 1, /* tag (including tag prefix) */
+ BT_LOG_PUT_SRC = 1 << 2, /* source location (file, line, function) */
+ BT_LOG_PUT_MSG = 1 << 3, /* message text (formatted string) */
+ BT_LOG_PUT_STD = 0xffff, /* everything (default) */
+};
+
+typedef struct bt_log_message
+{
+ int lvl; /* Log level of the message */
+ const char *tag; /* Associated tag (without tag prefix) */
+ char *buf; /* Buffer start */
+ char *e; /* Buffer end (last position where EOL with 0 could be written) */
+ char *p; /* Buffer content end (append position) */
+ char *tag_b; /* Prefixed tag start */
+ char *tag_e; /* Prefixed tag end (if != tag_b, points to msg separator) */
+ char *msg_b; /* Message start (expanded format string) */
+}
+bt_log_message;
+
+/* Type of output callback function. It will be called for each log line allowed
+ * by both "current" and "output" log levels ("enabled" and "turned on").
+ * Callback function is allowed to modify content of the buffers pointed by the
+ * msg, but it's not allowed to modify any of msg fields. Buffer pointed by msg
+ * is UTF-8 encoded (no BOM mark).
+ */
+typedef void (*bt_log_output_cb)(const bt_log_message *msg, void *arg);
+
+/* Format options. For more details see bt_log_set_mem_width().
+ */
+typedef struct bt_log_format
+{
+ unsigned mem_width; /* Bytes per line in memory (ASCII-HEX) dump */
+}
+bt_log_format;
+
+/* Output facility.
+ */
+typedef struct bt_log_output
+{
+ unsigned mask; /* What to put into log line buffer (see BT_LOG_PUT_XXX) */
+ void *arg; /* User provided output callback argument */
+ bt_log_output_cb callback; /* Output callback function */
+}
+bt_log_output;
+
+/* Set output callback function.
+ *
+ * Mask allows to control what information will be added to the log line buffer
+ * before callback function is invoked. Default mask value is BT_LOG_PUT_STD.
+ */
+void bt_log_set_output_v(const unsigned mask, void *const arg,
+ const bt_log_output_cb callback);
+static _BT_LOG_INLINE void bt_log_set_output_p(const bt_log_output *const output)
+{
+ bt_log_set_output_v(output->mask, output->arg, output->callback);
+}
+
+/* Used with _AUX macros and allows to override global format and output
+ * facility. Use BT_LOG_GLOBAL_FORMAT and BT_LOG_GLOBAL_OUTPUT for values from
+ * global configuration. Example:
+ *
+ * static const bt_log_output module_output = {
+ * BT_LOG_PUT_STD, 0, custom_output_callback
+ * };
+ * static const bt_log_spec module_spec = {
+ * BT_LOG_GLOBAL_FORMAT, &module_output
+ * };
+ * BT_LOGI_AUX(&module_spec, "Position: %ix%i", x, y);
+ *
+ * See BT_LOGF_AUX and BT_LOGF_MEM_AUX for details.
+ */
+typedef struct bt_log_spec
+{
+ const bt_log_format *format;
+ const bt_log_output *output;
+}
+bt_log_spec;
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Execute log statement if condition is true. Example:
+ *
+ * BT_LOG_IF(1 < 2, BT_LOGI("Log this"));
+ * BT_LOG_IF(1 > 2, BT_LOGI("Don't log this"));
+ *
+ * Keep in mind though, that if condition can't be evaluated at compile time,
+ * then it will be evaluated at run time. This will increase exectuable size
+ * and can have noticeable performance overhead. Try to limit conditions to
+ * expressions that can be evaluated at compile time.
+ */
+#define BT_LOG_IF(cond, f) do { _BT_LOG_IF((cond)) { f; } } _BT_LOG_ONCE
+
+/* Mark log statement as "secret". Log statements that are marked as secrets
+ * will NOT be executed when censoring is enabled (see BT_LOG_CENSORED).
+ * Example:
+ *
+ * BT_LOG_SECRET(BT_LOGI("Credit card: %s", credit_card));
+ * BT_LOG_SECRET(BT_LOGD_MEM(cipher, cipher_sz, "Cipher bytes:"));
+ */
+#define BT_LOG_SECRET(f) BT_LOG_IF(BT_LOG_SECRETS, f)
+
+/* Check "current" log level at compile time (ignoring "output" log level).
+ * Evaluates to true when specified log level is enabled. For example:
+ *
+ * #if BT_LOG_ENABLED_DEBUG
+ * const char *const g_enum_strings[] = {
+ * "enum_value_0", "enum_value_1", "enum_value_2"
+ * };
+ * #endif
+ * // ...
+ * #if BT_LOG_ENABLED_DEBUG
+ * BT_LOGD("enum value: %s", g_enum_strings[v]);
+ * #endif
+ *
+ * See BT_LOG_LEVEL for details.
+ */
+#define BT_LOG_ENABLED(lvl) ((lvl) >= _BT_LOG_LEVEL)
+#define BT_LOG_ENABLED_VERBOSE BT_LOG_ENABLED(BT_LOG_VERBOSE)
+#define BT_LOG_ENABLED_DEBUG BT_LOG_ENABLED(BT_LOG_DEBUG)
+#define BT_LOG_ENABLED_INFO BT_LOG_ENABLED(BT_LOG_INFO)
+#define BT_LOG_ENABLED_WARN BT_LOG_ENABLED(BT_LOG_WARN)
+#define BT_LOG_ENABLED_ERROR BT_LOG_ENABLED(BT_LOG_ERROR)
+#define BT_LOG_ENABLED_FATAL BT_LOG_ENABLED(BT_LOG_FATAL)
+
+/* Check "output" log level at run time (taking into account "current" log
+ * level as well). Evaluates to true when specified log level is turned on AND
+ * enabled. For example:
+ *
+ * if (BT_LOG_ON_DEBUG)
+ * {
+ * char hash[65];
+ * sha256(data_ptr, data_sz, hash);
+ * BT_LOGD("data: len=%u, sha256=%s", data_sz, hash);
+ * }
+ *
+ * See BT_LOG_OUTPUT_LEVEL for details.
+ */
+#define BT_LOG_ON(lvl) \
+ (BT_LOG_ENABLED((lvl)) && (lvl) >= _BT_LOG_OUTPUT_LEVEL)
+#define BT_LOG_ON_VERBOSE BT_LOG_ON(BT_LOG_VERBOSE)
+#define BT_LOG_ON_DEBUG BT_LOG_ON(BT_LOG_DEBUG)
+#define BT_LOG_ON_INFO BT_LOG_ON(BT_LOG_INFO)
+#define BT_LOG_ON_WARN BT_LOG_ON(BT_LOG_WARN)
+#define BT_LOG_ON_ERROR BT_LOG_ON(BT_LOG_ERROR)
+#define BT_LOG_ON_FATAL BT_LOG_ON(BT_LOG_FATAL)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char *_bt_log_tag_prefix;
+extern bt_log_format _bt_log_global_format;
+extern bt_log_output _bt_log_global_output;
+extern int _bt_log_global_output_lvl;
+extern const bt_log_spec _bt_log_stderr_spec;
+
+BT_HIDDEN
+void _bt_log_write_d(
+ const char *const func, const char *const file, const unsigned line,
+ const int lvl, const char *const tag,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(6, 7);
+
+BT_HIDDEN
+void _bt_log_write_aux_d(
+ const char *const func, const char *const file, const unsigned line,
+ const bt_log_spec *const log, const int lvl, const char *const tag,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(7, 8);
+
+BT_HIDDEN
+void _bt_log_write(
+ const int lvl, const char *const tag,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(3, 4);
+
+BT_HIDDEN
+void _bt_log_write_aux(
+ const bt_log_spec *const log, const int lvl, const char *const tag,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(4, 5);
+
+BT_HIDDEN
+void _bt_log_write_mem_d(
+ const char *const func, const char *const file, const unsigned line,
+ const int lvl, const char *const tag,
+ const void *const d, const unsigned d_sz,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(8, 9);
+
+BT_HIDDEN
+void _bt_log_write_mem_aux_d(
+ const char *const func, const char *const file, const unsigned line,
+ const bt_log_spec *const log, const int lvl, const char *const tag,
+ const void *const d, const unsigned d_sz,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(9, 10);
+
+BT_HIDDEN
+void _bt_log_write_mem(
+ const int lvl, const char *const tag,
+ const void *const d, const unsigned d_sz,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(5, 6);
+
+BT_HIDDEN
+void _bt_log_write_mem_aux(
+ const bt_log_spec *const log, const int lvl, const char *const tag,
+ const void *const d, const unsigned d_sz,
+ const char *const fmt, ...) _BT_LOG_PRINTFLIKE(6, 7);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Message logging macros:
+ * - BT_LOGV("format string", args, ...)
+ * - BT_LOGD("format string", args, ...)
+ * - BT_LOGI("format string", args, ...)
+ * - BT_LOGW("format string", args, ...)
+ * - BT_LOGE("format string", args, ...)
+ * - BT_LOGF("format string", args, ...)
+ *
+ * Message and error string (errno) logging macros:
+ * - BT_LOGV_ERRNO("initial message", "format string", args, ...)
+ * - BT_LOGD_ERRNO("initial message", "format string", args, ...)
+ * - BT_LOGI_ERRNO("initial message", "format string", args, ...)
+ * - BT_LOGW_ERRNO("initial message", "format string", args, ...)
+ * - BT_LOGE_ERRNO("initial message", "format string", args, ...)
+ * - BT_LOGF_ERRNO("initial message", "format string", args, ...)
+ *
+ * Memory logging macros:
+ * - BT_LOGV_MEM(data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGD_MEM(data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGI_MEM(data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGW_MEM(data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGE_MEM(data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGF_MEM(data_ptr, data_sz, "format string", args, ...)
+ *
+ * Auxiliary logging macros:
+ * - BT_LOGV_AUX(&log_instance, "format string", args, ...)
+ * - BT_LOGD_AUX(&log_instance, "format string", args, ...)
+ * - BT_LOGI_AUX(&log_instance, "format string", args, ...)
+ * - BT_LOGW_AUX(&log_instance, "format string", args, ...)
+ * - BT_LOGE_AUX(&log_instance, "format string", args, ...)
+ * - BT_LOGF_AUX(&log_instance, "format string", args, ...)
+ *
+ * Auxiliary memory logging macros:
+ * - BT_LOGV_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGD_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGI_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGW_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGE_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOGF_MEM_AUX(&log_instance, data_ptr, data_sz, "format string", args, ...)
+ *
+ * Preformatted string logging macros:
+ * - BT_LOGV_STR("preformatted string");
+ * - BT_LOGD_STR("preformatted string");
+ * - BT_LOGI_STR("preformatted string");
+ * - BT_LOGW_STR("preformatted string");
+ * - BT_LOGE_STR("preformatted string");
+ * - BT_LOGF_STR("preformatted string");
+ *
+ * Explicit log level and tag macros:
+ * - BT_LOG_WRITE(level, tag, "format string", args, ...)
+ * - BT_LOG_WRITE_MEM(level, tag, data_ptr, data_sz, "format string", args, ...)
+ * - BT_LOG_WRITE_AUX(&log_instance, level, tag, "format string", args, ...)
+ * - BT_LOG_WRITE_MEM_AUX(&log_instance, level, tag, data_ptr, data_sz,
+ * "format string", args, ...)
+ *
+ * Format string follows printf() conventions. Both data_ptr and data_sz could
+ * be 0. Tag can be 0 as well. Most compilers will verify that type of arguments
+ * match format specifiers in format string.
+ *
+ * Library assuming UTF-8 encoding for all strings (char *), including format
+ * string itself.
+ */
+#if BT_LOG_SRCLOC_NONE == _BT_LOG_SRCLOC
+ #define BT_LOG_WRITE(lvl, tag, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write(lvl, tag, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_mem(lvl, tag, d, d_sz, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_AUX(log, lvl, tag, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_aux(log, lvl, tag, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_mem_aux(log, lvl, tag, d, d_sz, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+#else
+ #define BT_LOG_WRITE(lvl, tag, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
+ lvl, tag, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_mem_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
+ lvl, tag, d, d_sz, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_AUX(log, lvl, tag, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_aux_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
+ log, lvl, tag, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+ #define BT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
+ do { \
+ if (BT_LOG_ON(lvl)) \
+ _bt_log_write_mem_aux_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
+ log, lvl, tag, d, d_sz, __VA_ARGS__); \
+ } _BT_LOG_ONCE
+#endif
+
+#define BT_LOG_WRITE_ERRNO(lvl, tag, _msg, _fmt, args...) \
+ do { \
+ const char *error_str; \
+ error_str = g_strerror(errno); \
+ BT_LOG_WRITE(lvl, tag, _msg ": %s" _fmt, error_str, ## args); \
+ } _BT_LOG_ONCE
+
+static _BT_LOG_INLINE void _bt_log_unused(const int dummy, ...) {(void)dummy;}
+
+#define _BT_LOG_UNUSED(...) \
+ do { _BT_LOG_NEVER _bt_log_unused(0, __VA_ARGS__); } _BT_LOG_ONCE
+
+#if BT_LOG_ENABLED_VERBOSE
+ #define BT_LOGV(...) \
+ BT_LOG_WRITE(BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGV_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGV_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_VERBOSE, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGV_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_VERBOSE, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGV_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(log, BT_LOG_VERBOSE, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGV(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGV_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGV_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGV_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#if BT_LOG_ENABLED_DEBUG
+ #define BT_LOGD(...) \
+ BT_LOG_WRITE(BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGD_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGD_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_DEBUG, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGD_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_DEBUG, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGD_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM_AUX(log, BT_LOG_DEBUG, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGD(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGD_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGD_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGD_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#if BT_LOG_ENABLED_INFO
+ #define BT_LOGI(...) \
+ BT_LOG_WRITE(BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGI_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGI_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_INFO, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGI_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_INFO, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGI_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM_AUX(log, BT_LOG_INFO, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGI(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGI_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGI_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGI_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#if BT_LOG_ENABLED_WARN
+ #define BT_LOGW(...) \
+ BT_LOG_WRITE(BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGW_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGW_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_WARN, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGW_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_WARN, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGW_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM_AUX(log, BT_LOG_WARN, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGW(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGW_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGW_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGW_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#if BT_LOG_ENABLED_ERROR
+ #define BT_LOGE(...) \
+ BT_LOG_WRITE(BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGE_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGE_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_ERROR, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGE_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_ERROR, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGE_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM_AUX(log, BT_LOG_ERROR, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGE(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGE_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGE_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGE_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#if BT_LOG_ENABLED_FATAL
+ #define BT_LOGF(...) \
+ BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGF_ERRNO(...) \
+ BT_LOG_WRITE_ERRNO(BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGF_AUX(log, ...) \
+ BT_LOG_WRITE_AUX(log, BT_LOG_FATAL, _BT_LOG_TAG, __VA_ARGS__)
+ #define BT_LOGF_MEM(d, d_sz, ...) \
+ BT_LOG_WRITE_MEM(BT_LOG_FATAL, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+ #define BT_LOGF_MEM_AUX(log, d, d_sz, ...) \
+ BT_LOG_WRITE_MEM_AUX(log, BT_LOG_FATAL, _BT_LOG_TAG, d, d_sz, __VA_ARGS__)
+#else
+ #define BT_LOGF(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGF_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGF_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
+ #define BT_LOGF_MEM_AUX(...) _BT_LOG_UNUSED(__VA_ARGS__)
+#endif
+
+#define BT_LOGV_STR(s) BT_LOGV("%s", (s))
+#define BT_LOGD_STR(s) BT_LOGD("%s", (s))
+#define BT_LOGI_STR(s) BT_LOGI("%s", (s))
+#define BT_LOGW_STR(s) BT_LOGW("%s", (s))
+#define BT_LOGE_STR(s) BT_LOGE("%s", (s))
+#define BT_LOGF_STR(s) BT_LOGF("%s", (s))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Output to standard error stream. Library uses it by default, though in few
+ * cases it could be necessary to specify it explicitly. For example, when
+ * bt_log library is compiled with BT_LOG_EXTERN_GLOBAL_OUTPUT, application must
+ * define and initialize global output variable:
+ *
+ * BT_LOG_DEFINE_GLOBAL_OUTPUT = {BT_LOG_OUT_STDERR};
+ *
+ * Another example is when using custom output, stderr could be used as a
+ * fallback when custom output facility failed to initialize:
+ *
+ * bt_log_set_output_v(BT_LOG_OUT_STDERR);
+ */
+enum { BT_LOG_OUT_STDERR_MASK = BT_LOG_PUT_STD };
+
+BT_HIDDEN
+void bt_log_out_stderr_callback(const bt_log_message *const msg, void *arg);
+#define BT_LOG_OUT_STDERR BT_LOG_OUT_STDERR_MASK, 0, bt_log_out_stderr_callback
+
+/* Predefined spec for stderr. Uses global format options (BT_LOG_GLOBAL_FORMAT)
+ * and BT_LOG_OUT_STDERR. Could be used to force output to stderr for a
+ * particular message. Example:
+ *
+ * f = fopen("foo.log", "w");
+ * if (!f)
+ * BT_LOGE_AUX(BT_LOG_STDERR, "Failed to open log file");
+ */
+#define BT_LOG_STDERR (&_bt_log_stderr_spec)
+
+static inline
+int bt_log_get_level_from_env(const char *var)
+{
+ const char *varval = getenv(var);
+ int level = BT_LOG_NONE;
+
+ if (!varval) {
+ goto end;
+ }
+
+ if (strcmp(varval, "VERBOSE") == 0 ||
+ strcmp(varval, "V") == 0) {
+ level = BT_LOG_VERBOSE;
+ } else if (strcmp(varval, "DEBUG") == 0 ||
+ strcmp(varval, "D") == 0) {
+ level = BT_LOG_DEBUG;
+ } else if (strcmp(varval, "INFO") == 0 ||
+ strcmp(varval, "I") == 0) {
+ level = BT_LOG_INFO;
+ } else if (strcmp(varval, "WARN") == 0 ||
+ strcmp(varval, "WARNING") == 0 ||
+ strcmp(varval, "W") == 0) {
+ level = BT_LOG_WARN;
+ } else if (strcmp(varval, "ERROR") == 0 ||
+ strcmp(varval, "E") == 0) {
+ level = BT_LOG_ERROR;
+ } else if (strcmp(varval, "FATAL") == 0 ||
+ strcmp(varval, "F") == 0) {
+ level = BT_LOG_FATAL;
+ } else if (strcmp(varval, "NONE") == 0 ||
+ strcmp(varval, "N") == 0) {
+ level = BT_LOG_NONE;
+ } else {
+ /* Should we warn here? How? */
+ }
+
+end:
+ return level;
+}
+
+#define BT_LOG_LEVEL_EXTERN_SYMBOL(_level_sym) \
+ extern int _level_sym
+
+#define BT_LOG_INIT_LOG_LEVEL(_level_sym, _env_var) \
+ BT_HIDDEN int _level_sym = BT_LOG_NONE; \
+ static \
+ void __attribute__((constructor)) _bt_log_level_ctor(void) \
+ { \
+ _level_sym = bt_log_get_level_from_env(_env_var); \
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_LOGGING_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_LOGGING_H
+#define BABELTRACE_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup logging Logging
+@ingroup apiref
+@brief Logging.
+
+@code
+#include <babeltrace2/logging.h>
+@endcode
+
+The functions in this module control the Babeltrace library's logging
+behaviour.
+
+You can set the current global log level of the library with
+bt_logging_set_global_level(). Note that, if the level you set is below
+the minimal logging level (configured at build time, which you can get
+with bt_logging_get_minimal_level()), the logging statement between the
+current global log level and the minimal log level are not executed.
+
+@file
+@brief Logging functions.
+@sa logging
+
+@addtogroup logging
+@{
+*/
+
+/**
+@brief Log levels.
+*/
+typedef enum bt_logging_level {
+ /// Additional, low-level debugging context information.
+ BT_LOGGING_LEVEL_VERBOSE = 1,
+
+ /**
+ Debugging information, only useful when searching for the
+ cause of a bug.
+ */
+ BT_LOGGING_LEVEL_DEBUG = 2,
+
+ /**
+ Non-debugging information and failure to load optional
+ subsystems.
+ */
+ BT_LOGGING_LEVEL_INFO = 3,
+
+ /**
+ Errors caused by a bad usage of the library, that is, a
+ non-observance of the documented function preconditions.
+
+ The library's and object's states remain consistent when a
+ warning is issued.
+ */
+ BT_LOGGING_LEVEL_WARN = 4,
+
+ /**
+ An important error from which the library cannot recover, but
+ the executed stack of functions can still return cleanly.
+ */
+ BT_LOGGING_LEVEL_ERROR = 5,
+
+ /**
+ The library cannot continue to work in this condition: it must
+ terminate immediately, without even returning to the user's
+ execution.
+ */
+ BT_LOGGING_LEVEL_FATAL = 6,
+
+ /// Logging is disabled.
+ BT_LOGGING_LEVEL_NONE = 0xff,
+} bt_logging_level;
+
+/**
+@brief Returns the minimal log level of the Babeltrace library.
+
+The minimal log level is defined at the library's build time. Any
+logging statement with a level below the minimal log level is not
+compiled. This means that it is useless, although possible, to set the
+global log level with bt_logging_set_global_level() below this level.
+
+@returns Minimal, build time log level.
+
+@sa bt_logging_get_global_level(): Returns the current global log level.
+*/
+extern bt_logging_level bt_logging_get_minimal_level(void);
+
+/**
+@brief Returns the current global log level of the Babeltrace library.
+
+@returns Current global log level.
+
+@sa bt_logging_set_global_level(): Sets the current global log level.
+@sa bt_logging_get_minimal_level(): Returns the minimal log level.
+*/
+extern bt_logging_level bt_logging_get_global_level(void);
+
+/**
+@brief Sets the current global log level of the Babeltrace library
+ to \p log_level.
+
+If \p log_level is below what bt_logging_get_minimal_level() returns,
+the logging statements with a level between \p log_level and the minimal
+log level cannot be executed.
+
+@param[in] log_level Library's new global log level.
+
+@sa bt_logging_get_global_level(): Returns the global log level.
+*/
+extern void bt_logging_set_global_level(bt_logging_level log_level);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_LOGGING_H */
--- /dev/null
+#ifndef _BABELTRACE_MMAP_ALIGN_H
+#define _BABELTRACE_MMAP_ALIGN_H
+
+/*
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <babeltrace2/align-internal.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <babeltrace2/compat/mman-internal.h>
+#include <babeltrace2/common-internal.h>
+
+/*
+ * This header implements a wrapper over mmap (mmap_align) that memory
+ * maps a file region that is not necessarily multiple of the page size.
+ * It returns a structure (instead of a pointer) that contains the mmap
+ * pointer (page-aligned) and a pointer to the offset requested within
+ * that page. Note: in the current implementation, the "addr" parameter
+ * cannot be forced, so we allocate at an address chosen by the OS.
+ */
+
+struct mmap_align {
+ void *page_aligned_addr; /* mmap address, aligned to floor */
+ size_t page_aligned_length; /* mmap length, containing range */
+
+ void *addr; /* virtual mmap address */
+ size_t length; /* virtual mmap length */
+};
+
+#ifdef __WIN32__
+#include <windows.h>
+
+/*
+ * On windows the memory mapping offset must be aligned to the memory
+ * allocator allocation granularity and not the page size.
+ */
+static inline
+off_t get_page_aligned_offset(off_t offset, size_t page_size)
+{
+ SYSTEM_INFO sysinfo;
+
+ GetNativeSystemInfo(&sysinfo);
+
+ return ALIGN_FLOOR(offset, sysinfo.dwAllocationGranularity);
+}
+#else
+static inline
+off_t get_page_aligned_offset(off_t offset, size_t page_size)
+{
+ return ALIGN_FLOOR(offset, page_size);
+}
+#endif
+
+static inline
+struct mmap_align *mmap_align(size_t length, int prot,
+ int flags, int fd, off_t offset)
+{
+ struct mmap_align *mma;
+ off_t page_aligned_offset; /* mmap offset, aligned to floor */
+ size_t page_size;
+
+ page_size = bt_common_get_page_size();
+
+ mma = malloc(sizeof(*mma));
+ if (!mma)
+ return MAP_FAILED;
+ mma->length = length;
+ page_aligned_offset = get_page_aligned_offset(offset, page_size);
+ /*
+ * Page aligned length needs to contain the requested range.
+ * E.g., for a small range that fits within a single page, we might
+ * require a 2 pages page_aligned_length if the range crosses a page
+ * boundary.
+ */
+ mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
+ mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length,
+ prot, flags, fd, page_aligned_offset);
+ if (mma->page_aligned_addr == MAP_FAILED) {
+ free(mma);
+ return MAP_FAILED;
+ }
+ mma->addr = ((uint8_t *) mma->page_aligned_addr) + (offset - page_aligned_offset);
+ return mma;
+}
+
+static inline
+int munmap_align(struct mmap_align *mma)
+{
+ void *page_aligned_addr;
+ size_t page_aligned_length;
+
+ page_aligned_addr = mma->page_aligned_addr;
+ page_aligned_length = mma->page_aligned_length;
+ free(mma);
+ return bt_munmap(page_aligned_addr, page_aligned_length);
+}
+
+static inline
+void *mmap_align_addr(struct mmap_align *mma)
+{
+ return mma->addr;
+}
+
+/*
+ * Helper for special-cases, normally unused.
+ */
+static inline
+void mmap_align_set_addr(struct mmap_align *mma, void *addr)
+{
+ mma->addr = addr;
+}
+
+#endif /* _BABELTRACE_MMAP_ALIGN_H */
--- /dev/null
+#ifndef BABELTRACE_OBJECT_INTERNAL_H
+#define BABELTRACE_OBJECT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdbool.h>
+
+struct bt_object;
+
+typedef void (*bt_object_release_func)(struct bt_object *);
+typedef void (*bt_object_parent_is_owner_listener_func)(
+ struct bt_object *);
+
+static inline
+void bt_object_get_no_null_check(const void *obj);
+
+static inline
+void bt_object_put_no_null_check(const void *obj);
+
+/*
+ * Babeltrace object base.
+ *
+ * All objects publicly exposed by Babeltrace APIs must contain this
+ * object as their first member.
+ */
+struct bt_object {
+ /*
+ * True if this object is shared, that is, it has a reference
+ * count.
+ */
+ bool is_shared;
+
+ /*
+ * Current reference count.
+ */
+ unsigned long long ref_count;
+
+ /*
+ * Release function called when the object's reference count
+ * falls to zero. For an object with a parent, this function is
+ * bt_object_with_parent_release_func(), which calls
+ * `spec_release_func` below if there's no current parent.
+ */
+ bt_object_release_func release_func;
+
+ /*
+ * Specific release function called by
+ * bt_object_with_parent_release_func() or directly by a
+ * parent object.
+ */
+ bt_object_release_func spec_release_func;
+
+ /*
+ * Optional callback for an object with a parent, called by
+ * bt_object_with_parent_release_func() to indicate to the
+ * object that its parent is its owner.
+ */
+ bt_object_parent_is_owner_listener_func
+ parent_is_owner_listener_func;
+
+ /*
+ * Optional parent object.
+ */
+ struct bt_object *parent;
+};
+
+static inline
+unsigned long long bt_object_get_ref_count(const struct bt_object *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->ref_count;
+}
+
+static inline
+struct bt_object *bt_object_borrow_parent(const struct bt_object *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ return obj->parent;
+}
+
+static inline
+struct bt_object *bt_object_get_parent(const struct bt_object *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+ struct bt_object *parent = bt_object_borrow_parent(obj);
+
+ if (parent) {
+ bt_object_get_no_null_check(parent);
+ }
+
+ return parent;
+}
+
+static inline
+void bt_object_set_parent(struct bt_object *child, struct bt_object *parent)
+{
+ BT_ASSERT(child);
+ BT_ASSERT(child->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p",
+ child, parent);
+#endif
+
+ /*
+ * It is assumed that a "child" having a parent is publicly
+ * reachable. Therefore, a reference to its parent must be
+ * taken. The reference to the parent will be released once the
+ * object's reference count falls to zero.
+ */
+ if (parent) {
+ BT_ASSERT(!child->parent);
+ child->parent = parent;
+ bt_object_get_no_null_check(parent);
+ } else {
+ if (child->parent) {
+ bt_object_put_no_null_check(child->parent);
+ }
+
+ child->parent = NULL;
+ }
+}
+
+static inline
+void bt_object_try_spec_release(struct bt_object *obj)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+
+ if (bt_object_get_ref_count(obj) == 0) {
+ obj->spec_release_func(obj);
+ }
+}
+
+static inline
+void bt_object_with_parent_release_func(struct bt_object *obj)
+{
+ if (obj->parent) {
+ /*
+ * Keep our own copy of the parent address because `obj`
+ * could be destroyed in
+ * obj->parent_is_owner_listener_func().
+ */
+ struct bt_object *parent = obj->parent;
+
+#ifdef BT_LOGV
+ BT_LOGV("Releasing parented object: addr=%p, ref-count=%llu, "
+ "parent-addr=%p, parent-ref-count=%llu",
+ obj, obj->ref_count,
+ parent, parent->ref_count);
+#endif
+
+ if (obj->parent_is_owner_listener_func) {
+ /*
+ * Object has a chance to destroy itself here
+ * under certain conditions and notify its
+ * parent. At this point the parent is
+ * guaranteed to exist because it's not put yet.
+ */
+ obj->parent_is_owner_listener_func(obj);
+ }
+
+ /* The release function will be invoked by the parent. */
+ bt_object_put_no_null_check(parent);
+ } else {
+ bt_object_try_spec_release(obj);
+ }
+}
+
+static inline
+void bt_object_init(struct bt_object *obj, bool is_shared,
+ bt_object_release_func release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(!is_shared || release_func);
+ obj->is_shared = is_shared;
+ obj->release_func = release_func;
+ obj->parent_is_owner_listener_func = NULL;
+ obj->spec_release_func = NULL;
+ obj->parent = NULL;
+ obj->ref_count = 1;
+}
+
+static inline
+void bt_object_init_shared(struct bt_object *obj,
+ bt_object_release_func release_func)
+{
+ bt_object_init(obj, true, release_func);
+}
+
+static inline
+void bt_object_init_unique(struct bt_object *obj)
+{
+ bt_object_init(obj, false, NULL);
+}
+
+static inline
+void bt_object_init_shared_with_parent(struct bt_object *obj,
+ bt_object_release_func spec_release_func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(spec_release_func);
+ bt_object_init_shared(obj, bt_object_with_parent_release_func);
+ obj->spec_release_func = spec_release_func;
+}
+
+static inline
+void bt_object_set_parent_is_owner_listener_func(struct bt_object *obj,
+ bt_object_parent_is_owner_listener_func func)
+{
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->spec_release_func);
+ ((struct bt_object *) obj)->parent_is_owner_listener_func = func;
+}
+
+static inline
+void bt_object_inc_ref_count(const struct bt_object *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ obj->ref_count++;
+ BT_ASSERT(obj->ref_count != 0);
+}
+
+static inline
+void bt_object_get_no_null_check_no_parent_check(const struct bt_object *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_object_inc_ref_count(obj);
+}
+
+static inline
+void bt_object_get_no_null_check(const void *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+
+ if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) {
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's parent's reference count: "
+ "addr=%p, parent-addr=%p", obj, obj->parent);
+#endif
+
+ bt_object_get_no_null_check(obj->parent);
+ }
+
+#ifdef BT_LOGV
+ BT_LOGV("Incrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count + 1,
+ obj, obj->ref_count, obj->ref_count + 1);
+#endif
+
+ bt_object_inc_ref_count(obj);
+}
+
+static inline
+void bt_object_put_no_null_check(const void *c_obj)
+{
+ struct bt_object *obj = (void *) c_obj;
+
+ BT_ASSERT(obj);
+ BT_ASSERT(obj->is_shared);
+ BT_ASSERT(obj->ref_count > 0);
+
+#ifdef BT_LOGV
+ BT_LOGV("Decrementing object's reference count: %llu -> %llu: "
+ "addr=%p, cur-count=%llu, new-count=%llu",
+ obj->ref_count, obj->ref_count - 1,
+ obj, obj->ref_count, obj->ref_count - 1);
+#endif
+
+ obj->ref_count--;
+
+ if (obj->ref_count == 0) {
+ BT_ASSERT(obj->release_func);
+ obj->release_func(obj);
+ }
+}
+
+static inline
+void bt_object_get_ref(const void *ptr)
+{
+ struct bt_object *obj = (void *) ptr;
+
+ if (unlikely(!obj)) {
+ return;
+ }
+
+#ifdef BT_ASSERT_PRE
+ BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj);
+#endif
+
+ bt_object_get_no_null_check(obj);
+}
+
+static inline
+void bt_object_put_ref(const void *ptr)
+{
+ struct bt_object *obj = (void *) ptr;
+
+ if (unlikely(!obj)) {
+ return;
+ }
+
+#ifdef BT_ASSERT_PRE
+ BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj);
+ BT_ASSERT_PRE(bt_object_get_ref_count(obj) > 0,
+ "Decrementing a reference count set to 0: %!+O", ptr);
+#endif
+
+ bt_object_put_no_null_check(obj);
+}
+
+#define BT_OBJECT_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_object_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_OBJECT_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_object_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#endif /* BABELTRACE_OBJECT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_OBJECT_POOL_INTERNAL_H
+#define BABELTRACE_OBJECT_POOL_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+/*
+ * This is a generic object pool to avoid memory allocation/deallocation
+ * for objects of which the lifespan is typically short, but which are
+ * created a lot.
+ *
+ * The object pool, thanks to two user functions, knows how to allocate
+ * a brand new object in memory when the pool is empty and how to
+ * destroy an object when we destroy the pool.
+ *
+ * The object pool's user is responsible for:
+ *
+ * * Setting whatever references the object needs to keep and reset some
+ * properties _after_ calling bt_object_pool_create_object(). This is
+ * typically done in the bt_*_create() function which calls
+ * bt_object_pool_create_object() (which could call the user-provided
+ * allocation function if the pool is empty) and then sets the
+ * appropriate properties on the possibly recycled object.
+ *
+ * * Releasing whatever references the object keeps _before_ calling
+ * bt_object_pool_recycle_object(). This is typically done in a custom
+ * bt_*_recycle() function which does the necessary before calling
+ * bt_object_pool_recycle_object() with an object ready to be reused
+ * at any time.
+ */
+
+#include <glib.h>
+#include <babeltrace2/object-internal.h>
+
+typedef void *(*bt_object_pool_new_object_func)(void *data);
+typedef void *(*bt_object_pool_destroy_object_func)(void *obj, void *data);
+
+struct bt_object_pool {
+ /*
+ * Container of recycled objects, owned by this. The array's size
+ * is the pool's capacity.
+ */
+ GPtrArray *objects;
+
+ /*
+ * Pool's size, that is, number of elements in the array above,
+ * starting at index 0, which exist as recycled objects.
+ */
+ size_t size;
+
+ /* User functions */
+ struct {
+ /* Allocate a new object in memory */
+ bt_object_pool_new_object_func new_object;
+
+ /* Free direct and indirect memory occupied by object */
+ bt_object_pool_destroy_object_func destroy_object;
+ } funcs;
+
+ /* User data passed to user functions */
+ void *data;
+};
+
+/*
+ * Initializes an object pool which is already allocated.
+ */
+int bt_object_pool_initialize(struct bt_object_pool *pool,
+ bt_object_pool_new_object_func new_object_func,
+ bt_object_pool_destroy_object_func destroy_object_func,
+ void *data);
+
+/*
+ * Finalizes an object pool without deallocating it.
+ */
+void bt_object_pool_finalize(struct bt_object_pool *pool);
+
+/*
+ * Creates an object from an object pool. If the pool is empty, this
+ * function calls the "new" user function to allocate a new object
+ * before returning it. Otherwise this function returns a recycled
+ * object, removing it from the pool.
+ *
+ * The returned object is owned by the caller.
+ */
+static inline
+void *bt_object_pool_create_object(struct bt_object_pool *pool)
+{
+ struct bt_object *obj;
+
+ BT_ASSERT(pool);
+
+#ifdef BT_LOGV
+ BT_LOGV("Creating object from pool: pool-addr=%p, pool-size=%zu, pool-cap=%u",
+ pool, pool->size, pool->objects->len);
+#endif
+
+ if (pool->size > 0) {
+ /* Pick one from the pool */
+ pool->size--;
+ obj = pool->objects->pdata[pool->size];
+ pool->objects->pdata[pool->size] = NULL;
+ goto end;
+ }
+
+ /* Pool is empty: create a brand new object */
+#ifdef BT_LOGV
+ BT_LOGV("Pool is empty: allocating new object: pool-addr=%p",
+ pool);
+#endif
+
+ obj = pool->funcs.new_object(pool->data);
+
+end:
+#ifdef BT_LOGV
+ BT_LOGV("Created one object from pool: pool-addr=%p, obj-addr=%p",
+ pool, obj);
+#endif
+
+ return obj;
+}
+
+/*
+ * Recycles an object, that is, puts it back into the pool.
+ *
+ * The pool becomes the sole owner of the object to recycle.
+ */
+static inline
+void bt_object_pool_recycle_object(struct bt_object_pool *pool, void *obj)
+{
+ struct bt_object *bt_obj = obj;
+
+ BT_ASSERT(pool);
+ BT_ASSERT(obj);
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycling object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+
+ if (pool->size == pool->objects->len) {
+ /* Backing array is full: make place for recycled object */
+#ifdef BT_LOGV
+ BT_LOGV("Object pool is full: increasing object pool capacity: "
+ "pool-addr=%p, old-pool-cap=%u, new-pool-cap=%u",
+ pool, pool->objects->len, pool->objects->len + 1);
+#endif
+ g_ptr_array_set_size(pool->objects, pool->size + 1);
+ }
+
+ /* Reset reference count to 1 since it could be 0 now */
+ bt_obj->ref_count = 1;
+
+ /* Back to the pool */
+ pool->objects->pdata[pool->size] = obj;
+ pool->size++;
+
+#ifdef BT_LOGV
+ BT_LOGV("Recycled object: pool-addr=%p, pool-size=%zu, pool-cap=%u, obj-addr=%p",
+ pool, pool->size, pool->objects->len, obj);
+#endif
+}
+
+#endif /* BABELTRACE_OBJECT_POOL_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_CONST_H
+#define BABELTRACE_PLUGIN_PLUGIN_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <stddef.h>
+
+/*
+ * For bt_bool, bt_plugin, bt_plugin_set, bt_component_class,
+ * bt_component_class_source, bt_component_class_filter,
+ * bt_component_class_sink
+ */
+#include <babeltrace2/types.h>
+
+/* For bt_property_availability */
+#include <babeltrace2/property.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const bt_plugin *bt_plugin_find(const char *plugin_name);
+
+extern const bt_plugin_set *bt_plugin_find_all_from_file(
+ const char *path);
+
+extern const bt_plugin_set *bt_plugin_find_all_from_dir(
+ const char *path, bt_bool recurse);
+
+extern const bt_plugin_set *bt_plugin_find_all_from_static(void);
+
+extern const char *bt_plugin_get_name(const bt_plugin *plugin);
+
+extern const char *bt_plugin_get_author(const bt_plugin *plugin);
+
+extern const char *bt_plugin_get_license(const bt_plugin *plugin);
+
+extern const char *bt_plugin_get_description(const bt_plugin *plugin);
+
+extern const char *bt_plugin_get_path(const bt_plugin *plugin);
+
+extern bt_property_availability bt_plugin_get_version(
+ const bt_plugin *plugin, unsigned int *major,
+ unsigned int *minor, unsigned int *patch, const char **extra);
+
+extern uint64_t bt_plugin_get_source_component_class_count(
+ const bt_plugin *plugin);
+
+extern uint64_t bt_plugin_get_filter_component_class_count(
+ const bt_plugin *plugin);
+
+extern uint64_t bt_plugin_get_sink_component_class_count(
+ const bt_plugin *plugin);
+
+extern const bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_index_const(
+ const bt_plugin *plugin, uint64_t index);
+
+extern const bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_index_const(
+ const bt_plugin *plugin, uint64_t index);
+
+extern const bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_index_const(
+ const bt_plugin *plugin, uint64_t index);
+
+extern const bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_name_const(
+ const bt_plugin *plugin, const char *name);
+
+extern const bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_name_const(
+ const bt_plugin *plugin, const char *name);
+
+extern const bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_name_const(
+ const bt_plugin *plugin, const char *name);
+
+extern void bt_plugin_get_ref(const bt_plugin *plugin);
+
+extern void bt_plugin_put_ref(const bt_plugin *plugin);
+
+#define BT_PLUGIN_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_plugin_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PLUGIN_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_plugin_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_DEV_H
+#define BABELTRACE_PLUGIN_PLUGIN_DEV_H
+
+/*
+ * This is the header that you need to include for the development of
+ * a Babeltrace plug-in.
+ *
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For enum bt_plugin_status */
+#include <babeltrace2/plugin/plugin-const.h>
+
+/* For bt_component_class_type */
+#include <babeltrace2/graph/component-class-const.h>
+
+/* For component class method type definitions */
+#include <babeltrace2/graph/component-class-source.h>
+#include <babeltrace2/graph/component-class-filter.h>
+#include <babeltrace2/graph/component-class-sink.h>
+
+/*
+ * _BT_HIDDEN: set the hidden attribute for internal functions
+ * On Windows, symbols are local unless explicitly exported,
+ * see https://gcc.gnu.org/wiki/Visibility
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define _BT_HIDDEN
+#else
+#define _BT_HIDDEN __attribute__((visibility("hidden")))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Plugin interface's version, not synced with Babeltrace's version
+ * (internal use).
+ */
+#define __BT_PLUGIN_VERSION_MAJOR 1
+#define __BT_PLUGIN_VERSION_MINOR 0
+
+/* Plugin initialization function type */
+typedef enum bt_self_plugin_status {
+ BT_SELF_PLUGIN_STATUS_OK = 0,
+ BT_SELF_PLUGIN_STATUS_NOMEM = -12,
+ BT_SELF_PLUGIN_STATUS_ERROR = -1,
+} bt_self_plugin_status;
+
+typedef struct bt_self_plugin bt_self_plugin;
+
+typedef bt_self_plugin_status (*bt_plugin_init_func)(
+ bt_self_plugin *plugin);
+
+/* Plugin exit function type */
+typedef void (*bt_plugin_exit_func)(void);
+
+/* Plugin descriptor: describes a single plugin (internal use) */
+struct __bt_plugin_descriptor {
+ /* Plugin's interface major version number */
+ uint32_t major;
+
+ /* Plugin's interface minor version number */
+ uint32_t minor;
+
+ /* Plugin's name */
+ const char *name;
+} __attribute__((packed));
+
+/* Type of a plugin attribute (internal use) */
+enum __bt_plugin_descriptor_attribute_type {
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT = 0,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT = 1,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR = 2,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE = 3,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 4,
+ BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION = 5,
+};
+
+/* Plugin (user) version */
+struct __bt_plugin_descriptor_version {
+ uint32_t major;
+ uint32_t minor;
+ uint32_t patch;
+ const char *extra;
+};
+
+/* Plugin attribute (internal use) */
+struct __bt_plugin_descriptor_attribute {
+ /* Plugin descriptor to which to associate this attribute */
+ const struct __bt_plugin_descriptor *plugin_descriptor;
+
+ /* Name of the attribute's type for debug purposes */
+ const char *type_name;
+
+ /* Attribute's type */
+ enum __bt_plugin_descriptor_attribute_type type;
+
+ /* Attribute's value (depends on attribute's type) */
+ union {
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT */
+ bt_plugin_init_func init;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT */
+ bt_plugin_exit_func exit;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR */
+ const char *author;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE */
+ const char *license;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
+ const char *description;
+
+ /* BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION */
+ struct __bt_plugin_descriptor_version version;
+ } value;
+} __attribute__((packed));
+
+/* Component class descriptor (internal use) */
+struct __bt_plugin_component_class_descriptor {
+ /*
+ * Plugin descriptor to which to associate this component
+ * class descriptor.
+ */
+ const struct __bt_plugin_descriptor *plugin_descriptor;
+
+ /* Component class name */
+ const char *name;
+
+ /* Component class type */
+ bt_component_class_type type;
+
+ /* Mandatory methods (depends on component class type) */
+ union {
+ /* BT_COMPONENT_CLASS_TYPE_SOURCE */
+ struct {
+ bt_component_class_source_message_iterator_next_method msg_iter_next;
+ } source;
+
+ /* BT_COMPONENT_CLASS_TYPE_FILTER */
+ struct {
+ bt_component_class_filter_message_iterator_next_method msg_iter_next;
+ } filter;
+
+ /* BT_COMPONENT_CLASS_TYPE_SINK */
+ struct {
+ bt_component_class_sink_consume_method consume;
+ } sink;
+ } methods;
+} __attribute__((packed));
+
+/* Type of a component class attribute (internal use) */
+enum __bt_plugin_component_class_descriptor_attribute_type {
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION = 0,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP = 1,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 2,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD = 3,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD = 4,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD = 5,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD = 6,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD = 7,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD = 8,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD = 9,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD = 10,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD = 11,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD = 12,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD = 13,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD = 14,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD = 15,
+};
+
+/* Component class attribute (internal use) */
+struct __bt_plugin_component_class_descriptor_attribute {
+ /*
+ * Component class plugin attribute to which to associate this
+ * component class attribute.
+ */
+ const struct __bt_plugin_component_class_descriptor *comp_class_descriptor;
+
+ /* Name of the attribute's type for debug purposes */
+ const char *type_name;
+
+ /* Attribute's type */
+ enum __bt_plugin_component_class_descriptor_attribute_type type;
+
+ /* Attribute's value (depends on attribute's type) */
+ union {
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION */
+ const char *description;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP */
+ const char *help;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD */
+ bt_component_class_source_init_method source_init_method;
+ bt_component_class_filter_init_method filter_init_method;
+ bt_component_class_sink_init_method sink_init_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD */
+ bt_component_class_source_finalize_method source_finalize_method;
+ bt_component_class_filter_finalize_method filter_finalize_method;
+ bt_component_class_sink_finalize_method sink_finalize_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD */
+ bt_component_class_source_query_method source_query_method;
+ bt_component_class_filter_query_method filter_query_method;
+ bt_component_class_sink_query_method sink_query_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD */
+ bt_component_class_filter_accept_input_port_connection_method filter_accept_input_port_connection_method;
+ bt_component_class_sink_accept_input_port_connection_method sink_accept_input_port_connection_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD */
+ bt_component_class_source_accept_output_port_connection_method source_accept_output_port_connection_method;
+ bt_component_class_filter_accept_output_port_connection_method filter_accept_output_port_connection_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD */
+ bt_component_class_filter_input_port_connected_method filter_input_port_connected_method;
+ bt_component_class_sink_input_port_connected_method sink_input_port_connected_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD */
+ bt_component_class_source_output_port_connected_method source_output_port_connected_method;
+ bt_component_class_filter_output_port_connected_method filter_output_port_connected_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD */
+ bt_component_class_sink_graph_is_configured_method sink_graph_is_configured_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_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;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD */
+ bt_component_class_source_message_iterator_seek_ns_from_origin_method source_msg_iter_seek_ns_from_origin_method;
+ bt_component_class_filter_message_iterator_seek_ns_from_origin_method filter_msg_iter_seek_ns_from_origin_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD */
+ bt_component_class_source_message_iterator_seek_beginning_method source_msg_iter_seek_beginning_method;
+ bt_component_class_filter_message_iterator_seek_beginning_method filter_msg_iter_seek_beginning_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD */
+ bt_component_class_source_message_iterator_can_seek_ns_from_origin_method source_msg_iter_can_seek_ns_from_origin_method;
+ bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method filter_msg_iter_can_seek_ns_from_origin_method;
+
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD */
+ bt_component_class_source_message_iterator_can_seek_beginning_method source_msg_iter_can_seek_beginning_method;
+ bt_component_class_filter_message_iterator_can_seek_beginning_method filter_msg_iter_can_seek_beginning_method;
+ } value;
+} __attribute__((packed));
+
+struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void);
+struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void);
+struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void);
+struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void);
+struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void);
+struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void);
+struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void);
+struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void);
+
+/*
+ * Variable attributes for a plugin descriptor pointer to be added to
+ * the plugin descriptor section (internal use).
+ */
+#ifdef __APPLE__
+#define __BT_PLUGIN_DESCRIPTOR_ATTRS \
+ __attribute__((section("__DATA,btp_desc"), used))
+
+#define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
+ __start___bt_plugin_descriptors
+
+#define __BT_PLUGIN_DESCRIPTOR_END_SYMBOL \
+ __stop___bt_plugin_descriptors
+
+#define __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA \
+ __asm("section$start$__DATA$btp_desc")
+
+#define __BT_PLUGIN_DESCRIPTOR_END_EXTRA \
+ __asm("section$end$__DATA$btp_desc")
+
+#else
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRS \
+ __attribute__((section("__bt_plugin_descriptors"), used))
+
+#define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \
+ __start___bt_plugin_descriptors
+
+#define __BT_PLUGIN_DESCRIPTOR_END_SYMBOL \
+ __stop___bt_plugin_descriptors
+
+#define __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA
+
+#define __BT_PLUGIN_DESCRIPTOR_END_EXTRA
+#endif
+
+/*
+ * Variable attributes for a plugin attribute pointer to be added to
+ * the plugin attribute section (internal use).
+ */
+#ifdef __APPLE__
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
+ __attribute__((section("__DATA,btp_desc_att"), used))
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
+ __start___bt_plugin_descriptor_attributes
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
+ __stop___bt_plugin_descriptor_attributes
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA \
+ __asm("section$start$__DATA$btp_desc_att")
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA \
+ __asm("section$end$__DATA$btp_desc_att")
+
+#else
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \
+ __attribute__((section("__bt_plugin_descriptor_attributes"), used))
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
+ __start___bt_plugin_descriptor_attributes
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
+ __stop___bt_plugin_descriptor_attributes
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA
+
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA
+#endif
+
+/*
+ * Variable attributes for a component class descriptor pointer to be
+ * added to the component class descriptor section (internal use).
+ */
+#ifdef __APPLE__
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
+ __attribute__((section("__DATA,btp_cc_desc"), used))
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
+ __start___bt_plugin_component_class_descriptors
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL \
+ __stop___bt_plugin_component_class_descriptors
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA \
+ __asm("section$start$__DATA$btp_cc_desc")
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA \
+ __asm("section$end$__DATA$btp_cc_desc")
+
+#else
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \
+ __attribute__((section("__bt_plugin_component_class_descriptors"), used))
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \
+ __start___bt_plugin_component_class_descriptors
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL \
+ __stop___bt_plugin_component_class_descriptors
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA
+#endif
+
+/*
+ * Variable attributes for a component class descriptor attribute
+ * pointer to be added to the component class descriptor attribute
+ * section (internal use).
+ */
+#ifdef __APPLE__
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
+ __attribute__((section("__DATA,btp_cc_desc_att"), used))
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
+ __start___bt_plugin_component_class_descriptor_attributes
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
+ __stop___bt_plugin_component_class_descriptor_attributes
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA \
+ __asm("section$start$__DATA$btp_cc_desc_att")
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA \
+ __asm("section$end$__DATA$btp_cc_desc_att")
+
+#else
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \
+ __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used))
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \
+ __start___bt_plugin_component_class_descriptor_attributes
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL \
+ __stop___bt_plugin_component_class_descriptor_attributes
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA
+
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA
+#endif
+
+/*
+ * Declares a plugin descriptor pointer variable with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ */
+#define BT_PLUGIN_DECLARE(_id) extern struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id
+
+/*
+ * Defines a plugin descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _name: Plugin's name (C string).
+ */
+#define BT_PLUGIN_WITH_ID(_id, _name) \
+ struct __bt_plugin_descriptor __bt_plugin_descriptor_##_id = { \
+ .major = __BT_PLUGIN_VERSION_MAJOR, \
+ .minor = __BT_PLUGIN_VERSION_MINOR, \
+ .name = _name, \
+ }; \
+ static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_##_id##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRS = &__bt_plugin_descriptor_##_id
+
+/*
+ * Defines a plugin attribute (generic, internal use).
+ *
+ * _attr_name: Name of the attribute (C identifier).
+ * _attr_type: Type of the attribute (enum __bt_plugin_descriptor_attribute_type).
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: Value.
+ */
+#define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _x) \
+ static struct __bt_plugin_descriptor_attribute __bt_plugin_descriptor_attribute_##_id##_##_attr_name = { \
+ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
+ .type_name = #_attr_name, \
+ .type = _attr_type, \
+ .value._attr_name = _x, \
+ }; \
+ static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_##_id##_##_attr_name##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_descriptor_attribute_##_id##_##_attr_name
+
+/*
+ * Defines a plugin initialization function attribute attached to a
+ * specific plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: Initialization function (bt_plugin_init_func).
+ */
+#define BT_PLUGIN_INIT_WITH_ID(_id, _x) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(init, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT, _id, _x)
+
+/*
+ * Defines a plugin exit function attribute attached to a specific
+ * plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: Exit function (bt_plugin_exit_func).
+ */
+#define BT_PLUGIN_EXIT_WITH_ID(_id, _x) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(exit, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT, _id, _x)
+
+/*
+ * Defines an author attribute attached to a specific plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: Author (C string).
+ */
+#define BT_PLUGIN_AUTHOR_WITH_ID(_id, _x) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(author, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR, _id, _x)
+
+/*
+ * Defines a license attribute attached to a specific plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: License (C string).
+ */
+#define BT_PLUGIN_LICENSE_WITH_ID(_id, _x) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(license, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE, _id, _x)
+
+/*
+ * Defines a description attribute attached to a specific plugin
+ * descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_DESCRIPTION_WITH_ID(_id, _x) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _x)
+
+#define __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra) \
+ {.major = _major, .minor = _minor, .patch = _patch, .extra = _extra,}
+
+/*
+ * Defines a version attribute attached to a specific plugin descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _major: Plugin's major version (uint32_t).
+ * _minor: Plugin's minor version (uint32_t).
+ * _patch: Plugin's patch version (uint32_t).
+ * _extra: Plugin's version extra information (C string).
+ */
+#define BT_PLUGIN_VERSION_WITH_ID(_id, _major, _minor, _patch, _extra) \
+ __BT_PLUGIN_DESCRIPTOR_ATTRIBUTE(version, BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION, _id, __BT_PLUGIN_VERSION_STRUCT_VALUE(_major, _minor, _patch, _extra))
+
+/*
+ * Defines a source component class descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _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, _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 = { \
+ .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
+
+/*
+ * Defines a filter component class descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _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, _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 = { \
+ .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
+
+/*
+ * Defines a sink component class descriptor with a custom ID.
+ *
+ * _id: ID (any valid C identifier except `auto`).
+ * _comp_class_id: Component class ID (C identifier).
+ * _name: Component class name (C string).
+ * _consume_method: Component class's iterator consume method
+ * (bt_component_class_sink_consume_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _consume_method) \
+ static struct __bt_plugin_component_class_descriptor __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id = { \
+ .plugin_descriptor = &__bt_plugin_descriptor_##_id, \
+ .name = _name, \
+ .type = BT_COMPONENT_CLASS_TYPE_SINK, \
+ .methods.sink = { \
+ .consume = _consume_method, \
+ }, \
+ }; \
+ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id
+
+/*
+ * Defines a component class descriptor attribute (generic, internal
+ * use).
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class ID (C identifier).
+ * _type: Component class type (`source`, `filter`, or `sink`).
+ * _attr_name: Name of the attribute (C identifier).
+ * _attr_type: Type of the attribute
+ * (enum __bt_plugin_descriptor_attribute_type).
+ * _x: Value.
+ */
+#define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(_attr_name, _attr_type, _id, _comp_class_id, _type, _x) \
+ static struct __bt_plugin_component_class_descriptor_attribute __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name = { \
+ .comp_class_descriptor = &__bt_plugin_##_type##_component_class_descriptor_##_id##_##_comp_class_id, \
+ .type_name = #_attr_name, \
+ .type = _attr_type, \
+ .value._attr_name = _x, \
+ }; \
+ static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name
+
+/*
+ * Defines a description attribute attached to a specific source
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a description attribute attached to a specific filter
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a description attribute attached to a specific sink
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(description, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines a help attribute attached to a specific source component
+ * class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a help attribute attached to a specific filter component
+ * class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a help attribute attached to a specific sink component class
+ * descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_HELP_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(help, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_source_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_filter_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an initialization method attribute attached to a specific
+ * sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Initialization method (bt_component_class_sink_init_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines a finalization method attribute attached to a specific source
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_source_finalize_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a finalization method attribute attached to a specific filter
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_filter_finalize_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a finalization method attribute attached to a specific sink
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_sink_finalize_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines a query method attribute attached to a specific source
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_source_query_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines a query method attribute attached to a specific filter
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_filter_query_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a query method attribute attached to a specific sink
+ * component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Finalize method (bt_component_class_sink_query_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an accept input port connection method attribute attached to
+ * a specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_filter_accept_input_port_connection_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an accept input port connection method attribute attached to
+ * a specific sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_sink_accept_input_port_connection_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_accept_input_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an accept output port connection method attribute attached to
+ * a specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_source_accept_output_port_connection_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an accept output port connection method attribute attached to
+ * a specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_filter_accept_output_port_connection_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_accept_output_port_connection_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an input port connected method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Port connected method
+ * (bt_component_class_filter_input_port_connected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an input port connected method attribute attached to a
+ * specific sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Port connected method
+ * (bt_component_class_sink_input_port_connected_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_input_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an output port connected method attribute attached to a
+ * specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Port connected method
+ * (bt_component_class_source_output_port_connected_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an output port connected method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Port connected method
+ * (bt_component_class_filter_output_port_connected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_output_port_connected_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a "graph is configured" method attribute attached to a
+ * specific sink component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: "Graph is configured" method
+ * (bt_component_class_sink_graph_is_configured_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_graph_is_configured_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD, _id, _comp_class_id, sink, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator initialization method
+ * (bt_component_class_source_message_iterator_init_method).
+ */
+#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
+ * source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator finalize method
+ * (bt_component_class_source_message_iterator_finalize_method).
+ */
+#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 "seek nanoseconds from origin" method attribute
+ * attached to a specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "seek nanoseconds from origin" method
+ * (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator "seek beginning" method attribute attached to a
+ * specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "seek beginning" method
+ * (bt_component_class_source_message_iterator_seek_beginning_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator "can seek nanoseconds from origin" method
+ * attribute attached to a specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "can seek nanoseconds from origin" method
+ * (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator "can seek beginning" method attribute attached to a
+ * specific source component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "can seek beginning" method
+ * (bt_component_class_source_message_iterator_can_seek_beginning_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator initialization method
+ * (bt_component_class_filter_message_iterator_init_method).
+ */
+#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
+ * filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator finalize method
+ * (bt_component_class_filter_message_iterator_finalize_method).
+ */
+#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 an iterator "seek nanoseconds from origin" method attribute
+ * attached to a specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "seek nanoseconds from origin" method
+ * (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an iterator "seek beginning" method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "seek beginning" method
+ * (bt_component_class_filter_message_iterator_seek_beginning_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an iterator "can seek nanoseconds from origin" method
+ * attribute attached to a specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "can seek nanoseconds from origin" method
+ * (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines an iterator "can seek beginning" method attribute attached to a
+ * specific filter component class descriptor.
+ *
+ * _id: Plugin descriptor ID (C identifier).
+ * _comp_class_id: Component class descriptor ID (C identifier).
+ * _x: Iterator "can seek beginning" method
+ * (bt_component_class_filter_message_iterator_can_seek_beginning_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _x)
+
+/*
+ * Defines a plugin descriptor with an automatic ID.
+ *
+ * _name: Plugin's name (C string).
+ */
+#define BT_PLUGIN(_name) static BT_PLUGIN_WITH_ID(auto, #_name)
+
+/*
+ * Defines a plugin initialization function attribute attached to the
+ * automatic plugin descriptor.
+ *
+ * _x: Initialization function (bt_plugin_init_func).
+ */
+#define BT_PLUGIN_INIT(_x) BT_PLUGIN_INIT_WITH_ID(auto, _x)
+
+ /*
+ * Defines a plugin exit function attribute attached to the automatic
+ * plugin descriptor.
+ *
+ * _x: Exit function (bt_plugin_exit_func).
+ */
+#define BT_PLUGIN_EXIT(_x) BT_PLUGIN_EXIT_WITH_ID(auto, _x)
+
+/*
+ * Defines an author attribute attached to the automatic plugin
+ * descriptor.
+ *
+ * _x: Author (C string).
+ */
+#define BT_PLUGIN_AUTHOR(_x) BT_PLUGIN_AUTHOR_WITH_ID(auto, _x)
+
+/*
+ * Defines a license attribute attached to the automatic plugin
+ * descriptor.
+ *
+ * _x: License (C string).
+ */
+#define BT_PLUGIN_LICENSE(_x) BT_PLUGIN_LICENSE_WITH_ID(auto, _x)
+
+/*
+ * Defines a description attribute attached to the automatic plugin
+ * descriptor.
+ *
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_DESCRIPTION(_x) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _x)
+
+/*
+ * Defines a version attribute attached to the automatic plugin
+ * descriptor.
+ *
+ * _major: Plugin's major version (uint32_t).
+ * _minor: Plugin's minor version (uint32_t).
+ * _patch: Plugin's patch version (uint32_t).
+ * _extra: Plugin's version extra information (C string).
+ */
+#define BT_PLUGIN_VERSION(_major, _minor, _patch, _extra) BT_PLUGIN_VERSION_WITH_ID(auto, _major, _minor, _patch, _extra)
+
+/*
+ * Defines a source component class attached to the automatic plugin
+ * descriptor. Its ID is the same as its name, hence its name must be a
+ * C identifier in this version.
+ *
+ * _name: Component class name (C identifier).
+ * _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, _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
+ * descriptor. Its ID is the same as its name, hence its name must be a
+ * C identifier in this version.
+ *
+ * _name: Component class name (C identifier).
+ * _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, _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
+ * descriptor. Its ID is the same as its name, hence its name must be a
+ * C identifier in this version.
+ *
+ * _name: Component class name (C identifier).
+ * _consume_method: Component class's consume method
+ * (bt_component_class_sink_consume_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS(_name, _consume_method) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _consume_method)
+
+/*
+ * Defines a description attribute attached to a source component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a description attribute attached to a filter component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a description attribute attached to a sink component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Description (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a help attribute attached to a source component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a help attribute attached to a filter component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a help attribute attached to a sink component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Help (C string).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_HELP_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a source
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_source_init_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_filter_init_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an initialization method attribute attached to a sink
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_sink_init_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a finalization method attribute attached to a source component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_source_finalize_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a finalization method attribute attached to a filter component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_filter_finalize_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a finalization method attribute attached to a sink component class
+ * descriptor which is attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_sink_finalize_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a query method attribute attached to a source component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_source_query_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a query method attribute attached to a filter component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_filter_query_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a query method attribute attached to a sink component
+ * class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Initialization method (bt_component_class_sink_query_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an accept input port connection method attribute attached to
+ * a filter component class descriptor which is attached to the
+ * automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_filter_accept_input_port_connection_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an accept input port connection method attribute attached to
+ * a sink component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_sink_accept_input_port_connection_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_INPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an accept output port connection method attribute attached to
+ * a source component class descriptor which is attached to the
+ * automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_source_accept_output_port_connection_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an accept output port connection method attribute attached to
+ * a filter component class descriptor which is attached to the
+ * automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Accept port connection method
+ * (bt_component_class_filter_accept_output_port_connection_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an input port connected method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port connected (bt_component_class_filter_input_port_connected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an input port connected method attribute attached to a sink
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port connected (bt_component_class_sink_input_port_connected_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_INPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an output port connected method attribute attached to a source
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port connected (bt_component_class_source_output_port_connected_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an output port connected method attribute attached to a filter
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Port connected (bt_component_class_filter_output_port_connected_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_OUTPUT_PORT_CONNECTED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines a "graph is configured" method attribute attached to
+ * a sink component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: "Graph is configured" method
+ * (bt_component_class_sink_graph_is_configured_method).
+ */
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * source component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator initialization method
+ * (bt_component_class_source_message_iterator_init_method).
+ */
+#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
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator finalize method
+ * (bt_component_class_source_message_iterator_finalize_method).
+ */
+#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 "seek nanoseconds from origin" method attribute
+ * attached to a source component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "seek nanoseconds from origin" method
+ * (bt_component_class_source_message_iterator_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "seek beginning" method attribute
+ * attached to a source component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "seek beginning" method
+ * (bt_component_class_source_message_iterator_seek_beginning_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "can seek nanoseconds from origin" method
+ * attribute attached to a source component class descriptor which is
+ * attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "can seek nanoseconds from origin" method
+ * (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "can seek beginning" method attribute
+ * attached to a source component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "can seek beginning" method
+ * (bt_component_class_source_message_iterator_can_seek_beginning_method).
+ */
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator initialization method attribute attached to a
+ * filter component class descriptor which is attached to the automatic
+ * plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator initialization method
+ * (bt_component_class_filter_message_iterator_init_method).
+ */
+#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
+ * component class descriptor which is attached to the automatic plugin
+ * descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator finalize method
+ * (bt_component_class_filter_message_iterator_finalize_method).
+ */
+#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)
+
+/*
+ * Defines an iterator "seek nanoseconds from origin" method attribute
+ * attached to a filter component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "seek nanoseconds from origin" method
+ * (bt_component_class_filter_message_iterator_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "seek beginning" method attribute
+ * attached to a filter component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "seek beginning" method
+ * (bt_component_class_filter_message_iterator_seek_beginning_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "can seek nanoseconds from origin" method
+ * attribute attached to a filter component class descriptor which is
+ * attached to the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "can seek nanoseconds from origin" method
+ * (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_WITH_ID(auto, _name, _x)
+
+/*
+ * Defines an iterator "can seek beginning" method attribute
+ * attached to a filter component class descriptor which is attached to
+ * the automatic plugin descriptor.
+ *
+ * _name: Component class name (C identifier).
+ * _x: Iterator "can seek beginning" method
+ * (bt_component_class_filter_message_iterator_can_seek_beginning_method).
+ */
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_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; \
+ _BT_HIDDEN extern struct __bt_plugin_descriptor const *__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL __BT_PLUGIN_DESCRIPTOR_BEGIN_EXTRA; \
+ _BT_HIDDEN extern struct __bt_plugin_descriptor const *__BT_PLUGIN_DESCRIPTOR_END_SYMBOL __BT_PLUGIN_DESCRIPTOR_END_EXTRA; \
+ \
+ static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_dummy __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = NULL; \
+ _BT_HIDDEN extern struct __bt_plugin_descriptor_attribute const *__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
+ _BT_HIDDEN extern struct __bt_plugin_descriptor_attribute const *__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
+ \
+ static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_component_class_descriptor_dummy __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = NULL; \
+ _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_EXTRA; \
+ _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_EXTRA; \
+ \
+ static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_component_class_descriptor_attribute_dummy __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = NULL; \
+ _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
+ _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
+ \
+ struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
+ { \
+ return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \
+ } \
+ struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
+ { \
+ return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \
+ } \
+ struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
+ { \
+ return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
+ } \
+ struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
+ { \
+ return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
+ } \
+ struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
+ { \
+ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \
+ } \
+ struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
+ { \
+ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \
+ } \
+ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
+ { \
+ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
+ } \
+ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
+ { \
+ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_DEV_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
+#define BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-dev.h>
+#include <babeltrace2/plugin/plugin-so-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+#include <glib.h>
+
+enum bt_plugin_type {
+ BT_PLUGIN_TYPE_SO = 0,
+ BT_PLUGIN_TYPE_PYTHON = 1,
+};
+
+enum bt_plugin_status {
+ BT_PLUGIN_STATUS_OK = 0,
+ BT_PLUGIN_STATUS_ERROR = -1,
+ BT_PLUGIN_STATUS_NOMEM = -12,
+};
+
+struct bt_plugin {
+ struct bt_object base;
+ enum bt_plugin_type type;
+
+ /* Arrays of `struct bt_component_class *` (owned by this) */
+ GPtrArray *src_comp_classes;
+ GPtrArray *flt_comp_classes;
+ GPtrArray *sink_comp_classes;
+
+ /* Info (owned by this) */
+ struct {
+ GString *path;
+ GString *name;
+ GString *author;
+ GString *license;
+ GString *description;
+ struct {
+ unsigned int major;
+ unsigned int minor;
+ unsigned int patch;
+ GString *extra;
+ } version;
+ bool path_set;
+ bool name_set;
+ bool author_set;
+ bool license_set;
+ bool description_set;
+ bool version_set;
+ } info;
+
+ /* Value depends on the specific plugin type */
+ void *spec_data;
+ void (*destroy_spec_data)(struct bt_plugin *);
+};
+
+struct bt_plugin_set {
+ struct bt_object base;
+
+ /* Array of struct bt_plugin * */
+ GPtrArray *plugins;
+};
+
+static inline
+const char *bt_plugin_status_string(enum bt_plugin_status status)
+{
+ switch (status) {
+ case BT_PLUGIN_STATUS_OK:
+ return "BT_PLUGIN_STATUS_OK";
+ case BT_PLUGIN_STATUS_ERROR:
+ return "BT_PLUGIN_STATUS_ERROR";
+ case BT_PLUGIN_STATUS_NOMEM:
+ return "BT_PLUGIN_STATUS_NOMEM";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+const char *bt_plugin_type_string(enum bt_plugin_type type)
+{
+ switch (type) {
+ case BT_PLUGIN_TYPE_SO:
+ return "BT_PLUGIN_TYPE_SO";
+ case BT_PLUGIN_TYPE_PYTHON:
+ return "BT_PLUGIN_TYPE_PYTHON";
+ default:
+ return "(unknown)";
+ }
+}
+
+static inline
+void bt_plugin_destroy(struct bt_object *obj)
+{
+ struct bt_plugin *plugin;
+
+ BT_ASSERT(obj);
+ plugin = container_of(obj, struct bt_plugin, base);
+ BT_LIB_LOGD("Destroying plugin object: %!+l", plugin);
+
+ if (plugin->destroy_spec_data) {
+ plugin->destroy_spec_data(plugin);
+ }
+
+ if (plugin->src_comp_classes) {
+ BT_LOGD_STR("Putting source component classes.");
+ g_ptr_array_free(plugin->src_comp_classes, TRUE);
+ plugin->src_comp_classes = NULL;
+ }
+
+ if (plugin->flt_comp_classes) {
+ BT_LOGD_STR("Putting filter component classes.");
+ g_ptr_array_free(plugin->flt_comp_classes, TRUE);
+ plugin->flt_comp_classes = NULL;
+ }
+
+ if (plugin->sink_comp_classes) {
+ BT_LOGD_STR("Putting sink component classes.");
+ g_ptr_array_free(plugin->sink_comp_classes, TRUE);
+ plugin->sink_comp_classes = NULL;
+ }
+
+ if (plugin->info.name) {
+ g_string_free(plugin->info.name, TRUE);
+ plugin->info.name = NULL;
+ }
+
+ if (plugin->info.path) {
+ g_string_free(plugin->info.path, TRUE);
+ plugin->info.path = NULL;
+ }
+
+ if (plugin->info.description) {
+ g_string_free(plugin->info.description, TRUE);
+ plugin->info.description = NULL;
+ }
+
+ if (plugin->info.author) {
+ g_string_free(plugin->info.author, TRUE);
+ plugin->info.author = NULL;
+ }
+
+ if (plugin->info.license) {
+ g_string_free(plugin->info.license, TRUE);
+ plugin->info.license = NULL;
+ }
+
+ if (plugin->info.version.extra) {
+ g_string_free(plugin->info.version.extra, TRUE);
+ plugin->info.version.extra = NULL;
+ }
+
+ g_free(plugin);
+}
+
+static inline
+struct bt_plugin *bt_plugin_create_empty(enum bt_plugin_type type)
+{
+ struct bt_plugin *plugin = NULL;
+
+ BT_LOGD("Creating empty plugin object: type=%s",
+ bt_plugin_type_string(type));
+
+ plugin = g_new0(struct bt_plugin, 1);
+ if (!plugin) {
+ BT_LOGE_STR("Failed to allocate one plugin.");
+ goto error;
+ }
+
+ bt_object_init_shared(&plugin->base, bt_plugin_destroy);
+ plugin->type = type;
+
+ /* Create empty arrays of component classes */
+ plugin->src_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->src_comp_classes) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ plugin->flt_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->flt_comp_classes) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ plugin->sink_comp_classes =
+ g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin->sink_comp_classes) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ goto error;
+ }
+
+ /* Create empty info */
+ plugin->info.name = g_string_new(NULL);
+ if (!plugin->info.name) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ plugin->info.path = g_string_new(NULL);
+ if (!plugin->info.path) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ plugin->info.description = g_string_new(NULL);
+ if (!plugin->info.description) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ plugin->info.author = g_string_new(NULL);
+ if (!plugin->info.author) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ plugin->info.license = g_string_new(NULL);
+ if (!plugin->info.license) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ plugin->info.version.extra = g_string_new(NULL);
+ if (!plugin->info.version.extra) {
+ BT_LOGE_STR("Failed to allocate a GString.");
+ goto error;
+ }
+
+ BT_LIB_LOGD("Created empty plugin object: %!+l", plugin);
+ goto end;
+
+error:
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
+
+end:
+ return plugin;
+}
+
+static inline
+void bt_plugin_set_path(struct bt_plugin *plugin, const char *path)
+{
+ BT_ASSERT(plugin);
+ BT_ASSERT(path);
+ g_string_assign(plugin->info.path, path);
+ plugin->info.path_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, path=\"%s\"",
+ plugin, path);
+}
+
+static inline
+void bt_plugin_set_name(struct bt_plugin *plugin, const char *name)
+{
+ BT_ASSERT(plugin);
+ BT_ASSERT(name);
+ g_string_assign(plugin->info.name, name);
+ plugin->info.name_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's name: %![plugin-]+l, name=\"%s\"",
+ plugin, name);
+}
+
+static inline
+void bt_plugin_set_description(struct bt_plugin *plugin,
+ const char *description)
+{
+ BT_ASSERT(plugin);
+ BT_ASSERT(description);
+ g_string_assign(plugin->info.description, description);
+ plugin->info.description_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's description: %![plugin-]+l", plugin);
+}
+
+static inline
+void bt_plugin_set_author(struct bt_plugin *plugin, const char *author)
+{
+ BT_ASSERT(plugin);
+ BT_ASSERT(author);
+ g_string_assign(plugin->info.author, author);
+ plugin->info.author_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's author: %![plugin-]+l, author=\"%s\"",
+ plugin, author);
+}
+
+static inline
+void bt_plugin_set_license(struct bt_plugin *plugin, const char *license)
+{
+ BT_ASSERT(plugin);
+ BT_ASSERT(license);
+ g_string_assign(plugin->info.license, license);
+ plugin->info.license_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's path: %![plugin-]+l, license=\"%s\"",
+ plugin, license);
+}
+
+static inline
+void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major,
+ unsigned int minor, unsigned int patch, const char *extra)
+{
+ BT_ASSERT(plugin);
+ plugin->info.version.major = major;
+ plugin->info.version.minor = minor;
+ plugin->info.version.patch = patch;
+
+ if (extra) {
+ g_string_assign(plugin->info.version.extra, extra);
+ }
+
+ plugin->info.version_set = BT_TRUE;
+ BT_LIB_LOGV("Set plugin's version: %![plugin-]+l, "
+ "major=%u, minor=%u, patch=%u, extra=\"%s\"",
+ plugin, major, minor, patch, extra);
+}
+
+static inline
+enum bt_plugin_status bt_plugin_add_component_class(
+ struct bt_plugin *plugin, struct bt_component_class *comp_class)
+{
+ GPtrArray *comp_classes;
+
+ BT_ASSERT(plugin);
+ BT_ASSERT(comp_class);
+
+ switch (comp_class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ comp_classes = plugin->src_comp_classes;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ comp_classes = plugin->flt_comp_classes;
+ break;
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ comp_classes = plugin->sink_comp_classes;
+ break;
+ default:
+ abort();
+ }
+
+ /* Add new component class */
+ bt_object_get_ref(comp_class);
+ g_ptr_array_add(comp_classes, comp_class);
+
+ /* Special case for a shared object plugin */
+ if (plugin->type == BT_PLUGIN_TYPE_SO) {
+ bt_plugin_so_on_add_component_class(plugin, comp_class);
+ }
+
+ BT_LIB_LOGD("Added component class to plugin: "
+ "%![plugin-]+l, %![cc-]+C", plugin, comp_class);
+ return BT_PLUGIN_STATUS_OK;
+}
+
+static
+void bt_plugin_set_destroy(struct bt_object *obj)
+{
+ struct bt_plugin_set *plugin_set =
+ container_of(obj, struct bt_plugin_set, base);
+
+ if (!plugin_set) {
+ return;
+ }
+
+ BT_LOGD("Destroying plugin set: addr=%p", plugin_set);
+
+ if (plugin_set->plugins) {
+ BT_LOGD_STR("Putting plugins.");
+ g_ptr_array_free(plugin_set->plugins, TRUE);
+ }
+
+ g_free(plugin_set);
+}
+
+static inline
+struct bt_plugin_set *bt_plugin_set_create(void)
+{
+ struct bt_plugin_set *plugin_set = g_new0(struct bt_plugin_set, 1);
+
+ if (!plugin_set) {
+ goto end;
+ }
+
+ BT_LOGD_STR("Creating empty plugin set.");
+ bt_object_init_shared(&plugin_set->base, bt_plugin_set_destroy);
+
+ plugin_set->plugins = g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_object_put_ref);
+ if (!plugin_set->plugins) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
+ goto end;
+ }
+
+ BT_LOGD("Created empty plugin set: addr=%p", plugin_set);
+
+end:
+ return plugin_set;
+}
+
+static inline
+void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
+ struct bt_plugin *plugin)
+{
+ BT_ASSERT(plugin_set);
+ BT_ASSERT(plugin);
+ bt_object_get_ref(plugin);
+ g_ptr_array_add(plugin_set->plugins, plugin);
+ BT_LIB_LOGV("Added plugin to plugin set: "
+ "plugin-set-addr=%p, %![plugin-]+l",
+ plugin_set, plugin);
+}
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
+#define BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* For bt_plugin, bt_plugin_set */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern uint64_t bt_plugin_set_get_plugin_count(
+ const bt_plugin_set *plugin_set);
+
+extern const bt_plugin *bt_plugin_set_borrow_plugin_by_index_const(
+ const bt_plugin_set *plugin_set, uint64_t index);
+
+extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set);
+
+extern void bt_plugin_set_put_ref(const bt_plugin_set *plugin_set);
+
+#define BT_PLUGIN_SET_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_plugin_set_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PLUGIN_SET_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_plugin_set_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H
+#define BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <glib.h>
+#include <gmodule.h>
+#include <babeltrace2/types.h>
+
+struct bt_plugin;
+struct bt_component_class;
+
+struct bt_plugin_so_shared_lib_handle {
+ struct bt_object base;
+ GString *path;
+ GModule *module;
+
+ /* True if initialization function was called */
+ bt_bool init_called;
+ bt_plugin_exit_func exit;
+};
+
+struct bt_plugin_so_spec_data {
+ /* Shared lib. handle: owned by this */
+ struct bt_plugin_so_shared_lib_handle *shared_lib_handle;
+
+ /* Pointers to plugin's memory: do NOT free */
+ const struct __bt_plugin_descriptor *descriptor;
+ bt_plugin_init_func init;
+ const struct __bt_plugin_descriptor_version *version;
+};
+
+BT_HIDDEN
+struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path);
+
+BT_HIDDEN
+struct bt_plugin_set *bt_plugin_so_create_all_from_static(void);
+
+void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
+ struct bt_component_class *comp_class);
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_SO_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H
+#define BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/plugin/plugin-const.h>
+
+extern
+struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path);
+
+#endif /* BABELTRACE_PLUGIN_PYTHON_PLUGIN_PROVIDER_INTERNAL_H */
--- /dev/null
+#ifndef _BABELTRACE_PRIO_HEAP_H
+#define _BABELTRACE_PRIO_HEAP_H
+
+/*
+ * Static-sized priority heap containing pointers. Based on CLRS,
+ * chapter 6.
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <unistd.h>
+#include <babeltrace2/babeltrace-internal.h>
+
+struct ptr_heap {
+ size_t len, alloc_len;
+ void **ptrs;
+ int (*gt)(void *a, void *b);
+};
+
+#ifdef DEBUG_HEAP
+void check_heap(const struct ptr_heap *heap);
+#else
+static inline
+void check_heap(const struct ptr_heap *heap)
+{
+}
+#endif
+
+/**
+ * bt_heap_maximum - return the largest element in the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap, without performing any modification
+ * to the heap structure. Returns NULL if the heap is empty.
+ */
+static inline void *bt_heap_maximum(const struct ptr_heap *heap)
+{
+ check_heap(heap);
+ return likely(heap->len) ? heap->ptrs[0] : NULL;
+}
+
+/**
+ * bt_heap_init - initialize the heap
+ * @heap: the heap to initialize
+ * @alloc_len: number of elements initially allocated
+ * @gt: function to compare the elements
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_init(struct ptr_heap *heap,
+ size_t alloc_len,
+ int gt(void *a, void *b));
+
+/**
+ * bt_heap_free - free the heap
+ * @heap: the heap to free
+ */
+extern void bt_heap_free(struct ptr_heap *heap);
+
+/**
+ * bt_heap_insert - insert an element into the heap
+ * @heap: the heap to be operated on
+ * @p: the element to add
+ *
+ * Insert an element into the heap.
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_insert(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_remove - remove the largest element from the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. Returns NULL if the heap is empty.
+ */
+extern void *bt_heap_remove(struct ptr_heap *heap);
+
+/**
+ * bt_heap_cherrypick - remove a given element from the heap
+ * @heap: the heap to be operated on
+ * @p: the element
+ *
+ * Remove the given element from the heap. Return the element if present, else
+ * return NULL. This algorithm has a complexity of O(n), which is higher than
+ * O(log(n)) provided by the rest of this API.
+ */
+extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_replace_max - replace the the largest element from the heap
+ * @heap: the heap to be operated on
+ * @p: the pointer to be inserted as topmost element replacement
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. The heap is rebalanced only once after the insertion. Returns NULL if
+ * the heap is empty.
+ *
+ * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but
+ * it only rebalances the heap once. It never allocates memory.
+ */
+extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_copy - copy a heap
+ * @dst: the destination heap (must be allocated)
+ * @src: the source heap
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
+
+#endif /* _BABELTRACE_PRIO_HEAP_H */
--- /dev/null
+#ifndef BABELTRACE_PROPERTY_INTERNAL_H
+#define BABELTRACE_PROPERTY_INTERNAL_H
+
+/*
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/assert-internal.h>
+#include <babeltrace2/property.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+
+struct bt_property {
+ enum bt_property_availability avail;
+};
+
+struct bt_property_uint {
+ struct bt_property base;
+ uint64_t value;
+};
+
+static inline
+void bt_property_uint_set(struct bt_property_uint *prop, uint64_t value)
+{
+ BT_ASSERT(prop);
+ prop->base.avail = BT_PROPERTY_AVAILABILITY_AVAILABLE;
+ prop->value = value;
+}
+
+static inline
+void bt_property_uint_init(struct bt_property_uint *prop,
+ enum bt_property_availability avail, uint64_t value)
+{
+ BT_ASSERT(prop);
+ prop->base.avail = avail;
+ prop->value = value;
+}
+
+#endif /* BABELTRACE_PROPERTY_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_PROPERTY_H
+#define BABELTRACE_PROPERTY_H
+
+/*
+ * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_property_availability {
+ BT_PROPERTY_AVAILABILITY_AVAILABLE,
+ BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
+} bt_property_availability;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PROPERTY_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_ATTRIBUTES_H
+#define BABELTRACE_TRACE_IR_ATTRIBUTES_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+
+BT_HIDDEN
+struct bt_value *bt_attributes_create(void);
+
+BT_HIDDEN
+void bt_attributes_destroy(struct bt_value *attr_obj);
+
+BT_HIDDEN
+int64_t bt_attributes_get_count(const struct bt_value *attr_obj);
+
+BT_HIDDEN
+const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
+ uint64_t index);
+
+BT_HIDDEN
+struct bt_value *bt_attributes_borrow_field_value(
+ struct bt_value *attr_obj,
+ uint64_t index);
+
+BT_HIDDEN
+int bt_attributes_set_field_value(struct bt_value *attr_obj,
+ const char *name, struct bt_value *value_obj);
+
+BT_HIDDEN
+struct bt_value *bt_attributes_borrow_field_value_by_name(
+ struct bt_value *attr_obj, const char *name);
+
+BT_HIDDEN
+int bt_attributes_freeze(const struct bt_value *attr_obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_ATTRIBUTES_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H
+#define BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_bool, bt_uuid, bt_clock_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_clock_class_status {
+ BT_CLOCK_CLASS_STATUS_OK = 0,
+ BT_CLOCK_CLASS_STATUS_NOMEM = -12,
+ BT_CLOCK_CLASS_STATUS_OVERFLOW = -75,
+} bt_clock_class_status;
+
+extern const char *bt_clock_class_get_name(
+ const bt_clock_class *clock_class);
+
+extern const char *bt_clock_class_get_description(
+ const bt_clock_class *clock_class);
+
+extern uint64_t bt_clock_class_get_frequency(
+ const bt_clock_class *clock_class);
+
+extern uint64_t bt_clock_class_get_precision(
+ const bt_clock_class *clock_class);
+
+extern void bt_clock_class_get_offset(const bt_clock_class *clock_class,
+ int64_t *seconds, uint64_t *cycles);
+
+extern bt_bool bt_clock_class_origin_is_unix_epoch(
+ const bt_clock_class *clock_class);
+
+extern bt_uuid bt_clock_class_get_uuid(
+ const bt_clock_class *clock_class);
+
+extern bt_clock_class_status bt_clock_class_cycles_to_ns_from_origin(
+ const bt_clock_class *clock_class,
+ uint64_t cycles, int64_t *ns_from_origin);
+
+extern void bt_clock_class_get_ref(const bt_clock_class *clock_class);
+
+extern void bt_clock_class_put_ref(const bt_clock_class *clock_class);
+
+#define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_clock_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_CLOCK_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_clock_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/property-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <glib.h>
+
+struct bt_clock_class {
+ struct bt_object base;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } description;
+
+ uint64_t frequency;
+ uint64_t precision;
+ int64_t offset_seconds;
+ uint64_t offset_cycles;
+
+ struct {
+ uint8_t uuid[BABELTRACE_UUID_LEN];
+
+ /* NULL or `uuid` above */
+ bt_uuid value;
+ } uuid;
+
+ bool origin_is_unix_epoch;
+
+ /*
+ * This is computed every time you call
+ * bt_clock_class_set_frequency() or
+ * bt_clock_class_set_offset(), as well as initially. It is the
+ * base offset in nanoseconds including both `offset_seconds`
+ * and `offset_cycles` above in the result. It is used to
+ * accelerate future calls to
+ * bt_clock_snapshot_get_ns_from_origin() and
+ * bt_clock_class_cycles_to_ns_from_origin().
+ *
+ * `overflows` is true if the base offset cannot be computed
+ * because of an overflow.
+ */
+ struct {
+ int64_t value_ns;
+ bool overflows;
+ } base_offset;
+
+ /* Pool of `struct bt_clock_snapshot *` */
+ struct bt_object_pool cs_pool;
+
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_clock_class_freeze(const struct bt_clock_class *clock_class);
+
+#ifdef BT_DEV_MODE
+# define bt_clock_class_freeze _bt_clock_class_freeze
+#else
+# define bt_clock_class_freeze(_cc)
+#endif
+
+BT_HIDDEN
+bt_bool bt_clock_class_is_valid(struct bt_clock_class *clock_class);
+
+static inline
+int bt_clock_class_clock_value_from_ns_from_origin(
+ struct bt_clock_class *cc, int64_t ns_from_origin,
+ uint64_t *raw_value)
+{
+ BT_ASSERT(cc);
+
+ return bt_common_clock_value_from_ns_from_origin(cc->offset_seconds,
+ cc->offset_cycles, cc->frequency, ns_from_origin,
+ raw_value);
+}
+
+#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_H
+#define BABELTRACE_TRACE_IR_CLOCK_CLASS_H
+
+/*
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_bool, bt_uuid, bt_clock_class, bt_trace_class */
+#include <babeltrace2/types.h>
+
+/* For bt_clock_class_status */
+#include <babeltrace2/trace-ir/clock-class-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_clock_class *bt_clock_class_create(bt_self_component *self_comp);
+
+extern bt_clock_class_status bt_clock_class_set_name(
+ bt_clock_class *clock_class, const char *name);
+
+extern bt_clock_class_status bt_clock_class_set_description(
+ bt_clock_class *clock_class, const char *description);
+
+extern void bt_clock_class_set_frequency(bt_clock_class *clock_class,
+ uint64_t freq);
+
+extern void bt_clock_class_set_precision(bt_clock_class *clock_class,
+ uint64_t precision);
+
+extern void bt_clock_class_set_offset(bt_clock_class *clock_class,
+ int64_t seconds, uint64_t cycles);
+
+extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class *clock_class,
+ bt_bool origin_is_unix_epoch);
+
+extern void bt_clock_class_set_uuid(bt_clock_class *clock_class,
+ bt_uuid uuid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H
+#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_clock_class, bt_clock_snapshot */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_clock_snapshot_status {
+ BT_CLOCK_SNAPSHOT_STATUS_OK = 0,
+ BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW = -75,
+} bt_clock_snapshot_status;
+
+extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const(
+ const bt_clock_snapshot *clock_snapshot);
+
+extern uint64_t bt_clock_snapshot_get_value(
+ const bt_clock_snapshot *clock_snapshot);
+
+extern bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin(
+ const bt_clock_snapshot *clock_snapshot,
+ int64_t *ns_from_origin);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
+#define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+struct bt_clock_class;
+
+struct bt_clock_snapshot {
+ struct bt_object base;
+ struct bt_clock_class *clock_class;
+ uint64_t value_cycles;
+ bool ns_from_origin_overflows;
+ int64_t ns_from_origin;
+ bool is_set;
+};
+
+static inline
+void bt_clock_snapshot_set(struct bt_clock_snapshot *clock_snapshot)
+{
+ BT_ASSERT(clock_snapshot);
+ clock_snapshot->is_set = true;
+}
+
+static inline
+void bt_clock_snapshot_reset(struct bt_clock_snapshot *clock_snapshot)
+{
+ BT_ASSERT(clock_snapshot);
+ clock_snapshot->is_set = false;
+}
+
+static inline
+void set_ns_from_origin(struct bt_clock_snapshot *clock_snapshot)
+{
+ if (bt_util_ns_from_origin_clock_class(clock_snapshot->clock_class,
+ clock_snapshot->value_cycles,
+ &clock_snapshot->ns_from_origin)) {
+ clock_snapshot->ns_from_origin_overflows = true;
+ }
+}
+
+static inline
+void bt_clock_snapshot_set_raw_value(struct bt_clock_snapshot *clock_snapshot,
+ uint64_t cycles)
+{
+ BT_ASSERT(clock_snapshot);
+ clock_snapshot->value_cycles = cycles;
+ set_ns_from_origin(clock_snapshot);
+ bt_clock_snapshot_set(clock_snapshot);
+}
+
+BT_HIDDEN
+void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot);
+
+BT_HIDDEN
+struct bt_clock_snapshot *bt_clock_snapshot_new(struct bt_clock_class *clock_class);
+
+BT_HIDDEN
+struct bt_clock_snapshot *bt_clock_snapshot_create(
+ struct bt_clock_class *clock_class);
+
+BT_HIDDEN
+void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot);
+
+#endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H
+#define BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H
+
+/*
+ * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <glib.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/assert-internal.h>
+
+struct bt_clock_snapshot_set {
+ /* Unique objects owned by this */
+ GPtrArray *clock_snapshots;
+
+ /* Weak; points to one of the clock snapshots above */
+ struct bt_clock_snapshot *default_cs;
+};
+
+static inline
+int bt_clock_snapshot_set_initialize(struct bt_clock_snapshot_set *cs_set)
+{
+ int ret = 0;
+
+ cs_set->clock_snapshots = g_ptr_array_sized_new(1);
+ if (!cs_set->clock_snapshots) {
+#ifdef BT_LOGE_STR
+ BT_LOGE_STR("Failed to allocate one GPtrArray.");
+#endif
+
+ ret = -1;
+ goto end;
+ }
+
+ cs_set->default_cs = NULL;
+
+end:
+ return ret;
+}
+
+static inline
+void bt_clock_snapshot_set_reset(struct bt_clock_snapshot_set *cs_set)
+{
+ uint64_t i;
+
+ BT_ASSERT(cs_set);
+ BT_ASSERT(cs_set->clock_snapshots);
+
+ for (i = 0; i < cs_set->clock_snapshots->len; i++) {
+ struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i];
+
+ BT_ASSERT(cs);
+ bt_clock_snapshot_reset(cs);
+ }
+
+ cs_set->default_cs = NULL;
+}
+
+static inline
+void bt_clock_snapshot_set_finalize(struct bt_clock_snapshot_set *cs_set)
+{
+ uint64_t i;
+
+ BT_ASSERT(cs_set);
+
+ if (cs_set->clock_snapshots) {
+ for (i = 0; i < cs_set->clock_snapshots->len; i++) {
+ struct bt_clock_snapshot *cs =
+ cs_set->clock_snapshots->pdata[i];
+
+ BT_ASSERT(cs);
+ bt_clock_snapshot_recycle(cs);
+ }
+
+ g_ptr_array_free(cs_set->clock_snapshots, TRUE);
+ }
+
+ cs_set->default_cs = NULL;
+}
+
+static inline
+int bt_clock_snapshot_set_set_clock_snapshot(struct bt_clock_snapshot_set *cs_set,
+ struct bt_clock_class *cc, uint64_t raw_value)
+{
+ int ret = 0;
+ struct bt_clock_snapshot *clock_snapshot = NULL;
+ uint64_t i;
+
+ BT_ASSERT(cs_set);
+ BT_ASSERT(cc);
+
+ /*
+ * Check if we already have a value for this clock class.
+ *
+ * TODO: When we have many clock classes, make this more
+ * efficient.
+ */
+ for (i = 0; i < cs_set->clock_snapshots->len; i++) {
+ struct bt_clock_snapshot *cs = cs_set->clock_snapshots->pdata[i];
+
+ BT_ASSERT(cs);
+
+ if (cs->clock_class == cc) {
+ clock_snapshot = cs;
+ break;
+ }
+ }
+
+ if (!clock_snapshot) {
+ clock_snapshot = bt_clock_snapshot_create(cc);
+ if (!clock_snapshot) {
+#ifdef BT_LIB_LOGE
+ BT_LIB_LOGE("Cannot create a clock snapshot from a clock class: "
+ "%![cc-]+K", cc);
+#endif
+
+ ret = -1;
+ goto end;
+ }
+
+ g_ptr_array_add(cs_set->clock_snapshots, clock_snapshot);
+ }
+
+ bt_clock_snapshot_set_raw_value(clock_snapshot, raw_value);
+
+end:
+ return ret;
+}
+
+static inline
+void bt_clock_snapshot_set_set_default_clock_snapshot(
+ struct bt_clock_snapshot_set *cs_set, uint64_t raw_value)
+{
+ BT_ASSERT(cs_set);
+ BT_ASSERT(cs_set->default_cs);
+ bt_clock_snapshot_set_raw_value(cs_set->default_cs, raw_value);
+}
+
+#endif /* BABELTRACE_GRAPH_CLOCK_SNAPSHOT_SET_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H
+#define BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_property_availability */
+#include <babeltrace2/property.h>
+
+/* For bt_event_class, bt_field_class, bt_stream_class */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_event_class_status {
+ BT_EVENT_CLASS_STATUS_OK = 0,
+ BT_EVENT_CLASS_STATUS_NOMEM = -12,
+} bt_event_class_status;
+
+typedef enum bt_event_class_log_level {
+ BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY,
+ BT_EVENT_CLASS_LOG_LEVEL_ALERT,
+ BT_EVENT_CLASS_LOG_LEVEL_CRITICAL,
+ BT_EVENT_CLASS_LOG_LEVEL_ERROR,
+ BT_EVENT_CLASS_LOG_LEVEL_WARNING,
+ BT_EVENT_CLASS_LOG_LEVEL_NOTICE,
+ BT_EVENT_CLASS_LOG_LEVEL_INFO,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE,
+ BT_EVENT_CLASS_LOG_LEVEL_DEBUG,
+} bt_event_class_log_level;
+
+extern const bt_stream_class *bt_event_class_borrow_stream_class_const(
+ const bt_event_class *event_class);
+
+extern const char *bt_event_class_get_name(const bt_event_class *event_class);
+
+extern uint64_t bt_event_class_get_id(const bt_event_class *event_class);
+
+extern bt_property_availability bt_event_class_get_log_level(
+ const bt_event_class *event_class,
+ bt_event_class_log_level *log_level);
+
+extern const char *bt_event_class_get_emf_uri(
+ const bt_event_class *event_class);
+
+extern const bt_field_class *
+bt_event_class_borrow_specific_context_field_class_const(
+ const bt_event_class *event_class);
+
+extern const bt_field_class *bt_event_class_borrow_payload_field_class_const(
+ const bt_event_class *event_class);
+
+extern void bt_event_class_get_ref(const bt_event_class *event_class);
+
+extern void bt_event_class_put_ref(const bt_event_class *event_class);
+
+#define BT_EVENT_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_event_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_EVENT_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_event_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/property-internal.h>
+#include <glib.h>
+#include <stdbool.h>
+
+struct bt_event_class {
+ struct bt_object base;
+ struct bt_field_class *specific_context_fc;
+ struct bt_field_class *payload_fc;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ uint64_t id;
+ struct bt_property_uint log_level;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } emf_uri;
+
+ /* Pool of `struct bt_event *` */
+ struct bt_object_pool event_pool;
+
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_event_class_freeze(const struct bt_event_class *event_class);
+
+#ifdef BT_DEV_MODE
+# define bt_event_class_freeze _bt_event_class_freeze
+#else
+# define bt_event_class_freeze(_ec)
+#endif
+
+static inline
+struct bt_stream_class *bt_event_class_borrow_stream_class_inline(
+ const struct bt_event_class *event_class)
+{
+ BT_ASSERT(event_class);
+ return (void *) bt_object_borrow_parent(&event_class->base);
+}
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_CLASS_H
+#define BABELTRACE_TRACE_IR_EVENT_CLASS_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_event_class_status, bt_event_class_log_level */
+#include <babeltrace2/trace-ir/event-class-const.h>
+
+/* For bt_event_class, bt_stream_class */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_event_class *bt_event_class_create(
+ bt_stream_class *stream_class);
+
+extern bt_event_class *bt_event_class_create_with_id(
+ bt_stream_class *stream_class, uint64_t id);
+
+extern bt_stream_class *bt_event_class_borrow_stream_class(
+ bt_event_class *event_class);
+
+extern bt_event_class_status bt_event_class_set_name(
+ bt_event_class *event_class, const char *name);
+
+extern void bt_event_class_set_log_level(bt_event_class *event_class,
+ bt_event_class_log_level log_level);
+
+extern bt_event_class_status bt_event_class_set_emf_uri(
+ bt_event_class *event_class, const char *emf_uri);
+
+extern bt_event_class_status
+bt_event_class_set_specific_context_field_class(bt_event_class *event_class,
+ bt_field_class *field_class);
+
+extern bt_field_class *
+bt_event_class_borrow_specific_context_field_class(bt_event_class *event_class);
+
+extern bt_event_class_status bt_event_class_set_payload_field_class(
+ bt_event_class *event_class,
+ bt_field_class *field_class);
+
+extern bt_field_class *bt_event_class_borrow_payload_field_class(
+ bt_event_class *event_class);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_CONST_H
+#define BABELTRACE_TRACE_IR_EVENT_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_event, bt_event_class, bt_field, bt_packet */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_event_status {
+ BT_EVENT_STATUS_OK = 0,
+ BT_EVENT_STATUS_NOMEM = -12,
+} bt_event_status;
+
+extern const bt_event_class *bt_event_borrow_class_const(
+ const bt_event *event);
+
+extern const bt_packet *bt_event_borrow_packet_const(
+ const bt_event *event);
+
+extern const bt_stream *bt_event_borrow_stream_const(
+ const bt_event *event);
+
+extern const bt_field *bt_event_borrow_common_context_field_const(
+ const bt_event *event);
+
+extern const bt_field *bt_event_borrow_specific_context_field_const(
+ const bt_event *event);
+
+extern const bt_field *bt_event_borrow_payload_field_const(
+ const bt_event *event);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_INTERNAL_H
+#define BABELTRACE_TRACE_IR_EVENT_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ */
+
+/* Protection: this file uses BT_LIB_LOG*() macros directly */
+#ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
+# error Please define include <babeltrace2/lib-logging-internal.h> before including this file.
+#endif
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <glib.h>
+
+#define BT_ASSERT_PRE_EVENT_HOT(_event) \
+ BT_ASSERT_PRE_HOT(((const struct bt_event *) (_event)), \
+ "Event", ": %!+e", (_event))
+
+struct bt_event {
+ struct bt_object base;
+
+ /* Owned by this */
+ struct bt_event_class *class;
+
+ /* Owned by this */
+ struct bt_packet *packet;
+
+ struct bt_field *common_context_field;
+ struct bt_field *specific_context_field;
+ struct bt_field *payload_field;
+ bool frozen;
+};
+
+BT_HIDDEN
+void bt_event_destroy(struct bt_event *event);
+
+BT_HIDDEN
+struct bt_event *bt_event_new(struct bt_event_class *event_class);
+
+BT_HIDDEN
+void _bt_event_set_is_frozen(const struct bt_event *event, bool is_frozen);
+
+#ifdef BT_DEV_MODE
+# define bt_event_set_is_frozen _bt_event_set_is_frozen
+#else
+# define bt_event_set_is_frozen(_event, _is_frozen)
+#endif
+
+BT_UNUSED
+static inline
+void _bt_event_reset_dev_mode(struct bt_event *event)
+{
+ BT_ASSERT(event);
+
+ if (event->common_context_field) {
+ bt_field_set_is_frozen(
+ event->common_context_field, false);
+ bt_field_reset(
+ event->common_context_field);
+ }
+
+ if (event->specific_context_field) {
+ bt_field_set_is_frozen(
+ event->specific_context_field, false);
+ bt_field_reset(event->specific_context_field);
+ }
+
+ if (event->payload_field) {
+ bt_field_set_is_frozen(
+ event->payload_field, false);
+ bt_field_reset(event->payload_field);
+ }
+}
+
+#ifdef BT_DEV_MODE
+# define bt_event_reset_dev_mode _bt_event_reset_dev_mode
+#else
+# define bt_event_reset_dev_mode(_x)
+#endif
+
+static inline
+void bt_event_reset(struct bt_event *event)
+{
+ BT_ASSERT(event);
+ BT_LIB_LOGD("Resetting event: %!+e", event);
+ bt_event_set_is_frozen(event, false);
+ bt_object_put_no_null_check(&event->packet->base);
+ event->packet = NULL;
+}
+
+static inline
+void bt_event_recycle(struct bt_event *event)
+{
+ struct bt_event_class *event_class;
+
+ BT_ASSERT(event);
+ BT_LIB_LOGD("Recycling event: %!+e", event);
+
+ /*
+ * Those are the important ordered steps:
+ *
+ * 1. Reset the event object (put any permanent reference it
+ * has, unfreeze it and its fields in developer mode, etc.),
+ * but do NOT put its class's reference. This event class
+ * contains the pool to which we're about to recycle this
+ * event object, so we must guarantee its existence thanks
+ * to this existing reference.
+ *
+ * 2. Move the event class reference to our `event_class`
+ * variable so that we can set the event's class member
+ * to NULL before recycling it. We CANNOT do this after
+ * we put the event class reference because this bt_object_put_ref()
+ * could destroy the event class, also destroying its
+ * event pool, thus also destroying our event object (this
+ * would result in an invalid write access).
+ *
+ * 3. Recycle the event object.
+ *
+ * 4. Put our event class reference.
+ */
+ bt_event_reset(event);
+ event_class = event->class;
+ BT_ASSERT(event_class);
+ event->class = NULL;
+ bt_object_pool_recycle_object(&event_class->event_pool, event);
+ bt_object_put_no_null_check(&event_class->base);
+}
+
+static inline
+void bt_event_set_packet(struct bt_event *event, struct bt_packet *packet)
+{
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+ BT_ASSERT_PRE_NON_NULL(packet, "Packet");
+ BT_ASSERT_PRE_EVENT_HOT(event);
+ BT_ASSERT_PRE(bt_event_class_borrow_stream_class(
+ event->class) == packet->stream->class,
+ "Packet's stream class and event's stream class differ: "
+ "%![event-]+e, %![packet-]+a", event, packet);
+
+ BT_ASSERT(!event->packet);
+ event->packet = packet;
+ bt_object_get_no_null_check_no_parent_check(&event->packet->base);
+ BT_LIB_LOGV("Set event's packet: %![event-]+e, %![packet-]+a",
+ event, packet);
+}
+
+static inline
+struct bt_event *bt_event_create(struct bt_event_class *event_class,
+ struct bt_packet *packet)
+{
+ struct bt_event *event = NULL;
+
+ BT_ASSERT(event_class);
+ event = bt_object_pool_create_object(&event_class->event_pool);
+ if (unlikely(!event)) {
+ BT_LIB_LOGE("Cannot allocate one event from event class's event pool: "
+ "%![ec-]+E", event_class);
+ goto end;
+ }
+
+ if (likely(!event->class)) {
+ event->class = event_class;
+ bt_object_get_no_null_check(&event_class->base);
+ }
+
+ BT_ASSERT(packet);
+ bt_event_set_packet(event, packet);
+ goto end;
+
+end:
+ return event;
+}
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_EVENT_H
+#define BABELTRACE_TRACE_IR_EVENT_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_event, bt_event_class, bt_field, bt_packet */
+#include <babeltrace2/types.h>
+
+/* For bt_event_status */
+#include <babeltrace2/trace-ir/event-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_event_class *bt_event_borrow_class(bt_event *event);
+
+extern bt_packet *bt_event_borrow_packet(bt_event *event);
+
+extern bt_stream *bt_event_borrow_stream(bt_event *event);
+
+extern bt_field *
+bt_event_borrow_common_context_field(bt_event *event);
+
+extern bt_field *
+bt_event_borrow_specific_context_field(bt_event *event);
+
+extern bt_field *bt_event_borrow_payload_field(bt_event *event);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_EVENT_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/*
+ * For bt_bool, bt_field_class, bt_field_path,
+ * bt_field_class_enumeration_mapping,
+ * bt_field_class_unsigned_enumeration_mapping,
+ * bt_field_class_signed_enumeration_mapping,
+ * bt_field_class_enumeration_mapping_label_array, __BT_UPCAST_CONST
+ */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_field_class_status {
+ BT_FIELD_CLASS_STATUS_OK = 0,
+ BT_FIELD_CLASS_STATUS_NOMEM = -12,
+} bt_field_class_status;
+
+typedef enum bt_field_class_type {
+ BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
+ BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
+ BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
+ BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
+ BT_FIELD_CLASS_TYPE_REAL,
+ BT_FIELD_CLASS_TYPE_STRING,
+ BT_FIELD_CLASS_TYPE_STRUCTURE,
+ BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+ BT_FIELD_CLASS_TYPE_VARIANT,
+} bt_field_class_type;
+
+typedef enum bt_field_class_integer_preferred_display_base {
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
+ BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
+} bt_field_class_integer_preferred_display_base;
+
+extern bt_field_class_type bt_field_class_get_type(
+ const bt_field_class *field_class);
+
+extern uint64_t bt_field_class_integer_get_field_value_range(
+ const bt_field_class *field_class);
+
+extern bt_field_class_integer_preferred_display_base
+bt_field_class_integer_get_preferred_display_base(
+ const bt_field_class *field_class);
+
+extern bt_bool bt_field_class_real_is_single_precision(
+ const bt_field_class *field_class);
+
+extern uint64_t bt_field_class_enumeration_get_mapping_count(
+ const bt_field_class *field_class);
+
+extern const bt_field_class_unsigned_enumeration_mapping *
+bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
+
+extern const bt_field_class_signed_enumeration_mapping *
+bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
+
+static inline
+const bt_field_class_enumeration_mapping *
+bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+ const bt_field_class_unsigned_enumeration_mapping *mapping)
+{
+ return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
+}
+
+static inline
+const bt_field_class_enumeration_mapping *
+bt_field_class_signed_enumeration_mapping_as_mapping_const(
+ const bt_field_class_signed_enumeration_mapping *mapping)
+{
+ return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
+}
+
+extern const char *bt_field_class_enumeration_mapping_get_label(
+ const bt_field_class_enumeration_mapping *mapping);
+
+extern uint64_t bt_field_class_enumeration_mapping_get_range_count(
+ const bt_field_class_enumeration_mapping *mapping);
+
+extern void
+bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ const bt_field_class_unsigned_enumeration_mapping *mapping,
+ uint64_t index, uint64_t *lower, uint64_t *upper);
+
+extern void
+bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ const bt_field_class_signed_enumeration_mapping *mapping,
+ uint64_t index, int64_t *lower, int64_t *upper);
+
+extern bt_field_class_status
+bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
+ const bt_field_class *field_class, uint64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern bt_field_class_status
+bt_field_class_signed_enumeration_get_mapping_labels_by_value(
+ const bt_field_class *field_class, int64_t value,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern uint64_t bt_field_class_structure_get_member_count(
+ const bt_field_class *field_class);
+
+extern const bt_field_class_structure_member *
+bt_field_class_structure_borrow_member_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
+
+extern const bt_field_class_structure_member *
+bt_field_class_structure_borrow_member_by_name_const(
+ const bt_field_class *field_class, const char *name);
+
+extern const char *bt_field_class_structure_member_get_name(
+ const bt_field_class_structure_member *member);
+
+extern const bt_field_class *
+bt_field_class_structure_member_borrow_field_class_const(
+ const bt_field_class_structure_member *member);
+
+extern const bt_field_class *
+bt_field_class_array_borrow_element_field_class_const(
+ const bt_field_class *field_class);
+
+extern uint64_t bt_field_class_static_array_get_length(
+ const bt_field_class *field_class);
+
+extern const bt_field_path *
+bt_field_class_dynamic_array_borrow_length_field_path_const(
+ const bt_field_class *field_class);
+
+extern const bt_field_path *
+bt_field_class_variant_borrow_selector_field_path_const(
+ const bt_field_class *field_class);
+
+extern uint64_t bt_field_class_variant_get_option_count(
+ const bt_field_class *field_class);
+
+extern const bt_field_class_variant_option *
+bt_field_class_variant_borrow_option_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
+
+extern const bt_field_class_variant_option *
+bt_field_class_variant_borrow_option_by_name_const(
+ const bt_field_class *field_class, const char *name);
+
+extern const char *bt_field_class_variant_option_get_name(
+ const bt_field_class_variant_option *option);
+
+extern const bt_field_class *
+bt_field_class_variant_option_borrow_field_class_const(
+ const bt_field_class_variant_option *option);
+
+extern void bt_field_class_get_ref(const bt_field_class *field_class);
+
+extern void bt_field_class_put_ref(const bt_field_class *field_class);
+
+#define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_field_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_field_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/types.h>
+#include <stdint.h>
+#include <glib.h>
+
+#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
+ _name " is not an integer field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
+ _name " is not an unsigned integer field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
+ _name " is not an enumeration field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
+ _name " is not an array field class: %![fc-]+F", (_fc))
+
+#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \
+ BT_ASSERT_PRE(((const struct bt_field_class *) (_fc))->type == (_type), \
+ _name " has the wrong type: expected-type=%s, " \
+ "%![fc-]+F", bt_common_field_class_type_string(_type), (_fc))
+
+#define BT_ASSERT_PRE_FC_HOT(_fc, _name) \
+ BT_ASSERT_PRE_HOT((const struct bt_field_class *) (_fc), \
+ (_name), ": %!+F", (_fc))
+
+#define BT_FIELD_CLASS_NAMED_FC_AT_INDEX(_fc, _index) \
+ (&g_array_index(((struct bt_field_class_named_field_class_container *) (_fc))->named_fcs, \
+ struct bt_named_field_class, (_index)))
+
+#define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \
+ (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
+ struct bt_field_class_enumeration_mapping, (_index)))
+
+#define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
+ (&g_array_index((_mapping)->ranges, \
+ struct bt_field_class_enumeration_mapping_range, (_index)))
+
+struct bt_field;
+struct bt_field_class;
+
+struct bt_field_class {
+ struct bt_object base;
+ enum bt_field_class_type type;
+ bool frozen;
+
+ /*
+ * Only used in developer mode, this flag indicates whether or
+ * not this field class is part of a trace class.
+ */
+ bool part_of_trace_class;
+};
+
+struct bt_field_class_integer {
+ struct bt_field_class common;
+
+ /*
+ * Value range of fields built from this integer field class:
+ * this is an equivalent integer size in bits. More formally,
+ * `range` is `n` in:
+ *
+ * Unsigned range: [0, 2^n - 1]
+ * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
+ */
+ uint64_t range;
+
+ enum bt_field_class_integer_preferred_display_base base;
+};
+
+struct bt_field_class_enumeration_mapping_range {
+ union {
+ uint64_t u;
+ int64_t i;
+ } lower;
+
+ union {
+ uint64_t u;
+ int64_t i;
+ } upper;
+};
+
+struct bt_field_class_enumeration_mapping {
+ GString *label;
+
+ /* Array of `struct bt_field_class_enumeration_mapping_range` */
+ GArray *ranges;
+};
+
+struct bt_field_class_unsigned_enumeration_mapping;
+struct bt_field_class_signed_enumeration_mapping;
+
+struct bt_field_class_enumeration {
+ struct bt_field_class_integer common;
+
+ /* Array of `struct bt_field_class_enumeration_mapping *` */
+ GArray *mappings;
+
+ /*
+ * This is an array of `const char *` which acts as a temporary
+ * (potentially growing) buffer for
+ * bt_field_class_unsigned_enumeration_get_mapping_labels_by_value()
+ * and
+ * bt_field_class_signed_enumeration_get_mapping_labels_by_value().
+ *
+ * The actual strings are owned by the mappings above.
+ */
+ GPtrArray *label_buf;
+};
+
+struct bt_field_class_real {
+ struct bt_field_class common;
+ bool is_single_precision;
+};
+
+struct bt_field_class_string {
+ struct bt_field_class common;
+};
+
+/* A named field class is a (name, field class) pair */
+struct bt_named_field_class {
+ GString *name;
+
+ /* Owned by this */
+ struct bt_field_class *fc;
+
+ bool frozen;
+};
+
+struct bt_field_class_structure_member;
+struct bt_field_class_variant_option;
+
+/*
+ * This is the base field class for a container of named field classes.
+ * Structure and variant field classes inherit this.
+ */
+struct bt_field_class_named_field_class_container {
+ struct bt_field_class common;
+
+ /*
+ * Key: `const char *`, not owned by this (owned by named field
+ * type objects contained in `named_fcs` below).
+ */
+ GHashTable *name_to_index;
+
+ /* Array of `struct bt_named_field_class` */
+ GArray *named_fcs;
+};
+
+struct bt_field_class_structure {
+ struct bt_field_class_named_field_class_container common;
+};
+
+struct bt_field_class_array {
+ struct bt_field_class common;
+
+ /* Owned by this */
+ struct bt_field_class *element_fc;
+};
+
+struct bt_field_class_static_array {
+ struct bt_field_class_array common;
+ uint64_t length;
+};
+
+struct bt_field_class_dynamic_array {
+ struct bt_field_class_array common;
+
+ /* Weak: never dereferenced, only use to find it elsewhere */
+ struct bt_field_class *length_fc;
+
+ /* Owned by this */
+ struct bt_field_path *length_field_path;
+};
+
+struct bt_field_class_variant {
+ struct bt_field_class_named_field_class_container common;
+
+ /* Weak: never dereferenced, only use to find it elsewhere */
+ struct bt_field_class *selector_fc;
+
+ /* Owned by this */
+ struct bt_field_path *selector_field_path;
+};
+
+static inline
+bool bt_field_class_has_known_type(const struct bt_field_class *fc)
+{
+ return fc->type >= BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER &&
+ fc->type <= BT_FIELD_CLASS_TYPE_VARIANT;
+}
+
+BT_HIDDEN
+void _bt_field_class_freeze(const struct bt_field_class *field_class);
+
+#ifdef BT_DEV_MODE
+# define bt_field_class_freeze _bt_field_class_freeze
+#else
+# define bt_field_class_freeze(_fc) ((void) _fc)
+#endif
+
+BT_HIDDEN
+void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc);
+
+#ifdef BT_DEV_MODE
+# define bt_named_field_class_freeze _bt_named_field_class_freeze
+#else
+# define bt_named_field_class_freeze(_named_fc) ((void) _named_fc)
+#endif
+
+/*
+ * This function recursively marks `field_class` and its children as
+ * being part of a trace. This is used to validate that all field classes
+ * are used at a single location within trace objects even if they are
+ * shared objects for other purposes.
+ */
+BT_HIDDEN
+void _bt_field_class_make_part_of_trace_class(
+ const struct bt_field_class *field_class);
+
+#ifdef BT_DEV_MODE
+# define bt_field_class_make_part_of_trace_class _bt_field_class_make_part_of_trace_class
+#else
+# define bt_field_class_make_part_of_trace_class(_fc) ((void) _fc)
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_H
+#define BABELTRACE_TRACE_IR_FIELD_CLASSES_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_bool, bt_field_class, bt_trace_class */
+#include <babeltrace2/types.h>
+
+/*
+ * For bt_field_class_status,
+ * bt_field_class_integer_preferred_display_base
+ */
+#include <babeltrace2/trace-ir/field-class-const.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_field_class *bt_field_class_unsigned_integer_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class *bt_field_class_signed_integer_create(
+ bt_trace_class *trace_class);
+
+extern void bt_field_class_integer_set_field_value_range(
+ bt_field_class *field_class, uint64_t size);
+
+extern void bt_field_class_integer_set_preferred_display_base(
+ bt_field_class *field_class,
+ bt_field_class_integer_preferred_display_base base);
+
+extern bt_field_class *bt_field_class_real_create(bt_trace_class *trace_class);
+
+extern void bt_field_class_real_set_is_single_precision(
+ bt_field_class *field_class,
+ bt_bool is_single_precision);
+
+extern bt_field_class *bt_field_class_unsigned_enumeration_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class *bt_field_class_signed_enumeration_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class_status bt_field_class_unsigned_enumeration_map_range(
+ bt_field_class *field_class, const char *label,
+ uint64_t range_lower, uint64_t range_upper);
+
+extern bt_field_class_status bt_field_class_signed_enumeration_map_range(
+ bt_field_class *field_class, const char *label,
+ int64_t range_lower, int64_t range_upper);
+
+extern bt_field_class *bt_field_class_string_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class *bt_field_class_structure_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class_status bt_field_class_structure_append_member(
+ bt_field_class *struct_field_class,
+ const char *name, bt_field_class *field_class);
+
+extern bt_field_class_structure_member *
+bt_field_class_structure_borrow_member_by_index(
+ bt_field_class *field_class, uint64_t index);
+
+extern bt_field_class_structure_member *
+bt_field_class_structure_borrow_member_by_name(
+ bt_field_class *field_class, const char *name);
+
+extern bt_field_class *bt_field_class_static_array_create(
+ bt_trace_class *trace_class,
+ bt_field_class *elem_field_class, uint64_t length);
+
+extern bt_field_class *bt_field_class_dynamic_array_create(
+ bt_trace_class *trace_class,
+ bt_field_class *elem_field_class);
+
+extern bt_field_class *bt_field_class_array_borrow_element_field_class(
+ bt_field_class *field_class);
+
+extern bt_field_class_status
+bt_field_class_dynamic_array_set_length_field_class(
+ bt_field_class *field_class,
+ bt_field_class *length_field_class);
+
+extern bt_field_class *bt_field_class_variant_create(
+ bt_trace_class *trace_class);
+
+extern bt_field_class_status
+bt_field_class_variant_set_selector_field_class(bt_field_class *field_class,
+ bt_field_class *selector_field_class);
+
+extern bt_field_class_status bt_field_class_variant_append_option(
+ bt_field_class *var_field_class,
+ const char *name, bt_field_class *field_class);
+
+extern bt_field_class_variant_option *
+bt_field_class_variant_borrow_option_by_index(
+ bt_field_class *field_class, uint64_t index);
+
+extern bt_field_class_variant_option *
+bt_field_class_variant_borrow_option_by_name(
+ bt_field_class *field_class, const char *name);
+
+extern bt_field_class *bt_field_class_variant_option_borrow_field_class(
+ bt_field_class_variant_option *option);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELDS_CONST_H
+#define BABELTRACE_TRACE_IR_FIELDS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_field_class_type */
+#include <babeltrace2/trace-ir/field-class.h>
+
+/* For bt_field, bt_field_class */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_field_status {
+ BT_FIELD_STATUS_OK = 0,
+ BT_FIELD_STATUS_NOMEM = -12,
+} bt_field_status;
+
+extern const bt_field_class *bt_field_borrow_class_const(
+ const bt_field *field);
+
+extern bt_field_class_type bt_field_get_class_type(
+ const bt_field *field);
+
+extern int64_t bt_field_signed_integer_get_value(const bt_field *field);
+
+extern uint64_t bt_field_unsigned_integer_get_value(
+ const bt_field *field);
+
+extern double bt_field_real_get_value(const bt_field *field);
+
+extern bt_field_status bt_field_unsigned_enumeration_get_mapping_labels(
+ const bt_field *field,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern bt_field_status bt_field_signed_enumeration_get_mapping_labels(
+ const bt_field *field,
+ bt_field_class_enumeration_mapping_label_array *label_array,
+ uint64_t *count);
+
+extern const char *bt_field_string_get_value(const bt_field *field);
+
+extern uint64_t bt_field_string_get_length(const bt_field *field);
+
+extern const bt_field *
+bt_field_structure_borrow_member_field_by_index_const(
+ const bt_field *field, uint64_t index);
+
+extern const bt_field *
+bt_field_structure_borrow_member_field_by_name_const(
+ const bt_field *field, const char *name);
+
+extern uint64_t bt_field_array_get_length(const bt_field *field);
+
+extern const bt_field *
+bt_field_array_borrow_element_field_by_index_const(
+ const bt_field *field, uint64_t index);
+
+extern uint64_t bt_field_variant_get_selected_option_field_index(
+ const bt_field *field);
+
+extern const bt_field *
+bt_field_variant_borrow_selected_option_field_const(
+ const bt_field *field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELDS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/types.h>
+#include <stdint.h>
+#include <string.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <glib.h>
+
+#define BT_ASSERT_PRE_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
+ BT_ASSERT_PRE(((const struct bt_field *) (_field))->class->type == (_cls_type), \
+ _name " has the wrong class type: expected-class-type=%s, " \
+ "%![field-]+f", \
+ bt_common_field_class_type_string(_cls_type), (_field))
+
+#define BT_ASSERT_PRE_FIELD_IS_UNSIGNED_INT(_field, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
+ _name " is not an unsigned integer field: %![field-]+f", \
+ (_field))
+
+#define BT_ASSERT_PRE_FIELD_IS_SIGNED_INT(_field, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
+ _name " is not a signed integer field: %![field-]+f", \
+ (_field))
+
+#define BT_ASSERT_PRE_FIELD_IS_ARRAY(_field, _name) \
+ BT_ASSERT_PRE( \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
+ _name " is not an array field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name) \
+ BT_ASSERT_PRE(bt_field_is_set(_field), \
+ _name " is not set: %!+f", (_field))
+
+#define BT_ASSERT_PRE_FIELD_HOT(_field, _name) \
+ BT_ASSERT_PRE_HOT((const struct bt_field *) (_field), (_name), \
+ ": %!+f", (_field))
+
+struct bt_field;
+
+typedef struct bt_field *(* bt_field_create_func)(struct bt_field_class *);
+typedef void (*bt_field_method_set_is_frozen)(struct bt_field *, bool);
+typedef bool (*bt_field_method_is_set)(const struct bt_field *);
+typedef void (*bt_field_method_reset)(struct bt_field *);
+
+struct bt_field_methods {
+ bt_field_method_set_is_frozen set_is_frozen;
+ bt_field_method_is_set is_set;
+ bt_field_method_reset reset;
+};
+
+struct bt_field {
+ struct bt_object base;
+
+ /* Owned by this */
+ struct bt_field_class *class;
+
+ /* Virtual table for slow path (dev mode) operations */
+ struct bt_field_methods *methods;
+
+ bool is_set;
+ bool frozen;
+};
+
+struct bt_field_integer {
+ struct bt_field common;
+
+ union {
+ uint64_t u;
+ int64_t i;
+ } value;
+};
+
+struct bt_field_real {
+ struct bt_field common;
+ double value;
+};
+
+struct bt_field_structure {
+ struct bt_field common;
+
+ /* Array of `struct bt_field *`, owned by this */
+ GPtrArray *fields;
+};
+
+struct bt_field_variant {
+ struct bt_field common;
+
+ /* Weak: belongs to `fields` below */
+ struct bt_field *selected_field;
+
+ /* Index of currently selected field */
+ uint64_t selected_index;
+
+ /* Array of `struct bt_field *`, owned by this */
+ GPtrArray *fields;
+};
+
+struct bt_field_array {
+ struct bt_field common;
+
+ /* Array of `struct bt_field *`, owned by this */
+ GPtrArray *fields;
+
+ /* Current effective length */
+ uint64_t length;
+};
+
+struct bt_field_string {
+ struct bt_field common;
+ GArray *buf;
+ uint64_t length;
+};
+
+#ifdef BT_DEV_MODE
+# define bt_field_set_is_frozen _bt_field_set_is_frozen
+# define bt_field_is_set _bt_field_is_set
+# define bt_field_reset _bt_field_reset
+# define bt_field_set_single _bt_field_set_single
+#else
+# define bt_field_set_is_frozen(_field, _is_frozen)
+# define bt_field_is_set(_field) (BT_FALSE)
+# define bt_field_reset(_field)
+# define bt_field_set_single(_field, _val)
+#endif
+
+BT_HIDDEN
+void _bt_field_set_is_frozen(const struct bt_field *field, bool is_frozen);
+
+static inline
+void _bt_field_reset(const struct bt_field *field)
+{
+ BT_ASSERT(field);
+ BT_ASSERT(field->methods->reset);
+ field->methods->reset((void *) field);
+}
+
+static inline
+void _bt_field_set_single(struct bt_field *field, bool value)
+{
+ BT_ASSERT(field);
+ field->is_set = value;
+}
+
+static inline
+bt_bool _bt_field_is_set(const struct bt_field *field)
+{
+ bt_bool is_set = BT_FALSE;
+
+ if (!field) {
+ goto end;
+ }
+
+ BT_ASSERT(bt_field_class_has_known_type(field->class));
+ BT_ASSERT(field->methods->is_set);
+ is_set = field->methods->is_set(field);
+
+end:
+ return is_set;
+}
+
+BT_HIDDEN
+struct bt_field *bt_field_create(struct bt_field_class *class);
+
+BT_HIDDEN
+void bt_field_destroy(struct bt_field *field);
+
+#endif /* BABELTRACE_TRACE_IR_FIELDS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H
+#define BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_field_path, bt_field_path_item */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_field_path_item_type {
+ BT_FIELD_PATH_ITEM_TYPE_INDEX,
+ BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT,
+} bt_field_path_item_type;
+
+typedef enum bt_scope {
+ BT_SCOPE_PACKET_CONTEXT,
+ BT_SCOPE_EVENT_COMMON_CONTEXT,
+ BT_SCOPE_EVENT_SPECIFIC_CONTEXT,
+ BT_SCOPE_EVENT_PAYLOAD,
+} bt_scope;
+
+extern bt_scope bt_field_path_get_root_scope(
+ const bt_field_path *field_path);
+
+extern uint64_t bt_field_path_get_item_count(
+ const bt_field_path *field_path);
+
+extern const bt_field_path_item *bt_field_path_borrow_item_by_index_const(
+ const bt_field_path *field_path, uint64_t index);
+
+extern bt_field_path_item_type bt_field_path_item_get_type(
+ const bt_field_path_item *field_path_item);
+
+extern uint64_t bt_field_path_item_index_get_index(
+ const bt_field_path_item *field_path_item);
+
+extern void bt_field_path_get_ref(const bt_field_path *field_path);
+
+extern void bt_field_path_put_ref(const bt_field_path *field_path);
+
+#define BT_FIELD_PATH_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_field_path_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_FIELD_PATH_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_field_path_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_PATH_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
+#define BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
+#include <babeltrace2/assert-internal.h>
+#include <glib.h>
+
+struct bt_field_path_item {
+ enum bt_field_path_item_type type;
+ uint64_t index;
+};
+
+struct bt_field_path {
+ struct bt_object base;
+ enum bt_scope root;
+
+ /* Array of `struct bt_field_path_item` (items) */
+ GArray *items;
+};
+
+BT_HIDDEN
+struct bt_field_path *bt_field_path_create(void);
+
+static inline
+struct bt_field_path_item *bt_field_path_borrow_item_by_index_inline(
+ const struct bt_field_path *field_path, uint64_t index)
+{
+ BT_ASSERT(field_path);
+ BT_ASSERT(index < field_path->items->len);
+ return &g_array_index(field_path->items, struct bt_field_path_item,
+ index);
+}
+
+static inline
+void bt_field_path_append_item(struct bt_field_path *field_path,
+ struct bt_field_path_item *item)
+{
+ BT_ASSERT(field_path);
+ BT_ASSERT(item);
+ g_array_append_val(field_path->items, *item);
+}
+
+static inline
+void bt_field_path_remove_last_item(struct bt_field_path *field_path)
+{
+ BT_ASSERT(field_path);
+ BT_ASSERT(field_path->items->len > 0);
+ g_array_set_size(field_path->items, field_path->items->len - 1);
+}
+
+static inline
+const char *bt_field_path_item_type_string(enum bt_field_path_item_type type)
+{
+ switch (type) {
+ case BT_FIELD_PATH_ITEM_TYPE_INDEX:
+ return "BT_FIELD_PATH_ITEM_TYPE_INDEX";
+ case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
+ return "BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT";
+ default:
+ return "(unknown)";
+ }
+};
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H
+#define BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H
+
+/*
+ * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/object-internal.h>
+
+struct bt_field_wrapper {
+ struct bt_object base;
+
+ /* Owned by this */
+ struct bt_field *field;
+};
+
+BT_HIDDEN
+struct bt_field_wrapper *bt_field_wrapper_new(void *data);
+
+BT_HIDDEN
+void bt_field_wrapper_destroy(struct bt_field_wrapper *field);
+
+BT_HIDDEN
+struct bt_field_wrapper *bt_field_wrapper_create(
+ struct bt_object_pool *pool, struct bt_field_class *fc);
+
+#endif /* BABELTRACE_TRACE_IR_FIELD_WRAPPER_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_FIELDS_H
+#define BABELTRACE_TRACE_IR_FIELDS_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_field, bt_field_class */
+#include <babeltrace2/types.h>
+
+/* For bt_field_status */
+#include <babeltrace2/trace-ir/field-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void bt_field_signed_integer_set_value(bt_field *field,
+ int64_t value);
+
+extern void bt_field_unsigned_integer_set_value(bt_field *field,
+ uint64_t value);
+
+extern void bt_field_real_set_value(bt_field *field, double value);
+
+extern bt_field_status bt_field_string_set_value(bt_field *field,
+ const char *value);
+
+extern bt_field_status bt_field_string_append(bt_field *field,
+ const char *value);
+
+extern bt_field_status bt_field_string_append_with_length(bt_field *field,
+ const char *value, uint64_t length);
+
+extern bt_field_status bt_field_string_clear(bt_field *field);
+
+extern bt_field *bt_field_structure_borrow_member_field_by_index(
+ bt_field *field, uint64_t index);
+
+extern bt_field *bt_field_structure_borrow_member_field_by_name(
+ bt_field *field, const char *name);
+
+extern bt_field *bt_field_array_borrow_element_field_by_index(
+ bt_field *field, uint64_t index);
+
+extern bt_field_status bt_field_dynamic_array_set_length(bt_field *field,
+ uint64_t length);
+
+extern bt_field_status bt_field_variant_select_option_field(
+ bt_field *field, uint64_t index);
+
+extern bt_field *bt_field_variant_borrow_selected_option_field(
+ bt_field *field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_FIELDS_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_PACKET_CONST_H
+#define BABELTRACE_TRACE_IR_PACKET_CONST_H
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/* For bt_property_availability */
+#include <babeltrace2/property.h>
+
+/*
+ * For bt_packet, bt_packet_context_field, bt_stream
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_packet_status {
+ BT_PACKET_STATUS_OK = 0,
+ BT_PACKET_STATUS_NOMEM = -12,
+} bt_packet_status;
+
+extern const bt_stream *bt_packet_borrow_stream_const(
+ const bt_packet *packet);
+
+extern
+const bt_field *bt_packet_borrow_context_field_const(
+ const bt_packet *packet);
+
+extern void bt_packet_get_ref(const bt_packet *packet);
+
+extern void bt_packet_put_ref(const bt_packet *packet);
+
+#define BT_PACKET_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_packet_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_PACKET_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_packet_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_PACKET_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H
+#define BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H
+
+/*
+ * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_stream_class, bt_packet_context_field, bt_field */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern
+bt_packet_context_field *bt_packet_context_field_create(
+ bt_stream_class *stream_class);
+
+extern
+bt_field *bt_packet_context_field_borrow_field(
+ bt_packet_context_field *field);
+
+extern
+void bt_packet_context_field_release(
+ bt_packet_context_field *field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_PACKET_CONTEXT_FIELD_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_PACKET_INTERNAL_H
+#define BABELTRACE_TRACE_IR_PACKET_INTERNAL_H
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdbool.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-const.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/property-internal.h>
+
+struct bt_packet {
+ struct bt_object base;
+ struct bt_field_wrapper *context_field;
+ struct bt_stream *stream;
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_packet_set_is_frozen(const struct bt_packet *packet, bool is_frozen);
+
+#ifdef BT_DEV_MODE
+# define bt_packet_set_is_frozen _bt_packet_set_is_frozen
+#else
+# define bt_packet_set_is_frozen(_packet, _is_frozen)
+#endif /* BT_DEV_MODE */
+
+BT_HIDDEN
+struct bt_packet *bt_packet_new(struct bt_stream *stream);
+
+BT_HIDDEN
+void bt_packet_recycle(struct bt_packet *packet);
+
+BT_HIDDEN
+void bt_packet_destroy(struct bt_packet *packet);
+
+#endif /* BABELTRACE_TRACE_IR_PACKET_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_PACKET_H
+#define BABELTRACE_TRACE_IR_PACKET_H
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_packet, bt_packet_context_field, bt_stream */
+#include <babeltrace2/types.h>
+
+/* For bt_packet_status */
+#include <babeltrace2/trace-ir/packet-const.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_packet *bt_packet_create(const bt_stream *stream);
+
+extern bt_stream *bt_packet_borrow_stream(bt_packet *packet);
+
+extern
+bt_field *bt_packet_borrow_context_field(bt_packet *packet);
+
+extern
+bt_packet_status bt_packet_move_context_field(bt_packet *packet,
+ bt_packet_context_field *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_PACKET_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL
+#define BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL
+
+/*
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/trace-ir/field-class-const.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
+#include <glib.h>
+
+struct bt_resolve_field_path_context {
+ struct bt_field_class *packet_context;
+ struct bt_field_class *event_common_context;
+ struct bt_field_class *event_specific_context;
+ struct bt_field_class *event_payload;
+};
+
+BT_HIDDEN
+int bt_resolve_field_paths(struct bt_field_class *field_class,
+ struct bt_resolve_field_path_context *ctx);
+
+#endif /* BABELTRACE_TRACE_IR_RESOLVE_FIELD_PATH_INTERNAL */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H
+#define BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/*
+ * For bt_bool, bt_trace_class, bt_stream_class, bt_event_class,
+ * bt_stream_class
+ */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_stream_class_status {
+ BT_STREAM_CLASS_STATUS_OK = 0,
+ BT_STREAM_CLASS_STATUS_NOMEM = -12,
+} bt_stream_class_status;
+
+extern const bt_trace_class *bt_stream_class_borrow_trace_class_const(
+ const bt_stream_class *stream_class);
+
+extern const char *bt_stream_class_get_name(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_assigns_automatic_event_class_id(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_assigns_automatic_stream_id(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_packets_have_end_default_clock_snapshot(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_supports_discarded_events(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_supports_discarded_packets(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots(
+ const bt_stream_class *stream_class);
+
+extern uint64_t bt_stream_class_get_id(
+ const bt_stream_class *stream_class);
+
+extern const bt_field_class *
+bt_stream_class_borrow_packet_context_field_class_const(
+ const bt_stream_class *stream_class);
+
+extern const bt_field_class *
+bt_stream_class_borrow_event_common_context_field_class_const(
+ const bt_stream_class *stream_class);
+
+extern uint64_t bt_stream_class_get_event_class_count(
+ const bt_stream_class *stream_class);
+
+extern const bt_event_class *
+bt_stream_class_borrow_event_class_by_index_const(
+ const bt_stream_class *stream_class, uint64_t index);
+
+extern const bt_event_class *
+bt_stream_class_borrow_event_class_by_id_const(
+ const bt_stream_class *stream_class, uint64_t id);
+
+extern const bt_clock_class *
+bt_stream_class_borrow_default_clock_class_const(
+ const bt_stream_class *stream_class);
+
+extern void bt_stream_class_get_ref(const bt_stream_class *stream_class);
+
+extern void bt_stream_class_put_ref(const bt_stream_class *stream_class);
+
+#define BT_STREAM_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_stream_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_STREAM_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_stream_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <glib.h>
+#include <inttypes.h>
+
+struct bt_stream_class {
+ struct bt_object base;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ uint64_t id;
+ bool assigns_automatic_event_class_id;
+ bool assigns_automatic_stream_id;
+ bool packets_have_beginning_default_clock_snapshot;
+ bool packets_have_end_default_clock_snapshot;
+ bool supports_discarded_events;
+ bool supports_discarded_packets;
+ bool discarded_events_have_default_clock_snapshots;
+ bool discarded_packets_have_default_clock_snapshots;
+ struct bt_field_class *packet_context_fc;
+ struct bt_field_class *event_common_context_fc;
+ struct bt_clock_class *default_clock_class;
+
+ /* Array of `struct bt_event_class *` */
+ GPtrArray *event_classes;
+
+ /* Pool of `struct bt_field_wrapper *` */
+ struct bt_object_pool packet_context_field_pool;
+
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_stream_class_freeze(const struct bt_stream_class *stream_class);
+
+#ifdef BT_DEV_MODE
+# define bt_stream_class_freeze _bt_stream_class_freeze
+#else
+# define bt_stream_class_freeze(_sc)
+#endif
+
+static inline
+struct bt_trace_class *bt_stream_class_borrow_trace_class_inline(
+ const struct bt_stream_class *stream_class)
+{
+ BT_ASSERT(stream_class);
+ return (void *) bt_object_borrow_parent(&stream_class->base);
+}
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_CLASS_H
+#define BABELTRACE_TRACE_IR_STREAM_CLASS_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+/*
+ * For bt_bool, bt_trace_class, bt_stream_class, bt_event_class,
+ * bt_clock_class
+ */
+#include <babeltrace2/types.h>
+
+/* For bt_stream_class_status */
+#include <babeltrace2/trace-ir/stream-class-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_stream_class *bt_stream_class_create(
+ bt_trace_class *trace_class);
+
+extern bt_stream_class *bt_stream_class_create_with_id(
+ bt_trace_class *trace_class, uint64_t id);
+
+extern bt_trace_class *bt_stream_class_borrow_trace_class(
+ bt_stream_class *stream_class);
+
+extern bt_stream_class_status bt_stream_class_set_name(
+ bt_stream_class *stream_class, const char *name);
+
+extern void bt_stream_class_set_assigns_automatic_event_class_id(
+ bt_stream_class *stream_class, bt_bool value);
+
+extern void bt_stream_class_set_assigns_automatic_stream_id(
+ bt_stream_class *stream_class, bt_bool value);
+
+extern void bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
+ bt_stream_class *stream_class, bt_bool value);
+
+extern void bt_stream_class_set_packets_have_end_default_clock_snapshot(
+ bt_stream_class *stream_class, bt_bool value);
+
+extern void bt_stream_class_set_supports_discarded_events(
+ bt_stream_class *stream_class,
+ bt_bool supports_discarded_events,
+ bt_bool with_default_clock_snapshots);
+
+extern void bt_stream_class_set_supports_discarded_packets(
+ bt_stream_class *stream_class,
+ bt_bool supports_discarded_packets,
+ bt_bool with_default_clock_snapshots);
+
+extern bt_stream_class_status
+bt_stream_class_set_packet_context_field_class(
+ bt_stream_class *stream_class,
+ bt_field_class *field_class);
+
+extern bt_field_class *
+bt_stream_class_borrow_packet_context_field_class(
+ bt_stream_class *stream_class);
+
+extern bt_stream_class_status
+bt_stream_class_set_event_common_context_field_class(
+ bt_stream_class *stream_class,
+ bt_field_class *field_class);
+
+extern bt_field_class *
+bt_stream_class_borrow_event_common_context_field_class(
+ bt_stream_class *stream_class);
+
+extern bt_event_class *
+bt_stream_class_borrow_event_class_by_index(
+ bt_stream_class *stream_class, uint64_t index);
+
+extern bt_event_class *
+bt_stream_class_borrow_event_class_by_id(
+ bt_stream_class *stream_class, uint64_t id);
+
+extern bt_clock_class *bt_stream_class_borrow_default_clock_class(
+ bt_stream_class *stream_class);
+
+extern bt_stream_class_status bt_stream_class_set_default_clock_class(
+ bt_stream_class *stream_class,
+ bt_clock_class *clock_class);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_CONST_H
+#define BABELTRACE_TRACE_IR_STREAM_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_trace, bt_stream, bt_stream_class */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_stream_status {
+ BT_STREAM_STATUS_OK = 0,
+ BT_STREAM_STATUS_NOMEM = -12,
+} bt_stream_status;
+
+extern const bt_stream_class *bt_stream_borrow_class_const(
+ const bt_stream *stream);
+
+extern const bt_trace *bt_stream_borrow_trace_const(
+ const bt_stream *stream);
+
+extern const char *bt_stream_get_name(const bt_stream *stream);
+
+extern uint64_t bt_stream_get_id(const bt_stream *stream);
+
+extern void bt_stream_get_ref(const bt_stream *stream);
+
+extern void bt_stream_put_ref(const bt_stream *stream);
+
+#define BT_STREAM_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_stream_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_STREAM_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_stream_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_INTERNAL_H
+#define BABELTRACE_TRACE_IR_STREAM_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <glib.h>
+
+struct bt_stream_class;
+struct bt_stream;
+
+struct bt_stream {
+ struct bt_object base;
+
+ /* Owned by this */
+ struct bt_stream_class *class;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ uint64_t id;
+
+ /* Pool of `struct bt_packet *` */
+ struct bt_object_pool packet_pool;
+
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_stream_freeze(const struct bt_stream *stream);
+
+#ifdef BT_DEV_MODE
+# define bt_stream_freeze _bt_stream_freeze
+#else
+# define bt_stream_freeze(_stream)
+#endif
+
+static inline
+struct bt_trace *bt_stream_borrow_trace_inline(const struct bt_stream *stream)
+{
+ BT_ASSERT(stream);
+ return (void *) bt_object_borrow_parent(&stream->base);
+}
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_STREAM_H
+#define BABELTRACE_TRACE_IR_STREAM_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_trace, bt_stream, bt_stream_class */
+#include <babeltrace2/types.h>
+
+/* For bt_stream_status */
+#include <babeltrace2/trace-ir/stream-const.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_stream *bt_stream_create(bt_stream_class *stream_class,
+ bt_trace *trace);
+
+extern bt_stream *bt_stream_create_with_id(
+ bt_stream_class *stream_class,
+ bt_trace *trace, uint64_t id);
+
+extern bt_trace *bt_stream_borrow_trace(bt_stream *stream);
+
+extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream);
+
+extern bt_stream_status bt_stream_set_name(bt_stream *stream,
+ const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_STREAM_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/*
+ * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class,
+ * bt_field_class, bt_value
+ */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_trace_class_status {
+ BT_TRACE_CLASS_STATUS_OK = 0,
+ BT_TRACE_CLASS_STATUS_NOMEM = -12,
+} bt_trace_class_status;
+
+typedef void (* bt_trace_class_destruction_listener_func)(
+ const bt_trace_class *trace_class, void *data);
+
+extern bt_bool bt_trace_class_assigns_automatic_stream_class_id(
+ const bt_trace_class *trace_class);
+
+extern const char *bt_trace_class_get_name(
+ const bt_trace_class *trace_class);
+
+extern bt_uuid bt_trace_class_get_uuid(
+ const bt_trace_class *trace_class);
+
+extern uint64_t bt_trace_class_get_environment_entry_count(
+ const bt_trace_class *trace_class);
+
+extern void bt_trace_class_borrow_environment_entry_by_index_const(
+ const bt_trace_class *trace_class, uint64_t index,
+ const char **name, const bt_value **value);
+
+extern const bt_value *
+bt_trace_class_borrow_environment_entry_value_by_name_const(
+ const bt_trace_class *trace_class, const char *name);
+
+extern uint64_t bt_trace_class_get_stream_class_count(
+ const bt_trace_class *trace_class);
+
+extern const bt_stream_class *
+bt_trace_class_borrow_stream_class_by_index_const(
+ const bt_trace_class *trace_class, uint64_t index);
+
+extern const bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const(
+ const bt_trace_class *trace_class, uint64_t id);
+
+extern bt_trace_class_status bt_trace_class_add_destruction_listener(
+ const bt_trace_class *trace_class,
+ bt_trace_class_destruction_listener_func listener,
+ void *data, uint64_t *listener_id);
+
+extern bt_trace_class_status bt_trace_class_remove_destruction_listener(
+ const bt_trace_class *trace_class, uint64_t listener_id);
+
+extern void bt_trace_class_get_ref(const bt_trace_class *trace_class);
+
+extern void bt_trace_class_put_ref(const bt_trace_class *trace_class);
+
+#define BT_TRACE_CLASS_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_trace_class_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_TRACE_CLASS_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_trace_class_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/trace-class.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+#include <sys/types.h>
+#include <babeltrace2/compat/uuid-internal.h>
+
+struct bt_trace_class {
+ struct bt_object base;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ struct {
+ uint8_t uuid[BABELTRACE_UUID_LEN];
+
+ /* NULL or `uuid` above */
+ bt_uuid value;
+ } uuid;
+
+ struct bt_value *environment;
+
+ /* Array of `struct bt_stream_class *` */
+ GPtrArray *stream_classes;
+
+ bool assigns_automatic_stream_class_id;
+ GArray *destruction_listeners;
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_trace_class_freeze(const struct bt_trace_class *trace_class);
+
+#ifdef BT_DEV_MODE
+# define bt_trace_class_freeze _bt_trace_class_freeze
+#else
+# define bt_trace_class_freeze(_tc)
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CLASS_H
+#define BABELTRACE_TRACE_IR_TRACE_CLASS_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/*
+ * For bt_bool, bt_uuid, bt_trace_class, bt_stream_class,
+ * bt_field_class, bt_self_component
+ */
+#include <babeltrace2/types.h>
+
+/* For bt_trace_class_status */
+#include <babeltrace2/trace-ir/trace-class-const.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_trace_class *bt_trace_class_create(bt_self_component *self_comp);
+
+extern void bt_trace_class_set_assigns_automatic_stream_class_id(
+ bt_trace_class *trace_class, bt_bool value);
+
+extern bt_trace_class_status bt_trace_class_set_name(
+ bt_trace_class *trace_class, const char *name);
+
+extern void bt_trace_class_set_uuid(bt_trace_class *trace_class,
+ bt_uuid uuid);
+
+extern bt_trace_class_status bt_trace_class_set_environment_entry_integer(
+ bt_trace_class *trace_class,
+ const char *name, int64_t value);
+
+extern bt_trace_class_status bt_trace_class_set_environment_entry_string(
+ bt_trace_class *trace_class,
+ const char *name, const char *value);
+
+extern bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
+ bt_trace_class *trace_class, uint64_t index);
+
+extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id(
+ bt_trace_class *trace_class, uint64_t id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CLASS_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_CONST_H
+#define BABELTRACE_TRACE_IR_TRACE_CONST_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/*
+ * For bt_bool, bt_uuid, bt_trace, bt_stream, bt_stream_class,
+ * bt_field_class, bt_value
+ */
+#include <babeltrace2/types.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_trace_status {
+ BT_TRACE_STATUS_OK = 0,
+ BT_TRACE_STATUS_NOMEM = -12,
+} bt_trace_status;
+
+typedef void (* bt_trace_destruction_listener_func)(
+ const bt_trace *trace, void *data);
+
+extern const bt_trace_class *bt_trace_borrow_class_const(
+ const bt_trace *trace);
+
+extern const char *bt_trace_get_name(const bt_trace *trace);
+
+extern uint64_t bt_trace_get_stream_count(const bt_trace *trace);
+
+extern const bt_stream *bt_trace_borrow_stream_by_index_const(
+ const bt_trace *trace, uint64_t index);
+
+extern const bt_stream *bt_trace_borrow_stream_by_id_const(
+ const bt_trace *trace, uint64_t id);
+
+extern bt_trace_status bt_trace_add_destruction_listener(
+ const bt_trace *trace,
+ bt_trace_destruction_listener_func listener,
+ void *data, uint64_t *listener_id);
+
+extern bt_trace_status bt_trace_remove_destruction_listener(
+ const bt_trace *trace, uint64_t listener_id);
+
+extern void bt_trace_get_ref(const bt_trace *trace);
+
+extern void bt_trace_put_ref(const bt_trace *trace);
+
+#define BT_TRACE_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_trace_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_TRACE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_trace_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_INTERNAL_H
+#define BABELTRACE_TRACE_IR_TRACE_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/trace-class-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+#include <sys/types.h>
+#include <babeltrace2/compat/uuid-internal.h>
+
+struct bt_trace {
+ struct bt_object base;
+
+ /* Owned by this */
+ struct bt_trace_class *class;
+
+ struct {
+ GString *str;
+
+ /* NULL or `str->str` above */
+ const char *value;
+ } name;
+
+ /* Array of `struct bt_stream *` */
+ GPtrArray *streams;
+
+ /*
+ * Stream class (weak, owned by owned trace class) to number of
+ * instantiated streams, used to automatically assign stream IDs
+ * per stream class within this trace.
+ */
+ GHashTable *stream_classes_stream_count;
+
+ GArray *destruction_listeners;
+ bool frozen;
+};
+
+BT_HIDDEN
+void _bt_trace_freeze(const struct bt_trace *trace);
+
+#ifdef BT_DEV_MODE
+# define bt_trace_freeze _bt_trace_freeze
+#else
+# define bt_trace_freeze(_trace)
+#endif
+
+BT_HIDDEN
+void bt_trace_add_stream(struct bt_trace *trace, struct bt_stream *stream);
+
+BT_HIDDEN
+uint64_t bt_trace_get_automatic_stream_id(const struct bt_trace *trace,
+ const struct bt_stream_class *stream_class);
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_TRACE_H
+#define BABELTRACE_TRACE_IR_TRACE_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+/* For bt_bool, bt_trace, bt_trace_class, bt_stream */
+#include <babeltrace2/types.h>
+
+/* For bt_trace_status */
+#include <babeltrace2/trace-ir/trace-const.h>
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace);
+
+extern bt_trace *bt_trace_create(bt_trace_class *trace_class);
+
+extern bt_trace_status bt_trace_set_name(bt_trace *trace,
+ const char *name);
+
+extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace,
+ uint64_t index);
+
+extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace,
+ uint64_t id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TRACE_IR_TRACE_H */
--- /dev/null
+#ifndef BABELTRACE_TRACE_IR_UTILS_INTERNAL_H
+#define BABELTRACE_TRACE_IR_UTILS_INTERNAL_H
+
+/*
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <stdint.h>
+
+struct search_query {
+ gpointer value;
+ int found;
+};
+
+static inline
+uint64_t bt_util_ns_from_value(uint64_t frequency, uint64_t value_cycles)
+{
+ uint64_t ns;
+
+ if (frequency == UINT64_C(1000000000)) {
+ ns = value_cycles;
+ } else {
+ double dblres = ((1e9 * (double) value_cycles) / (double) frequency);
+
+ if (dblres >= (double) UINT64_MAX) {
+ /* Overflows uint64_t */
+ ns = UINT64_C(-1);
+ } else {
+ ns = (uint64_t) dblres;
+ }
+ }
+
+ return ns;
+}
+
+static inline
+bool bt_util_get_base_offset_ns(int64_t offset_seconds, uint64_t offset_cycles,
+ uint64_t frequency, int64_t *base_offset_ns)
+{
+ bool overflows = false;
+ uint64_t offset_cycles_ns;
+
+ BT_ASSERT(base_offset_ns);
+
+ /* Initialize nanosecond timestamp to clock's offset in seconds */
+ if (offset_seconds <= (INT64_MIN / INT64_C(1000000000) - 1) ||
+ offset_seconds >= (INT64_MAX / INT64_C(1000000000)) - 1) {
+ /*
+ * Overflow: offset in seconds converted to nanoseconds
+ * is outside the int64_t range. We also subtract 1 here
+ * to leave "space" for the offset in cycles converted
+ * to nanoseconds (which is always less than 1 second by
+ * contract).
+ */
+ overflows = true;
+ goto end;
+ }
+
+ /* Offset (seconds) to nanoseconds */
+ *base_offset_ns = offset_seconds * INT64_C(1000000000);
+
+ /* Add offset in cycles */
+ BT_ASSERT(offset_cycles < frequency);
+ offset_cycles_ns = bt_util_ns_from_value(frequency,
+ offset_cycles);
+ BT_ASSERT(offset_cycles_ns < 1000000000);
+ *base_offset_ns += (int64_t) offset_cycles_ns;
+
+end:
+ return overflows;
+}
+
+static inline
+int bt_util_ns_from_origin_inline(int64_t base_offset_ns,
+ int64_t offset_seconds, uint64_t offset_cycles,
+ uint64_t frequency, uint64_t value, int64_t *ns_from_origin)
+{
+ int ret = 0;
+ uint64_t value_ns_unsigned;
+ int64_t value_ns_signed;
+
+ /* Initialize to clock class's base offset */
+ *ns_from_origin = base_offset_ns;
+
+ /* Add given value in cycles */
+ value_ns_unsigned = bt_util_ns_from_value(frequency, value);
+ if (value_ns_unsigned >= (uint64_t) INT64_MAX) {
+ /*
+ * FIXME: `value_ns_unsigned` could be greater than
+ * `INT64_MAX` in fact: in this case, we need to
+ * subtract `INT64_MAX` from `value_ns_unsigned`, make
+ * sure that the difference is less than `INT64_MAX`,
+ * and try to add them one after the other to
+ * `*ns_from_origin`.
+ */
+ ret = -1;
+ goto end;
+ }
+
+ value_ns_signed = (int64_t) value_ns_unsigned;
+ BT_ASSERT(value_ns_signed >= 0);
+
+ if (*ns_from_origin <= 0) {
+ goto add_value;
+ }
+
+ if (value_ns_signed > INT64_MAX - *ns_from_origin) {
+ ret = -1;
+ goto end;
+ }
+
+add_value:
+ *ns_from_origin += value_ns_signed;
+
+end:
+ return ret;
+}
+
+static inline
+int bt_util_ns_from_origin_clock_class(const struct bt_clock_class *clock_class,
+ uint64_t value, int64_t *ns_from_origin)
+{
+ int ret = 0;
+
+ if (clock_class->base_offset.overflows) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_util_ns_from_origin_inline(clock_class->base_offset.value_ns,
+ clock_class->offset_seconds, clock_class->offset_cycles,
+ clock_class->frequency, value, ns_from_origin);
+
+end:
+ return ret;
+}
+
+static inline
+bool bt_util_value_is_in_range_signed(uint64_t size, int64_t value)
+{
+ int64_t min_value = UINT64_C(-1) << (size - 1);
+ int64_t max_value = (UINT64_C(1) << (size - 1)) - 1;
+ return value >= min_value && value <= max_value;
+}
+
+static inline
+bool bt_util_value_is_in_range_unsigned(unsigned int size, uint64_t value)
+{
+ uint64_t max_value = (size == 64) ? UINT64_MAX :
+ (UINT64_C(1) << size) - 1;
+ return value <= max_value;
+}
+
+#endif /* BABELTRACE_TRACE_IR_UTILS_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_TYPES_H
+#define BABELTRACE_TYPES_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+/* Internal use */
+#ifdef __cplusplus
+# define __BT_UPCAST(_type, _p) static_cast<_type *>(static_cast<void *>(_p))
+# define __BT_UPCAST_CONST(_type, _p) static_cast<const _type *>(static_cast<const void *>(_p))
+#else
+# define __BT_UPCAST(_type, _p) ((_type *) (_p))
+# define __BT_UPCAST_CONST(_type, _p) ((const _type *) (_p))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup ctypes Babeltrace C types
+@ingroup apiref
+@brief Babeltrace C types.
+
+@code
+#include <babeltrace2/types.h>
+@endcode
+
+This header contains custom type definitions used across the library.
+
+@file
+@brief Babeltrace C types.
+@sa ctypes
+
+@addtogroup ctypes
+@{
+*/
+
+/// False boolean value for the #bt_bool type.
+#define BT_FALSE 0
+
+/// True boolean value for the #bt_bool type.
+#define BT_TRUE 1
+
+/**
+@brief Babeltrace's boolean type.
+
+Use only the #BT_FALSE and #BT_TRUE definitions for #bt_bool parameters.
+It is guaranteed that the library functions which return a #bt_bool
+value return either #BT_FALSE or #BT_TRUE.
+
+You can always test the truthness of a #bt_bool value directly, without
+comparing it to #BT_TRUE directly:
+
+@code
+bt_bool ret = bt_some_function(...);
+
+if (ret) {
+ // ret is true
+}
+@endcode
+*/
+typedef int bt_bool;
+
+typedef const uint8_t *bt_uuid;
+
+typedef struct bt_clock_class bt_clock_class;
+typedef struct bt_clock_snapshot bt_clock_snapshot;
+typedef struct bt_component bt_component;
+typedef struct bt_component_class bt_component_class;
+typedef struct bt_component_class_filter bt_component_class_filter;
+typedef struct bt_component_class_sink bt_component_class_sink;
+typedef struct bt_component_class_source bt_component_class_source;
+typedef struct bt_component_filter bt_component_filter;
+typedef struct bt_component_sink bt_component_sink;
+typedef struct bt_component_source bt_component_source;
+typedef struct bt_connection bt_connection;
+typedef struct bt_event bt_event;
+typedef struct bt_event_class bt_event_class;
+typedef struct bt_event_header_field bt_event_header_field;
+typedef struct bt_field bt_field;
+typedef struct bt_field_class bt_field_class;
+typedef struct bt_field_class_enumeration_mapping bt_field_class_enumeration_mapping;
+typedef struct bt_field_class_signed_enumeration_mapping bt_field_class_signed_enumeration_mapping;
+typedef struct bt_field_class_unsigned_enumeration_mapping bt_field_class_unsigned_enumeration_mapping;
+typedef struct bt_field_class_structure_member bt_field_class_structure_member;
+typedef struct bt_field_class_variant_option bt_field_class_variant_option;
+typedef struct bt_field_path bt_field_path;
+typedef struct bt_field_path_item bt_field_path_item;
+typedef struct bt_graph bt_graph;
+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;
+typedef struct bt_packet_header_field bt_packet_header_field;
+typedef struct bt_plugin bt_plugin;
+typedef struct bt_plugin_set bt_plugin_set;
+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_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;
+typedef struct bt_self_component_class_sink bt_self_component_class_sink;
+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_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_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_stream bt_stream;
+typedef struct bt_stream_class bt_stream_class;
+typedef struct bt_trace bt_trace;
+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_message **bt_message_array_const;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TYPES_H */
--- /dev/null
+#ifndef BABELTRACE_UTIL_H
+#define BABELTRACE_UTIL_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_util_status {
+ BT_UTIL_STATUS_OK = 0,
+ BT_UTIL_STATUS_OVERFLOW = -75,
+} bt_util_status;
+
+bt_util_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
+ uint64_t frequency, int64_t offset_seconds,
+ uint64_t offset_cycles, int64_t *ns);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_UTIL_H */
--- /dev/null
+#ifndef BABELTRACE_VALUES_CONST_H
+#define BABELTRACE_VALUES_CONST_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <stddef.h>
+
+/* For bt_bool, bt_value */
+#include <babeltrace2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_value_status {
+ /// Operation canceled.
+ BT_VALUE_STATUS_CANCELED = 125,
+
+ /// Cannot allocate memory.
+ BT_VALUE_STATUS_NOMEM = -12,
+
+ /// Okay, no error.
+ BT_VALUE_STATUS_OK = 0,
+} bt_value_status;
+
+typedef enum bt_value_type {
+ /// Null value object.
+ BT_VALUE_TYPE_NULL = 0,
+
+ /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
+ BT_VALUE_TYPE_BOOL = 1,
+
+ /// Unsigned integer value object (holds an unsigned 64-bit integer raw value).
+ BT_VALUE_TYPE_UNSIGNED_INTEGER = 2,
+
+ /// Signed integer value object (holds a signed 64-bit integer raw value).
+ BT_VALUE_TYPE_SIGNED_INTEGER = 3,
+
+ /// Floating point number value object (holds a \c double raw value).
+ BT_VALUE_TYPE_REAL = 4,
+
+ /// String value object.
+ BT_VALUE_TYPE_STRING = 5,
+
+ /// Array value object.
+ BT_VALUE_TYPE_ARRAY = 6,
+
+ /// Map value object.
+ BT_VALUE_TYPE_MAP = 7,
+} bt_value_type;
+
+extern bt_value_type bt_value_get_type(const bt_value *object);
+
+static inline
+bt_bool bt_value_is_null(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_NULL;
+}
+
+static inline
+bt_bool bt_value_is_bool(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
+}
+
+static inline
+bt_bool bt_value_is_unsigned_integer(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_UNSIGNED_INTEGER;
+}
+
+static inline
+bt_bool bt_value_is_signed_integer(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_SIGNED_INTEGER;
+}
+
+static inline
+bt_bool bt_value_is_real(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
+}
+
+static inline
+bt_bool bt_value_is_string(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
+}
+
+static inline
+bt_bool bt_value_is_array(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
+}
+
+static inline
+bt_bool bt_value_is_map(const bt_value *object)
+{
+ return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
+}
+
+extern bt_value_status bt_value_copy(const bt_value *object,
+ bt_value **copy);
+
+extern bt_bool bt_value_compare(const bt_value *object_a,
+ const bt_value *object_b);
+
+extern bt_bool bt_value_bool_get(const bt_value *bool_obj);
+
+extern uint64_t bt_value_unsigned_integer_get(const bt_value *integer_obj);
+
+extern int64_t bt_value_signed_integer_get(const bt_value *integer_obj);
+
+extern double bt_value_real_get(const bt_value *real_obj);
+
+extern const char *bt_value_string_get(const bt_value *string_obj);
+
+extern uint64_t bt_value_array_get_size(const bt_value *array_obj);
+
+static inline
+bt_bool bt_value_array_is_empty(const bt_value *array_obj)
+{
+ return bt_value_array_get_size(array_obj) == 0;
+}
+
+extern const bt_value *bt_value_array_borrow_element_by_index_const(
+ const bt_value *array_obj, uint64_t index);
+
+extern uint64_t bt_value_map_get_size(const bt_value *map_obj);
+
+static inline
+bt_bool bt_value_map_is_empty(const bt_value *map_obj)
+{
+ return bt_value_map_get_size(map_obj) == 0;
+}
+
+extern const bt_value *bt_value_map_borrow_entry_value_const(
+ const bt_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_value_map_foreach_entry_const_func)(const char *key,
+ const bt_value *object, void *data);
+
+extern bt_value_status bt_value_map_foreach_entry_const(
+ const bt_value *map_obj,
+ bt_value_map_foreach_entry_const_func func, void *data);
+
+extern bt_bool bt_value_map_has_entry(const bt_value *map_obj,
+ const char *key);
+
+extern bt_value_status bt_value_map_extend(
+ const bt_value *base_map_obj,
+ const bt_value *extension_map_obj,
+ bt_value **extended_map_obj);
+
+extern void bt_value_get_ref(const bt_value *value);
+
+extern void bt_value_put_ref(const bt_value *value);
+
+#define BT_VALUE_PUT_REF_AND_RESET(_var) \
+ do { \
+ bt_value_put_ref(_var); \
+ (_var) = NULL; \
+ } while (0)
+
+#define BT_VALUE_MOVE_REF(_var_dst, _var_src) \
+ do { \
+ bt_value_put_ref(_var_dst); \
+ (_var_dst) = (_var_src); \
+ (_var_src) = NULL; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_VALUES_CONST_H */
--- /dev/null
+#ifndef BABELTRACE_VALUES_INTERNAL_H
+#define BABELTRACE_VALUES_INTERNAL_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <babeltrace2/object-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/types.h>
+#include <glib.h>
+
+struct bt_value {
+ struct bt_object base;
+ enum bt_value_type type;
+ bt_bool frozen;
+};
+
+struct bt_value_bool {
+ struct bt_value base;
+ bt_bool value;
+};
+
+struct bt_value_integer {
+ struct bt_value base;
+ union {
+ uint64_t i;
+ int64_t u;
+ } value;
+};
+
+struct bt_value_real {
+ struct bt_value base;
+ double value;
+};
+
+struct bt_value_string {
+ struct bt_value base;
+ GString *gstr;
+};
+
+struct bt_value_array {
+ struct bt_value base;
+ GPtrArray *garray;
+};
+
+struct bt_value_map {
+ struct bt_value base;
+ GHashTable *ght;
+};
+
+BT_HIDDEN
+enum bt_value_status _bt_value_freeze(const struct bt_value *object);
+
+#ifdef BT_DEV_MODE
+# define bt_value_freeze _bt_value_freeze
+#else
+# define bt_value_freeze(_value)
+#endif /* BT_DEV_MODE */
+
+#endif /* BABELTRACE_VALUES_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_VALUES_H
+#define BABELTRACE_VALUES_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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 <stdint.h>
+#include <stddef.h>
+
+/* For bt_bool, bt_value */
+#include <babeltrace2/types.h>
+
+/* For bt_value_status, bt_value_type */
+#include <babeltrace2/value-const.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern bt_value *const bt_value_null;
+
+extern bt_value *bt_value_bool_create(void);
+
+extern bt_value *bt_value_bool_create_init(bt_bool val);
+
+extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val);
+
+extern bt_value *bt_value_unsigned_integer_create(void);
+
+extern bt_value *bt_value_unsigned_integer_create_init(uint64_t val);
+
+extern void bt_value_unsigned_integer_set(bt_value *integer_obj, uint64_t val);
+
+extern bt_value *bt_value_signed_integer_create(void);
+
+extern bt_value *bt_value_signed_integer_create_init(int64_t val);
+
+extern void bt_value_signed_integer_set(bt_value *integer_obj, int64_t val);
+
+extern bt_value *bt_value_real_create(void);
+
+extern bt_value *bt_value_real_create_init(double val);
+
+extern void bt_value_real_set(bt_value *real_obj, double val);
+
+extern bt_value *bt_value_string_create(void);
+
+extern bt_value *bt_value_string_create_init(const char *val);
+
+extern bt_value_status bt_value_string_set(bt_value *string_obj,
+ const char *val);
+
+extern bt_value *bt_value_array_create(void);
+
+extern bt_value *bt_value_array_borrow_element_by_index(
+ bt_value *array_obj, uint64_t index);
+
+extern bt_value_status bt_value_array_append_element(
+ bt_value *array_obj,
+ bt_value *element_obj);
+
+extern bt_value_status bt_value_array_append_bool_element(
+ bt_value *array_obj, bt_bool val);
+
+extern bt_value_status bt_value_array_append_unsigned_integer_element(
+ bt_value *array_obj, uint64_t val);
+
+extern bt_value_status bt_value_array_append_signed_integer_element(
+ bt_value *array_obj, int64_t val);
+
+extern bt_value_status bt_value_array_append_real_element(
+ bt_value *array_obj, double val);
+
+extern bt_value_status bt_value_array_append_string_element(
+ bt_value *array_obj, const char *val);
+
+extern bt_value_status bt_value_array_append_empty_array_element(
+ bt_value *array_obj);
+
+extern bt_value_status bt_value_array_append_empty_map_element(
+ bt_value *array_obj);
+
+extern bt_value_status bt_value_array_set_element_by_index(
+ bt_value *array_obj, uint64_t index,
+ bt_value *element_obj);
+
+extern bt_value *bt_value_map_create(void);
+
+extern bt_value *bt_value_map_borrow_entry_value(
+ bt_value *map_obj, const char *key);
+
+typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key,
+ bt_value *object, void *data);
+
+extern bt_value_status bt_value_map_foreach_entry(
+ bt_value *map_obj,
+ bt_value_map_foreach_entry_func func, void *data);
+
+extern bt_value_status bt_value_map_insert_entry(
+ bt_value *map_obj, const char *key,
+ bt_value *element_obj);
+
+extern bt_value_status bt_value_map_insert_bool_entry(
+ bt_value *map_obj, const char *key, bt_bool val);
+
+extern bt_value_status bt_value_map_insert_unsigned_integer_entry(
+ bt_value *map_obj, const char *key, uint64_t val);
+
+extern bt_value_status bt_value_map_insert_signed_integer_entry(
+ bt_value *map_obj, const char *key, int64_t val);
+
+extern bt_value_status bt_value_map_insert_real_entry(
+ bt_value *map_obj, const char *key, double val);
+
+extern bt_value_status bt_value_map_insert_string_entry(
+ bt_value *map_obj, const char *key,
+ const char *val);
+
+extern bt_value_status bt_value_map_insert_empty_array_entry(
+ bt_value *map_obj, const char *key);
+
+extern bt_value_status bt_value_map_insert_empty_map_entry(
+ bt_value *map_obj, const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_VALUES_H */
--- /dev/null
+#ifndef BABELTRACE_VERSION_H
+#define BABELTRACE_VERSION_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int bt_version_get_major(void);
+extern int bt_version_get_minor(void);
+extern int bt_version_get_patch(void);
+extern const char *bt_version_get_extra(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_VERSION_H */
* SOFTWARE.
*/
-#include <babeltrace/version.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/version.h>
+#include <babeltrace2/types.h>
#include <stdlib.h>
int bt_version_get_major(void)
*/
#define BT_LOG_TAG "CTF-WRITER-ATTRS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compat/string-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compat/string-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
#include <inttypes.h>
#define BT_CTF_ATTR_NAME_INDEX 0
*/
#define BT_LOG_TAG "CTF-WRITER-CLOCK-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/compat/string-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/compat/string-internal.h>
#include <inttypes.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/assert-internal.h>
static
void bt_ctf_clock_class_destroy(struct bt_ctf_object *obj);
*/
#define BT_LOG_TAG "CTF-WRITER-CLOCK"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <inttypes.h>
static
*/
#define BT_LOG_TAG "CTF-WRITER-EVENT-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/attributes-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/types.h>
-#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/attributes-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <inttypes.h>
*/
#define BT_LOG_TAG "CTF-WRITER-EVENT"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/attributes-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/attributes-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <inttypes.h>
static
*/
#define BT_LOG_TAG "CTF-WRITER-FIELD-PATH"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctf-writer/field-path-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctf-writer/field-path-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
#include <glib.h>
#include <inttypes.h>
#include <limits.h>
*/
#define BT_LOG_TAG "CTF-WRITER-FIELD-TYPES"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/field-path-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/fields.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/field-path-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <float.h>
#include <inttypes.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "CTF-WRITER-FIELD-WRAPPER"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/ctf-writer/field-wrapper-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/field-wrapper-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
#include <glib.h>
BT_HIDDEN
*/
#define BT_LOG_TAG "CTF-WRITER-FIELDS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/fcntl-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/fcntl-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctfser-internal.h>
#include <float.h>
#include <inttypes.h>
#include <inttypes.h>
*/
#include <glib.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/functor-internal.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
BT_HIDDEN
void value_exists(gpointer element, gpointer search_query)
*/
#define BT_LOG_TAG "OBJECT-POOL"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#include <stdint.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctf-writer/object-pool-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctf-writer/object-pool-internal.h>
int bt_ctf_object_pool_initialize(struct bt_ctf_object_pool *pool,
bt_ctf_object_pool_new_object_func new_object_func,
* SOFTWARE.
*/
-#include <babeltrace/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
void *bt_ctf_object_get_ref(void *obj)
{
*/
#define BT_LOG_TAG "CTF-WRITER-RESOLVE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/field-path-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/resolve-internal.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/types.h>
-#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/field-path-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/resolve-internal.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <limits.h>
*/
#define BT_LOG_TAG "CTF-WRITER-STREAM-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-wrapper-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/visitor-internal.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-wrapper-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/visitor-internal.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
*/
#define BT_LOG_TAG "CTF-WRITER-STREAM"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/field-types.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/field-types.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctfser-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <unistd.h>
*/
#define BT_LOG_TAG "CTF-WRITER-TRACE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/attributes-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-wrapper-internal.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/visitor-internal.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/types.h>
-#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/attributes-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/event-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-wrapper-internal.h>
+#include <babeltrace2/ctf-writer/functor-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/utils-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/visitor-internal.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "CTF-WRITER-UTILS"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctf-writer/clock-class-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctf-writer/clock-class-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <glib.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "CTF-WRITER-VALIDATION"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf-writer/event-class-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/resolve-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/values-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/ctf-writer/event-class-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/resolve-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/validation-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
/*
* This function resolves and validates the field types of an event
*/
#define BT_LOG_TAG "CTF-WRITER-VALUES"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <inttypes.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/ctf-writer/object.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/compat/glib-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/ctf-writer/object-internal.h>
-#include <babeltrace/ctf-writer/values-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/compat/glib-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/values-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
#define BT_CTF_VALUE_FROM_CONCRETE(_concrete) ((struct bt_ctf_value *) (_concrete))
#define BT_CTF_VALUE_TO_BOOL(_base) ((struct bt_ctf_value_bool *) (_base))
* SOFTWARE.
*/
-#include <babeltrace/ctf-writer/visitor-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/ctf-writer/visitor-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
BT_HIDDEN
int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root,
*/
#define BT_LOG_TAG "CTF-WRITER"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/ctf-writer/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/trace-internal.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/ctf-writer/object.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/ctf-writer/functor-internal.h>
+#include <babeltrace2/ctf-writer/stream-class-internal.h>
+#include <babeltrace2/ctf-writer/stream-internal.h>
+#include <babeltrace2/ctf-writer/trace-internal.h>
+#include <babeltrace2/ctf-writer/writer-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
*/
#define BT_LOG_TAG "COLANDER"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/self-component-sink.h>
-#include <babeltrace/graph/self-component-port.h>
-#include <babeltrace/graph/self-component-port-input-message-iterator.h>
-#include <babeltrace/graph/self-component.h>
-#include <babeltrace/graph/component-class-sink-colander-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/graph/self-component-sink.h>
+#include <babeltrace2/graph/self-component-port.h>
+#include <babeltrace2/graph/self-component-port-input-message-iterator.h>
+#include <babeltrace2/graph/self-component.h>
+#include <babeltrace2/graph/component-class-sink-colander-internal.h>
#include <glib.h>
static
*/
#define BT_LOG_TAG "COMP-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-const.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-source-const.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-filter-const.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/graph/component-class-sink-const.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-const.h>
+#include <babeltrace2/graph/component-class-source.h>
+#include <babeltrace2/graph/component-class-source-const.h>
+#include <babeltrace2/graph/component-class-filter.h>
+#include <babeltrace2/graph/component-class-filter-const.h>
+#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/graph/component-class-sink-const.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/types.h>
#include <glib.h>
#define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \
*/
#define BT_LOG_TAG "COMP-FILTER"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/graph/self-component-filter.h>
-#include <babeltrace/graph/component-filter-const.h>
-#include <babeltrace/graph/component-filter-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/graph.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/graph/self-component-filter.h>
+#include <babeltrace2/graph/component-filter-const.h>
+#include <babeltrace2/graph/component-filter-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/graph.h>
BT_HIDDEN
void bt_component_filter_destroy(struct bt_component *component)
*/
#define BT_LOG_TAG "COMP-SINK"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/graph/self-component-sink.h>
-#include <babeltrace/graph/component-sink-const.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/graph.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/graph/self-component-sink.h>
+#include <babeltrace2/graph/component-sink-const.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/graph.h>
BT_HIDDEN
void bt_component_sink_destroy(struct bt_component *component)
*/
#define BT_LOG_TAG "COMP-SOURCE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/graph/self-component-source.h>
-#include <babeltrace/graph/component-source-const.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/graph/message-iterator-const.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/graph.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/graph/self-component-source.h>
+#include <babeltrace2/graph/component-source-const.h>
+#include <babeltrace2/graph/component-source-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/graph/message-iterator-const.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/graph.h>
BT_HIDDEN
void bt_component_source_destroy(struct bt_component *component)
*/
#define BT_LOG_TAG "COMP"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/self-component.h>
-#include <babeltrace/graph/component-const.h>
-#include <babeltrace/graph/component-source-const.h>
-#include <babeltrace/graph/component-filter-const.h>
-#include <babeltrace/graph/component-sink-const.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/component-filter-internal.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/self-component.h>
+#include <babeltrace2/graph/component-const.h>
+#include <babeltrace2/graph/component-source-const.h>
+#include <babeltrace2/graph/component-filter-const.h>
+#include <babeltrace2/graph/component-sink-const.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/component-source-internal.h>
+#include <babeltrace2/graph/component-filter-internal.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-internal.h>
#include <stdint.h>
#include <inttypes.h>
*/
#define BT_LOG_TAG "CONNECTION"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/connection-const.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/connection-const.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
#include <stdlib.h>
#include <glib.h>
*/
#define BT_LOG_TAG "GRAPH"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/graph-const.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/component-source-const.h>
-#include <babeltrace/graph/component-filter-const.h>
-#include <babeltrace/graph/port-const.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-event-internal.h>
-#include <babeltrace/graph/message-packet-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/graph.h>
+#include <babeltrace2/graph/graph-const.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/graph/component-source-const.h>
+#include <babeltrace2/graph/component-filter-const.h>
+#include <babeltrace2/graph/port-const.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-event-internal.h>
+#include <babeltrace2/graph/message-packet-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value-internal.h>
#include <unistd.h>
#include <glib.h>
*/
#define BT_LOG_TAG "MSG-ITER"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/event-const.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/packet-const.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/graph/connection-const.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/component-const.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/component-class-sink-colander-internal.h>
-#include <babeltrace/graph/component-sink-const.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/message-iterator-const.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/self-component-port-input-message-iterator.h>
-#include <babeltrace/graph/port-output-message-iterator.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-event-const.h>
-#include <babeltrace/graph/message-event-internal.h>
-#include <babeltrace/graph/message-packet-beginning-const.h>
-#include <babeltrace/graph/message-packet-end-const.h>
-#include <babeltrace/graph/message-packet-internal.h>
-#include <babeltrace/graph/message-stream-beginning-const.h>
-#include <babeltrace/graph/message-stream-end-const.h>
-#include <babeltrace/graph/message-stream-internal.h>
-#include <babeltrace/graph/message-message-iterator-inactivity-internal.h>
-#include <babeltrace/graph/message-discarded-items-internal.h>
-#include <babeltrace/graph/message-stream-activity-internal.h>
-#include <babeltrace/graph/port-const.h>
-#include <babeltrace/graph/graph.h>
-#include <babeltrace/graph/graph-const.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/event-const.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/packet-const.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/graph/connection-const.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/component-const.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-source-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/component-class-sink-colander-internal.h>
+#include <babeltrace2/graph/component-sink-const.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message-iterator-const.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/self-component-port-input-message-iterator.h>
+#include <babeltrace2/graph/port-output-message-iterator.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-event-const.h>
+#include <babeltrace2/graph/message-event-internal.h>
+#include <babeltrace2/graph/message-packet-beginning-const.h>
+#include <babeltrace2/graph/message-packet-end-const.h>
+#include <babeltrace2/graph/message-packet-internal.h>
+#include <babeltrace2/graph/message-stream-beginning-const.h>
+#include <babeltrace2/graph/message-stream-end-const.h>
+#include <babeltrace2/graph/message-stream-internal.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity-internal.h>
+#include <babeltrace2/graph/message-discarded-items-internal.h>
+#include <babeltrace2/graph/message-stream-activity-internal.h>
+#include <babeltrace2/graph/port-const.h>
+#include <babeltrace2/graph/graph.h>
+#include <babeltrace2/graph/graph-const.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "MSG-DISCARDED-ITEMS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/property-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-discarded-items-internal.h>
-#include <babeltrace/graph/message-discarded-events.h>
-#include <babeltrace/graph/message-discarded-events-const.h>
-#include <babeltrace/graph/message-discarded-packets.h>
-#include <babeltrace/graph/message-discarded-packets-const.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/property-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-discarded-items-internal.h>
+#include <babeltrace2/graph/message-discarded-events.h>
+#include <babeltrace2/graph/message-discarded-events-const.h>
+#include <babeltrace2/graph/message-discarded-packets.h>
+#include <babeltrace2/graph/message-discarded-packets-const.h>
static
void destroy_discarded_items_message(struct bt_object *obj)
*/
#define BT_LOG_TAG "MSG-EVENT"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/event.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/message-event-const.h>
-#include <babeltrace/graph/message-event.h>
-#include <babeltrace/graph/message-event-internal.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/trace-ir/event.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/message-event-const.h>
+#include <babeltrace2/graph/message-event.h>
+#include <babeltrace2/graph/message-event-internal.h>
+#include <babeltrace2/types.h>
#include <stdbool.h>
#include <inttypes.h>
*/
#define BT_LOG_TAG "MSG-MESSAGE-ITERATOR-INACTIVITY"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-message-iterator-inactivity-const.h>
-#include <babeltrace/graph/message-message-iterator-inactivity.h>
-#include <babeltrace/graph/message-message-iterator-inactivity-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity-const.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity-internal.h>
static
void bt_message_message_iterator_inactivity_destroy(struct bt_object *obj)
*/
#define BT_LOG_TAG "MSG"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/message-const.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/graph-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/graph-internal.h>
BT_HIDDEN
void bt_message_init(struct bt_message *message,
*/
#define BT_LOG_TAG "MSG-PACKET"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/message-packet-beginning-const.h>
-#include <babeltrace/graph/message-packet-end-const.h>
-#include <babeltrace/graph/message-packet-beginning.h>
-#include <babeltrace/graph/message-packet-end.h>
-#include <babeltrace/graph/message-packet-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/message-packet-beginning-const.h>
+#include <babeltrace2/graph/message-packet-end-const.h>
+#include <babeltrace2/graph/message-packet-beginning.h>
+#include <babeltrace2/graph/message-packet-end.h>
+#include <babeltrace2/graph/message-packet-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
#include <inttypes.h>
static inline
*/
#define BT_LOG_TAG "MSG-STREAM-ACTIVITY"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-stream-activity-beginning-const.h>
-#include <babeltrace/graph/message-stream-activity-end-const.h>
-#include <babeltrace/graph/message-stream-activity-beginning.h>
-#include <babeltrace/graph/message-stream-activity-end.h>
-#include <babeltrace/graph/message-stream-activity-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-stream-activity-beginning-const.h>
+#include <babeltrace2/graph/message-stream-activity-end-const.h>
+#include <babeltrace2/graph/message-stream-activity-beginning.h>
+#include <babeltrace2/graph/message-stream-activity-end.h>
+#include <babeltrace2/graph/message-stream-activity-internal.h>
static
void destroy_stream_activity_message(struct bt_object *obj)
*/
#define BT_LOG_TAG "MSG-STREAM"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-const.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/graph/message-stream-beginning.h>
-#include <babeltrace/graph/message-stream-end.h>
-#include <babeltrace/graph/message-stream-beginning-const.h>
-#include <babeltrace/graph/message-stream-end-const.h>
-#include <babeltrace/graph/message-stream-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-const.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/graph/message-stream-beginning.h>
+#include <babeltrace2/graph/message-stream-end.h>
+#include <babeltrace2/graph/message-stream-beginning-const.h>
+#include <babeltrace2/graph/message-stream-end-const.h>
+#include <babeltrace2/graph/message-stream-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
static
*/
#define BT_LOG_TAG "PORT"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/port-const.h>
-#include <babeltrace/graph/port-input-const.h>
-#include <babeltrace/graph/port-output-const.h>
-#include <babeltrace/graph/self-component-port.h>
-#include <babeltrace/graph/self-component-port-input.h>
-#include <babeltrace/graph/self-component-port-output.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/port-const.h>
+#include <babeltrace2/graph/port-input-const.h>
+#include <babeltrace2/graph/port-output-const.h>
+#include <babeltrace2/graph/self-component-port.h>
+#include <babeltrace2/graph/self-component-port-input.h>
+#include <babeltrace2/graph/self-component-port-output.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
static
void destroy_port(struct bt_object *obj)
*/
#define BT_LOG_TAG "QUERY-EXECUTOR"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/graph/query-executor-const.h>
-#include <babeltrace/graph/query-executor.h>
-#include <babeltrace/graph/query-executor-internal.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/graph/query-executor-const.h>
+#include <babeltrace2/graph/query-executor.h>
+#include <babeltrace2/graph/query-executor-internal.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
static
void bt_query_executor_destroy(struct bt_object *obj)
#include <stdint.h>
#include <wchar.h>
#include <glib.h>
-#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/event-const.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/packet-const.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-const.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/trace-class-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/component-class-sink-colander-internal.h>
-#include <babeltrace/graph/component-filter-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/component-sink-internal.h>
-#include <babeltrace/graph/component-source-internal.h>
-#include <babeltrace/graph/connection-internal.h>
-#include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/message-event-internal.h>
-#include <babeltrace/graph/message-message-iterator-inactivity-internal.h>
-#include <babeltrace/graph/message-internal.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/message-packet-internal.h>
-#include <babeltrace/graph/message-stream-internal.h>
-#include <babeltrace/graph/message-stream-activity-internal.h>
-#include <babeltrace/graph/message-discarded-items-internal.h>
-#include <babeltrace/graph/port-internal.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/plugin/plugin-so-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/event-const.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/packet-const.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-const.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/trace-class-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/field-path-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/component-class-sink-colander-internal.h>
+#include <babeltrace2/graph/component-filter-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/component-sink-internal.h>
+#include <babeltrace2/graph/component-source-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
+#include <babeltrace2/graph/graph-internal.h>
+#include <babeltrace2/graph/message-event-internal.h>
+#include <babeltrace2/graph/message-message-iterator-inactivity-internal.h>
+#include <babeltrace2/graph/message-internal.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/message-packet-internal.h>
+#include <babeltrace2/graph/message-stream-internal.h>
+#include <babeltrace2/graph/message-stream-activity-internal.h>
+#include <babeltrace2/graph/message-discarded-items-internal.h>
+#include <babeltrace2/graph/port-internal.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/plugin/plugin-so-internal.h>
#define LIB_LOGGING_BUF_SIZE (4096 * 4)
*/
#include <stdlib.h>
-#include <babeltrace/logging.h>
-#include <babeltrace/version.h>
+#include <babeltrace2/logging.h>
+#include <babeltrace2/version.h>
#define BT_LOG_TAG "LIB"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#ifdef BT_DEV_MODE
/*
*/
#define BT_LOG_TAG "OBJECT-POOL"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#include <stdint.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-pool-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-pool-internal.h>
int bt_object_pool_initialize(struct bt_object_pool *pool,
bt_object_pool_new_object_func new_object_func,
*/
#define BT_LOG_TAG "PLUGIN-SO"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/plugin/plugin-so-internal.h>
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-source.h>
-#include <babeltrace/graph/component-class-filter.h>
-#include <babeltrace/graph/component-class-sink.h>
-#include <babeltrace/types.h>
-#include <babeltrace/list-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/plugin/plugin-so-internal.h>
+#include <babeltrace2/plugin/plugin-dev.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-source.h>
+#include <babeltrace2/graph/component-class-filter.h>
+#include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/list-internal.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
*/
#define BT_LOG_TAG "PLUGIN"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/plugin/plugin-so-internal.h>
-#include <babeltrace/plugin/plugin-const.h>
-#include <babeltrace/graph/component-class-const.h>
-#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/plugin/plugin-so-internal.h>
+#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/graph/component-class-const.h>
+#include <babeltrace2/graph/component-class-internal.h>
+#include <babeltrace2/types.h>
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
#define APPEND_ALL_FROM_DIR_NFDOPEN_MAX 8
#ifdef BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT
-#include <babeltrace/plugin/python-plugin-provider-internal.h>
+#include <babeltrace2/plugin/python-plugin-provider-internal.h>
static
struct bt_plugin_set *(*bt_plugin_python_create_all_from_file_sym)(const char *path) =
* SOFTWARE.
*/
-#include <babeltrace/prio-heap-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/prio-heap-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
*/
#define BT_LOG_TAG "ATTRS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
#include <inttypes.h>
-#include <babeltrace/compat/string-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/compat/string-internal.h>
+#include <babeltrace2/assert-internal.h>
#define BT_ATTR_NAME_INDEX 0
#define BT_ATTR_VALUE_INDEX 1
*/
#define BT_LOG_TAG "CLOCK-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/trace-ir/clock-class-const.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/compat/string-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/trace-ir/clock-class-const.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/compat/string-internal.h>
#include <inttypes.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
#define BT_ASSERT_PRE_CLOCK_CLASS_HOT(_cc) \
BT_ASSERT_PRE_HOT((_cc), "Clock class", ": %!+K", (_cc))
*/
#define BT_LOG_TAG "CLOCK-SNAPSHOT"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-const.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/compat/string-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-const.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/compat/string-internal.h>
#include <inttypes.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
BT_HIDDEN
void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot)
*/
#define BT_LOG_TAG "EVENT-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/clock-snapshot-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event-class-const.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event-class-const.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "EVENT"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/event-const.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream-class-const.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compiler-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/event-const.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream-class-const.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
#include <inttypes.h>
BT_HIDDEN
*/
#define BT_LOG_TAG "FIELD-CLASSES"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field-class-const.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-const.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/glib-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field-class-const.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/field-path-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/field-const.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/glib-internal.h>
#include <float.h>
#include <inttypes.h>
#include <stdlib.h>
*/
#define BT_LOG_TAG "FIELD-PATH"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-class.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/field-path-const.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field-class.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/field-path-internal.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
#include <limits.h>
#include <stdint.h>
#include <inttypes.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
static
*/
#define BT_LOG_TAG "FIELD-WRAPPER"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/object-pool-internal.h>
-#include <babeltrace/object-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/object-pool-internal.h>
+#include <babeltrace2/object-internal.h>
#include <glib.h>
BT_HIDDEN
*/
#define BT_LOG_TAG "FIELDS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field.h>
-#include <babeltrace/trace-ir/field-const.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/compat/fcntl-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field.h>
+#include <babeltrace2/trace-ir/field-const.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/compat/fcntl-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
static
*/
#define BT_LOG_TAG "PACKET-CONTEXT-FIELD"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/packet-context-field.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/packet-context-field.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
#include <glib.h>
struct bt_field *bt_packet_context_field_borrow_field(
*/
#define BT_LOG_TAG "PACKET"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/packet-const.h>
-#include <babeltrace/trace-ir/packet.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/packet-const.h>
+#include <babeltrace2/trace-ir/packet.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
#define BT_ASSERT_PRE_PACKET_HOT(_packet) \
*/
#define BT_LOG_TAG "RESOLVE-FIELD-PATH"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/field-path-internal.h>
-#include <babeltrace/trace-ir/field-path-const.h>
-#include <babeltrace/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/field-path-internal.h>
+#include <babeltrace2/trace-ir/field-path-const.h>
+#include <babeltrace2/trace-ir/resolve-field-path-internal.h>
#include <limits.h>
#include <stdint.h>
#include <inttypes.h>
*/
#define BT_LOG_TAG "STREAM-CLASS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/field-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/trace-const.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/property-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/field-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/trace-const.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/property-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
*/
#define BT_LOG_TAG "STREAM"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/stream-const.h>
-#include <babeltrace/trace-ir/stream.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-class.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/property-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/stream-const.h>
+#include <babeltrace2/trace-ir/stream.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-class.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/packet-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/property-internal.h>
#include <inttypes.h>
#include <unistd.h>
*/
#define BT_LOG_TAG "TRACE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/trace-class.h>
-#include <babeltrace/trace-ir/trace-class-const.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/glib-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/trace-class.h>
+#include <babeltrace2/trace-ir/trace-class-const.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/ctf-writer/functor-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/glib-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
*/
#define BT_LOG_TAG "TRACE"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/trace-ir/trace.h>
-#include <babeltrace/trace-ir/trace-class-internal.h>
-#include <babeltrace/trace-ir/trace-const.h>
-#include <babeltrace/trace-ir/trace-internal.h>
-#include <babeltrace/trace-ir/clock-class-internal.h>
-#include <babeltrace/trace-ir/stream-internal.h>
-#include <babeltrace/trace-ir/stream-class-internal.h>
-#include <babeltrace/trace-ir/event-internal.h>
-#include <babeltrace/trace-ir/event-class.h>
-#include <babeltrace/trace-ir/event-class-internal.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
-#include <babeltrace/trace-ir/field-wrapper-internal.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/attributes-internal.h>
-#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/value.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/glib-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/trace-ir/trace.h>
+#include <babeltrace2/trace-ir/trace-class-internal.h>
+#include <babeltrace2/trace-ir/trace-const.h>
+#include <babeltrace2/trace-ir/trace-internal.h>
+#include <babeltrace2/trace-ir/clock-class-internal.h>
+#include <babeltrace2/trace-ir/stream-internal.h>
+#include <babeltrace2/trace-ir/stream-class-internal.h>
+#include <babeltrace2/trace-ir/event-internal.h>
+#include <babeltrace2/trace-ir/event-class.h>
+#include <babeltrace2/trace-ir/event-class-internal.h>
+#include <babeltrace2/ctf-writer/functor-internal.h>
+#include <babeltrace2/ctf-writer/clock-internal.h>
+#include <babeltrace2/trace-ir/field-wrapper-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/attributes-internal.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
+#include <babeltrace2/trace-ir/resolve-field-path-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/glib-internal.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
*/
#define BT_LOG_TAG "TRACE-IR-UTILS"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#include <stdlib.h>
#include <glib.h>
-#include <babeltrace/trace-ir/field-class-internal.h>
-#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/trace-ir/field-class-internal.h>
+#include <babeltrace2/trace-ir/clock-class.h>
+#include <babeltrace2/assert-internal.h>
*/
#define BT_LOG_TAG "UTIL"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
-#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace2/assert-pre-internal.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <inttypes.h>
-#include <babeltrace/util.h>
-#include <babeltrace/trace-ir/utils-internal.h>
+#include <babeltrace2/util.h>
+#include <babeltrace2/trace-ir/utils-internal.h>
bt_util_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
uint64_t frequency, int64_t offset_seconds,
*/
#define BT_LOG_TAG "VALUES"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace2/lib-logging-internal.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <inttypes.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/value-const.h>
-#include <babeltrace/value.h>
-#include <babeltrace/compat/glib-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/value-const.h>
+#include <babeltrace2/value.h>
+#include <babeltrace2/compat/glib-internal.h>
+#include <babeltrace2/types.h>
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/assert-internal.h>
#define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
#define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base))
* See LICENSE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
#include <pthread.h>
#include <assert.h>
#undef __STRICT_ANSI__
#endif
#endif
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#define BT_LOG_OUTPUT_LEVEL dummy
-#include <babeltrace/logging-internal.h>
-#include <babeltrace/logging.h>
+#include <babeltrace2/logging-internal.h>
+#include <babeltrace2/logging.h>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <string.h>
-#include <babeltrace/bitfield-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/align-internal.h>
+#include <babeltrace2/bitfield-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/align-internal.h>
#include <glib.h>
#include "bfcr.h"
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "../metadata/ctf-meta.h"
*/
#define BT_LOG_OUTPUT_LEVEL bfcr_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bfcr_log_level, "BABELTRACE_PLUGIN_CTF_BFCR_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bfcr_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bfcr_log_level);
#include <stdint.h>
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/list-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/list-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "decoder.h"
#include "ctf-meta.h"
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-RESOLVE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-TRANSLATE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-DEF-CC"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-IN-IR"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/glib-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/glib-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-MEANINGS"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-SC-CONFIG"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-TEXT-ARRAY-SEQ"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-UPDATE-VALUE-STORING-INDEXES"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-VALIDATE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
* all copies or substantial portions of the Software.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "ctf-meta.h"
#define BT_LOG_TAG "PLUGIN-CTF-METADATA-META-WARN-MEANINGLESS-HEADER-FIELDS"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
* all copies or substantial portions of the Software.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <inttypes.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/compat/memstream-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/compat/memstream-internal.h>
+#include <babeltrace2/babeltrace.h>
#include <glib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
/* A CTF metadata decoder object */
struct ctf_metadata_decoder;
*/
#define BT_LOG_OUTPUT_LEVEL metadata_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(metadata_log_level, "BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL metadata_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(metadata_log_level);
#include "logging.h"
#include <stdlib.h>
-#include <babeltrace/list-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/align-internal.h>
+#include <babeltrace2/list-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/align-internal.h>
#define OBJSTACK_ALIGN 8 /* Object stack alignment */
#define OBJSTACK_INIT_LEN 128
#include <glib.h>
#include <errno.h>
#include <inttypes.h>
-#include <babeltrace/list-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/list-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "scanner.h"
#include "parser.h"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/list-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/list-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
-#include <babeltrace/list-internal.h>
+#include <babeltrace2/list-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
*/
#define BT_LOG_OUTPUT_LEVEL ctf_msg_iter_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(ctf_msg_iter_log_level,
"BABELTRACE_PLUGIN_CTF_MSG_ITER_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL ctf_msg_iter_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_msg_iter_log_level);
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <string.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include <glib.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "../metadata/ctf-meta.h"
*/
#include <stdio.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
#define PERR(fmt, ...) \
do { \
*/
#define BT_LOG_OUTPUT_LEVEL utils_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(utils_log_level, "BABELTRACE_PLUGIN_CTF_UTILS_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL utils_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(utils_log_level);
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#endif /* CTF_UTILS_H */
* all copies or substantial portions of the Software.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
#include <glib.h>
#include <stdint.h>
#include <string.h>
#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-STREAM"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctfser-internal.h>
-#include <babeltrace/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctfser-internal.h>
+#include <babeltrace2/endian-internal.h>
#include "fs-sink-trace.h"
#include "fs-sink-stream.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/ctfser-internal.h>
#include <glib.h>
#include <stdbool.h>
#include <stdint.h>
#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-TRACE"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctfser-internal.h>
#include "translate-trace-ir-to-ctf-ir.h"
#include "translate-ctf-ir-to-tsdl.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/ctfser-internal.h>
#include <glib.h>
#include <stdbool.h>
#include <stdint.h>
#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/ctfser-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/ctfser-internal.h>
#include "fs-sink.h"
#include "fs-sink-trace.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include <stdbool.h>
#include <glib.h>
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_fs_sink_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_fs_sink_log_level,
"BABELTRACE_SINK_CTF_FS_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_fs_sink_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_fs_sink_log_level);
#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-TRANSLATE-CTF-IR-TO-TSDL"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/endian-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/endian-internal.h>
#include "fs-sink-ctf-meta.h"
#define BT_LOG_TAG "PLUGIN-CTF-FS-SINK-TRANSLATE-TRACE-IR-TO-CTF-IR"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "fs-sink-ctf-meta.h"
#include <stdbool.h>
#include <glib.h>
#include <inttypes.h>
-#include <babeltrace/compat/mman-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/compat/mman-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include "file.h"
#include "metadata.h"
#include "../common/msg-iter/msg-iter.h"
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "data-stream-file.h"
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "../common/msg-iter/msg-iter.h"
#include "lttng-index.h"
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "fs.h"
BT_HIDDEN
* SOFTWARE.
*/
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/compat/uuid-internal.h>
#include <plugins-common.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
#include <stdbool.h>
#include "fs.h"
*/
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "data-stream-file.h"
#include "metadata.h"
#include "../common/metadata/decoder.h"
*/
#define BT_LOG_OUTPUT_LEVEL ctf_fs_src_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(BT_LOG_OUTPUT_LEVEL, "BABELTRACE_SRC_CTF_FS_LOG_LEVEL");
#define CTF_FS_SRC_LOGGING_H
#define BT_LOG_OUTPUT_LEVEL ctf_fs_src_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_fs_src_log_level);
#ifndef LTTNG_INDEX_H
#define LTTNG_INDEX_H
-#include <babeltrace/compat/limits-internal.h>
+#include <babeltrace2/compat/limits-internal.h>
#define CTF_INDEX_MAGIC 0xC1F1DCC1
#define CTF_INDEX_MAJOR 1
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/compat/memstream-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/compat/memstream-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "fs.h"
#include "file.h"
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#define CTF_FS_METADATA_FILENAME "metadata"
#include "query.h"
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "metadata.h"
#include "../common/metadata/decoder.h"
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "fs.h"
#define BT_LOG_TAG "PLUGIN-CTF-FS-QUERY-SRC"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
BT_HIDDEN
bt_query_status metadata_info_query(
#include <stdbool.h>
#include <glib.h>
#include <inttypes.h>
-#include <babeltrace/compat/mman-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/compat/mman-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "../common/msg-iter/msg-iter.h"
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "data-stream.h"
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "lttng-live.h"
#include "../common/msg-iter/msg-iter.h"
*/
#define BT_LOG_OUTPUT_LEVEL lttng_live_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(lttng_live_log_level, "BABELTRACE_SRC_CTF_LTTNG_LIVE_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL lttng_live_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(lttng_live_log_level);
#include <inttypes.h>
#include <unistd.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
#include <plugins-common.h>
#include "data-stream.h"
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "../common/metadata/decoder.h"
#include "../common/msg-iter/msg-iter.h"
* SOFTWARE.
*/
-#include <babeltrace/compat/limits-internal.h>
+#include <babeltrace2/compat/limits-internal.h>
#define LTTNG_VIEWER_PATH_MAX 4096
#define LTTNG_VIEWER_NAME_MAX 255
#include <stdlib.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/compat/memstream-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/compat/memstream-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "metadata.h"
#include "../common/metadata/decoder.h"
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "lttng-live.h"
int lttng_live_metadata_create_stream(struct lttng_live_session *session,
#include <sys/types.h>
#include <fcntl.h>
-#include <babeltrace/compat/socket-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/compat/socket-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "lttng-live.h"
#include "viewer-connection.h"
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compat/socket-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compat/socket-internal.h>
//TODO: this should not be used by plugins. Should copy code into plugin
//instead.
-#include <babeltrace/object-internal.h>
+#include <babeltrace2/object-internal.h>
#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "fs-src/fs.h"
#include "fs-sink/fs-sink.h"
#include <glib.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/common-internal.h>
#include "bin-info.h"
#include "crc32.h"
#include <stdbool.h>
#include <gelf.h>
#include <elfutils/libdw.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/fd-cache-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/fd-cache-internal.h>
#define DEFAULT_DEBUG_DIR "/usr/lib/debug"
#define DEBUG_SUBDIR ".debug"
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
/**
* Compute a 32-bit cyclic redundancy checksum for a given file.
#include <glib.h>
#include <plugins-common.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/fd-cache-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/fd-cache-internal.h>
#include "bin-info.h"
#include "debug-info.h"
*/
#include <stdint.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#define VPID_FIELD_NAME "vpid"
#define IP_FIELD_NAME "ip"
#include <stdlib.h>
#include <dwarf.h>
#include <elfutils/libdw.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
/*
* bt_dwarf is a wrapper over libdw providing a nicer, higher-level
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_lttng_utils_debug_info_log_level,
"BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_lttng_utils_debug_info_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_lttng_utils_debug_info_log_level);
#include <inttypes.h>
#include <stdint.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "trace-ir-data-copy.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "trace-ir-mapping.h"
#include <stdbool.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
/* For bt_property_availability */
-#include <babeltrace/property.h>
+#include <babeltrace2/property.h>
#include "debug-info.h"
#include "trace-ir-data-copy.h"
#include <glib.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "debug-info.h"
#include <inttypes.h>
#include <stdint.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "trace-ir-metadata-copy.h"
#include "trace-ir-metadata-field-class-copy.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "trace-ir-mapping.h"
BT_HIDDEN
#define BT_LOG_TAG "PLUGIN-LTTNG-UTILS-DEBUG-INFO-TRACE-IR-METADATA-FC-COPY"
#include "logging.h"
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/babeltrace.h>
#include "trace-ir-metadata-copy.h"
#include "trace-ir-metadata-field-class-copy.h"
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "trace-ir-mapping.h"
BT_HIDDEN
* SOFTWARE.
*/
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
#include "trace-ir-mapping.h"
/*
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "debug-info/debug-info.h"
#ifndef BT_BUILT_IN_PLUGINS
#include <string.h>
#include <ctype.h>
#include <stdio.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/compat/utc-internal.h>
-#include <babeltrace/compat/stdio-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/compat/utc-internal.h>
+#include <babeltrace2/compat/stdio-internal.h>
#include <glib.h>
#define NSEC_PER_USEC 1000UL
*/
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
BT_HIDDEN
bt_self_component_status dmesg_init(
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_text_dmesg_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_text_dmesg_log_level,
"BABELTRACE_SRC_TEXT_DMESG_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_text_dmesg_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_text_dmesg_log_level);
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "pretty/pretty.h"
#include "dmesg/dmesg.h"
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_text_pretty_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_text_pretty_log_level,
"BABELTRACE_SINK_TEXT_PRETTY_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_text_pretty_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_text_pretty_log_level);
#define BT_LOG_TAG "PLUGIN-TEXT-PRETTY-SINK"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
#include <plugins-common.h>
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "pretty.h"
*/
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
enum pretty_default {
PRETTY_DEFAULT_UNSET,
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/bitfield-internal.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/compat/time-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/bitfield-internal.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/compat/time-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
#include <ctype.h>
#include "pretty.h"
#define BT_LOG_TAG "PLUGIN-UTILS-COUNTER-FLT"
#include "logging.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/common-internal.h>
#include <plugins-common.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <inttypes.h>
#include <stdint.h>
*/
#include <glib.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdbool.h>
#include <stdint.h>
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_counter_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_counter_log_level,
"BABELTRACE_FLT_UTILS_COUNTER_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_muxer_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_muxer_log_level);
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include <plugins-common.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "dummy.h"
static
*/
#include <glib.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
#include <stdbool.h>
struct dummy {
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_muxer_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_muxer_log_level,
"BABELTRACE_FLT_UTILS_MUXER_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_muxer_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_muxer_log_level);
#define BT_LOG_TAG "PLUGIN-UTILS-MUXER-FLT"
#include "logging.h"
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compat/uuid-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/value-internal.h>
-#include <babeltrace/graph/component-internal.h>
-#include <babeltrace/graph/message-iterator-internal.h>
-#include <babeltrace/graph/connection-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compat/uuid-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/value-internal.h>
+#include <babeltrace2/graph/component-internal.h>
+#include <babeltrace2/graph/message-iterator-internal.h>
+#include <babeltrace2/graph/connection-internal.h>
#include <plugins-common.h>
#include <glib.h>
#include <stdbool.h>
#include <inttypes.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/common-internal.h>
#include <stdlib.h>
#include <string.h>
*/
#include <stdint.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
BT_HIDDEN
bt_self_component_status muxer_init(
* SOFTWARE.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include "dummy/dummy.h"
#include "counter/counter.h"
#include "muxer/muxer.h"
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_trimmer_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_INIT_LOG_LEVEL(bt_plugin_utils_trimmer_log_level,
"BABELTRACE_FLT_UTILS_TRIMMER_LOG_LEVEL");
*/
#define BT_LOG_OUTPUT_LEVEL bt_plugin_utils_trimmer_log_level
-#include <babeltrace/logging-internal.h>
+#include <babeltrace2/logging-internal.h>
BT_LOG_LEVEL_EXTERN_SYMBOL(bt_plugin_utils_trimmer_log_level);
#define BT_LOG_TAG "PLUGIN-UTILS-TRIMMER-FLT"
#include "logging.h"
-#include <babeltrace/compat/utc-internal.h>
-#include <babeltrace/compat/time-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
+#include <babeltrace2/compat/utc-internal.h>
+#include <babeltrace2/compat/time-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
#include <plugins-common.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <stdint.h>
#include <inttypes.h>
#include <glib.h>
*/
#include <stdbool.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/babeltrace.h>
BT_HIDDEN
void trimmer_finalize(bt_self_component_filter *self_comp);
#define BT_LOG_TAG "PLUGIN-PY"
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/plugin/plugin-const.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-internal.h>
#include <stdlib.h>
#include <signal.h>
#include <Python.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdlib.h>
#include <glib.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
static bt_self_component_status sink_consume(
bt_self_component_sink *self_comp)
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/bitfield-internal.h>
+#include <babeltrace2/bitfield-internal.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
#include <string.h>
#include "tap/tap.h"
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/ctf-writer/writer.h>
-#include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/clock-class.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/stream-class.h>
-#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ctf/events.h>
-#include <babeltrace/value.h>
+#include <babeltrace2/ctf-writer/writer.h>
+#include <babeltrace2/ctf-writer/clock.h>
+#include <babeltrace2/ctf-writer/clock-class.h>
+#include <babeltrace2/ctf-writer/stream.h>
+#include <babeltrace2/ctf-writer/event.h>
+#include <babeltrace2/ctf-writer/event-types.h>
+#include <babeltrace2/ctf-writer/event-fields.h>
+#include <babeltrace2/ctf-writer/stream-class.h>
+#include <babeltrace2/ctf-writer/trace.h>
+#include <babeltrace2/ctf/events.h>
+#include <babeltrace2/value.h>
#include <glib.h>
#include <unistd.h>
-#include <babeltrace/compat/stdlib-internal.h>
+#include <babeltrace2/compat/stdlib-internal.h>
#include <stdio.h>
-#include <babeltrace/compat/limits-internal.h>
-#include <babeltrace/compat/stdio-internal.h>
+#include <babeltrace2/compat/limits-internal.h>
+#include <babeltrace2/compat/stdio-internal.h>
#include <string.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <fcntl.h>
#include "tap/tap.h"
#include <math.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/assert-internal.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/babeltrace.h>
+#include <babeltrace2/babeltrace.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <glib.h>
#include "tap/tap.h"
#include "common.h"
*/
#include "tap/tap.h"
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/compat/stdlib-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/object-internal.h>
+#include <babeltrace2/compat/stdlib-internal.h>
+#include <babeltrace2/assert-internal.h>
#include "common.h"
#define NR_TESTS 37
#include <inttypes.h>
#include <glib.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/assert-internal.h>
#include <lttng-utils/debug-info/bin-info.h>
#include "tap/tap.h"