uint64_t index);
BT_HIDDEN
-struct bt_value *bt_attributes_get_field_value(struct bt_value *attr_obj,
+struct bt_value *bt_attributes_borrow_field_value(struct bt_value *attr_obj,
uint64_t index);
BT_HIDDEN
const char *name, struct bt_value *value_obj);
BT_HIDDEN
-struct bt_value *bt_attributes_get_field_value_by_name(
+struct bt_value *bt_attributes_borrow_field_value_by_name(
struct bt_value *attr_obj, const char *name);
BT_HIDDEN
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
extern struct bt_clock_value *bt_clock_value_create(
struct bt_clock_class *clock_class, uint64_t value);
-extern struct bt_clock_class *bt_clock_value_get_class(
+extern struct bt_clock_class *bt_clock_value_borrow_class(
struct bt_clock_value *clock_value);
+
+static inline
+struct bt_clock_class *bt_clock_value_get_class(
+ struct bt_clock_value *clock_value)
+{
+ return bt_get(bt_clock_value_borrow_class(clock_value));
+}
+
extern int bt_clock_value_get_value(
struct bt_clock_value *clock_value, uint64_t *raw_value);
extern int bt_clock_value_get_value_ns_from_epoch(
return (void *) bt_object_borrow_parent(event_class);
}
-static inline
-struct bt_stream_class *bt_event_class_borrow_stream_class(
- struct bt_event_class *event_class)
-{
- return BT_FROM_COMMON(bt_event_class_common_borrow_stream_class(
- BT_TO_COMMON(event_class)));
-}
-
typedef struct bt_field_type_common *(*bt_field_type_structure_create_func)();
BT_HIDDEN
}
static inline
-struct bt_field_type_common *bt_event_class_common_get_context_field_type(
+struct bt_field_type_common *bt_event_class_common_borrow_context_field_type(
struct bt_event_class_common *event_class)
{
struct bt_field_type_common *context_ft = NULL;
goto end;
}
- context_ft = bt_get(event_class->context_field_type);
+ context_ft = event_class->context_field_type;
end:
return context_ft;
}
static inline
-struct bt_field_type_common *bt_event_class_common_get_payload_field_type(
+struct bt_field_type_common *bt_event_class_common_borrow_payload_field_type(
struct bt_event_class_common *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return bt_get(event_class->payload_field_type);
+ return event_class->payload_field_type;
}
static inline
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#include <stddef.h>
*/
extern struct bt_event_class *bt_event_class_create(const char *name);
+extern struct bt_stream_class *bt_event_class_borrow_stream_class(
+ struct bt_event_class *event_class);
+
/**
@brief Returns the parent CTF IR stream class of the CTF IR event
class \p event_class.
@sa bt_stream_class_add_event_class(): Add an event class to
a stream class.
*/
-extern struct bt_stream_class *bt_event_class_get_stream_class(
- struct bt_event_class *event_class);
+static inline
+struct bt_stream_class *bt_event_class_get_stream_class(
+ struct bt_event_class *event_class)
+{
+ return bt_get(bt_event_class_borrow_stream_class(event_class));
+}
/** @} */
@{
*/
+extern struct bt_field_type *bt_event_class_borrow_context_field_type(
+ struct bt_event_class *event_class);
+
/**
@brief Returns the context field type of the CTF IR event class
\p event_class.
@sa bt_event_class_set_context_field_type(): Sets the context field type of a
given event class.
*/
-extern struct bt_field_type *bt_event_class_get_context_field_type(
- struct bt_event_class *event_class);
+static inline
+struct bt_field_type *bt_event_class_get_context_field_type(
+ struct bt_event_class *event_class)
+{
+ return bt_get(bt_event_class_borrow_context_field_type(event_class));
+}
/**
@brief Sets the context field type of the CTF IR event class \p event_class to
struct bt_event_class *event_class,
struct bt_field_type *context_type);
+extern struct bt_field_type *bt_event_class_borrow_payload_field_type(
+ struct bt_event_class *event_class);
+
/**
@brief Returns the payload field type of the CTF IR event class
\p event_class.
@sa bt_event_class_set_payload_field_type(): Sets the payload field type of a
given event class.
*/
-extern struct bt_field_type *bt_event_class_get_payload_field_type(
- struct bt_event_class *event_class);
+static inline
+struct bt_field_type *bt_event_class_get_payload_field_type(
+ struct bt_event_class *event_class)
+{
+ return bt_get(bt_event_class_borrow_payload_field_type(event_class));
+}
/**
@brief Sets the payload field type of the CTF IR event class \p event_class to
#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \
BT_ASSERT_PRE_HOT((_event), (_name), ": +%!+_e", (_event))
-static inline struct bt_packet *bt_event_borrow_packet(struct bt_event *event)
-{
- BT_ASSERT(event);
- return event->packet;
-}
-
-BT_HIDDEN
-struct bt_stream *bt_event_borrow_stream(struct bt_event *event);
-
static inline
struct bt_event_class_common *bt_event_common_borrow_class(
struct bt_event_common *event)
return event->class;
}
-static inline
-struct bt_event_class *bt_event_borrow_class(struct bt_event *event)
-{
- return BT_FROM_COMMON(bt_event_common_borrow_class(
- BT_TO_COMMON(event)));
-}
-
BT_HIDDEN
int bt_event_common_initialize(struct bt_event_common *event,
struct bt_event_class_common *event_class,
void *(*create_field_func)(void *));
static inline
-struct bt_field_common *bt_event_common_get_payload(
+struct bt_field_common *bt_event_common_borrow_payload(
struct bt_event_common *event)
{
struct bt_field_common *payload = NULL;
}
payload = event->payload_field;
- bt_get(payload);
end:
return payload;
}
static inline
-struct bt_field_common *bt_event_common_get_header(
+struct bt_field_common *bt_event_common_borrow_header(
struct bt_event_common *event)
{
struct bt_field_common *header = NULL;
}
header = event->header_field;
- bt_get(header);
end:
return header;
}
static inline
-struct bt_field_common *bt_event_common_get_context(
+struct bt_field_common *bt_event_common_borrow_context(
struct bt_event_common *event)
{
struct bt_field_common *context = NULL;
}
context = event->context_field;
- bt_get(context);
end:
return context;
}
static inline
-struct bt_field_common *bt_event_common_get_stream_event_context(
+struct bt_field_common *bt_event_common_borrow_stream_event_context(
struct bt_event_common *event)
{
struct bt_field_common *stream_event_context = NULL;
stream_event_context = event->stream_event_context_field;
end:
- return bt_get(stream_event_context);
+ return stream_event_context;
}
static inline
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#include <stddef.h>
*/
extern struct bt_event *bt_event_create(struct bt_event_class *event_class);
+extern struct bt_event_class *bt_event_borrow_class(struct bt_event *event);
+
/**
@brief Returns the parent CTF IR event class of the CTF IR event
\p event.
@postrefcountsame{event}
@postsuccessrefcountretinc
*/
-extern struct bt_event_class *bt_event_get_class(struct bt_event *event);
+static inline
+struct bt_event_class *bt_event_get_class(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_class(event));
+}
+
+extern struct bt_packet *bt_event_borrow_packet(struct bt_event *event);
/**
@brief Returns the CTF IR packet associated to the CTF IR event
@sa bt_event_set_packet(): Associates a given event to a given
packet.
*/
-extern struct bt_packet *bt_event_get_packet(struct bt_event *event);
+static inline
+struct bt_packet *bt_event_get_packet(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_packet(event));
+}
/**
@brief Associates the CTF IR event \p event to the CTF IR packet
extern int bt_event_set_packet(struct bt_event *event,
struct bt_packet *packet);
+extern struct bt_stream *bt_event_borrow_stream(struct bt_event *event);
+
/**
@brief Returns the parent CTF IR stream associated to the CTF IR event
\p event.
@postrefcountsame{event}
@postsuccessrefcountretinc
*/
-extern struct bt_stream *bt_event_get_stream(struct bt_event *event);
+static inline
+struct bt_stream *bt_event_get_stream(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_stream(event));
+}
/** @} */
@{
*/
+extern struct bt_field *bt_event_borrow_header(struct bt_event *event);
+
/**
@brief Returns the stream event header field of the CTF IR event
\p event.
@sa bt_event_get_header(): Sets the stream event header
field of a given event.
*/
-extern struct bt_field *bt_event_get_header(struct bt_event *event);
+static inline
+struct bt_field *bt_event_get_header(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_header(event));
+}
/**
@brief Sets the stream event header field of the CTF IR event
extern int bt_event_set_header(struct bt_event *event,
struct bt_field *header);
+extern struct bt_field *bt_event_borrow_stream_event_context(
+ struct bt_event *event);
+
/**
@brief Returns the stream event context field of the CTF IR event
\p event.
@sa bt_event_set_stream_event_context(): Sets the stream event context
field of a given event.
*/
-extern struct bt_field *bt_event_get_stream_event_context(
- struct bt_event *event);
+static inline
+struct bt_field *bt_event_get_stream_event_context(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_stream_event_context(event));
+}
/**
@brief Sets the stream event context field of the CTF IR event
extern int bt_event_set_stream_event_context(struct bt_event *event,
struct bt_field *context);
+extern struct bt_field *bt_event_borrow_context(struct bt_event *event);
+
/**
@brief Returns the event context field of the CTF IR event \p event.
@sa bt_event_set_context(): Sets the event context field of a given
event.
*/
-extern struct bt_field *bt_event_get_context(struct bt_event *event);
+static inline
+struct bt_field *bt_event_get_context(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_context(event));
+}
/**
@brief Sets the event context field of the CTF IR event \p event to \p context,
extern int bt_event_set_context(struct bt_event *event,
struct bt_field *context);
+extern struct bt_field *bt_event_borrow_payload(struct bt_event *event);
+
/**
@brief Returns the payload field of the CTF IR event \p event.
@sa bt_event_set_payload(): Sets the payload field of a given
event.
*/
-extern struct bt_field *bt_event_get_payload(struct bt_event *event);
+static inline
+struct bt_field *bt_event_get_payload(struct bt_event *event)
+{
+ return bt_get(bt_event_borrow_payload(event));
+}
/**
@brief Sets the payload field of the CTF IR event \p event to \p payload,
@{
*/
+extern struct bt_clock_value *bt_event_borrow_clock_value(
+ struct bt_event *event,
+ struct bt_clock_class *clock_class);
+
/**
@brief Returns the value, as of the CTF IR event \p event, of the
clock described by the
@sa bt_event_set_clock_value(): Sets the clock value of a given event.
*/
-extern struct bt_clock_value *bt_event_get_clock_value(
+static inline
+struct bt_clock_value *bt_event_get_clock_value(
struct bt_event *event,
- struct bt_clock_class *clock_class);
+ struct bt_clock_class *clock_class)
+{
+ return bt_get(bt_event_borrow_clock_value(event, clock_class));
+}
/**
@brief Sets the value, as of the CTF IR event \p event, of the
enum bt_string_encoding encoding);
BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_get_mapped_clock_class(
+struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
struct bt_field_type_common *ft);
BT_HIDDEN
uint64_t *range_end);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_enumeration_get_container_field_type(
+struct bt_field_type_common *
+bt_field_type_common_enumeration_borrow_container_field_type(
struct bt_field_type_common *ft);
BT_HIDDEN
struct bt_field_type_common *ft);
BT_HIDDEN
-int bt_field_type_common_structure_get_field_by_index(
+int bt_field_type_common_structure_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_structure_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_structure_borrow_field_type_by_name(
struct bt_field_type_common *ft, const char *name);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_tag_field_type(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_tag_field_type(
struct bt_field_type_common *ft);
BT_HIDDEN
const char *field_name);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_by_name(
struct bt_field_type_common *ft,
const char *field_name);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_from_tag(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_from_tag(
struct bt_field_type_common *ft,
struct bt_field_common *tag_field,
bt_field_common_create_func field_create_func);
struct bt_field_type_common *ft);
BT_HIDDEN
-int bt_field_type_common_variant_get_field_by_index(
+int bt_field_type_common_variant_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_array_get_element_field_type(
+struct bt_field_type_common *
+bt_field_type_common_array_borrow_element_field_type(
struct bt_field_type_common *ft);
BT_HIDDEN
int64_t bt_field_type_common_array_get_length(struct bt_field_type_common *ft);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_sequence_get_element_field_type(
+struct bt_field_type_common *
+bt_field_type_common_sequence_borrow_element_field_type(
struct bt_field_type_common *ft);
BT_HIDDEN
void _bt_field_type_freeze(struct bt_field_type *ft);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_signed(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_signed(
struct bt_field_type_common_variant *var_ft,
int64_t tag_value);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_unsigned(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_unsigned(
struct bt_field_type_common_variant *var_ft,
uint64_t tag_value);
int64_t bt_field_type_common_get_field_count(struct bt_field_type_common *ft);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_get_field_at_index(
+struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
struct bt_field_type_common *ft, int index);
BT_HIDDEN
const char *name);
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_get_tag_field_path(
+struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
struct bt_field_type_common *ft);
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_sequence_get_length_field_path(
+struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path(
struct bt_field_type_common *ft);
BT_HIDDEN
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
/* For bt_bool */
#include <babeltrace/types.h>
struct bt_field_type *int_field_type,
enum bt_string_encoding encoding);
+extern struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
+ struct bt_field_type *int_field_type);
+
/**
@brief Returns the \link ctfirclockclass CTF IR clock class\endlink
mapped to the @intft \p int_field_type.
@sa bt_field_type_integer_set_mapped_clock_class(): Sets the mapped
clock class of a given integer field type.
*/
-extern struct bt_clock_class *bt_field_type_integer_get_mapped_clock_class(
- struct bt_field_type *int_field_type);
+static inline
+struct bt_clock_class *bt_field_type_integer_get_mapped_clock_class(
+ struct bt_field_type *int_field_type)
+{
+ return bt_get(bt_field_type_integer_borrow_mapped_clock_class(
+ int_field_type));
+}
/**
@brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
extern struct bt_field_type *bt_field_type_enumeration_create(
struct bt_field_type *int_field_type);
+extern
+struct bt_field_type *bt_field_type_enumeration_borrow_container_field_type(
+ struct bt_field_type *enum_field_type);
+
/**
@brief Returns the @intft wrapped by the @enumft \p enum_field_type.
@postrefcountsame{enum_field_type}
@postsuccessrefcountretinc
*/
-extern
+static inline
struct bt_field_type *bt_field_type_enumeration_get_container_field_type(
- struct bt_field_type *enum_field_type);
+ struct bt_field_type *enum_field_type)
+{
+ return bt_get(bt_field_type_enumeration_borrow_container_field_type(
+ enum_field_type));
+}
/**
@brief Returns the number of mappings contained in the
extern int64_t bt_field_type_structure_get_field_count(
struct bt_field_type *struct_field_type);
+extern int bt_field_type_structure_borrow_field_by_index(
+ struct bt_field_type *struct_field_type,
+ const char **field_name, struct bt_field_type **field_type,
+ uint64_t index);
+
/**
@brief Returns the field of the @structft \p struct_field_type
at index \p index.
@sa bt_field_type_structure_get_field_type_by_name(): Finds a
structure field type's field by name.
*/
-extern int bt_field_type_structure_get_field_by_index(
+static inline
+int bt_field_type_structure_get_field_by_index(
struct bt_field_type *struct_field_type,
const char **field_name, struct bt_field_type **field_type,
- uint64_t index);
+ uint64_t index)
+{
+ int ret = bt_field_type_structure_borrow_field_by_index(
+ struct_field_type, field_name, field_type, index);
+
+ if (ret == 0 && field_type) {
+ bt_get(*field_type);
+ }
+
+ return ret;
+}
+
+extern
+struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
+ struct bt_field_type *struct_field_type,
+ const char *field_name);
/**
@brief Returns the type of the field named \p field_name found in
@sa bt_field_type_structure_get_field_by_index(): Finds a
structure field type's field by index.
*/
-extern
+static inline
struct bt_field_type *bt_field_type_structure_get_field_type_by_name(
struct bt_field_type *struct_field_type,
- const char *field_name);
+ const char *field_name)
+{
+ return bt_get(bt_field_type_structure_borrow_field_type_by_name(
+ struct_field_type, field_name));
+}
/**
@brief Adds a field named \p field_name with the @ft
struct bt_field_type *element_field_type,
unsigned int length);
+extern struct bt_field_type *bt_field_type_array_borrow_element_field_type(
+ struct bt_field_type *array_field_type);
+
/**
@brief Returns the @ft of the @fields contained in
the @arrayfields described by the @arrayft \p array_field_type.
@postrefcountsame{array_field_type}
@postsuccessrefcountretinc
*/
-extern struct bt_field_type *bt_field_type_array_get_element_field_type(
- struct bt_field_type *array_field_type);
+static inline
+struct bt_field_type *bt_field_type_array_get_element_field_type(
+ struct bt_field_type *array_field_type)
+{
+ return bt_get(bt_field_type_array_borrow_element_field_type(
+ array_field_type));
+}
/**
@brief Returns the number of @fields contained in the
struct bt_field_type *element_field_type,
const char *length_name);
+extern struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
+ struct bt_field_type *sequence_field_type);
+
/**
@brief Returns the @ft of the @fields contained in the @seqft
described by the @seqft \p sequence_field_type.
@postrefcountsame{sequence_field_type}
@postsuccessrefcountretinc
*/
-extern struct bt_field_type *bt_field_type_sequence_get_element_field_type(
- struct bt_field_type *sequence_field_type);
+static inline
+struct bt_field_type *bt_field_type_sequence_get_element_field_type(
+ struct bt_field_type *sequence_field_type)
+{
+ return bt_get(bt_field_type_sequence_borrow_element_field_type(
+ sequence_field_type));
+}
/**
@brief Returns the length name of the @seqft \p sequence_field_type.
extern const char *bt_field_type_sequence_get_length_field_name(
struct bt_field_type *sequence_field_type);
+extern struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
+ struct bt_field_type *sequence_field_type);
+
/**
@brief Returns the length's CTF IR field path of the @seqft
\p sequence_field_type.
@sa bt_field_type_sequence_get_length_field_name(): Returns the
length's name of a given sequence field type.
*/
-extern struct bt_field_path *bt_field_type_sequence_get_length_field_path(
- struct bt_field_type *sequence_field_type);
+static inline
+struct bt_field_path *bt_field_type_sequence_get_length_field_path(
+ struct bt_field_type *sequence_field_type)
+{
+ return bt_get(bt_field_type_sequence_borrow_length_field_path(
+ sequence_field_type));
+}
/** @} */
struct bt_field_type *tag_field_type,
const char *tag_name);
+extern struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
+ struct bt_field_type *variant_field_type);
+
/**
@brief Returns the tag's @enumft of the @varft \p variant_field_type.
@postrefcountsame{variant_field_type}
@postsuccessrefcountretinc
*/
-extern struct bt_field_type *bt_field_type_variant_get_tag_field_type(
- struct bt_field_type *variant_field_type);
+static inline
+struct bt_field_type *bt_field_type_variant_get_tag_field_type(
+ struct bt_field_type *variant_field_type)
+{
+ return bt_get(bt_field_type_variant_borrow_tag_field_type(
+ variant_field_type));
+}
/**
@brief Returns the tag name of the @varft \p variant_field_type.
struct bt_field_type *variant_field_type,
const char *tag_name);
+extern struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
+ struct bt_field_type *variant_field_type);
+
/**
@brief Returns the tag's CTF IR field path of the @varft
\p variant_field_type.
@sa bt_field_type_variant_get_tag_name(): Returns the tag's
name of a given variant field type.
*/
-extern struct bt_field_path *bt_field_type_variant_get_tag_field_path(
- struct bt_field_type *variant_field_type);
+static inline
+struct bt_field_path *bt_field_type_variant_get_tag_field_path(
+ struct bt_field_type *variant_field_type)
+{
+ return bt_get(bt_field_type_variant_borrow_tag_field_path(
+ variant_field_type));
+}
/**
@brief Returns the number of fields (choices) contained in the @varft
extern int64_t bt_field_type_variant_get_field_count(
struct bt_field_type *variant_field_type);
+extern int bt_field_type_variant_borrow_field_by_index(
+ struct bt_field_type *variant_field_type,
+ const char **field_name,
+ struct bt_field_type **field_type, uint64_t index);
+
/**
@brief Returns the field (choice) of the @varft \p variant_field_type
at index \p index.
@sa bt_field_type_variant_get_field_type_from_tag(): Finds a variant
field type's field by current tag value.
*/
-extern int bt_field_type_variant_get_field_by_index(
+static inline
+int bt_field_type_variant_get_field_by_index(
struct bt_field_type *variant_field_type,
const char **field_name,
- struct bt_field_type **field_type, uint64_t index);
+ struct bt_field_type **field_type, uint64_t index)
+{
+ int ret = bt_field_type_variant_borrow_field_by_index(
+ variant_field_type, field_name, field_type, index);
+
+ if (ret == 0 && field_type) {
+ bt_get(*field_type);
+ }
+
+ return ret;
+}
+
+extern
+struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
+ struct bt_field_type *variant_field_type,
+ const char *field_name);
/**
@brief Returns the type of the field (choice) named \p field_name
@sa bt_field_type_variant_get_field_type_from_tag(): Finds a variant
field type's field by current tag value.
*/
-extern
+static inline
struct bt_field_type *bt_field_type_variant_get_field_type_by_name(
struct bt_field_type *variant_field_type,
- const char *field_name);
+ const char *field_name)
+{
+ return bt_get(bt_field_type_variant_borrow_field_type_by_name(
+ variant_field_type, field_name));
+}
+
+extern
+struct bt_field_type *bt_field_type_variant_borrow_field_type_from_tag(
+ struct bt_field_type *variant_field_type,
+ struct bt_field *tag_field);
/**
@brief Returns the type of the field (choice) selected by the value of
@sa bt_field_type_variant_get_field_type_by_name(): Finds a variant
field type's field by name.
*/
-extern
+static inline
struct bt_field_type *bt_field_type_variant_get_field_type_from_tag(
struct bt_field_type *variant_field_type,
- struct bt_field *tag_field);
+ struct bt_field *tag_field)
+{
+ return bt_get(bt_field_type_variant_borrow_field_type_from_tag(
+ variant_field_type, tag_field));
+}
/**
@brief Adds a field (a choice) named \p field_name with the @ft
GString *payload;
};
-static inline
-struct bt_field_type *bt_field_borrow_type(struct bt_field *field)
-{
- struct bt_field_common *field_common = (void *) field;
-
- BT_ASSERT(field);
- return (void *) field_common->type;
-}
-
BT_HIDDEN
int64_t bt_field_sequence_get_int_length(struct bt_field *field);
}
static inline
-struct bt_field_type_common *bt_field_common_get_type(
+struct bt_field_type_common *bt_field_common_borrow_type(
struct bt_field_common *field)
{
struct bt_field_type_common *ret = NULL;
BT_ASSERT_PRE_NON_NULL(field, "Field");
- ret = bt_get(field->type);
+ ret = field->type;
return ret;
}
}
static inline
-struct bt_field_common *bt_field_common_sequence_get_length(
+struct bt_field_common *bt_field_common_sequence_borrow_length(
struct bt_field_common *field)
{
struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
"Field");
- return bt_get(sequence->length);
+ return sequence->length;
}
static inline
}
static inline
-struct bt_field_common *bt_field_common_structure_get_field_by_name(
+struct bt_field_common *bt_field_common_structure_borrow_field_by_name(
struct bt_field_common *field, const char *name)
{
struct bt_field_common *ret = NULL;
goto error;
}
- ret = bt_get(structure->fields->pdata[index]);
+ ret = structure->fields->pdata[index];
BT_ASSERT(ret);
error:
}
static inline
-struct bt_field_common *bt_field_common_structure_get_field_by_index(
+struct bt_field_common *bt_field_common_structure_borrow_field_by_index(
struct bt_field_common *field, uint64_t index)
{
struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
"Index is out of bound: %![struct-field-]+_f, "
"index=%" PRIu64 ", count=%u", field, index,
structure->fields->len);
- return bt_get(structure->fields->pdata[index]);
+ return structure->fields->pdata[index];
}
BT_ASSERT_PRE_FUNC
struct bt_field_type_common *expected_field_type = NULL;
expected_field_type =
- bt_field_type_common_structure_get_field_type_by_name(
+ bt_field_type_common_structure_borrow_field_type_by_name(
struct_field->type, name);
if (bt_field_type_common_compare(expected_field_type, value->type)) {
}
end:
- bt_put(expected_field_type);
return ret;
}
}
static inline
-struct bt_field_common *bt_field_common_array_get_field(
+struct bt_field_common *bt_field_common_array_borrow_field(
struct bt_field_common *field, uint64_t index,
bt_field_common_create_func field_create_func)
{
"index=%" PRIu64 ", count=%u", field,
index, array->elements->len);
- field_type = bt_field_type_common_array_get_element_field_type(
+ field_type = bt_field_type_common_array_borrow_element_field_type(
field->type);
if (array->elements->pdata[(size_t) index]) {
new_field = array->elements->pdata[(size_t) index];
array->elements->pdata[(size_t) index] = new_field;
end:
- bt_put(field_type);
- bt_get(new_field);
return new_field;
}
static inline
-struct bt_field_common *bt_field_common_sequence_get_field(
+struct bt_field_common *bt_field_common_sequence_borrow_field(
struct bt_field_common *field, uint64_t index,
bt_field_common_create_func field_create_func)
{
"Index is out of bound: %![seq-field-]+_f, "
"index=%" PRIu64 ", count=%u", field, index,
sequence->elements->len);
- field_type = bt_field_type_common_sequence_get_element_field_type(
+ field_type = bt_field_type_common_sequence_borrow_element_field_type(
field->type);
if (sequence->elements->pdata[(size_t) index]) {
new_field = sequence->elements->pdata[(size_t) index];
sequence->elements->pdata[(size_t) index] = new_field;
end:
- bt_put(field_type);
- bt_get(new_field);
return new_field;
}
static inline
-struct bt_field_common *bt_field_common_enumeration_get_container(
+struct bt_field_common *bt_field_common_enumeration_borrow_container(
struct bt_field_common *field,
bt_field_common_create_func field_create_func)
{
BT_TO_COMMON(enumeration_type->container_ft));
}
- return bt_get(enumeration->payload);
+ return enumeration->payload;
}
static inline
-struct bt_field_common *bt_field_common_variant_get_field(
+struct bt_field_common *bt_field_common_variant_borrow_field(
struct bt_field_common *field,
struct bt_field_common *tag_field,
bt_field_common_create_func field_create_func)
BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(tag_field, BT_FIELD_TYPE_ID_ENUM,
"Tag field");
variant_type = BT_FROM_COMMON(field->type);
- tag_enum = bt_field_common_enumeration_get_container(tag_field,
+ tag_enum = bt_field_common_enumeration_borrow_container(tag_field,
field_create_func);
BT_ASSERT_PRE_NON_NULL(tag_enum, "Tag field's container");
tag_enum_integer = BT_FROM_COMMON(tag_enum);
int64_t cur_tag_value;
cur_tag_container =
- bt_field_common_enumeration_get_container(variant->tag,
- field_create_func);
+ bt_field_common_enumeration_borrow_container(
+ variant->tag, field_create_func);
BT_ASSERT(cur_tag_container);
cur_tag_enum_integer = BT_FROM_COMMON(cur_tag_container);
- bt_put(cur_tag_container);
cur_tag_value = cur_tag_enum_integer->payload.signd;
if (cur_tag_value == tag_enum_value) {
new_field = variant->payload;
- bt_get(new_field);
goto end;
}
}
/* We don't want to modify this field if it's frozen */
BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "Variant field");
- field_type = bt_field_type_common_variant_get_field_type_signed(
+ field_type = bt_field_type_common_variant_borrow_field_type_signed(
variant_type, tag_enum_value);
/* It's the caller's job to make sure the tag's value is valid */
bt_put(variant->tag);
bt_put(variant->payload);
- bt_get(new_field);
- bt_get(tag_field);
- variant->tag = tag_field;
+ variant->tag = bt_get(tag_field);
variant->payload = new_field;
end:
- bt_put(tag_enum);
return new_field;
}
static inline
-struct bt_field_common *bt_field_common_variant_get_current_field(
+struct bt_field_common *bt_field_common_variant_borrow_current_field(
struct bt_field_common *variant_field)
{
struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
BT_FIELD_TYPE_ID_VARIANT, "Field");
- return bt_get(variant->payload);
+ return variant->payload;
}
static inline
-struct bt_field_common *bt_field_common_variant_get_tag(
+struct bt_field_common *bt_field_common_variant_borrow_tag(
struct bt_field_common *variant_field)
{
struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
BT_FIELD_TYPE_ID_VARIANT, "Field");
- return bt_get(variant->tag);
+ return variant->tag;
}
static inline
BT_ASSERT_PRE_NON_NULL(field, "Enumeration field");
BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
BT_FIELD_TYPE_ID_ENUM, "Field");
- container = bt_field_common_enumeration_get_container(field,
+ container = bt_field_common_enumeration_borrow_container(field,
field_create_func);
BT_ASSERT_PRE(container,
"Enumeration field has no container field: %!+_f", field);
field->type, value);
}
- bt_put(container);
return iter;
}
#include <stdint.h>
#include <stddef.h>
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
/* For bt_bool */
#include <babeltrace/types.h>
*/
extern struct bt_field *bt_field_create(struct bt_field_type *field_type);
+extern struct bt_field_type *bt_field_borrow_type(struct bt_field *field);
+
/**
@brief Returns the parent @ft of the @field \p field.
@postrefcountsame{field}
@postsuccessrefcountretinc
*/
-extern struct bt_field_type *bt_field_get_type(struct bt_field *field);
+static inline
+struct bt_field_type *bt_field_get_type(struct bt_field *field)
+{
+ return bt_get(bt_field_borrow_type(field));
+}
/** @} */
@{
*/
+extern struct bt_field *bt_field_enumeration_borrow_container(
+ struct bt_field *enum_field);
+
/**
@brief Returns the @intfield, potentially creating it, wrapped by the
@enumfield \p enum_field.
@postrefcountsame{enum_field}
@postsuccessrefcountretinc
*/
-extern struct bt_field *bt_field_enumeration_get_container(
- struct bt_field *enum_field);
+static inline
+struct bt_field *bt_field_enumeration_get_container(
+ struct bt_field *enum_field)
+{
+ return bt_get(bt_field_enumeration_borrow_container(enum_field));
+}
/**
@brief Returns a @enumftiter on all the mappings of the field type of
@{
*/
+extern struct bt_field *bt_field_structure_borrow_field_by_name(
+ struct bt_field *struct_field, const char *name);
+
/**
@brief Returns the @field named \p name, potentially creating it,
in the @structfield \p struct_field.
@sa bt_field_structure_set_field_by_name(): Sets the field of a
given structure field by name.
*/
-extern struct bt_field *bt_field_structure_get_field_by_name(
- struct bt_field *struct_field, const char *name);
+static inline
+struct bt_field *bt_field_structure_get_field_by_name(
+ struct bt_field *struct_field, const char *name)
+{
+ return bt_get(bt_field_structure_borrow_field_by_name(struct_field,
+ name));
+}
+
+extern struct bt_field *bt_field_structure_borrow_field_by_index(
+ struct bt_field *struct_field, uint64_t index);
/**
@brief Returns the @field at index \p index in the @structfield
@sa bt_field_structure_set_field_by_name(): Sets the field of a
given structure field by name.
*/
-extern struct bt_field *bt_field_structure_get_field_by_index(
- struct bt_field *struct_field, uint64_t index);
+static inline
+struct bt_field *bt_field_structure_get_field_by_index(
+ struct bt_field *struct_field, uint64_t index)
+{
+ return bt_get(bt_field_structure_borrow_field_by_index(struct_field,
+ index));
+}
/**
@brief Sets the field of the @structfield \p struct_field named \p name
@{
*/
+extern struct bt_field *bt_field_array_borrow_field(
+ struct bt_field *array_field, uint64_t index);
+
/**
@brief Returns the @field at index \p index, potentially creating it,
in the @arrayfield \p array_field.
@postrefcountsame{array_field}
@postsuccessrefcountretinc
*/
-extern struct bt_field *bt_field_array_get_field(
- struct bt_field *array_field, uint64_t index);
+static inline
+struct bt_field *bt_field_array_get_field(
+ struct bt_field *array_field, uint64_t index)
+{
+ return bt_get(bt_field_array_borrow_field(array_field, index));
+}
/** @} */
@{
*/
+extern struct bt_field *bt_field_sequence_borrow_field(
+ struct bt_field *sequence_field, uint64_t index);
+
/**
@brief Returns the @field at index \p index, potentially creating it,
in the @seqfield \p sequence_field.
@postrefcountsame{sequence_field}
@postsuccessrefcountretinc
*/
-extern struct bt_field *bt_field_sequence_get_field(
- struct bt_field *sequence_field, uint64_t index);
+static inline
+struct bt_field *bt_field_sequence_get_field(
+ struct bt_field *sequence_field, uint64_t index)
+{
+ return bt_get(bt_field_sequence_borrow_field(sequence_field, index));
+}
+
+extern struct bt_field *bt_field_sequence_borrow_length(
+ struct bt_field *sequence_field);
/**
@brief Returns the length @intfield of the @seqfield \p sequence_field.
@sa bt_field_sequence_set_length(): Sets the length field of a given
sequence field.
*/
-extern struct bt_field *bt_field_sequence_get_length(
- struct bt_field *sequence_field);
+static inline
+struct bt_field *bt_field_sequence_get_length(
+ struct bt_field *sequence_field)
+{
+ return bt_get(bt_field_sequence_borrow_length(sequence_field));
+}
/**
@brief Sets the length @intfield of the @seqfield \p sequence_field
@{
*/
+extern struct bt_field *bt_field_variant_borrow_field(
+ struct bt_field *variant_field,
+ struct bt_field *tag_field);
+
/**
@brief Returns the @field, potentially creating it, selected by the
tag @intfield \p tag_field in the @varfield \p variant_field.
@postsuccessrefcountinc{tag_field}
@postsuccessrefcountretinc
*/
-extern struct bt_field *bt_field_variant_get_field(
+static inline
+struct bt_field *bt_field_variant_get_field(
struct bt_field *variant_field,
- struct bt_field *tag_field);
+ struct bt_field *tag_field)
+{
+ return bt_get(bt_field_variant_borrow_field(variant_field, tag_field));
+}
+
+extern struct bt_field *bt_field_variant_borrow_current_field(
+ struct bt_field *variant_field);
/**
@brief Returns the currently selected @field of the @varfield
@postrefcountsame{variant_field}
@postsuccessrefcountretinc
*/
-extern struct bt_field *bt_field_variant_get_current_field(
+static inline
+struct bt_field *bt_field_variant_get_current_field(
+ struct bt_field *variant_field)
+{
+ return bt_get(bt_field_variant_borrow_current_field(variant_field));
+}
+
+extern struct bt_field *bt_field_variant_borrow_tag(
struct bt_field *variant_field);
/**
@postsuccessrefcountretinc
@post <strong>On success</strong>, the returned field is a @enumfield.
*/
-extern struct bt_field *bt_field_variant_get_tag(
- struct bt_field *variant_field);
+static inline
+struct bt_field *bt_field_variant_get_tag(
+ struct bt_field *variant_field)
+{
+ return bt_get(bt_field_variant_borrow_tag(variant_field));
+}
/** @} */
# define bt_packet_freeze
#endif /* BT_DEV_MODE */
-static inline
-struct bt_stream *bt_packet_borrow_stream(
- struct bt_packet *packet)
-{
- BT_ASSERT(packet);
- return packet->stream;
-}
-
#endif /* BABELTRACE_CTF_IR_PACKET_INTERNAL_H */
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
extern struct bt_packet *bt_packet_create(
struct bt_stream *stream);
+extern struct bt_stream *bt_packet_borrow_stream(
+ struct bt_packet *packet);
+
/**
@brief Returns the parent CTF IR stream of the CTF IR packet \p packet.
@postrefcountsame{packet}
@postsuccessrefcountretinc
*/
-extern struct bt_stream *bt_packet_get_stream(
- struct bt_packet *packet);
+static inline
+struct bt_stream *bt_packet_get_stream(
+ struct bt_packet *packet)
+{
+ return bt_get(bt_packet_borrow_stream(packet));
+}
/** @} */
@{
*/
+extern
+struct bt_field *bt_packet_borrow_header(struct bt_packet *packet);
+
/**
@brief Returns the trace packet header field of the CTF IR packet
\p packet.
@sa bt_packet_set_header(): Sets the trace packet header
field of a given packet.
*/
-extern struct bt_field *bt_packet_get_header(
- struct bt_packet *packet);
+static inline
+struct bt_field *bt_packet_get_header(struct bt_packet *packet)
+{
+ return bt_get(bt_packet_borrow_header(packet));
+}
/**
@brief Sets the trace packet header field of the CTF IR packet \p packet to
@sa bt_packet_get_header(): Returns the trace packet header field of a given
packet.
*/
-extern int bt_packet_set_header(
- struct bt_packet *packet, struct bt_field *header);
+extern int bt_packet_set_header(struct bt_packet *packet,
+ struct bt_field *header);
+
+extern struct bt_field *bt_packet_borrow_context(
+ struct bt_packet *packet);
/**
@brief Returns the stream packet context field of the CTF IR packet
@sa bt_packet_set_context(): Sets the stream packet context
field of a given packet.
*/
-extern struct bt_field *bt_packet_get_context(
- struct bt_packet *packet);
+static inline
+struct bt_field *bt_packet_get_context(struct bt_packet *packet)
+{
+ return bt_get(bt_packet_borrow_context(packet));
+}
/**
@brief Sets the stream packet context field of the CTF IR packet \p packet to
return (void *) bt_object_borrow_parent(stream_class);
}
-static inline
-struct bt_trace *bt_stream_class_borrow_trace(
- struct bt_stream_class *stream_class)
-{
- return BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
- BT_TO_COMMON(stream_class)));
-}
-
-static inline
-struct bt_trace_common *bt_stream_class_common_get_trace(
- struct bt_stream_class_common *stream_class)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return bt_get(bt_stream_class_common_borrow_trace(stream_class));
-}
-
static inline
int bt_stream_class_common_set_name(struct bt_stream_class_common *stream_class,
const char *name)
}
static inline
-struct bt_event_class_common *bt_stream_class_common_get_event_class_by_index(
+struct bt_event_class_common *bt_stream_class_common_borrow_event_class_by_index(
struct bt_stream_class_common *stream_class, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
"Index is out of bounds: index=%" PRIu64 ", "
"count=%u",
index, stream_class->event_classes->len);
- return bt_get(g_ptr_array_index(stream_class->event_classes, index));
+ return g_ptr_array_index(stream_class->event_classes, index);
}
static inline
-struct bt_event_class_common *bt_stream_class_common_get_event_class_by_id(
+struct bt_event_class_common *bt_stream_class_common_borrow_event_class_by_id(
struct bt_stream_class_common *stream_class, uint64_t id)
{
int64_t id_key = (int64_t) id;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE(id_key >= 0,
"Invalid event class ID: %" PRIu64, id);
- return bt_get(g_hash_table_lookup(stream_class->event_classes_ht,
- &id_key));
+ return g_hash_table_lookup(stream_class->event_classes_ht,
+ &id_key);
}
static inline
-struct bt_field_type_common *bt_stream_class_common_get_packet_context_field_type(
+struct bt_field_type_common *
+bt_stream_class_common_borrow_packet_context_field_type(
struct bt_stream_class_common *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return bt_get(stream_class->packet_context_field_type);
+ return stream_class->packet_context_field_type;
}
static inline
}
static inline
-struct bt_field_type_common *bt_stream_class_common_get_event_header_field_type(
+struct bt_field_type_common *
+bt_stream_class_common_borrow_event_header_field_type(
struct bt_stream_class_common *stream_class)
{
struct bt_field_type_common *ret = NULL;
goto end;
}
- ret = bt_get(stream_class->event_header_field_type);
+ ret = stream_class->event_header_field_type;
end:
return ret;
}
static inline
-struct bt_field_type_common *bt_stream_class_common_get_event_context_field_type(
+struct bt_field_type_common *
+bt_stream_class_common_borrow_event_context_field_type(
struct bt_stream_class_common *stream_class)
{
struct bt_field_type_common *ret = NULL;
goto end;
}
- ret = bt_get(stream_class->event_context_field_type);
+ ret = stream_class->event_context_field_type;
end:
return ret;
#include <stdint.h>
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
/* For bt_visitor */
#include <babeltrace/ctf-ir/visitor.h>
*/
extern struct bt_stream_class *bt_stream_class_create(const char *name);
+extern struct bt_trace *bt_stream_class_borrow_trace(
+ struct bt_stream_class *stream_class);
+
/**
@brief Returns the parent CTF IR trace class of the CTF IR stream
class \p stream_class.
@sa bt_trace_add_stream_class(): Add a stream class to
a trace class.
*/
-extern struct bt_trace *bt_stream_class_get_trace(
- struct bt_stream_class *stream_class);
+static inline
+struct bt_trace *bt_stream_class_get_trace(
+ struct bt_stream_class *stream_class)
+{
+ return bt_get(bt_stream_class_borrow_trace(stream_class));
+}
/** @} */
@{
*/
+extern struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
+ struct bt_stream_class *stream_class);
+
/**
@brief Returns the packet context field type of the CTF IR stream class
\p stream_class.
@sa bt_stream_class_set_packet_context_field_type(): Sets the packet
context field type of a given stream class.
*/
-extern struct bt_field_type *bt_stream_class_get_packet_context_field_type(
- struct bt_stream_class *stream_class);
+static inline
+struct bt_field_type *bt_stream_class_get_packet_context_field_type(
+ struct bt_stream_class *stream_class)
+{
+ return bt_get(bt_stream_class_borrow_packet_context_field_type(
+ stream_class));
+}
/**
@brief Sets the packet context field type of the CTF IR stream class
struct bt_stream_class *stream_class,
struct bt_field_type *packet_context_type);
+extern struct bt_field_type *
+bt_stream_class_borrow_event_header_field_type(
+ struct bt_stream_class *stream_class);
+
/**
@brief Returns the event header field type of the CTF IR stream class
\p stream_class.
@sa bt_stream_class_set_event_header_field_type(): Sets the event
header field type of a given stream class.
*/
-extern struct bt_field_type *
-bt_stream_class_get_event_header_field_type(
- struct bt_stream_class *stream_class);
+static inline
+struct bt_field_type *bt_stream_class_get_event_header_field_type(
+ struct bt_stream_class *stream_class)
+{
+ return bt_get(bt_stream_class_borrow_event_header_field_type(
+ stream_class));
+}
/**
@brief Sets the event header field type of the CTF IR stream class
struct bt_stream_class *stream_class,
struct bt_field_type *event_header_type);
+extern struct bt_field_type *
+bt_stream_class_borrow_event_context_field_type(
+ struct bt_stream_class *stream_class);
+
/**
@brief Returns the event context field type of the CTF IR stream class
\p stream_class.
@sa bt_stream_class_set_event_context_field_type(): Sets the event
context field type of a given stream class.
*/
-extern struct bt_field_type *
+static inline
+struct bt_field_type *
bt_stream_class_get_event_context_field_type(
- struct bt_stream_class *stream_class);
+ struct bt_stream_class *stream_class)
+{
+ return bt_get(bt_stream_class_borrow_event_context_field_type(
+ stream_class));
+}
/**
@brief Sets the event context field type of the CTF IR stream class
extern int64_t bt_stream_class_get_event_class_count(
struct bt_stream_class *stream_class);
+extern struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
+ struct bt_stream_class *stream_class, uint64_t index);
+
/**
@brief Returns the event class at index \p index in the CTF IR stream
class \p stream_class.
@sa bt_stream_class_get_event_class_by_id(): Finds an event class
by ID.
*/
-extern struct bt_event_class *bt_stream_class_get_event_class_by_index(
- struct bt_stream_class *stream_class, uint64_t index);
+static inline
+struct bt_event_class *bt_stream_class_get_event_class_by_index(
+ struct bt_stream_class *stream_class, uint64_t index)
+{
+ return bt_get(bt_stream_class_borrow_event_class_by_index(stream_class,
+ index));
+}
+
+extern struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
+ struct bt_stream_class *stream_class, uint64_t id);
/**
@brief Returns the event class with ID \c id found in the CTF IR stream
@postrefcountsame{stream_class}
@postsuccessrefcountretinc
*/
-extern struct bt_event_class *bt_stream_class_get_event_class_by_id(
- struct bt_stream_class *stream_class, uint64_t id);
+static inline
+struct bt_event_class *bt_stream_class_get_event_class_by_id(
+ struct bt_stream_class *stream_class, uint64_t id)
+{
+ return bt_get(bt_stream_class_borrow_event_class_by_id(stream_class,
+ id));
+}
/**
@brief Adds the CTF IR event class \p event_class to the
return stream->stream_class;
}
-static inline
-struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
-{
- BT_ASSERT(stream);
- return BT_FROM_COMMON(bt_stream_common_borrow_class(BT_TO_COMMON(stream)));
-}
-
-static inline
-struct bt_stream_class_common *bt_stream_common_get_class(
- struct bt_stream_common *stream)
-{
- return bt_get(bt_stream_common_borrow_class(stream));
-}
-
static inline
const char *bt_stream_common_get_name(struct bt_stream_common *stream)
{
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
*/
extern int64_t bt_stream_get_id(struct bt_stream *stream);
+extern struct bt_stream_class *bt_stream_borrow_class(
+ struct bt_stream *stream);
+
/**
@brief Returns the parent CTF IR stream class of the CTF IR
stream \p stream.
@postrefcountsame{stream}
@postsuccessrefcountretinc
*/
-extern struct bt_stream_class *bt_stream_get_class(
- struct bt_stream *stream);
+static inline
+struct bt_stream_class *bt_stream_get_class(
+ struct bt_stream *stream)
+{
+ return bt_get(bt_stream_borrow_class(stream));
+}
/** @} */
static inline
const char *
bt_trace_common_get_environment_field_name_by_index(
- struct bt_trace_common *trace,
- uint64_t index)
+ struct bt_trace_common *trace, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
return bt_attributes_get_field_name(trace->environment, index);
}
static inline
-struct bt_value *bt_trace_common_get_environment_field_value_by_index(
+struct bt_value *bt_trace_common_borrow_environment_field_value_by_index(
struct bt_trace_common *trace, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return bt_attributes_get_field_value(trace->environment, index);
+ return bt_attributes_borrow_field_value(trace->environment, index);
}
static inline
-struct bt_value *bt_trace_common_get_environment_field_value_by_name(
+struct bt_value *bt_trace_common_borrow_environment_field_value_by_name(
struct bt_trace_common *trace, const char *name)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- return bt_attributes_get_field_value_by_name(trace->environment,
+ return bt_attributes_borrow_field_value_by_name(trace->environment,
name);
}
}
static inline
-struct bt_clock_class *bt_trace_common_get_clock_class_by_index(
+struct bt_clock_class *bt_trace_common_borrow_clock_class_by_index(
struct bt_trace_common *trace, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
"Index is out of bounds: index=%" PRIu64 ", "
"count=%u",
index, trace->clock_classes->len);
- return bt_get(g_ptr_array_index(trace->clock_classes, index));
+ return g_ptr_array_index(trace->clock_classes, index);
}
static inline
}
static inline
-struct bt_stream_common *bt_trace_common_get_stream_by_index(
+struct bt_stream_common *bt_trace_common_borrow_stream_by_index(
struct bt_trace_common *trace,
uint64_t index)
{
"Index is out of bounds: index=%" PRIu64 ", "
"count=%u",
index, trace->streams->len);
- return bt_get(g_ptr_array_index(trace->streams, index));
+ return g_ptr_array_index(trace->streams, index);
}
static inline
}
static inline
-struct bt_stream_class_common *bt_trace_common_get_stream_class_by_index(
+struct bt_stream_class_common *bt_trace_common_borrow_stream_class_by_index(
struct bt_trace_common *trace, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
"Index is out of bounds: index=%" PRIu64 ", "
"count=%u",
index, trace->stream_classes->len);
- return bt_get(g_ptr_array_index(trace->stream_classes, index));
+ return g_ptr_array_index(trace->stream_classes, index);
}
static inline
-struct bt_stream_class_common *bt_trace_common_get_stream_class_by_id(
+struct bt_stream_class_common *bt_trace_common_borrow_stream_class_by_id(
struct bt_trace_common *trace, uint64_t id_param)
{
int i;
if (bt_stream_class_common_get_id(stream_class_candidate) ==
(int64_t) id) {
stream_class = stream_class_candidate;
- bt_get(stream_class);
goto end;
}
}
}
static inline
-struct bt_clock_class *bt_trace_common_get_clock_class_by_name(
+struct bt_clock_class *bt_trace_common_borrow_clock_class_by_name(
struct bt_trace_common *trace, const char *name)
{
size_t i;
if (!strcmp(cur_clk_name, name)) {
clock_class = cur_clk;
- bt_get(clock_class);
goto end;
}
}
enum bt_byte_order byte_order, bool allow_unspecified);
static inline
-struct bt_field_type_common *bt_trace_common_get_packet_header_field_type(
+struct bt_field_type_common *bt_trace_common_borrow_packet_header_field_type(
struct bt_trace_common *trace)
{
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return bt_get(trace->packet_header_field_type);
+ return trace->packet_header_field_type;
}
BT_HIDDEN
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
/* For bt_visitor */
#include <babeltrace/ctf-ir/visitor.h>
bt_trace_get_environment_field_name_by_index(
struct bt_trace *trace_class, uint64_t index);
+extern struct bt_value *
+bt_trace_borrow_environment_field_value_by_index(struct bt_trace *trace_class,
+ uint64_t index);
+
/**
@brief Returns the value of the environment entry at index
\p index in the CTF IR trace class \p trace_class.
@sa bt_trace_set_environment_field(): Sets the value of a trace
class's environment entry.
*/
+static inline
+struct bt_value *bt_trace_get_environment_field_value_by_index(
+ struct bt_trace *trace_class, uint64_t index)
+{
+ return bt_get(bt_trace_borrow_environment_field_value_by_index(
+ trace_class, index));
+}
+
extern struct bt_value *
-bt_trace_get_environment_field_value_by_index(struct bt_trace *trace_class,
- uint64_t index);
+bt_trace_borrow_environment_field_value_by_name(
+ struct bt_trace *trace_class, const char *name);
/**
@brief Returns the value of the environment entry named \p name
@sa bt_trace_set_environment_field(): Sets the value of a trace
class's environment entry.
*/
-extern struct bt_value *
+static inline
+struct bt_value *
bt_trace_get_environment_field_value_by_name(
- struct bt_trace *trace_class, const char *name);
+ struct bt_trace *trace_class, const char *name)
+{
+ return bt_get(
+ bt_trace_borrow_environment_field_value_by_name(
+ trace_class, name));
+}
/**
@brief Sets the environment entry named \p name in the
@{
*/
+extern struct bt_field_type *bt_trace_borrow_packet_header_field_type(
+ struct bt_trace *trace_class);
+
/**
@brief Returns the packet header field type of the CTF IR trace class
\p trace_class.
@sa bt_trace_set_packet_header_field_type(): Sets the packet
header field type of a given trace class.
*/
-extern struct bt_field_type *bt_trace_get_packet_header_field_type(
- struct bt_trace *trace_class);
+static inline
+struct bt_field_type *bt_trace_get_packet_header_field_type(
+ struct bt_trace *trace_class)
+{
+ return bt_get(bt_trace_borrow_packet_header_field_type(trace_class));
+}
/**
@brief Sets the packet header field type of the CTF IR trace class
extern int64_t bt_trace_get_clock_class_count(
struct bt_trace *trace_class);
+extern struct bt_clock_class *bt_trace_borrow_clock_class_by_index(
+ struct bt_trace *trace_class, uint64_t index);
+
/**
@brief Returns the CTF IR clock class at index \p index in the CTF
IR trace class \p trace_class.
in a given trace class.
@sa bt_trace_add_clock_class(): Adds a clock class to a trace class.
*/
-extern struct bt_clock_class *bt_trace_get_clock_class_by_index(
- struct bt_trace *trace_class, uint64_t index);
+static inline
+struct bt_clock_class *bt_trace_get_clock_class_by_index(
+ struct bt_trace *trace_class, uint64_t index)
+{
+ return bt_get(bt_trace_borrow_clock_class_by_index(
+ trace_class, index));
+}
+
+extern struct bt_clock_class *bt_trace_borrow_clock_class_by_name(
+ struct bt_trace *trace_class, const char *name);
/**
@brief Returns the CTF IR clock class named \c name found in the CTF
in a given trace class at a given index.
@sa bt_trace_add_clock_class(): Adds a clock class to a trace class.
*/
-extern struct bt_clock_class *bt_trace_get_clock_class_by_name(
- struct bt_trace *trace_class, const char *name);
+static inline
+struct bt_clock_class *bt_trace_get_clock_class_by_name(
+ struct bt_trace *trace_class, const char *name)
+{
+ return bt_get(bt_trace_borrow_clock_class_by_name(trace_class, name));
+}
/**
@brief Adds the CTF IR clock class \p clock_class to the CTF IR
extern int64_t bt_trace_get_stream_class_count(
struct bt_trace *trace_class);
+extern struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
+ struct bt_trace *trace_class, uint64_t index);
+
/**
@brief Returns the stream class at index \p index in the CTF IR trace
class \p trace_class.
@sa bt_trace_get_stream_class_by_id(): Finds a stream class by ID.
@sa bt_trace_add_stream_class(): Adds a stream class to a trace class.
*/
-extern struct bt_stream_class *bt_trace_get_stream_class_by_index(
- struct bt_trace *trace_class, uint64_t index);
+static inline
+struct bt_stream_class *bt_trace_get_stream_class_by_index(
+ struct bt_trace *trace_class, uint64_t index)
+{
+ return bt_get(bt_trace_borrow_stream_class_by_index(
+ trace_class, index));
+}
+
+extern struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
+ struct bt_trace *trace_class, uint64_t id);
/**
@brief Returns the stream class with ID \c id found in the CTF IR
in a given trace class at a given index.
@sa bt_trace_add_stream_class(): Adds a stream class to a trace class.
*/
-extern struct bt_stream_class *bt_trace_get_stream_class_by_id(
- struct bt_trace *trace_class, uint64_t id);
+static inline
+struct bt_stream_class *bt_trace_get_stream_class_by_id(
+ struct bt_trace *trace_class, uint64_t id)
+{
+ return bt_get(bt_trace_borrow_stream_class_by_id(trace_class, id));
+}
/**
@brief Adds the CTF IR stream class \p stream_class to the
*/
extern int64_t bt_trace_get_stream_count(struct bt_trace *trace_class);
+extern struct bt_stream *bt_trace_borrow_stream_by_index(
+ struct bt_trace *trace_class, uint64_t index);
+
/**
@brief Returns the stream at index \p index in the CTF IR trace
class \p trace_class.
bt_trace_get_stream_count()).
@postrefcountsame{trace_class}
*/
-extern struct bt_stream *bt_trace_get_stream_by_index(
- struct bt_trace *trace_class, uint64_t index);
+static inline
+struct bt_stream *bt_trace_get_stream_by_index(
+ struct bt_trace *trace_class, uint64_t index)
+{
+ return bt_get(bt_trace_borrow_stream_by_index(trace_class, index));
+}
/** @} */
* http://www.efficios.com/ctf
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#include <stddef.h>
extern int64_t bt_clock_class_priority_map_get_clock_class_count(
struct bt_clock_class_priority_map *clock_class_priority_map);
+extern struct bt_clock_class *
+bt_clock_class_priority_map_borrow_clock_class_by_index(
+ struct bt_clock_class_priority_map *clock_class_priority_map,
+ uint64_t index);
+
/**
@brief Returns the CTF IR clock class at index \p index in the clock
class priority map \p clock_class_priority_map.
@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
to a clock class priority map.
*/
-extern struct bt_clock_class *
+static inline
+struct bt_clock_class *
bt_clock_class_priority_map_get_clock_class_by_index(
struct bt_clock_class_priority_map *clock_class_priority_map,
- uint64_t index);
+ uint64_t index)
+{
+ return bt_get(bt_clock_class_priority_map_borrow_clock_class_by_index(
+ clock_class_priority_map, index));
+}
+
+extern struct bt_clock_class *
+bt_clock_class_priority_map_borrow_clock_class_by_name(
+ struct bt_clock_class_priority_map *clock_class_priority_map,
+ const char *name);
/**
@brief Returns the CTF IR clock class named \c name found in the clock
@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
to a clock class priority map.
*/
-extern struct bt_clock_class *
-bt_clock_class_priority_map_get_clock_class_by_name(
+static inline
+struct bt_clock_class *bt_clock_class_priority_map_get_clock_class_by_name(
struct bt_clock_class_priority_map *clock_class_priority_map,
- const char *name);
+ const char *name)
+{
+ return bt_get(bt_clock_class_priority_map_borrow_clock_class_by_name(
+ clock_class_priority_map, name));
+}
+
+extern struct bt_clock_class *
+bt_clock_class_priority_map_borrow_highest_priority_clock_class(
+ struct bt_clock_class_priority_map *clock_class_priority_map);
/**
@brief Returns the CTF IR clock class with the currently highest
@sa bt_clock_class_priority_map_add_clock_class(): Adds a clock class
to a clock class priority map.
*/
-extern struct bt_clock_class *
+static inline
+struct bt_clock_class *
bt_clock_class_priority_map_get_highest_priority_clock_class(
- struct bt_clock_class_priority_map *clock_class_priority_map);
+ struct bt_clock_class_priority_map *clock_class_priority_map)
+{
+ return bt_get(
+ bt_clock_class_priority_map_borrow_highest_priority_clock_class(
+ clock_class_priority_map));
+}
/**
@brief Returns the priority of the CTF IR clock class \p clock_class
uint64_t count);
BT_HIDDEN
-struct bt_stream *bt_notification_discarded_elements_get_stream(
+struct bt_stream *bt_notification_discarded_elements_borrow_stream(
enum bt_notification_type type,
struct bt_notification *notification);
BT_HIDDEN
struct bt_clock_value *
-bt_notification_discarded_elements_get_begin_clock_value(
+bt_notification_discarded_elements_borrow_begin_clock_value(
enum bt_notification_type type,
struct bt_notification *notification);
BT_HIDDEN
struct bt_clock_value *
-bt_notification_discarded_elements_get_end_clock_value(
+bt_notification_discarded_elements_borrow_end_clock_value(
enum bt_notification_type type,
struct bt_notification *notification);
enum bt_notification_type type,
struct bt_notification *notification);
-static inline
-struct bt_stream *bt_notification_discarded_elements_borrow_stream(
- struct bt_notification *notification)
-{
- struct bt_notification_discarded_elements *discarded_elems_notif;
-
- BT_ASSERT(notification);
- discarded_elems_notif = container_of(notification,
- struct bt_notification_discarded_elements, parent);
- return discarded_elems_notif->stream;
-}
-
#endif /* BABELTRACE_GRAPH_NOTIFICATION_DISCARDED_ELEMENTS_INTERNAL_H */
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
struct bt_stream;
extern struct bt_clock_value *
-bt_notification_discarded_events_get_begin_clock_value(
+bt_notification_discarded_events_borrow_begin_clock_value(
struct bt_notification *notification);
+static inline
+struct bt_clock_value *
+bt_notification_discarded_events_get_begin_clock_value(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_discarded_events_borrow_begin_clock_value(
+ notification));
+}
+
extern struct bt_clock_value *
-bt_notification_discarded_events_get_end_clock_value(
+bt_notification_discarded_events_borrow_end_clock_value(
struct bt_notification *notification);
+static inline
+struct bt_clock_value *
+bt_notification_discarded_events_get_end_clock_value(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_discarded_events_borrow_end_clock_value(
+ notification));
+}
+
extern int64_t bt_notification_discarded_events_get_count(
struct bt_notification *notification);
-extern struct bt_stream *bt_notification_discarded_events_get_stream(
+extern struct bt_stream *bt_notification_discarded_events_borrow_stream(
struct bt_notification *notification);
+static inline
+struct bt_stream *bt_notification_discarded_events_get_stream(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_discarded_events_borrow_stream(
+ notification));
+}
+
#ifdef __cplusplus
}
#endif
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
struct bt_stream;
extern struct bt_clock_value *
-bt_notification_discarded_packets_get_begin_clock_value(
+bt_notification_discarded_packets_borrow_begin_clock_value(
struct bt_notification *notification);
+static inline
+struct bt_clock_value *
+bt_notification_discarded_packets_get_begin_clock_value(
+ struct bt_notification *notification)
+{
+ return bt_get(
+ bt_notification_discarded_packets_borrow_begin_clock_value(
+ notification));
+}
+
extern struct bt_clock_value *
-bt_notification_discarded_packets_get_end_clock_value(
+bt_notification_discarded_packets_borrow_end_clock_value(
struct bt_notification *notification);
+static inline
+struct bt_clock_value *
+bt_notification_discarded_packets_get_end_clock_value(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_discarded_packets_borrow_end_clock_value(
+ notification));
+}
+
extern int64_t bt_notification_discarded_packets_get_count(
struct bt_notification *notification);
-extern struct bt_stream *bt_notification_discarded_packets_get_stream(
+extern struct bt_stream *bt_notification_discarded_packets_borrow_stream(
struct bt_notification *notification);
+static inline
+struct bt_stream *bt_notification_discarded_packets_get_stream(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_discarded_packets_borrow_stream(
+ notification));
+}
+
#ifdef __cplusplus
}
#endif
struct bt_clock_class_priority_map *cc_prio_map;
};
-static inline
-struct bt_event *bt_notification_event_borrow_event(
- struct bt_notification *notif)
-{
- struct bt_notification_event *notif_event = container_of(notif,
- struct bt_notification_event, parent);
-
- BT_ASSERT(notif_event);
- return notif_event->event;
-}
-
-static inline
-struct bt_clock_class_priority_map *
-bt_notification_event_borrow_clock_class_priority_map(
- struct bt_notification *notif)
-{
- struct bt_notification_event *notif_event = container_of(notif,
- struct bt_notification_event, parent);
-
- BT_ASSERT(notif_event);
- return notif_event->cc_prio_map;
-}
-
-
#ifdef __cplusplus
}
#endif
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
struct bt_event;
struct bt_clock_class_priority_map;
-/***BT_NOTIFICATION_TYPE_EVENT ***/
/**
* Create an event notification.
*
struct bt_event *event,
struct bt_clock_class_priority_map *clock_class_priority_map);
+extern struct bt_event *bt_notification_event_borrow_event(
+ struct bt_notification *notification);
+
/**
* Get an event notification's event.
*
*
* @see #bt_event
*/
-extern struct bt_event *bt_notification_event_get_event(
- struct bt_notification *notification);
+static inline
+struct bt_event *bt_notification_event_get_event(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_event_borrow_event(notification));
+}
extern struct bt_clock_class_priority_map *
-bt_notification_event_get_clock_class_priority_map(
+bt_notification_event_borrow_clock_class_priority_map(
struct bt_notification *notification);
+static inline
+struct bt_clock_class_priority_map *
+bt_notification_event_get_clock_class_priority_map(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_event_borrow_clock_class_priority_map(
+ notification));
+}
+
#ifdef __cplusplus
}
#endif
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
struct bt_clock_class_priority_map *clock_class_priority_map);
extern struct bt_clock_class_priority_map *
-bt_notification_inactivity_get_clock_class_priority_map(
+bt_notification_inactivity_borrow_clock_class_priority_map(
struct bt_notification *notification);
-extern struct bt_clock_value *bt_notification_inactivity_get_clock_value(
+static inline
+struct bt_clock_class_priority_map *
+bt_notification_inactivity_get_clock_class_priority_map(
+ struct bt_notification *notification)
+{
+ return bt_get(
+ bt_notification_inactivity_borrow_clock_class_priority_map(
+ notification));
+}
+
+extern struct bt_clock_value *bt_notification_inactivity_borrow_clock_value(
struct bt_notification *notification,
struct bt_clock_class *clock_class);
+static inline
+struct bt_clock_value *bt_notification_inactivity_get_clock_value(
+ struct bt_notification *notification,
+ struct bt_clock_class *clock_class)
+{
+ return bt_get(bt_notification_inactivity_borrow_clock_value(
+ notification, clock_class));
+}
+
extern int bt_notification_inactivity_set_clock_value(
struct bt_notification *notification,
struct bt_clock_value *clock_value);
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#include <stdint.h>
#ifdef __cplusplus
BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED = -2,
};
+extern struct bt_notification *bt_notification_iterator_borrow_notification(
+ struct bt_notification_iterator *iterator);
+
/**
* Get current notification at iterator's position.
*
*
* @see bt_put()
*/
-extern struct bt_notification *bt_notification_iterator_get_notification(
- struct bt_notification_iterator *iterator);
+static inline
+struct bt_notification *bt_notification_iterator_get_notification(
+ struct bt_notification_iterator *iterator)
+{
+ return bt_get(bt_notification_iterator_borrow_notification(iterator));
+}
/**
* Advance the iterator's position forward.
struct bt_packet *packet;
};
-static inline
-struct bt_packet *bt_notification_packet_begin_borrow_packet(
- struct bt_notification *notif)
-{
- struct bt_notification_packet_begin *notif_packet_begin =
- container_of(notif,
- struct bt_notification_packet_begin, parent);
-
- BT_ASSERT(notif_packet_begin);
- return notif_packet_begin->packet;
-}
-
-static inline
-struct bt_packet *bt_notification_packet_end_borrow_packet(
- struct bt_notification *notif)
-{
- struct bt_notification_packet_end *notif_packet_end =
- container_of(notif,
- struct bt_notification_packet_end, parent);
-
- BT_ASSERT(notif_packet_end);
- return notif_packet_end->packet;
-}
-
#endif /* BABELTRACE_GRAPH_NOTIFICATION_PACKET_INTERNAL_H */
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
extern struct bt_notification *bt_notification_packet_end_create(
struct bt_packet *packet);
-/*** BT_NOTIFICATION_TYPE_PACKET_BEGIN ***/
-extern struct bt_packet *bt_notification_packet_begin_get_packet(
+extern struct bt_packet *bt_notification_packet_begin_borrow_packet(
struct bt_notification *notification);
-/*** BT_NOTIFICATION_TYPE_PACKET_END ***/
-extern struct bt_packet *bt_notification_packet_end_get_packet(
+static inline
+struct bt_packet *bt_notification_packet_begin_get_packet(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_packet_begin_borrow_packet(notification));
+}
+
+extern struct bt_packet *bt_notification_packet_end_borrow_packet(
struct bt_notification *notification);
+static inline
+struct bt_packet *bt_notification_packet_end_get_packet(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_packet_end_borrow_packet(notification));
+}
+
#ifdef __cplusplus
}
#endif
struct bt_stream *stream;
};
-static inline
-struct bt_stream *bt_notification_stream_begin_borrow_stream(
- struct bt_notification *notif)
-{
- struct bt_notification_stream_begin *notif_stream_begin =
- container_of(notif,
- struct bt_notification_stream_begin, parent);
-
- BT_ASSERT(notif_stream_begin);
- return notif_stream_begin->stream;
-}
-
-static inline
-struct bt_stream *bt_notification_stream_end_borrow_stream(
- struct bt_notification *notif)
-{
- struct bt_notification_stream_end *notif_stream_end =
- container_of(notif,
- struct bt_notification_stream_end, parent);
-
- BT_ASSERT(notif_stream_end);
- return notif_stream_end->stream;
-}
-
#endif /* BABELTRACE_GRAPH_NOTIFICATION_STREAM_INTERNAL_H */
* SOFTWARE.
*/
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
extern struct bt_notification *bt_notification_stream_end_create(
struct bt_stream *stream);
-extern struct bt_stream *bt_notification_stream_begin_get_stream(
+extern struct bt_stream *bt_notification_stream_begin_borrow_stream(
struct bt_notification *notification);
-extern struct bt_stream *bt_notification_stream_end_get_stream(
+static inline
+struct bt_stream *bt_notification_stream_begin_get_stream(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_stream_begin_borrow_stream(notification));
+}
+
+extern struct bt_stream *bt_notification_stream_end_borrow_stream(
struct bt_notification *notification);
+static inline
+struct bt_stream *bt_notification_stream_end_get_stream(
+ struct bt_notification *notification)
+{
+ return bt_get(bt_notification_stream_end_borrow_stream(notification));
+}
+
#ifdef __cplusplus
}
#endif
/* For bt_bool */
#include <babeltrace/types.h>
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
*/
extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
+extern struct bt_value *bt_value_array_borrow(const struct bt_value *array_obj,
+ uint64_t index);
+
/**
@brief Returns the value object contained in the array value object
\p array_obj at the index \p index.
\ref bt_value_null</strong>, its reference count is incremented.
@postrefcountsame{array_obj}
*/
-extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
- uint64_t index);
+static inline
+struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
+ uint64_t index)
+{
+ return bt_get(bt_value_array_borrow(array_obj, index));
+}
/**
@brief Appends the value object \p element_obj to the array value
*/
extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
+extern struct bt_value *bt_value_map_borrow(const struct bt_value *map_obj,
+ const char *key);
+
/**
@brief Returns the value object associated with the key \p key within
the map value object \p map_obj.
@post <strong>On success, if the returned value object is not
\ref bt_value_null</strong>, its reference count is incremented.
*/
-extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
- const char *key);
+static inline
+struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
+ const char *key)
+{
+ return bt_get(bt_value_map_borrow(map_obj, key));
+}
/**
@brief User function type to use with bt_value_map_foreach().
goto end;
}
- attr_field_obj = bt_value_array_get(attr_obj, index);
+ attr_field_obj = bt_value_array_borrow(attr_obj, index);
if (!attr_field_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- attr_field_name_obj = bt_value_array_get(attr_field_obj,
+ attr_field_name_obj = bt_value_array_borrow(attr_field_obj,
BT_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
}
end:
- BT_PUT(attr_field_name_obj);
- BT_PUT(attr_field_obj);
return ret;
}
BT_HIDDEN
-struct bt_value *bt_attributes_get_field_value(struct bt_value *attr_obj,
+struct bt_value *bt_attributes_borrow_field_value(struct bt_value *attr_obj,
uint64_t index)
{
struct bt_value *value_obj = NULL;
goto end;
}
- attr_field_obj = bt_value_array_get(attr_obj, index);
+ attr_field_obj = bt_value_array_borrow(attr_obj, index);
if (!attr_field_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_obj, index);
goto end;
}
- value_obj = bt_value_array_get(attr_field_obj,
+ value_obj = bt_value_array_borrow(attr_field_obj,
BT_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
}
end:
- BT_PUT(attr_field_obj);
return value_obj;
}
static
-struct bt_value *bt_attributes_get_field_by_name(
+struct bt_value *bt_attributes_borrow_field_by_name(
struct bt_value *attr_obj, const char *name)
{
uint64_t i;
int ret;
const char *field_name;
- value_obj = bt_value_array_get(attr_obj, i);
+ value_obj = bt_value_array_borrow(attr_obj, i);
if (!value_obj) {
BT_LOGE("Cannot get attributes object's array value's element by index: "
"value-addr=%p, index=%" PRIu64, attr_obj, i);
goto error;
}
- attr_field_name_obj = bt_value_array_get(value_obj, 0);
+ attr_field_name_obj = bt_value_array_borrow(value_obj,
+ BT_ATTR_NAME_INDEX);
if (!attr_field_name_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
"value-addr=%p, index=%" PRIu64,
- value_obj, (int64_t) 0);
+ value_obj, (int64_t) BT_ATTR_NAME_INDEX);
goto error;
}
}
if (!strcmp(field_name, name)) {
- BT_PUT(attr_field_name_obj);
break;
}
- BT_PUT(attr_field_name_obj);
- BT_PUT(value_obj);
+ value_obj = NULL;
}
return value_obj;
error:
- BT_PUT(attr_field_name_obj);
- BT_PUT(value_obj);
-
+ value_obj = NULL;
return value_obj;
}
goto end;
}
- attr_field_obj = bt_attributes_get_field_by_name(attr_obj, name);
+ attr_field_obj = bt_attributes_borrow_field_by_name(attr_obj, name);
if (attr_field_obj) {
ret = bt_value_array_set(attr_field_obj,
BT_ATTR_VALUE_INDEX, value_obj);
+ attr_field_obj = NULL;
goto end;
}
}
end:
- BT_PUT(attr_field_obj);
-
+ bt_put(attr_field_obj);
return ret;
}
BT_HIDDEN
-struct bt_value *bt_attributes_get_field_value_by_name(
+struct bt_value *bt_attributes_borrow_field_value_by_name(
struct bt_value *attr_obj, const char *name)
{
struct bt_value *value_obj = NULL;
goto end;
}
- attr_field_obj = bt_attributes_get_field_by_name(attr_obj, name);
+ attr_field_obj = bt_attributes_borrow_field_by_name(attr_obj, name);
if (!attr_field_obj) {
BT_LOGD("Cannot find attributes object's field by name: "
"value-addr=%p, name=\"%s\"", attr_obj, name);
goto end;
}
- value_obj = bt_value_array_get(attr_field_obj,
+ value_obj = bt_value_array_borrow(attr_field_obj,
BT_ATTR_VALUE_INDEX);
if (!value_obj) {
BT_LOGE("Cannot get attribute array value's element by index: "
}
end:
- BT_PUT(attr_field_obj);
-
return value_obj;
}
for (i = 0; i < count; ++i) {
struct bt_value *obj = NULL;
- obj = bt_attributes_get_field_value(attr_obj, i);
+ obj = bt_attributes_borrow_field_value(attr_obj, i);
if (!obj) {
BT_LOGE("Cannot get attributes object's field value by index: "
"value-addr=%p, index=%" PRIu64,
}
bt_value_freeze(obj);
- BT_PUT(obj);
}
end:
return ret;
}
-struct bt_clock_class *bt_clock_value_get_class(
+struct bt_clock_class *bt_clock_value_borrow_class(
struct bt_clock_value *clock_value)
{
struct bt_clock_class *clock_class = NULL;
goto end;
}
- clock_class = bt_get(clock_value->clock_class);
+ clock_class = clock_value->clock_class;
end:
return clock_class;
emf_uri);
}
-struct bt_stream_class *bt_event_class_get_stream_class(
+struct bt_stream_class *bt_event_class_borrow_stream_class(
struct bt_event_class *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return bt_get(bt_event_class_borrow_stream_class(event_class));
+ return BT_FROM_COMMON(
+ bt_event_class_common_borrow_stream_class(BT_TO_COMMON(
+ event_class)));
}
-struct bt_field_type *bt_event_class_get_payload_field_type(
+struct bt_field_type *bt_event_class_borrow_payload_field_type(
struct bt_event_class *event_class)
{
- return BT_FROM_COMMON(bt_event_class_common_get_payload_field_type(
+ return BT_FROM_COMMON(bt_event_class_common_borrow_payload_field_type(
BT_TO_COMMON(event_class)));
}
BT_TO_COMMON(event_class), (void *) field_type);
}
-struct bt_field_type *bt_event_class_get_context_field_type(
+struct bt_field_type *bt_event_class_borrow_context_field_type(
struct bt_event_class *event_class)
{
- return BT_FROM_COMMON(bt_event_class_common_get_context_field_type(
+ return BT_FROM_COMMON(bt_event_class_common_borrow_context_field_type(
BT_TO_COMMON(event_class)));
}
trace = bt_stream_class_common_borrow_trace(stream_class);
if (trace) {
BT_LOGD_STR("Event class is part of a trace.");
- packet_header_type = bt_trace_common_get_packet_header_field_type(trace);
+ packet_header_type =
+ bt_trace_common_borrow_packet_header_field_type(trace);
trace_valid = trace->valid;
BT_ASSERT(trace_valid);
environment = trace->environment;
}
- packet_context_type = bt_stream_class_common_get_packet_context_field_type(
- stream_class);
- event_header_type = bt_stream_class_common_get_event_header_field_type(
- stream_class);
- stream_event_ctx_type = bt_stream_class_common_get_event_context_field_type(
- stream_class);
- event_context_type = bt_event_class_common_get_context_field_type(event_class);
- event_payload_type = bt_event_class_common_get_payload_field_type(event_class);
+ packet_context_type =
+ bt_stream_class_common_borrow_packet_context_field_type(
+ stream_class);
+ event_header_type =
+ bt_stream_class_common_borrow_event_header_field_type(
+ stream_class);
+ stream_event_ctx_type =
+ bt_stream_class_common_borrow_event_context_field_type(
+ stream_class);
+ event_context_type =
+ bt_event_class_common_borrow_context_field_type(event_class);
+ event_payload_type =
+ bt_event_class_common_borrow_payload_field_type(event_class);
ret = bt_validate_class_types(environment, packet_header_type,
packet_context_type, event_header_type, stream_event_ctx_type,
event_context_type, event_payload_type, trace_valid,
stream_class->valid, event_class->valid,
validation_output, validation_flags, copy_field_type_func);
- BT_PUT(packet_header_type);
- BT_PUT(packet_context_type);
- BT_PUT(event_header_type);
- BT_PUT(stream_event_ctx_type);
- BT_PUT(event_context_type);
- BT_PUT(event_payload_type);
if (ret) {
/*
* This means something went wrong during the validation
ret = -1;
end:
- BT_ASSERT(!packet_header_type);
- BT_ASSERT(!packet_context_type);
- BT_ASSERT(!event_header_type);
- BT_ASSERT(!stream_event_ctx_type);
- BT_ASSERT(!event_context_type);
- BT_ASSERT(!event_payload_type);
return ret;
}
}
event->clock_values = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, bt_put, bt_put);
+ g_direct_equal, NULL, bt_put);
assert(event->clock_values);
goto end;
return event;
}
-struct bt_event_class *bt_event_get_class(struct bt_event *event)
+struct bt_event_class *bt_event_borrow_class(struct bt_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_get(bt_event_common_borrow_class(BT_TO_COMMON(event)));
+ return BT_FROM_COMMON(
+ bt_event_common_borrow_class(BT_TO_COMMON(event)));
}
-BT_HIDDEN
struct bt_stream *bt_event_borrow_stream(struct bt_event *event)
-{
- struct bt_stream *stream = NULL;
-
- BT_ASSERT(event);
-
- if (event->packet) {
- stream = event->packet->stream;
- }
-
- return stream;
-}
-
-struct bt_stream *bt_event_get_stream(struct bt_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_get(bt_event_borrow_stream(event));
+ return event->packet ? event->packet->stream : NULL;
}
-struct bt_field *bt_event_get_payload(struct bt_event *event)
+struct bt_field *bt_event_borrow_payload(struct bt_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_payload(BT_TO_COMMON(event)));
+ return BT_FROM_COMMON(
+ bt_event_common_borrow_payload(BT_TO_COMMON(event)));
}
int bt_event_set_payload(struct bt_event *event, struct bt_field *field)
(void *) field);
}
-struct bt_field *bt_event_get_header(struct bt_event *event)
+struct bt_field *bt_event_borrow_header(struct bt_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_header(BT_TO_COMMON(event)));
+ return BT_FROM_COMMON(
+ bt_event_common_borrow_header(BT_TO_COMMON(event)));
}
int bt_event_set_header(struct bt_event *event, struct bt_field *field)
return bt_event_common_set_header(BT_TO_COMMON(event), (void *) field);
}
-struct bt_field *bt_event_get_context(struct bt_event *event)
+struct bt_field *bt_event_borrow_context(struct bt_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_context(BT_TO_COMMON(event)));
+ return BT_FROM_COMMON(
+ bt_event_common_borrow_context(BT_TO_COMMON(event)));
}
int bt_event_set_context(struct bt_event *event, struct bt_field *field)
return bt_event_common_set_context(BT_TO_COMMON(event), (void *) field);
}
-struct bt_field *bt_event_get_stream_event_context(
+struct bt_field *bt_event_borrow_stream_event_context(
struct bt_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_stream_event_context(
+ return BT_FROM_COMMON(bt_event_common_borrow_stream_event_context(
BT_TO_COMMON(event)));
}
g_free(event);
}
-struct bt_clock_value *bt_event_get_clock_value(
+struct bt_clock_value *bt_event_borrow_clock_value(
struct bt_event *event, struct bt_clock_class *clock_class)
{
struct bt_clock_value *clock_value = NULL;
goto end;
}
- bt_get(clock_value);
-
end:
return clock_value;
}
BT_ASSERT_PRE_NON_NULL(event, "Event");
BT_ASSERT_PRE_NON_NULL(value, "Clock value");
BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_TO_COMMON(event), "Event");
- clock_class = bt_clock_value_get_class(value);
+ clock_class = bt_clock_value_borrow_class(value);
event_class = BT_FROM_COMMON(event->common.class);
BT_ASSERT(event_class);
stream_class = bt_event_class_borrow_stream_class(event_class);
bt_event_class_common_get_id(event->common.class),
clock_class, bt_clock_class_get_name(clock_class),
value, value->value);
- clock_class = NULL;
- bt_put(clock_class);
return 0;
}
-struct bt_packet *bt_event_get_packet(struct bt_event *event)
+struct bt_packet *bt_event_borrow_packet(struct bt_event *event)
{
struct bt_packet *packet = NULL;
goto end;
}
- packet = bt_get(event->packet);
+ packet = event->packet;
end:
return packet;
for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_structure_get_field_by_index(ft,
+ ret = bt_field_type_common_structure_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate(child_ft);
ft, child_ft, field_name, i);
goto end;
}
-
- BT_PUT(child_ft);
}
end:
- BT_PUT(child_ft);
return ret;
}
for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_variant_get_field_by_index(ft,
+ ret = bt_field_type_common_variant_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate(child_ft);
field_name, i);
goto end;
}
-
- BT_PUT(child_ft);
}
end:
- BT_PUT(child_ft);
return ret;
}
}
BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_get_mapped_clock_class(
+struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
- return bt_get(int_ft->mapped_clock_class);
+ return int_ft->mapped_clock_class;
}
-struct bt_clock_class *bt_field_type_integer_get_mapped_clock_class(
+struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
struct bt_field_type *ft)
{
- return bt_field_type_common_integer_get_mapped_clock_class((void *) ft);
+ return bt_field_type_common_integer_borrow_mapped_clock_class(
+ (void *) ft);
}
BT_HIDDEN
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_enumeration_get_container_field_type(
+struct bt_field_type_common *
+bt_field_type_common_enumeration_borrow_container_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
- return bt_get(enum_ft->container_ft);
+ return BT_TO_COMMON(enum_ft->container_ft);
}
-struct bt_field_type *bt_field_type_enumeration_get_container_field_type(
+struct bt_field_type *bt_field_type_enumeration_borrow_container_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_enumeration_get_container_field_type(
+ return (void *) bt_field_type_common_enumeration_borrow_container_field_type(
(void *) ft);
}
}
BT_HIDDEN
-int bt_field_type_common_structure_get_field_by_index(
+int bt_field_type_common_structure_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index)
if (field_type) {
*field_type = field->type;
- bt_get(field->type);
}
if (field_name) {
return 0;
}
-int bt_field_type_structure_get_field_by_index(
+int bt_field_type_structure_borrow_field_by_index(
struct bt_field_type *ft,
const char **field_name,
struct bt_field_type **field_type, uint64_t index)
{
- return bt_field_type_common_structure_get_field_by_index(
+ return bt_field_type_common_structure_borrow_field_by_index(
(void *) ft, field_name, (void *) field_type, index);
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_structure_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_structure_borrow_field_type_by_name(
struct bt_field_type_common *ft, const char *name)
{
size_t index;
field = struct_ft->fields->pdata[index];
field_type = field->type;
- bt_get(field_type);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_structure_get_field_type_by_name(
+struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
struct bt_field_type *ft, const char *name)
{
- return (void *) bt_field_type_common_structure_get_field_type_by_name(
+ return (void *) bt_field_type_common_structure_borrow_field_type_by_name(
(void *) ft, name);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_tag_field_type(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_tag_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
goto end;
}
- tag_ft = bt_get(var_ft->tag_ft);
+ tag_ft = BT_TO_COMMON(var_ft->tag_ft);
end:
return tag_ft;
}
-struct bt_field_type *bt_field_type_variant_get_tag_field_type(
+struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_variant_get_tag_field_type(
+ return (void *) bt_field_type_common_variant_borrow_tag_field_type(
(void *) ft);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_by_name(
struct bt_field_type_common *ft,
const char *field_name)
{
field = g_ptr_array_index(var_ft->fields, index);
field_type = field->type;
- bt_get(field_type);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_variant_get_field_type_by_name(
+struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
struct bt_field_type *ft,
const char *field_name)
{
- return (void *) bt_field_type_common_variant_get_field_type_by_name(
+ return (void *) bt_field_type_common_variant_borrow_field_type_by_name(
(void *) ft, field_name);
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_from_tag(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_from_tag(
struct bt_field_type_common *ft,
struct bt_field_common *tag_field,
bt_field_common_create_func field_create_func)
goto end;
}
- field_type = bt_field_type_common_variant_get_field_type_by_name(
+ field_type = bt_field_type_common_variant_borrow_field_type_by_name(
ft, enum_value);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_variant_get_field_type_from_tag(
+struct bt_field_type *bt_field_type_variant_borrow_field_type_from_tag(
struct bt_field_type *ft,
struct bt_field *tag_field)
{
- return (void *) bt_field_type_common_variant_get_field_type_from_tag(
+ return (void *) bt_field_type_common_variant_borrow_field_type_from_tag(
(void *) ft, (void *) tag_field,
(bt_field_common_create_func) bt_field_create);
}
}
BT_HIDDEN
-int bt_field_type_common_variant_get_field_by_index(
+int bt_field_type_common_variant_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index)
if (field_type) {
*field_type = field->type;
- bt_get(field->type);
}
if (field_name) {
return 0;
}
-int bt_field_type_variant_get_field_by_index(struct bt_field_type *ft,
+int bt_field_type_variant_borrow_field_by_index(struct bt_field_type *ft,
const char **field_name, struct bt_field_type **field_type,
uint64_t index)
{
- return bt_field_type_common_variant_get_field_by_index((void *) ft,
+ return bt_field_type_common_variant_borrow_field_by_index((void *) ft,
field_name, (void *) field_type, index);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_array_get_element_field_type(
+struct bt_field_type_common *
+bt_field_type_common_array_borrow_element_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
"Field type");
BT_ASSERT(array_ft && array_ft->element_ft);
- return bt_get(array_ft->element_ft);
+ return array_ft->element_ft;
}
-struct bt_field_type *bt_field_type_array_get_element_field_type(
+struct bt_field_type *bt_field_type_array_borrow_element_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_array_get_element_field_type(
+ return (void *) bt_field_type_common_array_borrow_element_field_type(
(void *) ft);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_sequence_get_element_field_type(
+struct bt_field_type_common *bt_field_type_common_sequence_borrow_element_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
- return bt_get(seq_ft->element_ft);
+ return seq_ft->element_ft;
}
-struct bt_field_type *bt_field_type_sequence_get_element_field_type(
+struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_sequence_get_element_field_type(
+ return (void *) bt_field_type_common_sequence_borrow_element_field_type(
(void *) ft);
}
case BT_FIELD_TYPE_ID_SEQUENCE:
{
struct bt_field_type_common *element_ft =
- bt_field_type_common_sequence_get_element_field_type(ft);
+ bt_field_type_common_sequence_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
ret = bt_field_type_common_get_alignment(element_ft);
- bt_put(element_ft);
break;
}
case BT_FIELD_TYPE_ID_ARRAY:
{
struct bt_field_type_common *element_ft =
- bt_field_type_common_array_get_element_field_type(ft);
+ bt_field_type_common_array_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
ret = bt_field_type_common_get_alignment(element_ft);
- bt_put(element_ft);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
struct bt_field_type_common *field = NULL;
int field_alignment;
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
ft, NULL, &field, i);
BT_ASSERT(ret == 0);
BT_ASSERT(field);
field_alignment = bt_field_type_common_get_alignment(
field);
- bt_put(field);
if (field_alignment < 0) {
ret = field_alignment;
goto end;
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_signed(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_signed(
struct bt_field_type_common_variant *var_ft,
int64_t tag_value)
{
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_unsigned(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_unsigned(
struct bt_field_type_common_variant *var_ft,
uint64_t tag_value)
{
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_get_field_at_index(
+struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
struct bt_field_type_common *ft, int index)
{
struct bt_field_type_common *field_type = NULL;
switch (ft->id) {
case BT_FIELD_TYPE_ID_STRUCT:
{
- int ret = bt_field_type_common_structure_get_field_by_index(
+ int ret = bt_field_type_common_structure_borrow_field_by_index(
ft, NULL, &field_type, index);
if (ret) {
field_type = NULL;
}
case BT_FIELD_TYPE_ID_VARIANT:
{
- int ret = bt_field_type_common_variant_get_field_by_index(
+ int ret = bt_field_type_common_variant_borrow_field_by_index(
ft, NULL, &field_type, index);
if (ret) {
field_type = NULL;
break;
}
case BT_FIELD_TYPE_ID_ARRAY:
- field_type = bt_field_type_common_array_get_element_field_type(ft);
+ field_type =
+ bt_field_type_common_array_borrow_element_field_type(ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
- field_type = bt_field_type_common_sequence_get_element_field_type(ft);
+ field_type =
+ bt_field_type_common_sequence_borrow_element_field_type(ft);
break;
default:
break;
}
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_get_tag_field_path(
+struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
- return bt_get(var_ft->tag_field_path);
+ return var_ft->tag_field_path;
}
-struct bt_field_path *bt_field_type_variant_get_tag_field_path(
+struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
struct bt_field_type *ft)
{
- return bt_field_type_common_variant_get_tag_field_path((void *) ft);
+ return bt_field_type_common_variant_borrow_tag_field_path((void *) ft);
}
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_sequence_get_length_field_path(
+struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
- return bt_get(seq_ft->length_field_path);
+ return seq_ft->length_field_path;
}
-struct bt_field_path *bt_field_type_sequence_get_length_field_path(
+struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
struct bt_field_type *ft)
{
- return bt_field_type_common_sequence_get_length_field_path((void *) ft);
+ return bt_field_type_common_sequence_borrow_length_field_path(
+ (void *) ft);
}
BT_HIDDEN
case BT_FIELD_TYPE_ID_INTEGER:
{
struct bt_clock_class *mapped_clock_class =
- bt_field_type_common_integer_get_mapped_clock_class(ft);
+ bt_field_type_common_integer_borrow_mapped_clock_class(ft);
if (!mapped_clock_class) {
goto end;
if (!*expected_clock_class) {
/* Move reference to output parameter */
- *expected_clock_class = mapped_clock_class;
+ *expected_clock_class = bt_get(mapped_clock_class);
mapped_clock_class = NULL;
BT_LOGV("Setting expected clock class: "
"expected-clock-class-addr=%p",
}
}
- bt_put(mapped_clock_class);
break;
}
case BT_FIELD_TYPE_ID_ENUM:
switch (ft->id) {
case BT_FIELD_TYPE_ID_ENUM:
- sub_ft = bt_field_type_common_enumeration_get_container_field_type(
+ sub_ft = bt_field_type_common_enumeration_borrow_container_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_ARRAY:
- sub_ft = bt_field_type_common_array_get_element_field_type(
+ sub_ft = bt_field_type_common_array_borrow_element_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
- sub_ft = bt_field_type_common_sequence_get_element_field_type(
+ sub_ft = bt_field_type_common_sequence_borrow_element_field_type(
ft);
break;
default:
BT_ASSERT(sub_ft);
ret = bt_field_type_common_validate_single_clock_class(sub_ft,
expected_clock_class);
- bt_put(sub_ft);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
const char *name;
struct bt_field_type_common *member_type;
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate_single_clock_class(
member_type, expected_clock_class);
- bt_put(member_type);
if (ret) {
BT_LOGW("Structure field type's field's type "
"is not recursively mapped to the "
const char *name;
struct bt_field_type_common *member_type;
- ret = bt_field_type_common_variant_get_field_by_index(
+ ret = bt_field_type_common_variant_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate_single_clock_class(
member_type, expected_clock_class);
- bt_put(member_type);
if (ret) {
BT_LOGW("Variant field type's field's type "
"is not recursively mapped to the "
return field;
}
-struct bt_field_type *bt_field_get_type(struct bt_field *field)
+struct bt_field_type *bt_field_borrow_type(struct bt_field *field)
{
- return (void *) bt_field_common_get_type((void *) field);
+ return (void *) bt_field_common_borrow_type((void *) field);
}
enum bt_field_type_id bt_field_get_type_id(struct bt_field *field)
return bt_field_common_sequence_get_int_length((void *) field);
}
-struct bt_field *bt_field_sequence_get_length(struct bt_field *field)
+struct bt_field *bt_field_sequence_borrow_length(struct bt_field *field)
{
- return (void *) bt_field_common_sequence_get_length((void *) field);
+ return (void *) bt_field_common_sequence_borrow_length((void *) field);
}
int bt_field_sequence_set_length(struct bt_field *field,
(void *) length_field);
}
-struct bt_field *bt_field_structure_get_field_by_index(
+struct bt_field *bt_field_structure_borrow_field_by_index(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_structure_get_field_by_index(
+ return (void *) bt_field_common_structure_borrow_field_by_index(
(void *) field, index);
}
-struct bt_field *bt_field_structure_get_field_by_name(
+struct bt_field *bt_field_structure_borrow_field_by_name(
struct bt_field *field, const char *name)
{
- return (void *) bt_field_common_structure_get_field_by_name(
+ return (void *) bt_field_common_structure_borrow_field_by_name(
(void *) field, name);
}
name, (void *) value);
}
-struct bt_field *bt_field_array_get_field(
+struct bt_field *bt_field_array_borrow_field(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_array_get_field((void *) field, index,
- (bt_field_common_create_func) bt_field_create);
+ return (void *) bt_field_common_array_borrow_field((void *) field,
+ index, (bt_field_common_create_func) bt_field_create);
}
-struct bt_field *bt_field_sequence_get_field(
+struct bt_field *bt_field_sequence_borrow_field(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_sequence_get_field((void *) field,
+ return (void *) bt_field_common_sequence_borrow_field((void *) field,
index, (bt_field_common_create_func) bt_field_create);
}
-struct bt_field *bt_field_variant_get_field(struct bt_field *field,
+struct bt_field *bt_field_variant_borrow_field(struct bt_field *field,
struct bt_field *tag_field)
{
- return (void *) bt_field_common_variant_get_field((void *) field,
+ return (void *) bt_field_common_variant_borrow_field((void *) field,
(void *) tag_field,
(bt_field_common_create_func) bt_field_create);
}
-struct bt_field *bt_field_variant_get_current_field(
+struct bt_field *bt_field_variant_borrow_current_field(
struct bt_field *variant_field)
{
- return (void *) bt_field_common_variant_get_current_field(
+ return (void *) bt_field_common_variant_borrow_current_field(
(void *) variant_field);
}
-struct bt_field_common *bt_field_variant_get_tag(
+struct bt_field_common *bt_field_variant_borrow_tag(
struct bt_field_common *variant_field)
{
- return (void *) bt_field_common_variant_get_tag((void *) variant_field);
+ return (void *) bt_field_common_variant_borrow_tag(
+ (void *) variant_field);
}
-struct bt_field *bt_field_enumeration_get_container(struct bt_field *field)
+struct bt_field *bt_field_enumeration_borrow_container(struct bt_field *field)
{
- return (void *) bt_field_common_enumeration_get_container(
+ return (void *) bt_field_common_enumeration_borrow_container(
(void *) field, (bt_field_common_create_func) bt_field_create);
}
int this_ret;
const char *name;
- this_ret = bt_field_type_common_structure_get_field_by_index(
+ this_ret = bt_field_type_common_structure_borrow_field_by_index(
field->type, &name, NULL, i);
BT_ASSERT(this_ret == 0);
BT_ASSERT_PRE_MSG("Invalid structure field's field: "
goto error;
}
- src_length = bt_field_common_sequence_get_length(src);
+ src_length = bt_field_common_sequence_borrow_length(src);
if (!src_length) {
/* no length set yet: keep destination sequence empty */
goto end;
/* copy source length */
BT_LOGD_STR("Copying sequence field's length field.");
dst_length = (void *) bt_field_copy((void *) src_length);
- BT_PUT(src_length);
if (!dst_length) {
BT_LOGE_STR("Cannot copy sequence field's length field.");
goto error;
#include <babeltrace/assert-internal.h>
#include <inttypes.h>
-struct bt_stream *bt_packet_get_stream(struct bt_packet *packet)
+struct bt_stream *bt_packet_borrow_stream(struct bt_packet *packet)
{
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- return bt_get(packet->stream);
+ return packet->stream;
}
-struct bt_field *bt_packet_get_header(
+struct bt_field *bt_packet_borrow_header(
struct bt_packet *packet)
{
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- return bt_get(packet->header);
+ return packet->header;
}
BT_ASSERT_PRE_FUNC
return 0;
}
-struct bt_field *bt_packet_get_context(struct bt_packet *packet)
+struct bt_field *bt_packet_borrow_context(struct bt_packet *packet)
{
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- return bt_get(packet->context);
+ return packet->context;
}
int bt_packet_set_context(struct bt_packet *packet,
stream->common.stream_class,
bt_stream_class_common_get_name(stream->common.stream_class),
bt_stream_class_common_get_id(stream->common.stream_class));
- stream_class = bt_stream_get_class(stream);
+ stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- trace = bt_stream_class_get_trace(stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
BT_ASSERT(trace);
packet = g_new0(struct bt_packet, 1);
if (!packet) {
BT_LOGD("Created packet object: addr=%p", packet);
end:
- BT_PUT(trace);
- BT_PUT(stream_class);
-
return packet;
}
g_array_append_val(field_path->indexes, child_index);
/* Get child field type */
- child_type = bt_field_type_common_get_field_at_index(type,
+ child_type = bt_field_type_common_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get child field type: "
}
/* Move child type to current type */
+ bt_get(child_type);
BT_MOVE(type, child_type);
}
g_array_index(field_path->indexes, int, i);
/* Get child field type */
- child_type = bt_field_type_common_get_field_at_index(type,
+ child_type = bt_field_type_common_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get field type: "
}
/* Move child type to current type */
+ bt_get(child_type);
BT_MOVE(type, child_type);
}
for (f_index = 0; f_index < field_count; f_index++) {
struct bt_field_type_common *child_type =
- bt_field_type_common_get_field_at_index(type,
+ bt_field_type_common_borrow_field_at_index(type,
f_index);
if (!child_type) {
"index=%" PRId64 ", count=%" PRId64,
type, child_type, f_index, field_count);
ret = resolve_type(child_type, ctx);
- BT_PUT(child_type);
if (ret) {
goto end;
}
return NULL;
}
-struct bt_trace *bt_stream_class_get_trace(struct bt_stream_class *stream_class)
+struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_trace(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
BT_TO_COMMON(stream_class)));
}
event_class,
bt_event_class_common_get_name(event_class),
bt_event_class_common_get_id(event_class));
-
- trace = bt_stream_class_common_get_trace(stream_class);
+ trace = bt_stream_class_common_borrow_trace(stream_class);
if (stream_class->frozen) {
/*
BT_ASSERT(trace->valid);
BT_ASSERT(stream_class->valid);
packet_header_type =
- bt_trace_common_get_packet_header_field_type(trace);
+ bt_trace_common_borrow_packet_header_field_type(trace);
packet_context_type =
- bt_stream_class_common_get_packet_context_field_type(
+ bt_stream_class_common_borrow_packet_context_field_type(
stream_class);
event_header_type =
- bt_stream_class_common_get_event_header_field_type(
+ bt_stream_class_common_borrow_event_header_field_type(
stream_class);
stream_event_ctx_type =
- bt_stream_class_common_get_event_context_field_type(
+ bt_stream_class_common_borrow_event_context_field_type(
stream_class);
event_context_type =
- bt_event_class_common_get_context_field_type(event_class);
+ bt_event_class_common_borrow_context_field_type(
+ event_class);
event_payload_type =
- bt_event_class_common_get_payload_field_type(event_class);
+ bt_event_class_common_borrow_payload_field_type(
+ event_class);
ret = bt_validate_class_types(
trace->environment, packet_header_type,
packet_context_type, event_header_type,
stream_class->valid, event_class->valid,
&validation_output, validation_flags,
copy_field_type_func);
- BT_PUT(packet_header_type);
- BT_PUT(packet_context_type);
- BT_PUT(event_header_type);
- BT_PUT(stream_event_ctx_type);
- BT_PUT(event_context_type);
- BT_PUT(event_payload_type);
if (ret) {
/*
bt_event_class_common_get_id(event_class));
end:
- BT_PUT(trace);
bt_validation_output_put_types(&validation_output);
bt_put(expected_clock_class);
- BT_ASSERT(!packet_header_type);
- BT_ASSERT(!packet_context_type);
- BT_ASSERT(!event_header_type);
- BT_ASSERT(!stream_event_ctx_type);
- BT_ASSERT(!event_context_type);
- BT_ASSERT(!event_payload_type);
g_free(event_id);
return ret;
}
BT_TO_COMMON(stream_class));
}
-struct bt_event_class *bt_stream_class_get_event_class_by_index(
+struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
struct bt_stream_class *stream_class, uint64_t index)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_event_class_by_index(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_index(
BT_TO_COMMON(stream_class), index));
}
-struct bt_event_class *bt_stream_class_get_event_class_by_id(
+struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
struct bt_stream_class *stream_class, uint64_t id)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_event_class_by_id(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_id(
BT_TO_COMMON(stream_class), id));
}
-struct bt_field_type *bt_stream_class_get_packet_context_field_type(
+struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
struct bt_stream_class *stream_class)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_packet_context_field_type(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_packet_context_field_type(
BT_TO_COMMON(stream_class)));
}
BT_TO_COMMON(stream_class), (void *) packet_context_type);
}
-struct bt_field_type *bt_stream_class_get_event_header_field_type(
+struct bt_field_type *bt_stream_class_borrow_event_header_field_type(
struct bt_stream_class *stream_class)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_event_header_field_type(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_event_header_field_type(
BT_TO_COMMON(stream_class)));
}
BT_TO_COMMON(stream_class), (void *) event_header_type);
}
-struct bt_field_type *bt_stream_class_get_event_context_field_type(
+struct bt_field_type *bt_stream_class_borrow_event_context_field_type(
struct bt_stream_class *stream_class)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_event_context_field_type(
+ return BT_FROM_COMMON(bt_stream_class_common_borrow_event_context_field_type(
BT_TO_COMMON(stream_class)));
}
return stream;
}
-struct bt_stream_class *bt_stream_get_class(struct bt_stream *stream)
+struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
{
- return BT_FROM_COMMON(bt_stream_common_get_class(BT_TO_COMMON(stream)));
+ return BT_FROM_COMMON(bt_stream_common_borrow_class(BT_TO_COMMON(stream)));
}
const char *bt_stream_get_name(struct bt_stream *stream)
* The object passed is frozen like all other attributes.
*/
struct bt_value *attribute =
- bt_attributes_get_field_value_by_name(
+ bt_attributes_borrow_field_value_by_name(
trace->environment, name);
if (attribute) {
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\"",
trace, bt_trace_common_get_name(trace), name);
- BT_PUT(attribute);
ret = -1;
goto end;
}
BT_TO_COMMON(trace), index);
}
-struct bt_value *bt_trace_get_environment_field_value_by_index(
+struct bt_value *bt_trace_borrow_environment_field_value_by_index(
struct bt_trace *trace, uint64_t index)
{
- return bt_trace_common_get_environment_field_value_by_index(
+ return bt_trace_common_borrow_environment_field_value_by_index(
BT_TO_COMMON(trace), index);
}
-struct bt_value *bt_trace_get_environment_field_value_by_name(
+struct bt_value *bt_trace_borrow_environment_field_value_by_name(
struct bt_trace *trace, const char *name)
{
- return bt_trace_common_get_environment_field_value_by_name(
+ return bt_trace_common_borrow_environment_field_value_by_name(
BT_TO_COMMON(trace), name);
}
return bt_trace_common_get_clock_class_count(BT_TO_COMMON(trace));
}
-struct bt_clock_class *bt_trace_get_clock_class_by_index(
+struct bt_clock_class *bt_trace_borrow_clock_class_by_index(
struct bt_trace *trace, uint64_t index)
{
- return bt_trace_common_get_clock_class_by_index(
+ return bt_trace_common_borrow_clock_class_by_index(
BT_TO_COMMON(trace), index);
}
* integer field type. Also it must be the first field of the
* packet header field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_header_type, "magic");
if (field_type) {
const char *field_name;
goto invalid;
}
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
packet_header_type, &field_name, NULL, 0);
BT_ASSERT(ret == 0);
field_type, field_name);
goto invalid;
}
-
- BT_PUT(field_type);
}
/*
* If there's a `uuid` field, it must be an array field type of
* length 16 with an 8-bit unsigned integer element field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_header_type, "uuid");
if (field_type) {
struct bt_field_type_common *elem_ft;
goto invalid;
}
- elem_ft = bt_field_type_common_array_get_element_field_type(field_type);
+ elem_ft = bt_field_type_common_array_borrow_element_field_type(field_type);
BT_ASSERT(elem_ft);
if (elem_ft->id != BT_FIELD_TYPE_ID_INTEGER) {
"elem-ft-addr=%p, elem-ft-id=%s",
elem_ft,
bt_common_field_type_id_string(elem_ft->id));
- bt_put(elem_ft);
goto invalid;
}
if (bt_field_type_common_integer_is_signed(elem_ft)) {
BT_LOGW("Invalid packet header field type: `uuid` field's element field type must be an unsigned integer field type: "
"elem-ft-addr=%p", elem_ft);
- bt_put(elem_ft);
goto invalid;
}
"elem-ft-addr=%p, elem-ft-size=%u",
elem_ft,
bt_field_type_common_integer_get_size(elem_ft));
- bt_put(elem_ft);
goto invalid;
}
-
- bt_put(elem_ft);
- BT_PUT(field_type);
}
/*
* The `stream_id` field must exist if there's more than one
* stream classes in the trace.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_header_type, "stream_id");
if (!field_type && trace->stream_classes->len >= 1) {
"stream-id-ft-addr=%p", field_type);
goto invalid;
}
-
- BT_PUT(field_type);
}
/*
* If there's a `packet_seq_num` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_header_type, "packet_seq_num");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
"packet-seq-num-ft-addr=%p", field_type);
goto invalid;
}
-
- BT_PUT(field_type);
}
goto end;
is_valid = false;
end:
- bt_put(field_type);
return is_valid;
}
* If there's a `packet_size` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_context_type, "packet_size");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
"packet-size-ft-addr=%p", field_type);
goto invalid;
}
-
- BT_PUT(field_type);
}
/*
* If there's a `content_size` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_context_type, "content_size");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
"content-size-ft-addr=%p", field_type);
goto invalid;
}
-
- BT_PUT(field_type);
}
/*
* If there's a `events_discarded` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_context_type, "events_discarded");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
"events-discarded-ft-addr=%p", field_type);
goto invalid;
}
-
- BT_PUT(field_type);
}
/*
* trace, then we cannot automatically set the mapped clock
* class of this field, so it must have a mapped clock class.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_context_type, "timestamp_begin");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
if (check_ts_begin_end_mapped) {
struct bt_clock_class *clock_class =
- bt_field_type_common_integer_get_mapped_clock_class(
+ bt_field_type_common_integer_borrow_mapped_clock_class(
field_type);
- bt_put(clock_class);
if (!clock_class) {
BT_LOGW("Invalid packet context field type: `timestamp_begin` field must be mapped to a clock class: "
"timestamp-begin-ft-addr=%p", field_type);
goto invalid;
}
}
-
- BT_PUT(field_type);
}
/*
* trace, then we cannot automatically set the mapped clock
* class of this field, so it must have a mapped clock class.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
packet_context_type, "timestamp_end");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
if (check_ts_begin_end_mapped) {
struct bt_clock_class *clock_class =
- bt_field_type_common_integer_get_mapped_clock_class(
+ bt_field_type_common_integer_borrow_mapped_clock_class(
field_type);
- bt_put(clock_class);
if (!clock_class) {
BT_LOGW("Invalid packet context field type: `timestamp_end` field must be mapped to a clock class: "
"timestamp-end-ft-addr=%p", field_type);
goto invalid;
}
}
-
- BT_PUT(field_type);
}
goto end;
is_valid = false;
end:
- bt_put(field_type);
return is_valid;
}
* field type or an enumeration field type with an unsigned
* integer container field type.
*/
- field_type = bt_field_type_common_structure_get_field_type_by_name(
+ field_type = bt_field_type_common_structure_borrow_field_type_by_name(
event_header_type, "id");
if (field_type) {
struct bt_field_type_common *int_ft;
if (field_type->id == BT_FIELD_TYPE_ID_INTEGER) {
- int_ft = bt_get(field_type);
+ int_ft = field_type;
} else if (field_type->id == BT_FIELD_TYPE_ID_ENUM) {
- int_ft = bt_field_type_common_enumeration_get_container_field_type(
+ int_ft = bt_field_type_common_enumeration_borrow_container_field_type(
field_type);
} else {
BT_LOGW("Invalid event header field type: `id` field must be an integer or enumeration field type: "
"id-ft-addr=%p", int_ft);
goto invalid;
}
-
- bt_put(int_ft);
- BT_PUT(field_type);
}
goto end;
is_valid = false;
end:
- bt_put(field_type);
return is_valid;
}
stream_class, bt_stream_class_common_get_name(stream_class),
bt_stream_class_common_get_id(stream_class));
- current_parent_trace = bt_stream_class_common_get_trace(stream_class);
+ current_parent_trace = bt_stream_class_common_borrow_trace(stream_class);
if (current_parent_trace) {
/* Stream class is already associated to a trace, abort. */
BT_LOGW("Invalid parameter: stream class is already part of a trace: "
* class of this stream class can be validated individually.
*/
packet_header_type =
- bt_trace_common_get_packet_header_field_type(trace);
+ bt_trace_common_borrow_packet_header_field_type(trace);
packet_context_type =
- bt_stream_class_common_get_packet_context_field_type(stream_class);
+ bt_stream_class_common_borrow_packet_context_field_type(stream_class);
event_header_type =
- bt_stream_class_common_get_event_header_field_type(stream_class);
+ bt_stream_class_common_borrow_event_header_field_type(stream_class);
stream_event_ctx_type =
- bt_stream_class_common_get_event_context_field_type(stream_class);
+ bt_stream_class_common_borrow_event_context_field_type(stream_class);
BT_LOGD("Validating trace and stream class field types.");
ret = bt_validate_class_types(trace->environment,
stream_event_ctx_type, NULL, NULL, trace->valid,
stream_class->valid, 1, &trace_sc_validation_output,
trace_sc_validation_flags, copy_field_type_func);
- BT_PUT(packet_header_type);
- BT_PUT(packet_context_type);
- BT_PUT(event_header_type);
- BT_PUT(stream_event_ctx_type);
if (ret) {
/*
/* Validate each event class individually */
for (i = 0; i < event_class_count; i++) {
struct bt_event_class_common *event_class =
- bt_stream_class_common_get_event_class_by_index(
+ bt_stream_class_common_borrow_event_class_by_index(
stream_class, i);
struct bt_field_type_common *event_context_type = NULL;
struct bt_field_type_common *event_payload_type = NULL;
event_context_type =
- bt_event_class_common_get_context_field_type(event_class);
+ bt_event_class_common_borrow_context_field_type(
+ event_class);
event_payload_type =
- bt_event_class_common_get_payload_field_type(event_class);
+ bt_event_class_common_borrow_payload_field_type(
+ event_class);
/*
* It is important to use the field types returned by
event_context_type, event_payload_type,
1, 1, event_class->valid, &ec_validation_outputs[i],
ec_validation_flags, copy_field_type_func);
- BT_PUT(event_context_type);
- BT_PUT(event_payload_type);
- BT_PUT(event_class);
if (ret) {
BT_LOGE("Failed to validate event class field types: "
for (i = 0; i < event_class_count; i++) {
struct bt_event_class_common *event_class =
- bt_stream_class_common_get_event_class_by_index(
+ bt_stream_class_common_borrow_event_class_by_index(
stream_class, i);
bt_validation_replace_types(NULL, NULL, event_class,
&ec_validation_outputs[i], ec_validation_flags);
event_class->valid = 1;
- BT_PUT(event_class);
/*
* Put what was not moved in
g_free(ec_validation_outputs);
bt_validation_output_put_types(&trace_sc_validation_output);
- bt_put(current_parent_trace);
bt_put(expected_clock_class);
- BT_ASSERT(!packet_header_type);
- BT_ASSERT(!packet_context_type);
- BT_ASSERT(!event_header_type);
- BT_ASSERT(!stream_event_ctx_type);
return ret;
}
return bt_trace_common_get_stream_count(BT_TO_COMMON(trace));
}
-struct bt_stream *bt_trace_get_stream_by_index(
- struct bt_trace *trace,
- uint64_t index)
+struct bt_stream *bt_trace_borrow_stream_by_index(
+ struct bt_trace *trace, uint64_t index)
{
- return BT_FROM_COMMON(bt_trace_common_get_stream_by_index(
+ return BT_FROM_COMMON(bt_trace_common_borrow_stream_by_index(
BT_TO_COMMON(trace), index));
}
return bt_trace_common_get_stream_class_count(BT_TO_COMMON(trace));
}
-struct bt_stream_class *bt_trace_get_stream_class_by_index(
+struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
struct bt_trace *trace, uint64_t index)
{
- return BT_FROM_COMMON(bt_trace_common_get_stream_class_by_index(
+ return BT_FROM_COMMON(bt_trace_common_borrow_stream_class_by_index(
BT_TO_COMMON(trace), index));
}
-struct bt_stream_class *bt_trace_get_stream_class_by_id(
+struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
struct bt_trace *trace, uint64_t id)
{
return BT_FROM_COMMON(
- bt_trace_common_get_stream_class_by_id(
+ bt_trace_common_borrow_stream_class_by_id(
BT_TO_COMMON(trace), id));
}
-struct bt_clock_class *bt_trace_get_clock_class_by_name(
+struct bt_clock_class *bt_trace_borrow_clock_class_by_name(
struct bt_trace *trace, const char *name)
{
- return bt_trace_common_get_clock_class_by_name(BT_TO_COMMON(trace),
+ return bt_trace_common_borrow_clock_class_by_name(BT_TO_COMMON(trace),
name);
}
byte_order, true);
}
-struct bt_field_type *bt_trace_get_packet_header_field_type(
+struct bt_field_type *bt_trace_borrow_packet_header_field_type(
struct bt_trace *trace)
{
- return BT_FROM_COMMON(bt_trace_common_get_packet_header_field_type(
+ return BT_FROM_COMMON(bt_trace_common_borrow_packet_header_field_type(
BT_TO_COMMON(trace)));
}
for (i = 0; i < field_count; ++i) {
struct bt_field_type_common *child_type =
- bt_field_type_common_get_field_at_index(type, i);
+ bt_field_type_common_borrow_field_at_index(
+ type, i);
ret = field_type_contains_sequence_or_variant_ft(
child_type);
- BT_PUT(child_type);
if (ret != 0) {
goto end;
}
struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type(
struct bt_ctf_event_class *event_class)
{
- return BT_FROM_COMMON(bt_event_class_common_get_payload_field_type(
+ return bt_get(bt_event_class_common_borrow_payload_field_type(
BT_TO_COMMON(event_class)));
}
struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type(
struct bt_ctf_event_class *event_class)
{
- return BT_FROM_COMMON(bt_event_class_common_get_context_field_type(
+ return bt_get(bt_event_class_common_borrow_context_field_type(
BT_TO_COMMON(event_class)));
}
* No need to increment field_type's reference count since getting it
* from the structure already does.
*/
- field_type = (void *) bt_field_type_common_structure_get_field_type_by_name(
- event_class->common.payload_field_type, name);
+ field_type = bt_get(
+ bt_field_type_common_structure_borrow_field_type_by_name(
+ event_class->common.payload_field_type, name));
end:
return field_type;
struct bt_ctf_field *bt_ctf_event_get_payload_field(
struct bt_ctf_event *event)
{
- return (void *) bt_event_common_get_payload(BT_TO_COMMON(event));
+ return bt_get(bt_event_common_borrow_payload(BT_TO_COMMON(event)));
}
int bt_ctf_event_set_payload_field(struct bt_ctf_event *event,
struct bt_ctf_field *bt_ctf_event_get_header(struct bt_ctf_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_header(BT_TO_COMMON(event)));
+ return bt_get(bt_event_common_borrow_header(BT_TO_COMMON(event)));
}
int bt_ctf_event_set_header(struct bt_ctf_event *event,
struct bt_ctf_field *bt_ctf_event_get_context(struct bt_ctf_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_context(BT_TO_COMMON(event)));
+ return bt_get(bt_event_common_borrow_context(BT_TO_COMMON(event)));
}
int bt_ctf_event_set_context(struct bt_ctf_event *event,
struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
struct bt_ctf_event *event)
{
- return BT_FROM_COMMON(bt_event_common_get_stream_event_context(
+ return bt_get(bt_event_common_borrow_stream_event_context(
BT_TO_COMMON(event)));
}
BT_LOGD("Serializing CTF writer enumeration field type's metadata: "
"ft-addr=%p, metadata-context-addr=%p", type, context);
container_type =
- bt_field_type_common_enumeration_get_container_field_type(type);
+ bt_field_type_common_enumeration_borrow_container_field_type(type);
BT_ASSERT(container_type);
container_signed = bt_field_type_common_integer_is_signed(
container_type);
}
end:
- bt_put(container_type);
return ret;
}
struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
struct bt_ctf_field_type *ft)
{
- return BT_FROM_COMMON(
- bt_field_type_common_integer_get_mapped_clock_class((void *) ft));
+ return bt_get(bt_field_type_common_integer_borrow_mapped_clock_class(
+ (void *) ft));
}
int bt_ctf_field_type_integer_set_mapped_clock_class(
struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
struct bt_ctf_field_type *ft)
{
- return (void *) bt_field_type_common_enumeration_get_container_field_type(
- (void *) ft);
+ return bt_get(
+ bt_field_type_common_enumeration_borrow_container_field_type(
+ (void *) ft));
}
int bt_ctf_field_type_enumeration_signed_add_mapping(
const char **field_name,
struct bt_ctf_field_type **field_type, uint64_t index)
{
- return bt_field_type_common_structure_get_field_by_index(
+ int ret = bt_field_type_common_structure_borrow_field_by_index(
(void *) ft, field_name, (void *) field_type, index);
+
+ if (ret == 0 && field_type) {
+ bt_get(*field_type);
+ }
+
+ return ret;
}
struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
struct bt_ctf_field_type *ft, const char *name)
{
- return (void *) bt_field_type_common_structure_get_field_type_by_name(
- (void *) ft, name);
+ return bt_get(bt_field_type_common_structure_borrow_field_type_by_name(
+ (void *) ft, name));
}
struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
struct bt_ctf_field_type *ft)
{
- return (void *) bt_field_type_common_variant_get_tag_field_type(
- (void *) ft);
+ return bt_get(bt_field_type_common_variant_borrow_tag_field_type(
+ (void *) ft));
}
const char *bt_ctf_field_type_variant_get_tag_name(struct bt_ctf_field_type *ft)
struct bt_ctf_field_type *ft,
const char *field_name)
{
- return (void *) bt_field_type_common_variant_get_field_type_by_name(
- (void *) ft, field_name);
+ return bt_get(bt_field_type_common_variant_borrow_field_type_by_name(
+ (void *) ft, field_name));
}
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
struct bt_ctf_field_type *ft,
struct bt_ctf_field *tag_field)
{
- return (void *) bt_field_type_common_variant_get_field_type_from_tag(
+ return bt_get(bt_field_type_common_variant_borrow_field_type_from_tag(
(void *) ft, (void *) tag_field,
- (bt_field_common_create_func) bt_field_create);
+ (bt_field_common_create_func) bt_field_create));
}
int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *ft)
const char **field_name, struct bt_ctf_field_type **field_type,
uint64_t index)
{
- return bt_field_type_common_variant_get_field_by_index((void *) ft,
- field_name, (void *) field_type, index);
+ int ret = bt_field_type_common_variant_borrow_field_by_index(
+ (void *) ft, field_name, (void *) field_type, index);
+
+ if (ret == 0 && field_type) {
+ bt_get(*field_type);
+ }
+
+ return ret;
}
struct bt_ctf_field_type *bt_ctf_field_type_array_create(
struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return (void *) bt_field_type_common_array_get_element_field_type(
- (void *) ft);
+ return bt_get(bt_field_type_common_array_borrow_element_field_type(
+ (void *) ft));
}
int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *ft)
struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return (void *) bt_field_type_common_sequence_get_element_field_type(
- (void *) ft);
+ return bt_get(bt_field_type_common_sequence_borrow_element_field_type(
+ (void *) ft));
}
const char *bt_ctf_field_type_sequence_get_length_field_name(
pos->offset, member, i);
if (!member) {
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
field->type, &field_name, NULL, i);
BT_ASSERT(ret == 0);
BT_LOGW("Cannot serialize structure field's field: field is not set: "
ret = bt_ctf_field_serialize_recursive((void *) member, pos,
native_byte_order);
if (ret) {
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
field->type, &field_name, NULL, i);
BT_ASSERT(ret == 0);
BT_LOGW("Cannot serialize structure field's field: "
struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field)
{
- return (void *) bt_field_common_get_type((void *) field);
+ return bt_get(bt_field_common_borrow_type((void *) field));
}
enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field)
struct bt_ctf_field *bt_ctf_field_sequence_get_length(
struct bt_ctf_field *field)
{
- return (void *) bt_field_common_sequence_get_length((void *) field);
+ return bt_get(bt_field_common_sequence_borrow_length((void *) field));
}
int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field,
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
struct bt_ctf_field *field, uint64_t index)
{
- return (void *) bt_field_common_structure_get_field_by_index(
- (void *) field, index);
+ return bt_get(bt_field_common_structure_borrow_field_by_index(
+ (void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
struct bt_ctf_field *field, const char *name)
{
- return (void *) bt_field_common_structure_get_field_by_name(
- (void *) field, name);
+ return bt_get(bt_field_common_structure_borrow_field_by_name(
+ (void *) field, name));
}
int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field,
struct bt_ctf_field *bt_ctf_field_array_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return (void *) bt_field_common_array_get_field((void *) field, index,
- (bt_field_common_create_func) bt_ctf_field_create);
+ return bt_get(bt_field_common_array_borrow_field((void *) field, index,
+ (bt_field_common_create_func) bt_ctf_field_create));
}
struct bt_ctf_field *bt_ctf_field_sequence_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return (void *) bt_field_common_sequence_get_field((void *) field,
- index, (bt_field_common_create_func) bt_ctf_field_create);
+ return bt_get(bt_field_common_sequence_borrow_field((void *) field,
+ index, (bt_field_common_create_func) bt_ctf_field_create));
}
struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *field,
struct bt_ctf_field *tag_field)
{
- return (void *) bt_field_common_variant_get_field((void *) field,
+ return bt_get(bt_field_common_variant_borrow_field((void *) field,
(void *) tag_field,
- (bt_field_common_create_func) bt_ctf_field_create);
+ (bt_field_common_create_func) bt_ctf_field_create));
}
struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
struct bt_ctf_field *variant_field)
{
- return (void *) bt_field_common_variant_get_current_field(
- (void *) variant_field);
+ return bt_get(bt_field_common_variant_borrow_current_field(
+ (void *) variant_field));
}
struct bt_ctf_field *bt_ctf_field_variant_get_tag(
struct bt_ctf_field *variant_field)
{
- return (void *) bt_field_common_variant_get_tag((void *) variant_field);
+ return bt_get(bt_field_common_variant_borrow_tag(
+ (void *) variant_field));
}
struct bt_ctf_field *bt_ctf_field_enumeration_get_container(struct bt_ctf_field *field)
{
- return (void *) bt_field_common_enumeration_get_container(
- (void *) field, (bt_field_common_create_func) bt_ctf_field_create);
+ return bt_get(bt_field_common_enumeration_borrow_container(
+ (void *) field,
+ (bt_field_common_create_func) bt_ctf_field_create));
}
int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field, int64_t *value)
struct bt_ctf_trace *bt_ctf_stream_class_get_trace(
struct bt_ctf_stream_class *stream_class)
{
- return BT_FROM_COMMON(bt_stream_class_common_get_trace(
+ return bt_get(bt_stream_class_common_borrow_trace(
BT_TO_COMMON(stream_class)));
}
struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return BT_FROM_COMMON(
- bt_stream_class_common_get_packet_context_field_type(
+ return bt_get(
+ bt_stream_class_common_borrow_packet_context_field_type(
BT_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_header_type(
struct bt_ctf_stream_class *stream_class)
{
- return BT_FROM_COMMON(
- bt_stream_class_common_get_event_header_field_type(
+ return bt_get(
+ bt_stream_class_common_borrow_event_header_field_type(
BT_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return BT_FROM_COMMON(
- bt_stream_class_common_get_event_context_field_type(
+ return bt_get(
+ bt_stream_class_common_borrow_event_context_field_type(
BT_TO_COMMON(stream_class)));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
struct bt_ctf_stream_class *stream_class, uint64_t index)
{
- return BT_FROM_COMMON(
- bt_stream_class_common_get_event_class_by_index(
+ return bt_get(
+ bt_stream_class_common_borrow_event_class_by_index(
BT_TO_COMMON(stream_class), index));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
struct bt_ctf_stream_class *stream_class, uint64_t id)
{
- return BT_FROM_COMMON(
- bt_stream_class_common_get_event_class_by_id(
+ return bt_get(
+ bt_stream_class_common_borrow_event_class_by_id(
BT_TO_COMMON(stream_class), id));
}
struct bt_ctf_stream_class *bt_ctf_stream_get_class(
struct bt_ctf_stream *stream)
{
- return BT_FROM_COMMON(bt_stream_common_get_class(BT_TO_COMMON(stream)));
+ return bt_get(bt_stream_common_borrow_class(BT_TO_COMMON(stream)));
}
const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream)
struct bt_value *bt_ctf_trace_get_environment_field_value_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_trace_common_get_environment_field_value_by_index(
- BT_TO_COMMON(trace), index);
+ return bt_get(bt_trace_common_borrow_environment_field_value_by_index(
+ BT_TO_COMMON(trace), index));
}
struct bt_value *bt_ctf_trace_get_environment_field_value_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return bt_trace_common_get_environment_field_value_by_name(
- BT_TO_COMMON(trace), name);
+ return bt_get(bt_trace_common_borrow_environment_field_value_by_name(
+ BT_TO_COMMON(trace), name));
}
int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace,
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return (void *) bt_trace_common_get_clock_class_by_index(
- BT_TO_COMMON(trace), index);
+ return bt_get(bt_trace_common_borrow_clock_class_by_index(
+ BT_TO_COMMON(trace), index));
}
static
struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return BT_FROM_COMMON(bt_trace_common_get_stream_by_index(
+ return bt_get(bt_trace_common_borrow_stream_by_index(
BT_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return BT_FROM_COMMON(bt_trace_common_get_stream_class_by_index(
+ return bt_get(bt_trace_common_borrow_stream_class_by_index(
BT_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
struct bt_ctf_trace *trace, uint64_t id)
{
- return BT_FROM_COMMON(
- bt_trace_common_get_stream_class_by_id(
- BT_TO_COMMON(trace), id));
+ return bt_get(bt_trace_common_borrow_stream_class_by_id(
+ BT_TO_COMMON(trace), id));
}
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return BT_FROM_COMMON(
- bt_trace_common_get_clock_class_by_name(BT_TO_COMMON(trace),
+ return bt_get(
+ bt_trace_common_borrow_clock_class_by_name(BT_TO_COMMON(trace),
name));
}
entry_name = bt_attributes_get_field_name(
trace->common.environment, i);
- env_field_value_obj = bt_attributes_get_field_value(
+ env_field_value_obj = bt_attributes_borrow_field_value(
trace->common.environment, i);
BT_ASSERT(entry_name);
if (!escaped_str) {
BT_LOGE("Cannot escape string: string=\"%s\"",
str_value);
- goto loop_next;
+ continue;
}
g_string_append_printf(context->string,
break;
}
default:
- goto loop_next;
+ continue;
}
-
-loop_next:
- BT_PUT(env_field_value_obj);
}
g_string_append(context->string, "};\n\n");
struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
struct bt_ctf_trace *trace)
{
- return BT_FROM_COMMON(bt_trace_common_get_packet_header_field_type(
+ return bt_get(bt_trace_common_borrow_packet_header_field_type(
BT_TO_COMMON(trace)));
}
return (int64_t) cc_prio_map->entries->len;
}
-struct bt_clock_class *bt_clock_class_priority_map_get_clock_class_by_index(
+struct bt_clock_class *bt_clock_class_priority_map_borrow_clock_class_by_index(
struct bt_clock_class_priority_map *cc_prio_map,
uint64_t index)
{
BT_ASSERT_PRE(index < cc_prio_map->entries->len,
"Index is out of bounds: index=%" PRIu64 ", count=%" PRIu64,
index, cc_prio_map->entries->len);
- return bt_get(g_ptr_array_index(cc_prio_map->entries, index));
+ return g_ptr_array_index(cc_prio_map->entries, index);
}
-struct bt_clock_class *bt_clock_class_priority_map_get_clock_class_by_name(
+struct bt_clock_class *bt_clock_class_priority_map_borrow_clock_class_by_name(
struct bt_clock_class_priority_map *cc_prio_map,
const char *name)
{
BT_ASSERT(cur_cc_name);
if (strcmp(cur_cc_name, name) == 0) {
- clock_class = bt_get(cur_cc);
+ clock_class = cur_cc;
goto end;
}
}
}
struct bt_clock_class *
-bt_clock_class_priority_map_get_highest_priority_clock_class(
+bt_clock_class_priority_map_borrow_highest_priority_clock_class(
struct bt_clock_class_priority_map *cc_prio_map)
{
BT_ASSERT_PRE_NON_NULL(cc_prio_map, "Clock class priority map");
- return(bt_get(cc_prio_map->highest_prio_cc));
+ return cc_prio_map->highest_prio_cc;
}
int bt_clock_class_priority_map_get_clock_class_priority(
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
-struct bt_notification *bt_notification_iterator_get_notification(
+struct bt_notification *bt_notification_iterator_borrow_notification(
struct bt_notification_iterator *iterator)
{
BT_ASSERT_PRE_NON_NULL(iterator, "Notification iterator");
- return bt_get(
- bt_notification_iterator_borrow_current_notification(iterator));
+ return bt_notification_iterator_borrow_current_notification(iterator);
}
BT_ASSERT_PRE_FUNC
BT_HIDDEN
struct bt_clock_value *
-bt_notification_discarded_elements_get_begin_clock_value(
+bt_notification_discarded_elements_borrow_begin_clock_value(
enum bt_notification_type type,
struct bt_notification *notification)
{
BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- return bt_get(discarded_elems_notif->begin_clock_value);
+ return discarded_elems_notif->begin_clock_value;
}
BT_HIDDEN
struct bt_clock_value *
-bt_notification_discarded_elements_get_end_clock_value(
+bt_notification_discarded_elements_borrow_end_clock_value(
enum bt_notification_type type,
struct bt_notification *notification)
{
BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- return bt_get(discarded_elems_notif->end_clock_value);
+ return discarded_elems_notif->end_clock_value;
}
BT_HIDDEN
}
BT_HIDDEN
-struct bt_stream *bt_notification_discarded_elements_get_stream(
+struct bt_stream *bt_notification_discarded_elements_borrow_stream(
enum bt_notification_type type,
struct bt_notification *notification)
{
BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- return bt_get(discarded_elems_notif->stream);
+ return discarded_elems_notif->stream;
}
#include <stdint.h>
struct bt_clock_value *
-bt_notification_discarded_events_get_begin_clock_value(
+bt_notification_discarded_events_borrow_begin_clock_value(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_begin_clock_value(
+ return bt_notification_discarded_elements_borrow_begin_clock_value(
BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification);
}
struct bt_clock_value *
-bt_notification_discarded_events_get_end_clock_value(
+bt_notification_discarded_events_borrow_end_clock_value(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_end_clock_value(
+ return bt_notification_discarded_elements_borrow_end_clock_value(
BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification);
}
BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification);
}
-struct bt_stream *bt_notification_discarded_events_get_stream(
+struct bt_stream *bt_notification_discarded_events_borrow_stream(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_stream(
+ return bt_notification_discarded_elements_borrow_stream(
BT_NOTIFICATION_TYPE_DISCARDED_EVENTS, notification);
}
#include <stdint.h>
struct bt_clock_value *
-bt_notification_discarded_packets_get_begin_clock_value(
+bt_notification_discarded_packets_borrow_begin_clock_value(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_begin_clock_value(
+ return bt_notification_discarded_elements_borrow_begin_clock_value(
BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification);
}
struct bt_clock_value *
-bt_notification_discarded_packets_get_end_clock_value(
+bt_notification_discarded_packets_borrow_end_clock_value(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_end_clock_value(
+ return bt_notification_discarded_elements_borrow_end_clock_value(
BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification);
}
BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification);
}
-struct bt_stream *bt_notification_discarded_packets_get_stream(
+struct bt_stream *bt_notification_discarded_packets_borrow_stream(
struct bt_notification *notification)
{
- return bt_notification_discarded_elements_get_stream(
+ return bt_notification_discarded_elements_borrow_stream(
BT_NOTIFICATION_TYPE_DISCARDED_PACKETS, notification);
}
return ¬ification->parent;
}
-struct bt_event *bt_notification_event_get_event(
+struct bt_event *bt_notification_event_borrow_event(
struct bt_notification *notification)
{
struct bt_notification_event *event_notification;
BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, BT_NOTIFICATION_TYPE_EVENT);
event_notification = container_of(notification,
struct bt_notification_event, parent);
- return bt_get(event_notification->event);
+ return event_notification->event;
}
extern struct bt_clock_class_priority_map *
-bt_notification_event_get_clock_class_priority_map(
+bt_notification_event_borrow_clock_class_priority_map(
struct bt_notification *notification)
{
struct bt_notification_event *event_notification;
BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, BT_NOTIFICATION_TYPE_EVENT);
event_notification = container_of(notification,
struct bt_notification_event, parent);
- return bt_get(event_notification->cc_prio_map);
+ return event_notification->cc_prio_map;
}
}
extern struct bt_clock_class_priority_map *
-bt_notification_inactivity_get_clock_class_priority_map(
+bt_notification_inactivity_borrow_clock_class_priority_map(
struct bt_notification *notification)
{
struct bt_notification_inactivity *inactivity_notification;
BT_NOTIFICATION_TYPE_INACTIVITY);
inactivity_notification = container_of(notification,
struct bt_notification_inactivity, parent);
- return bt_get(inactivity_notification->cc_prio_map);
+ return inactivity_notification->cc_prio_map;
}
-struct bt_clock_value *bt_notification_inactivity_get_clock_value(
+struct bt_clock_value *bt_notification_inactivity_borrow_clock_value(
struct bt_notification *notification,
struct bt_clock_class *clock_class)
{
BT_NOTIFICATION_TYPE_INACTIVITY);
inactivity_notification = container_of(notification,
struct bt_notification_inactivity, parent);
- return bt_get(g_hash_table_lookup(
- inactivity_notification->clock_values, clock_class));
+ return g_hash_table_lookup(
+ inactivity_notification->clock_values, clock_class);
}
BT_ASSERT_PRE_FUNC
return NULL;
}
-struct bt_packet *bt_notification_packet_begin_get_packet(
+struct bt_packet *bt_notification_packet_begin_borrow_packet(
struct bt_notification *notification)
{
struct bt_notification_packet_begin *packet_begin;
BT_NOTIFICATION_TYPE_PACKET_BEGIN);
packet_begin = container_of(notification,
struct bt_notification_packet_begin, parent);
- return bt_get(packet_begin->packet);
+ return packet_begin->packet;
}
struct bt_notification *bt_notification_packet_end_create(
return NULL;
}
-struct bt_packet *bt_notification_packet_end_get_packet(
+struct bt_packet *bt_notification_packet_end_borrow_packet(
struct bt_notification *notification)
{
struct bt_notification_packet_end *packet_end;
BT_NOTIFICATION_TYPE_PACKET_END);
packet_end = container_of(notification,
struct bt_notification_packet_end, parent);
- return bt_get(packet_end->packet);
+ return packet_end->packet;
}
return NULL;
}
-struct bt_stream *bt_notification_stream_end_get_stream(
+struct bt_stream *bt_notification_stream_end_borrow_stream(
struct bt_notification *notification)
{
struct bt_notification_stream_end *stream_end;
BT_NOTIFICATION_TYPE_STREAM_END);
stream_end = container_of(notification,
struct bt_notification_stream_end, parent);
- return bt_get(stream_end->stream);
+ return stream_end->stream;
}
static
return NULL;
}
-struct bt_stream *bt_notification_stream_begin_get_stream(
+struct bt_stream *bt_notification_stream_begin_borrow_stream(
struct bt_notification *notification)
{
struct bt_notification_stream_begin *stream_begin;
BT_NOTIFICATION_TYPE_STREAM_BEGIN);
stream_begin = container_of(notification,
struct bt_notification_stream_begin, parent);
- return bt_get(stream_begin->stream);
+ return stream_begin->stream;
}
for (i = 0; i < typed_array_obj->garray->len; ++i) {
struct bt_value *element_obj_copy;
- struct bt_value *element_obj = bt_value_array_get(array_obj, i);
+ struct bt_value *element_obj = bt_value_array_borrow(
+ array_obj, i);
BT_ASSERT(element_obj);
BT_LOGD("Copying array value's element: element-addr=%p, "
"index=%d", element_obj, i);
element_obj_copy = bt_value_copy(element_obj);
- BT_PUT(element_obj);
if (!element_obj_copy) {
BT_LOGE("Cannot copy array value's element: "
"array-addr=%p, index=%d",
struct bt_value *element_obj_a;
struct bt_value *element_obj_b;
- element_obj_a = bt_value_array_get(object_a, i);
- element_obj_b = bt_value_array_get(object_b, i);
+ element_obj_a = bt_value_array_borrow(object_a, i);
+ element_obj_b = bt_value_array_borrow(object_b, i);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
BT_LOGV("Array values's elements are different: "
"value-a-addr=%p, value-b-addr=%p, index=%d",
element_obj_a, element_obj_b, i);
- BT_PUT(element_obj_a);
- BT_PUT(element_obj_b);
ret = BT_FALSE;
goto end;
}
-
- BT_PUT(element_obj_a);
- BT_PUT(element_obj_b);
}
end:
struct bt_value *element_obj_b;
const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
- element_obj_b = bt_value_map_get(object_b, key_str);
+ element_obj_b = bt_value_map_borrow(object_b, key_str);
if (!bt_value_compare(element_obj_a, element_obj_b)) {
BT_LOGV("Map values's elements are different: "
"value-a-addr=%p, value-b-addr=%p, key=\"%s\"",
element_obj_a, element_obj_b, key_str);
- BT_PUT(element_obj_b);
ret = BT_FALSE;
goto end;
}
-
- BT_PUT(element_obj_b);
}
end:
return bt_value_array_size(array_obj) == 0;
}
-struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
+struct bt_value *bt_value_array_borrow(const struct bt_value *array_obj,
uint64_t index)
{
struct bt_value_array *typed_array_obj =
BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
typed_array_obj->garray->len);
- return bt_get(g_ptr_array_index(typed_array_obj->garray, index));
+ return g_ptr_array_index(typed_array_obj->garray, index);
}
enum bt_value_status bt_value_array_append(struct bt_value *array_obj,
return bt_value_map_size(map_obj) == 0;
}
-struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
+struct bt_value *bt_value_map_borrow(const struct bt_value *map_obj,
const char *key)
{
BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
BT_ASSERT_PRE_NON_NULL(key, "Key");
BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
- return bt_get(g_hash_table_lookup(BT_VALUE_TO_MAP(map_obj)->ght,
- GUINT_TO_POINTER(g_quark_from_string(key))));
+ return g_hash_table_lookup(BT_VALUE_TO_MAP(map_obj)->ght,
+ GUINT_TO_POINTER(g_quark_from_string(key)));
}
bt_bool bt_value_map_has_key(const struct bt_value *map_obj, const char *key)