From: Philippe Proulx Date: Wed, 10 Jul 2019 06:05:42 +0000 (-0400) Subject: Move `include/babeltrace2/ctf-writer` -> `include/babeltrace2-ctf-writer` X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=217cf9d33a3ffc88e6eeaf21f3d46ee00cbeb0c4 Move `include/babeltrace2/ctf-writer` -> `include/babeltrace2-ctf-writer` CTF writer is not part of the Babeltrace library. With this patch, `include/babeltrace2` contains only the Babeltrace library public headers, and `include/babeltrace2-ctf-writer` contains only the Babeltrace CTF writer library public headers. Signed-off-by: Philippe Proulx Change-Id: I605ef01e1afbf0188f1ba5b094aed48717d46aff Reviewed-on: https://review.lttng.org/c/babeltrace/+/1675 Tested-by: jenkins --- diff --git a/include/Makefile.am b/include/Makefile.am index 339ccc22..8063039f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -15,23 +15,23 @@ babeltrace2include_HEADERS = \ babeltrace2/version.h # CTF writer API -babeltrace2ctfwriterincludedir = "$(includedir)/babeltrace2/ctf-writer" +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/types.h \ - babeltrace2/ctf-writer/utils.h \ - babeltrace2/ctf-writer/visitor.h \ - babeltrace2/ctf-writer/writer.h + 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/types.h \ + babeltrace2-ctf-writer/utils.h \ + babeltrace2-ctf-writer/visitor.h \ + babeltrace2-ctf-writer/writer.h # Trace IR API babeltrace2traceirincludedir = "$(includedir)/babeltrace2/trace-ir" diff --git a/include/babeltrace2-ctf-writer/clock-class.h b/include/babeltrace2-ctf-writer/clock-class.h new file mode 100644 index 00000000..c73f7e9c --- /dev/null +++ b/include/babeltrace2-ctf-writer/clock-class.h @@ -0,0 +1,89 @@ +#ifndef BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H +#define BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include + +#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_ctf_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_ctf_bool is_absolute); + +extern const uint8_t *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 uint8_t *uuid); +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H */ diff --git a/include/babeltrace2-ctf-writer/clock.h b/include/babeltrace2-ctf-writer/clock.h new file mode 100644 index 00000000..24170938 --- /dev/null +++ b/include/babeltrace2-ctf-writer/clock.h @@ -0,0 +1,282 @@ +#ifndef BABELTRACE2_CTF_WRITER_CLOCK_H +#define BABELTRACE2_CTF_WRITER_CLOCK_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include +#include + +#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 uint8_t *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 uint8_t *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 /* BABELTRACE2_CTF_WRITER_CLOCK_H */ diff --git a/include/babeltrace2-ctf-writer/event-fields.h b/include/babeltrace2-ctf-writer/event-fields.h new file mode 100644 index 00000000..83df286f --- /dev/null +++ b/include/babeltrace2-ctf-writer/event-fields.h @@ -0,0 +1,69 @@ +#ifndef BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H +#define BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include +#include + +#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 /* BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H */ diff --git a/include/babeltrace2-ctf-writer/event-types.h b/include/babeltrace2-ctf-writer/event-types.h new file mode 100644 index 00000000..4df0e5d5 --- /dev/null +++ b/include/babeltrace2-ctf-writer/event-types.h @@ -0,0 +1,68 @@ +#ifndef BABELTRACE2_CTF_WRITER_EVENT_TYPES_H +#define BABELTRACE2_CTF_WRITER_EVENT_TYPES_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include + +#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 /* BABELTRACE2_CTF_WRITER_EVENT_TYPES_H */ diff --git a/include/babeltrace2-ctf-writer/event.h b/include/babeltrace2-ctf-writer/event.h new file mode 100644 index 00000000..98151253 --- /dev/null +++ b/include/babeltrace2-ctf-writer/event.h @@ -0,0 +1,211 @@ +#ifndef BABELTRACE2_CTF_WRITER_EVENT_H +#define BABELTRACE2_CTF_WRITER_EVENT_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include + +#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 /* BABELTRACE2_CTF_WRITER_EVENT_H */ diff --git a/include/babeltrace2-ctf-writer/field-types.h b/include/babeltrace2-ctf-writer/field-types.h new file mode 100644 index 00000000..84076066 --- /dev/null +++ b/include/babeltrace2-ctf-writer/field-types.h @@ -0,0 +1,339 @@ +#ifndef BABELTRACE2_CTF_WRITER_FIELD_TYPES_H +#define BABELTRACE2_CTF_WRITER_FIELD_TYPES_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include +#include + +#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_ctf_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_ctf_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_CTF_TRUE : BT_CTF_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 /* BABELTRACE2_CTF_WRITER_FIELD_TYPES_H */ diff --git a/include/babeltrace2-ctf-writer/fields.h b/include/babeltrace2-ctf-writer/fields.h new file mode 100644 index 00000000..13455984 --- /dev/null +++ b/include/babeltrace2-ctf-writer/fields.h @@ -0,0 +1,134 @@ +#ifndef BABELTRACE2_CTF_WRITER_FIELDS_H +#define BABELTRACE2_CTF_WRITER_FIELDS_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include + +#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 /* BABELTRACE2_CTF_WRITER_FIELDS_H */ diff --git a/include/babeltrace2-ctf-writer/object.h b/include/babeltrace2-ctf-writer/object.h new file mode 100644 index 00000000..904cfa22 --- /dev/null +++ b/include/babeltrace2-ctf-writer/object.h @@ -0,0 +1,213 @@ +#ifndef BABELTRACE2_CTF_WRITER_OBJECT_H +#define BABELTRACE2_CTF_WRITER_OBJECT_H + +/* + * Copyright (c) 2010-2019 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 + +/** +@defgroup refs Reference counting management +@ingroup apiref +@brief Common reference counting management for all Babeltrace objects. + +@code +#include +@endcode + +The macros and functions of this module are everything that is needed +to handle the reference counting of +Babeltrace objects. + +Any Babeltrace object can be shared by multiple owners thanks to +reference +counting. + +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 borrows the + reference for the duration of the function. + + @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 never + transferred 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 new reference. 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 + borrowed, or weak reference: 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 If \p _var does not contain \p NULL, + 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 If \p _var_dst and \p _var_src contain the same + value which is not \c NULL, this object's reference + count is greater than 1. +@post If \c _var_dst is not \c NULL, 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 If \c obj is not \c NULL, 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 If \c obj is not \c NULL, 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 /* BABELTRACE2_CTF_WRITER_OBJECT_H */ diff --git a/include/babeltrace2-ctf-writer/stream-class.h b/include/babeltrace2-ctf-writer/stream-class.h new file mode 100644 index 00000000..e1d34717 --- /dev/null +++ b/include/babeltrace2-ctf-writer/stream-class.h @@ -0,0 +1,117 @@ +#ifndef BABELTRACE2_CTF_WRITER_STREAM_CLASS_H +#define BABELTRACE2_CTF_WRITER_STREAM_CLASS_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include + +#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 /* BABELTRACE2_CTF_WRITER_STREAM_CLASS_H */ diff --git a/include/babeltrace2-ctf-writer/stream.h b/include/babeltrace2-ctf-writer/stream.h new file mode 100644 index 00000000..003e8d5d --- /dev/null +++ b/include/babeltrace2-ctf-writer/stream.h @@ -0,0 +1,182 @@ +#ifndef BABELTRACE2_CTF_WRITER_STREAM_H +#define BABELTRACE2_CTF_WRITER_STREAM_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include + +#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 /* BABELTRACE2_CTF_WRITER_STREAM_H */ diff --git a/include/babeltrace2-ctf-writer/trace.h b/include/babeltrace2-ctf-writer/trace.h new file mode 100644 index 00000000..95e88544 --- /dev/null +++ b/include/babeltrace2-ctf-writer/trace.h @@ -0,0 +1,83 @@ +#ifndef BABELTRACE2_CTF_WRITER_TRACE_H +#define BABELTRACE2_CTF_WRITER_TRACE_H + +/* + * Copyright (c) 2010-2019 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 + +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 uint8_t *bt_ctf_trace_get_uuid( + struct bt_ctf_trace *trace); + +extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace, + const uint8_t *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 /* BABELTRACE2_CTF_WRITER_TRACE_H */ diff --git a/include/babeltrace2-ctf-writer/types.h b/include/babeltrace2-ctf-writer/types.h new file mode 100644 index 00000000..c45b2b1b --- /dev/null +++ b/include/babeltrace2-ctf-writer/types.h @@ -0,0 +1,42 @@ +#ifndef BABELTRACE2_CTF_WRITER_TYPES_H +#define BABELTRACE2_CTF_WRITER_TYPES_H + +/* + * Copyright (c) 2010-2019 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 + +/// False boolean value for the #bt_ctf_bool type. +#define BT_CTF_FALSE 0 + +/// True boolean value for the #bt_ctf_bool type. +#define BT_CTF_TRUE 1 + +typedef int bt_ctf_bool; + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE2_CTF_WRITER_TYPES_H */ diff --git a/include/babeltrace2-ctf-writer/utils.h b/include/babeltrace2-ctf-writer/utils.h new file mode 100644 index 00000000..e39d0094 --- /dev/null +++ b/include/babeltrace2-ctf-writer/utils.h @@ -0,0 +1,45 @@ +#ifndef BABELTRACE2_CTF_WRITER_UTILS_H +#define BABELTRACE2_CTF_WRITER_UTILS_H + +/* + * Copyright (c) 2010-2019 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. + */ + +/* For bt_ctf_bool */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bt_ctf_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 /* BABELTRACE2_CTF_WRITER_UTILS_H */ diff --git a/include/babeltrace2-ctf-writer/visitor.h b/include/babeltrace2-ctf-writer/visitor.h new file mode 100644 index 00000000..c2fb0daf --- /dev/null +++ b/include/babeltrace2-ctf-writer/visitor.h @@ -0,0 +1,168 @@ +#ifndef BABELTRACE2_CTF_WRITER_VISITOR_H +#define BABELTRACE2_CTF_WRITER_VISITOR_H + +/* + * Copyright (c) 2010-2019 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 + +/** +@defgroup ctfirvisitor CTF IR visitor +@ingroup ctfir +@brief CTF IR visitor. + +@code +#include +@endcode + +A CTF IR visitor 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 no reference count: 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 no reference count: 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 /* BABELTRACE2_CTF_WRITER_VISITOR_H */ diff --git a/include/babeltrace2-ctf-writer/writer.h b/include/babeltrace2-ctf-writer/writer.h new file mode 100644 index 00000000..7718d25e --- /dev/null +++ b/include/babeltrace2-ctf-writer/writer.h @@ -0,0 +1,199 @@ +#ifndef BABELTRACE2_CTF_WRITER_WRITER_H +#define BABELTRACE2_CTF_WRITER_WRITER_H + +/* + * Copyright (c) 2010-2019 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. + */ + +#include +#include +#include +#include + +#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 /* BABELTRACE2_CTF_WRITER_WRITER_H */ diff --git a/include/babeltrace2/ctf-writer/clock-class.h b/include/babeltrace2/ctf-writer/clock-class.h deleted file mode 100644 index c73f7e9c..00000000 --- a/include/babeltrace2/ctf-writer/clock-class.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H -#define BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include - -#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_ctf_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_ctf_bool is_absolute); - -extern const uint8_t *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 uint8_t *uuid); -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE2_CTF_WRITER_CLOCK_CLASS_H */ diff --git a/include/babeltrace2/ctf-writer/clock.h b/include/babeltrace2/ctf-writer/clock.h deleted file mode 100644 index 0f1bfa10..00000000 --- a/include/babeltrace2/ctf-writer/clock.h +++ /dev/null @@ -1,282 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_CLOCK_H -#define BABELTRACE2_CTF_WRITER_CLOCK_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include -#include - -#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 uint8_t *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 uint8_t *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 /* BABELTRACE2_CTF_WRITER_CLOCK_H */ diff --git a/include/babeltrace2/ctf-writer/event-fields.h b/include/babeltrace2/ctf-writer/event-fields.h deleted file mode 100644 index 568e387c..00000000 --- a/include/babeltrace2/ctf-writer/event-fields.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H -#define BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include -#include - -#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 /* BABELTRACE2_CTF_WRITER_EVENT_FIELDS_H */ diff --git a/include/babeltrace2/ctf-writer/event-types.h b/include/babeltrace2/ctf-writer/event-types.h deleted file mode 100644 index db863edb..00000000 --- a/include/babeltrace2/ctf-writer/event-types.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_EVENT_TYPES_H -#define BABELTRACE2_CTF_WRITER_EVENT_TYPES_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include - -#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 /* BABELTRACE2_CTF_WRITER_EVENT_TYPES_H */ diff --git a/include/babeltrace2/ctf-writer/event.h b/include/babeltrace2/ctf-writer/event.h deleted file mode 100644 index 3e0965b1..00000000 --- a/include/babeltrace2/ctf-writer/event.h +++ /dev/null @@ -1,211 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_EVENT_H -#define BABELTRACE2_CTF_WRITER_EVENT_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include - -#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 /* BABELTRACE2_CTF_WRITER_EVENT_H */ diff --git a/include/babeltrace2/ctf-writer/field-types.h b/include/babeltrace2/ctf-writer/field-types.h deleted file mode 100644 index 10b10338..00000000 --- a/include/babeltrace2/ctf-writer/field-types.h +++ /dev/null @@ -1,339 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_FIELD_TYPES_H -#define BABELTRACE2_CTF_WRITER_FIELD_TYPES_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include -#include - -#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_ctf_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_ctf_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_CTF_TRUE : BT_CTF_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 /* BABELTRACE2_CTF_WRITER_FIELD_TYPES_H */ diff --git a/include/babeltrace2/ctf-writer/fields.h b/include/babeltrace2/ctf-writer/fields.h deleted file mode 100644 index 13455984..00000000 --- a/include/babeltrace2/ctf-writer/fields.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_FIELDS_H -#define BABELTRACE2_CTF_WRITER_FIELDS_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include - -#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 /* BABELTRACE2_CTF_WRITER_FIELDS_H */ diff --git a/include/babeltrace2/ctf-writer/object.h b/include/babeltrace2/ctf-writer/object.h deleted file mode 100644 index 2feedac5..00000000 --- a/include/babeltrace2/ctf-writer/object.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_OBJECT_H -#define BABELTRACE2_CTF_WRITER_OBJECT_H - -/* - * Copyright (c) 2010-2019 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 - -/** -@defgroup refs Reference counting management -@ingroup apiref -@brief Common reference counting management for all Babeltrace objects. - -@code -#include -@endcode - -The macros and functions of this module are everything that is needed -to handle the reference counting of -Babeltrace objects. - -Any Babeltrace object can be shared by multiple owners thanks to -reference -counting. - -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 borrows the - reference for the duration of the function. - - @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 never - transferred 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 new reference. 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 - borrowed, or weak reference: 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 If \p _var does not contain \p NULL, - 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 If \p _var_dst and \p _var_src contain the same - value which is not \c NULL, this object's reference - count is greater than 1. -@post If \c _var_dst is not \c NULL, 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 If \c obj is not \c NULL, 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 If \c obj is not \c NULL, 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 /* BABELTRACE2_CTF_WRITER_OBJECT_H */ diff --git a/include/babeltrace2/ctf-writer/stream-class.h b/include/babeltrace2/ctf-writer/stream-class.h deleted file mode 100644 index 5d433186..00000000 --- a/include/babeltrace2/ctf-writer/stream-class.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_STREAM_CLASS_H -#define BABELTRACE2_CTF_WRITER_STREAM_CLASS_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include - -#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 /* BABELTRACE2_CTF_WRITER_STREAM_CLASS_H */ diff --git a/include/babeltrace2/ctf-writer/stream.h b/include/babeltrace2/ctf-writer/stream.h deleted file mode 100644 index 003e8d5d..00000000 --- a/include/babeltrace2/ctf-writer/stream.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_STREAM_H -#define BABELTRACE2_CTF_WRITER_STREAM_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include - -#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 /* BABELTRACE2_CTF_WRITER_STREAM_H */ diff --git a/include/babeltrace2/ctf-writer/trace.h b/include/babeltrace2/ctf-writer/trace.h deleted file mode 100644 index 95e88544..00000000 --- a/include/babeltrace2/ctf-writer/trace.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_TRACE_H -#define BABELTRACE2_CTF_WRITER_TRACE_H - -/* - * Copyright (c) 2010-2019 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 - -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 uint8_t *bt_ctf_trace_get_uuid( - struct bt_ctf_trace *trace); - -extern int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace, - const uint8_t *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 /* BABELTRACE2_CTF_WRITER_TRACE_H */ diff --git a/include/babeltrace2/ctf-writer/types.h b/include/babeltrace2/ctf-writer/types.h deleted file mode 100644 index c45b2b1b..00000000 --- a/include/babeltrace2/ctf-writer/types.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_TYPES_H -#define BABELTRACE2_CTF_WRITER_TYPES_H - -/* - * Copyright (c) 2010-2019 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 - -/// False boolean value for the #bt_ctf_bool type. -#define BT_CTF_FALSE 0 - -/// True boolean value for the #bt_ctf_bool type. -#define BT_CTF_TRUE 1 - -typedef int bt_ctf_bool; - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE2_CTF_WRITER_TYPES_H */ diff --git a/include/babeltrace2/ctf-writer/utils.h b/include/babeltrace2/ctf-writer/utils.h deleted file mode 100644 index 6465c0d5..00000000 --- a/include/babeltrace2/ctf-writer/utils.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_UTILS_H -#define BABELTRACE2_CTF_WRITER_UTILS_H - -/* - * Copyright (c) 2010-2019 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. - */ - -/* For bt_ctf_bool */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern bt_ctf_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 /* BABELTRACE2_CTF_WRITER_UTILS_H */ diff --git a/include/babeltrace2/ctf-writer/visitor.h b/include/babeltrace2/ctf-writer/visitor.h deleted file mode 100644 index c2fb0daf..00000000 --- a/include/babeltrace2/ctf-writer/visitor.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_VISITOR_H -#define BABELTRACE2_CTF_WRITER_VISITOR_H - -/* - * Copyright (c) 2010-2019 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 - -/** -@defgroup ctfirvisitor CTF IR visitor -@ingroup ctfir -@brief CTF IR visitor. - -@code -#include -@endcode - -A CTF IR visitor 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 no reference count: 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 no reference count: 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 /* BABELTRACE2_CTF_WRITER_VISITOR_H */ diff --git a/include/babeltrace2/ctf-writer/writer.h b/include/babeltrace2/ctf-writer/writer.h deleted file mode 100644 index 63c1ba3b..00000000 --- a/include/babeltrace2/ctf-writer/writer.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifndef BABELTRACE2_CTF_WRITER_WRITER_H -#define BABELTRACE2_CTF_WRITER_WRITER_H - -/* - * Copyright (c) 2010-2019 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. - */ - -#include -#include -#include -#include - -#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 /* BABELTRACE2_CTF_WRITER_WRITER_H */ diff --git a/src/ctf-writer/attributes.c b/src/ctf-writer/attributes.c index f331019e..dc51fc6b 100644 --- a/src/ctf-writer/attributes.c +++ b/src/ctf-writer/attributes.c @@ -31,7 +31,7 @@ #include "common/assert.h" #include "common/macros.h" #include "compat/string.h" -#include +#include #include #include "values.h" diff --git a/src/ctf-writer/clock-class.c b/src/ctf-writer/clock-class.c index 47c49bac..c1d3caff 100644 --- a/src/ctf-writer/clock-class.c +++ b/src/ctf-writer/clock-class.c @@ -30,8 +30,8 @@ #include "logging.h" #include "common/uuid.h" -#include -#include +#include +#include #include "compat/compiler.h" #include #include "compat/string.h" diff --git a/src/ctf-writer/clock-class.h b/src/ctf-writer/clock-class.h index 14e0bd47..413e6e80 100644 --- a/src/ctf-writer/clock-class.h +++ b/src/ctf-writer/clock-class.h @@ -28,7 +28,7 @@ #include "common/macros.h" #include "object-pool.h" #include "common/uuid.h" -#include +#include #include #include #include diff --git a/src/ctf-writer/clock.c b/src/ctf-writer/clock.c index e1c00dac..b6889a6c 100644 --- a/src/ctf-writer/clock.c +++ b/src/ctf-writer/clock.c @@ -33,8 +33,8 @@ #include "common/assert.h" #include "common/uuid.h" #include "compat/compiler.h" -#include -#include +#include +#include #include #include "clock-class.h" diff --git a/src/ctf-writer/clock.h b/src/ctf-writer/clock.h index 01cddc47..a6bfd5ce 100644 --- a/src/ctf-writer/clock.h +++ b/src/ctf-writer/clock.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include +#include #include "common/macros.h" #include diff --git a/src/ctf-writer/event-class.c b/src/ctf-writer/event-class.c index ac5d8926..823165c8 100644 --- a/src/ctf-writer/event-class.c +++ b/src/ctf-writer/event-class.c @@ -28,11 +28,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include "common/assert.h" diff --git a/src/ctf-writer/event-class.h b/src/ctf-writer/event-class.h index 35c1de5d..522f15e4 100644 --- a/src/ctf-writer/event-class.h +++ b/src/ctf-writer/event-class.h @@ -27,11 +27,11 @@ #include "common/assert.h" #include "common/macros.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include "object.h" diff --git a/src/ctf-writer/event.c b/src/ctf-writer/event.c index a4706876..abe2521a 100644 --- a/src/ctf-writer/event.c +++ b/src/ctf-writer/event.c @@ -26,13 +26,13 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "common/assert.h" #include "compat/compiler.h" diff --git a/src/ctf-writer/event.h b/src/ctf-writer/event.h index 0bfbb007..ed21444a 100644 --- a/src/ctf-writer/event.h +++ b/src/ctf-writer/event.h @@ -30,10 +30,10 @@ #include "common/assert.h" #include "common/macros.h" -#include -#include -#include -#include +#include +#include +#include +#include #include "ctfser/ctfser.h" #include "assert-pre.h" diff --git a/src/ctf-writer/field-path.c b/src/ctf-writer/field-path.c index be19b403..6770290c 100644 --- a/src/ctf-writer/field-path.c +++ b/src/ctf-writer/field-path.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include "common/assert.h" diff --git a/src/ctf-writer/field-path.h b/src/ctf-writer/field-path.h index 76d3793e..c63a7752 100644 --- a/src/ctf-writer/field-path.h +++ b/src/ctf-writer/field-path.h @@ -29,7 +29,7 @@ #include "common/common.h" #include "common/assert.h" #include "common/macros.h" -#include +#include #include #include "object.h" diff --git a/src/ctf-writer/field-types.c b/src/ctf-writer/field-types.c index c427ee4f..30b2cdc3 100644 --- a/src/ctf-writer/field-types.c +++ b/src/ctf-writer/field-types.c @@ -29,10 +29,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "common/assert.h" #include "compat/compiler.h" diff --git a/src/ctf-writer/field-types.h b/src/ctf-writer/field-types.h index 52118235..ce4dafe6 100644 --- a/src/ctf-writer/field-types.h +++ b/src/ctf-writer/field-types.h @@ -31,8 +31,8 @@ #include #include -#include -#include +#include +#include #include "common/macros.h" diff --git a/src/ctf-writer/fields.c b/src/ctf-writer/fields.c index 3909deb6..2d3fc63c 100644 --- a/src/ctf-writer/fields.c +++ b/src/ctf-writer/fields.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include "common/align.h" #include "common/assert.h" diff --git a/src/ctf-writer/fields.h b/src/ctf-writer/fields.h index b2284996..87063fe2 100644 --- a/src/ctf-writer/fields.h +++ b/src/ctf-writer/fields.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include "common/macros.h" diff --git a/src/ctf-writer/resolve.c b/src/ctf-writer/resolve.c index bc6ede5f..ae5fe94f 100644 --- a/src/ctf-writer/resolve.c +++ b/src/ctf-writer/resolve.c @@ -36,9 +36,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include "common/macros.h" diff --git a/src/ctf-writer/resolve.h b/src/ctf-writer/resolve.h index 930b22c4..799b3e6a 100644 --- a/src/ctf-writer/resolve.h +++ b/src/ctf-writer/resolve.h @@ -27,7 +27,7 @@ * SOFTWARE. */ -#include +#include #include "common/macros.h" #include diff --git a/src/ctf-writer/stream-class.c b/src/ctf-writer/stream-class.c index 5346c530..ffec6655 100644 --- a/src/ctf-writer/stream-class.c +++ b/src/ctf-writer/stream-class.c @@ -28,10 +28,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "common/align.h" #include "common/assert.h" diff --git a/src/ctf-writer/stream-class.h b/src/ctf-writer/stream-class.h index f39f405e..ca5a3075 100644 --- a/src/ctf-writer/stream-class.h +++ b/src/ctf-writer/stream-class.h @@ -31,8 +31,8 @@ #include "common/assert.h" #include "common/macros.h" #include "common/common.h" -#include -#include +#include +#include #include #include "clock.h" diff --git a/src/ctf-writer/stream.c b/src/ctf-writer/stream.c index 7d371ffd..1bf60df1 100644 --- a/src/ctf-writer/stream.c +++ b/src/ctf-writer/stream.c @@ -28,11 +28,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "common/align.h" #include "common/assert.h" diff --git a/src/ctf-writer/stream.h b/src/ctf-writer/stream.h index ff6f8a82..5596e33d 100644 --- a/src/ctf-writer/stream.h +++ b/src/ctf-writer/stream.h @@ -30,7 +30,7 @@ #include "common/assert.h" #include "common/macros.h" -#include +#include #include "ctfser/ctfser.h" #include diff --git a/src/ctf-writer/trace.c b/src/ctf-writer/trace.c index 3e29ce7b..56a9a55f 100644 --- a/src/ctf-writer/trace.c +++ b/src/ctf-writer/trace.c @@ -29,9 +29,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include "common/assert.h" diff --git a/src/ctf-writer/trace.h b/src/ctf-writer/trace.h index cd724c6a..1b426821 100644 --- a/src/ctf-writer/trace.h +++ b/src/ctf-writer/trace.h @@ -30,9 +30,9 @@ #include "common/macros.h" #include "common/uuid.h" -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ctf-writer/utils.c b/src/ctf-writer/utils.c index 935bfa84..5c951ea9 100644 --- a/src/ctf-writer/utils.c +++ b/src/ctf-writer/utils.c @@ -32,8 +32,8 @@ #include #include -#include -#include +#include +#include #include "common/assert.h" diff --git a/src/ctf-writer/utils.h b/src/ctf-writer/utils.h index 6cb0609a..f08d544b 100644 --- a/src/ctf-writer/utils.h +++ b/src/ctf-writer/utils.h @@ -22,8 +22,8 @@ */ #include "common/macros.h" -#include -#include +#include +#include #include #include "field-path.h" diff --git a/src/ctf-writer/validation.c b/src/ctf-writer/validation.c index f6d031d7..7acf37b0 100644 --- a/src/ctf-writer/validation.c +++ b/src/ctf-writer/validation.c @@ -27,7 +27,7 @@ #define BT_LOG_TAG "CTF-WRITER/VALIDATION" #include "logging.h" -#include +#include #include "common/macros.h" diff --git a/src/ctf-writer/values.c b/src/ctf-writer/values.c index 89a808d4..f7f5a72e 100644 --- a/src/ctf-writer/values.c +++ b/src/ctf-writer/values.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include "common/assert.h" diff --git a/src/ctf-writer/values.h b/src/ctf-writer/values.h index 99037666..dc237c5b 100644 --- a/src/ctf-writer/values.h +++ b/src/ctf-writer/values.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include +#include #include "common/macros.h" diff --git a/src/ctf-writer/visitor.c b/src/ctf-writer/visitor.c index ca943f87..0043611a 100644 --- a/src/ctf-writer/visitor.c +++ b/src/ctf-writer/visitor.c @@ -26,7 +26,7 @@ * SOFTWARE. */ -#include +#include #include "common/macros.h" diff --git a/src/ctf-writer/visitor.h b/src/ctf-writer/visitor.h index 5c583745..bc6e0567 100644 --- a/src/ctf-writer/visitor.h +++ b/src/ctf-writer/visitor.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include "common/macros.h" typedef void *(*bt_ctf_child_accessor)(void *object, int index); diff --git a/src/ctf-writer/writer.c b/src/ctf-writer/writer.c index a3d6f8b4..1738b70c 100644 --- a/src/ctf-writer/writer.c +++ b/src/ctf-writer/writer.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include "common/assert.h" #include "compat/compiler.h" diff --git a/src/ctf-writer/writer.h b/src/ctf-writer/writer.h index 15b08856..33f2fbe6 100644 --- a/src/ctf-writer/writer.h +++ b/src/ctf-writer/writer.h @@ -29,8 +29,8 @@ #include #include -#include -#include +#include +#include #include "common/macros.h" diff --git a/tests/ctf-writer/ctf_writer.c b/tests/ctf-writer/ctf_writer.c index b41a068c..73edf75c 100644 --- a/tests/ctf-writer/ctf_writer.c +++ b/tests/ctf-writer/ctf_writer.c @@ -19,15 +19,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index 90cff9cd..e1b215b8 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -25,15 +25,15 @@ #include "lib/object.h" #include "compat/stdlib.h" #include "common/assert.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common.h" #define NR_TESTS 37 diff --git a/tests/plugins/sink.ctf.fs/succeed/gen-trace-double.c b/tests/plugins/sink.ctf.fs/succeed/gen-trace-double.c index 3c187ee3..8357facb 100644 --- a/tests/plugins/sink.ctf.fs/succeed/gen-trace-double.c +++ b/tests/plugins/sink.ctf.fs/succeed/gen-trace-double.c @@ -21,15 +21,15 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common/assert.h" diff --git a/tests/plugins/sink.ctf.fs/succeed/gen-trace-float.c b/tests/plugins/sink.ctf.fs/succeed/gen-trace-float.c index 34444b2e..8ba7c21d 100644 --- a/tests/plugins/sink.ctf.fs/succeed/gen-trace-float.c +++ b/tests/plugins/sink.ctf.fs/succeed/gen-trace-float.c @@ -21,15 +21,15 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common/assert.h" diff --git a/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c b/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c index a7b9e9b6..75132ecc 100644 --- a/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c +++ b/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c @@ -21,15 +21,15 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "common/assert.h"