#include <babeltrace/object-pool-internal.h>
#include <glib.h>
-struct bt_event_class_common {
+struct bt_event_class {
struct bt_object base;
- struct bt_field_type_common *context_field_type;
- struct bt_field_type_common *payload_field_type;
+ struct bt_field_type *context_field_type;
+ struct bt_field_type *payload_field_type;
int frozen;
/*
int64_t id;
int log_level;
GString *emf_uri;
-};
-
-struct bt_event_class {
- struct bt_event_class_common common;
/* Pool of `struct bt_event *` */
struct bt_object_pool event_pool;
BT_HIDDEN
void bt_event_class_freeze(struct bt_event_class *event_class);
-BT_HIDDEN
-void bt_event_class_common_freeze(struct bt_event_class_common *event_class);
-
-BT_HIDDEN
-void bt_event_class_common_set_native_byte_order(
- struct bt_event_class_common *event_class, int byte_order);
-
-static inline
-struct bt_stream_class_common *bt_event_class_common_borrow_stream_class(
- struct bt_event_class_common *event_class)
-{
- BT_ASSERT(event_class);
- return (void *) bt_object_borrow_parent(&event_class->base);
-}
-
-typedef struct bt_field_type_common *(*bt_field_type_structure_create_func)();
-
-BT_HIDDEN
-int bt_event_class_common_initialize(struct bt_event_class_common *event_class,
- const char *name, bt_object_release_func release_func,
- bt_field_type_structure_create_func ft_struct_create_func);
+typedef struct bt_field_type *(*bt_field_type_structure_create_func)();
BT_HIDDEN
-void bt_event_class_common_finalize(struct bt_object *obj);
-
-BT_HIDDEN
-int bt_event_class_common_validate_single_clock_class(
- struct bt_event_class_common *event_class,
+int bt_event_class_validate_single_clock_class(
+ struct bt_event_class *event_class,
struct bt_clock_class **expected_clock_class);
-static inline
-const char *bt_event_class_common_get_name(
- struct bt_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- BT_ASSERT(event_class->name);
- return event_class->name->str;
-}
-
-static inline
-int64_t bt_event_class_common_get_id(
- struct bt_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->id;
-}
-
-static inline
-int bt_event_class_common_set_id(
- struct bt_event_class_common *event_class, uint64_t id_param)
-{
- int ret = 0;
- int64_t id = (int64_t) id_param;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class,
- bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (id < 0) {
- BT_LOGW("Invalid parameter: invalid event class's ID: "
- "addr=%p, name=\"%s\", id=%" PRIu64,
- event_class,
- bt_event_class_common_get_name(event_class),
- id_param);
- ret = -1;
- goto end;
- }
-
- event_class->id = id;
- BT_LOGV("Set event class's ID: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class), id);
-
-end:
- return ret;
-}
-
-static inline
-int bt_event_class_common_get_log_level(
- struct bt_event_class_common *event_class)
-{
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return event_class->log_level;
-}
-
-static inline
-int bt_event_class_common_set_log_level(
- struct bt_event_class_common *event_class, int log_level)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class,
- bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- switch (log_level) {
- case BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
- case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
- case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
- case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
- case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
- case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
- case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
- case BT_EVENT_CLASS_LOG_LEVEL_INFO:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
- case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
- break;
- default:
- BT_LOGW("Invalid parameter: unknown event class log level: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class), log_level);
- ret = -1;
- goto end;
- }
-
- event_class->log_level = log_level;
- BT_LOGV("Set event class's log level: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class),
- bt_common_event_class_log_level_string(log_level));
-
-end:
- return ret;
-}
-
-static inline
-const char *bt_event_class_common_get_emf_uri(
- struct bt_event_class_common *event_class)
-{
- const char *emf_uri = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
- if (event_class->emf_uri->len > 0) {
- emf_uri = event_class->emf_uri->str;
- }
-
- return emf_uri;
-}
-
-static inline
-int bt_event_class_common_set_emf_uri(
- struct bt_event_class_common *event_class,
- const char *emf_uri)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (emf_uri && strlen(emf_uri) == 0) {
- BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (emf_uri) {
- g_string_assign(event_class->emf_uri, emf_uri);
- BT_LOGV("Set event class's EMF URI: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class), emf_uri);
- } else {
- g_string_assign(event_class->emf_uri, "");
- BT_LOGV("Reset event class's EMF URI: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- }
-
-end:
- return ret;
-}
-
-static inline
-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;
-
- BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
- if (!event_class->context_field_type) {
- BT_LOGV("Event class has no context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- goto end;
- }
-
- context_ft = event_class->context_field_type;
-
-end:
- return context_ft;
-}
-
-static inline
-int bt_event_class_common_set_context_field_type(
- struct bt_event_class_common *event_class,
- struct bt_field_type_common *context_ft)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (event_class->frozen) {
- BT_LOGW("Invalid parameter: event class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
- ret = -1;
- goto end;
- }
-
- if (context_ft && bt_field_type_common_get_type_id(context_ft) !=
- BT_FIELD_TYPE_ID_STRUCT) {
- BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "context-ft-id=%s",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class),
- bt_common_field_type_id_string(
- bt_field_type_common_get_type_id(context_ft)));
- ret = -1;
- goto end;
- }
-
- bt_put(event_class->context_field_type);
- event_class->context_field_type = bt_get(context_ft);
- BT_LOGV("Set event class's context field type: "
- "event-class-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", context-ft-addr=%p",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class), context_ft);
-
-end:
- return ret;
-}
-
-static inline
-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 event_class->payload_field_type;
-}
-
-static inline
-int bt_event_class_common_set_payload_field_type(
- struct bt_event_class_common *event_class,
- struct bt_field_type_common *payload_ft)
-{
- int ret = 0;
-
- if (!event_class) {
- BT_LOGW_STR("Invalid parameter: event class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (payload_ft && bt_field_type_common_get_type_id(payload_ft) !=
- BT_FIELD_TYPE_ID_STRUCT) {
- BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "payload-ft-addr=%p, payload-ft-id=%s",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class), payload_ft,
- bt_common_field_type_id_string(
- bt_field_type_common_get_type_id(payload_ft)));
- ret = -1;
- goto end;
- }
-
- bt_put(event_class->payload_field_type);
- event_class->payload_field_type = bt_get(payload_ft);
- BT_LOGV("Set event class's payload field type: "
- "event-class-addr=%p, event-class-name=\"%s\", "
- "event-class-id=%" PRId64 ", payload-ft-addr=%p",
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class), payload_ft);
-end:
- return ret;
-}
-
#endif /* BABELTRACE_CTF_IR_EVENT_CLASS_INTERNAL_H */
struct bt_stream_pos;
-struct bt_event_common {
+struct bt_event {
struct bt_object base;
- struct bt_event_class_common *class;
+ struct bt_event_class *class;
struct bt_field_wrapper *header_field;
- struct bt_field_common *stream_event_context_field;
- struct bt_field_common *context_field;
- struct bt_field_common *payload_field;
- int frozen;
-};
-
-struct bt_event {
- struct bt_event_common common;
+ struct bt_field *stream_event_context_field;
+ struct bt_field *context_field;
+ struct bt_field *payload_field;
struct bt_clock_value_set cv_set;
struct bt_packet *packet;
+ int frozen;
};
BT_HIDDEN
-int _bt_event_common_validate(struct bt_event_common *event);
+void bt_event_destroy(struct bt_event *event);
BT_HIDDEN
-void _bt_event_common_set_is_frozen(struct bt_event_common *event,
- bool is_frozen);
+struct bt_event *bt_event_new(struct bt_event_class *event_class);
BT_HIDDEN
void _bt_event_set_is_frozen(struct bt_event *event, bool is_frozen);
#ifdef BT_DEV_MODE
-# define bt_event_common_validate _bt_event_common_validate
-# define bt_event_common_set_is_frozen _bt_event_common_set_is_frozen
# define bt_event_set_is_frozen _bt_event_set_is_frozen
#else
-# define bt_event_common_validate(_event) 0
-# define bt_event_common_set_is_frozen(_event, _is_frozen)
# define bt_event_set_is_frozen(_event, _is_frozen)
#endif
-#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name) \
- BT_ASSERT_PRE_HOT((_event), (_name), ": %!+_e", (_event))
-
-static inline
-struct bt_event_class_common *bt_event_common_borrow_class(
- struct bt_event_common *event)
-{
- BT_ASSERT(event);
- return event->class;
-}
+#define BT_ASSERT_PRE_EVENT_HOT(_event, _name) \
+ BT_ASSERT_PRE_HOT((_event), (_name), ": %!+e", (_event))
typedef void *(*create_field_func)(void *);
typedef void (*release_field_func)(void *);
typedef void *(*create_header_field_func)(void *, void *);
typedef void (*release_header_field_func)(void *, void *);
-BT_HIDDEN
-int bt_event_common_initialize(struct bt_event_common *event,
- struct bt_event_class_common *event_class,
- struct bt_clock_class *init_expected_clock_class,
- bool is_shared_with_parent, bt_object_release_func release_func,
- bt_validation_flag_copy_field_type_func field_type_copy_func,
- bool must_be_in_trace,
- int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_field_type,
- struct bt_field_type_common *event_header_field_type),
- create_field_func create_field_func,
- release_field_func release_field_func,
- create_header_field_func create_header_field_func,
- release_header_field_func release_header_field_func);
-
-static inline
-struct bt_field_common *bt_event_common_borrow_payload(
- struct bt_event_common *event)
-{
- struct bt_field_common *payload = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->payload_field) {
- BT_LOGV("Event has no current payload field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
- goto end;
- }
-
- payload = event->payload_field;
-
-end:
- return payload;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_header(
- struct bt_event_common *event)
-{
- struct bt_field_common *header = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->header_field) {
- BT_LOGV("Event has no current header field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
- goto end;
- }
-
- header = event->header_field->field;
-
-end:
- return header;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_context(
- struct bt_event_common *event)
-{
- struct bt_field_common *context = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->context_field) {
- BT_LOGV("Event has no current context field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
- goto end;
- }
-
- context = event->context_field;
-
-end:
- return context;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_stream_event_context(
- struct bt_event_common *event)
-{
- struct bt_field_common *stream_event_context = NULL;
-
- BT_ASSERT_PRE_NON_NULL(event, "Event");
-
- if (!event->stream_event_context_field) {
- BT_LOGV("Event has no current stream event context field: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
- goto end;
- }
-
- stream_event_context = event->stream_event_context_field;
-
-end:
- return stream_event_context;
-}
-
+BT_UNUSED
static inline
-void bt_event_common_finalize(struct bt_object *obj,
- void (*field_release_func)(void *),
- void (*header_field_release_func)(void *, struct bt_event_common *))
+void _bt_event_reset_dev_mode(struct bt_event *event)
{
- struct bt_event_common *event = (void *) obj;
-
- BT_LOGD("Destroying event: addr=%p, "
- "event-class-name=\"%s\", event-class-id=%" PRId64,
- event,
- event->class ? bt_event_class_common_get_name(event->class) : NULL,
- event->class ? bt_event_class_common_get_id(event->class) : INT64_C(-1));
+ BT_ASSERT(event);
if (event->header_field) {
- BT_LOGD_STR("Releasing event's header field.");
- header_field_release_func(event->header_field, event);
+ bt_field_set_is_frozen_recursive(
+ event->header_field->field, false);
+ bt_field_reset_recursive(
+ event->header_field->field);
}
if (event->stream_event_context_field) {
- BT_LOGD_STR("Releasing event's stream event context field.");
- field_release_func(event->stream_event_context_field);
+ bt_field_set_is_frozen_recursive(
+ event->stream_event_context_field, false);
+ bt_field_reset_recursive(
+ event->stream_event_context_field);
}
if (event->context_field) {
- BT_LOGD_STR("Releasing event's context field.");
- field_release_func(event->context_field);
+ bt_field_set_is_frozen_recursive(
+ event->context_field, false);
+ bt_field_reset_recursive(event->context_field);
}
if (event->payload_field) {
- BT_LOGD_STR("Releasing event's payload field.");
- field_release_func(event->payload_field);
- }
-
- /*
- * Leave this after calling header_field_release_func() because
- * this function receives the event object and could need its
- * class to perform some cleanup.
- */
- if (!event->base.parent) {
- /*
- * Event was keeping a reference to its class since it shared no
- * common ancestor with it to guarantee they would both have the
- * same lifetime.
- */
- bt_put(event->class);
- }
-}
-
-BT_UNUSED
-static inline
-void _bt_event_reset_dev_mode(struct bt_event *event)
-{
- BT_ASSERT(event);
-
- if (event->common.header_field) {
- bt_field_common_set_is_frozen_recursive(
- event->common.header_field->field, false);
- bt_field_common_reset_recursive(
- event->common.header_field->field);
- }
-
- if (event->common.stream_event_context_field) {
- bt_field_common_set_is_frozen_recursive(
- event->common.stream_event_context_field, false);
- bt_field_common_reset_recursive(
- event->common.stream_event_context_field);
- }
-
- if (event->common.context_field) {
- bt_field_common_set_is_frozen_recursive(
- event->common.context_field, false);
- bt_field_common_reset_recursive(event->common.context_field);
- }
-
- if (event->common.payload_field) {
- bt_field_common_set_is_frozen_recursive(
- event->common.payload_field, false);
- bt_field_common_reset_recursive(event->common.payload_field);
+ bt_field_set_is_frozen_recursive(
+ event->payload_field, false);
+ bt_field_reset_recursive(event->payload_field);
}
}
# define bt_event_reset_dev_mode(_x)
#endif
-BT_HIDDEN
-void bt_event_destroy(struct bt_event *event);
-
static inline
void bt_event_reset(struct bt_event *event)
{
* 4. Put our event class reference.
*/
bt_event_reset(event);
- event_class = BT_FROM_COMMON(event->common.class);
+ event_class = event->class;
BT_ASSERT(event_class);
- event->common.class = NULL;
+ event->class = NULL;
bt_object_pool_recycle_object(&event_class->event_pool, event);
- bt_object_put_no_null_check(&event_class->common.base);
+ bt_object_put_no_null_check(&event_class->base);
}
static inline
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
- BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_TO_COMMON(event), "Event");
+ BT_ASSERT_PRE_EVENT_HOT(event, "Event");
BT_ASSERT_PRE(bt_event_class_borrow_stream_class(
- BT_FROM_COMMON(event->common.class)) ==
- BT_FROM_COMMON(packet->stream->common.stream_class),
+ event->class) == packet->stream->stream_class,
"Packet's stream class and event's stream class differ: "
"%![event-]+e, %![packet-]+a",
event, packet);
BT_LOGV("Set event's packet: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"packet-addr=%p",
- event, bt_event_class_common_get_name(event->common.class),
- bt_event_class_common_get_id(event->common.class), packet);
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class), packet);
}
static inline
goto end;
}
- if (unlikely(!event->common.class)) {
- event->common.class = BT_TO_COMMON(event_class);
- bt_object_get_no_null_check(&event_class->common.base);
+ if (unlikely(!event->class)) {
+ event->class = event_class;
+ bt_object_get_no_null_check(&event_class->base);
}
BT_ASSERT(packet);
return event;
}
-BT_HIDDEN
-struct bt_event *bt_event_new(struct bt_event_class *event_class);
-
#endif /* BABELTRACE_CTF_IR_EVENT_INTERNAL_H */
#include <stdint.h>
#include <glib.h>
-#define BT_ASSERT_PRE_FT_COMMON_HAS_ID(_ft, _type_id, _name) \
- BT_ASSERT_PRE(((struct bt_field_type_common *) (_ft))->id == (_type_id), \
+#define BT_ASSERT_PRE_FT_HAS_ID(_ft, _type_id, _name) \
+ BT_ASSERT_PRE(((struct bt_field_type *) (_ft))->id == (_type_id), \
_name " has the wrong type ID: expected-type-id=%s, " \
- "%![ft-]+_F", bt_common_field_type_id_string(_type_id), (_ft))
+ "%![ft-]+F", bt_common_field_type_id_string(_type_id), (_ft))
#define BT_ASSERT_PRE_FT_HOT(_ft, _name) \
- BT_ASSERT_PRE_HOT((_ft), (_name), ": %!+_F", (_ft))
+ BT_ASSERT_PRE_HOT((_ft), (_name), ": %!+F", (_ft))
-#define BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_field_type_common_structure *) (_ft))->fields, \
- struct bt_field_type_common_structure_field, (_index)))
+#define BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \
+ (&g_array_index(((struct bt_field_type_structure *) (_ft))->fields, \
+ struct bt_field_type_structure_field, (_index)))
-#define BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index) \
- (&g_array_index(((struct bt_field_type_common_variant *) (_ft))->choices, \
- struct bt_field_type_common_variant_choice, (_index)))
+#define BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(_ft, _index) \
+ (&g_array_index(((struct bt_field_type_variant *) (_ft))->choices, \
+ struct bt_field_type_variant_choice, (_index)))
-struct bt_field_common;
-struct bt_field_type_common;
+struct bt_field;
struct bt_field_type;
-typedef void (*bt_field_type_common_method_freeze)(
- struct bt_field_type_common *);
-typedef int (*bt_field_type_common_method_validate)(
- struct bt_field_type_common *);
-typedef void (*bt_field_type_common_method_set_byte_order)(
- struct bt_field_type_common *, enum bt_byte_order);
-typedef struct bt_field_type_common *(*bt_field_type_common_method_copy)(
- struct bt_field_type_common *);
-typedef int (*bt_field_type_common_method_compare)(
- struct bt_field_type_common *,
- struct bt_field_type_common *);
-
-struct bt_field_type_common_methods {
- bt_field_type_common_method_freeze freeze;
- bt_field_type_common_method_validate validate;
- bt_field_type_common_method_set_byte_order set_byte_order;
- bt_field_type_common_method_copy copy;
- bt_field_type_common_method_compare compare;
+typedef void (*bt_field_type_method_freeze)(
+ struct bt_field_type *);
+typedef int (*bt_field_type_method_validate)(
+ struct bt_field_type *);
+typedef void (*bt_field_type_method_set_byte_order)(
+ struct bt_field_type *, enum bt_byte_order);
+typedef struct bt_field_type *(*bt_field_type_method_copy)(
+ struct bt_field_type *);
+typedef int (*bt_field_type_method_compare)(
+ struct bt_field_type *,
+ struct bt_field_type *);
+
+struct bt_field_type_methods {
+ bt_field_type_method_freeze freeze;
+ bt_field_type_method_validate validate;
+ bt_field_type_method_set_byte_order set_byte_order;
+ bt_field_type_method_copy copy;
+ bt_field_type_method_compare compare;
};
-struct bt_field_type_common {
+struct bt_field_type {
struct bt_object base;
enum bt_field_type_id id;
unsigned int alignment;
/* Virtual table */
- struct bt_field_type_common_methods *methods;
+ struct bt_field_type_methods *methods;
/*
* A type can't be modified once it is added to an event or after a
* a valid field type are also valid (and thus frozen).
*/
int valid;
-
- /*
- * Specialized data for either CTF IR or CTF writer APIs.
- * Having this here ensures that:
- *
- * * The type-specific common data is always found at the same
- * offset when the common API has a `struct
- * bt_field_type_common *` so that you can cast it to `struct
- * bt_field_type_common_integer *` for example and access the
- * common integer field type fields.
- *
- * * The specific CTF IR and CTF writer APIs can access their
- * specific field type fields in this union at an offset known
- * at build time. This avoids a pointer to specific data so
- * that all the fields, common or specific, of a CTF IR
- * integer field type or of a CTF writer integer field type,
- * for example, are contained within the same contiguous block
- * of memory.
- */
- union {
- struct {
- } ir;
- struct {
- void *serialize_func;
- } writer;
- } spec;
};
-struct bt_field_type_common_integer {
- struct bt_field_type_common common;
+struct bt_field_type_integer {
+ struct bt_field_type common;
/* Owned by this */
struct bt_clock_class *mapped_clock_class;
GQuark string;
};
-struct bt_field_type_common_enumeration {
- struct bt_field_type_common common;
+struct bt_field_type_enumeration {
+ struct bt_field_type common;
/* Owned by this */
- struct bt_field_type_common_integer *container_ft;
+ struct bt_field_type_integer *container_ft;
/* Array of `struct enumeration_mapping *`, owned by this */
GPtrArray *entries;
struct bt_object base;
/* Owned by this */
- struct bt_field_type_common_enumeration *enumeration_ft;
+ struct bt_field_type_enumeration *enumeration_ft;
enum bt_field_type_enumeration_mapping_iterator_type type;
int index;
} u;
};
-struct bt_field_type_common_floating_point {
- struct bt_field_type_common common;
+struct bt_field_type_floating_point {
+ struct bt_field_type common;
enum bt_byte_order user_byte_order;
unsigned int exp_dig;
unsigned int mant_dig;
};
-struct bt_field_type_common_structure_field {
+struct bt_field_type_structure_field {
GQuark name;
/* Owned by this */
- struct bt_field_type_common *type;
+ struct bt_field_type *type;
};
-struct bt_field_type_common_structure {
- struct bt_field_type_common common;
+struct bt_field_type_structure {
+ struct bt_field_type common;
GHashTable *field_name_to_index;
/*
- * Array of `struct bt_field_type_common_structure_field`,
+ * Array of `struct bt_field_type_structure_field`,
* owned by this
*/
GArray *fields;
};
-struct bt_field_type_common_variant_choice_range {
+struct bt_field_type_variant_choice_range {
union {
int64_t i;
uint64_t u;
} upper;
};
-struct bt_field_type_common_variant_choice {
+struct bt_field_type_variant_choice {
GQuark name;
/* Owned by this */
- struct bt_field_type_common *type;
+ struct bt_field_type *type;
- /* Array of `struct bt_field_type_common_variant_choice_range` */
+ /* Array of `struct bt_field_type_variant_choice_range` */
GArray *ranges;
};
-struct bt_field_type_common_variant {
- struct bt_field_type_common common;
+struct bt_field_type_variant {
+ struct bt_field_type common;
GString *tag_name;
bool choices_up_to_date;
/* Owned by this */
- struct bt_field_type_common_enumeration *tag_ft;
+ struct bt_field_type_enumeration *tag_ft;
/* Owned by this */
struct bt_field_path *tag_field_path;
GHashTable *choice_name_to_index;
/*
- * Array of `struct bt_field_type_common_variant_choice`,
+ * Array of `struct bt_field_type_variant_choice`,
* owned by this */
GArray *choices;
};
-struct bt_field_type_common_array {
- struct bt_field_type_common common;
+struct bt_field_type_array {
+ struct bt_field_type common;
/* Owned by this */
- struct bt_field_type_common *element_ft;
+ struct bt_field_type *element_ft;
unsigned int length;
};
-struct bt_field_type_common_sequence {
- struct bt_field_type_common common;
+struct bt_field_type_sequence {
+ struct bt_field_type common;
/* Owned by this */
- struct bt_field_type_common *element_ft;
+ struct bt_field_type *element_ft;
GString *length_field_name;
struct bt_field_path *length_field_path;
};
-struct bt_field_type_common_string {
- struct bt_field_type_common common;
+struct bt_field_type_string {
+ struct bt_field_type common;
enum bt_string_encoding encoding;
};
-typedef struct bt_field_common *(* bt_field_common_create_func)(
- struct bt_field_type_common *);
-
-BT_HIDDEN
-void bt_field_type_common_initialize(struct bt_field_type_common *ft,
- bool init_bo, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_integer_initialize(
- struct bt_field_type_common *ft,
- unsigned int size, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_floating_point_initialize(
- struct bt_field_type_common *ft,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *container_ft,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_string_initialize(
- struct bt_field_type_common *ft,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_structure_initialize(
- struct bt_field_type_common *ft,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_array_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft,
- unsigned int length, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft,
- const char *length_field_name,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_variant_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *tag_ft,
- const char *tag_name,
- bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_integer_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_floating_point_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_string_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_array_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-int bt_field_type_common_integer_validate(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_validate_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_validate_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_array_validate_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_structure_validate_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_variant_validate_recursive(
- struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_validate(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_get_size(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-bt_bool bt_field_type_common_integer_is_signed(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_is_signed(struct bt_field_type_common *ft,
- bt_bool is_signed);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_size(struct bt_field_type_common *ft,
- unsigned int size);
-
-BT_HIDDEN
-enum bt_integer_base bt_field_type_common_integer_get_base(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_base(struct bt_field_type_common *ft,
- enum bt_integer_base base);
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_integer_get_encoding(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_encoding(struct bt_field_type_common *ft,
- enum bt_string_encoding encoding);
-
-BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
- struct bt_field_type_common *ft,
- struct bt_clock_class *clock_class);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class(
- struct bt_field_type_common *ft,
- struct bt_clock_class *clock_class);
-
-BT_HIDDEN
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_find_mappings_by_name(
- struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_signed_find_mappings_by_value(
- struct bt_field_type_common *ft, int64_t value);
-
-BT_HIDDEN
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
- struct bt_field_type_common *ft, uint64_t value);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_get_mapping_by_index(
- struct bt_field_type_common *ft, uint64_t index,
- const char **mapping_name, int64_t *range_begin,
- int64_t *range_end);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
- struct bt_field_type_common *ft, uint64_t index,
- const char **mapping_name, uint64_t *range_begin,
- uint64_t *range_end);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_enumeration_borrow_container_field_type(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_add_mapping(
- struct bt_field_type_common *ft, const char *string,
- int64_t range_start, int64_t range_end);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_add_mapping(
- struct bt_field_type_common *ft, const char *string,
- uint64_t range_start, uint64_t range_end);
-
-BT_HIDDEN
-int64_t bt_field_type_common_enumeration_get_mapping_count(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_exponent_digits(
- struct bt_field_type_common *ft);
+typedef struct bt_field *(* bt_field_create_func)(
+ struct bt_field_type *);
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_exponent_digits(
- struct bt_field_type_common *ft,
- unsigned int exponent_digits);
+BT_ASSERT_FUNC
+static inline bool bt_field_type_has_known_id(
+ struct bt_field_type *ft)
+{
+ return (int) ft->id > BT_FIELD_TYPE_ID_UNKNOWN ||
+ (int) ft->id < BT_FIELD_TYPE_ID_NR;
+}
BT_HIDDEN
-int bt_field_type_common_floating_point_get_mantissa_digits(
- struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_mantissa_digits(
- struct bt_field_type_common *ft, unsigned int mantissa_digits);
-
-BT_HIDDEN
-int bt_field_type_common_structure_replace_field(
- struct bt_field_type_common *ft,
- const char *field_name,
- struct bt_field_type_common *field_type);
-
-BT_HIDDEN
-int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft,
- struct bt_field_type_common *field_type,
- const char *field_name);
-
-BT_HIDDEN
-int64_t bt_field_type_common_structure_get_field_count(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-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_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_borrow_tag_field_type(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-const char *bt_field_type_common_variant_get_tag_name(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_variant_set_tag_name(
- struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft,
- struct bt_field_type_common *field_type,
- const char *field_name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_update_choices(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-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
-int64_t bt_field_type_common_variant_get_field_count(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-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_borrow_element_field_type(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_array_set_element_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_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_borrow_element_field_type(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_set_element_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft);
-
-BT_HIDDEN
-const char *bt_field_type_common_sequence_get_length_field_name(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_string_get_encoding(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_string_set_encoding(struct bt_field_type_common *ft,
- enum bt_string_encoding encoding);
-
-BT_HIDDEN
-int bt_field_type_common_get_alignment(struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_set_alignment(struct bt_field_type_common *ft,
- unsigned int alignment);
-
-BT_HIDDEN
-enum bt_byte_order bt_field_type_common_get_byte_order(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_set_byte_order(struct bt_field_type_common *ft,
- enum bt_byte_order byte_order);
-
-BT_HIDDEN
-enum bt_field_type_id bt_field_type_common_get_type_id(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_freeze(struct bt_field_type_common *ft);
+int bt_field_type_variant_update_choices(
+ struct bt_field_type *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_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_borrow_field_type_unsigned(
- struct bt_field_type_common_variant *var_ft,
- uint64_t tag_value);
+int bt_field_type_validate(struct bt_field_type *ft);
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_copy(
- struct bt_field_type_common *ft);
+int bt_field_type_sequence_set_length_field_path(
+ struct bt_field_type *ft, struct bt_field_path *path);
BT_HIDDEN
-int bt_field_type_common_structure_get_field_name_index(
- struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_get_field_name_index(
- struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_set_length_field_path(
- struct bt_field_type_common *ft, struct bt_field_path *path);
-
-BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_path(
- struct bt_field_type_common *ft,
+int bt_field_type_variant_set_tag_field_path(
+ struct bt_field_type *ft,
struct bt_field_path *path);
BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *tag_ft);
-
-BT_HIDDEN
-void bt_field_type_common_generic_freeze(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_freeze_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_structure_freeze_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_variant_freeze_recursive(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_array_freeze_recursive(
- struct bt_field_type_common *ft);
+int bt_field_type_variant_set_tag_field_type(
+ struct bt_field_type *ft,
+ struct bt_field_type *tag_ft);
BT_HIDDEN
-void bt_field_type_common_sequence_freeze_recursive(
- struct bt_field_type_common *type);
+int64_t bt_field_type_get_field_count(struct bt_field_type *ft);
BT_HIDDEN
-void bt_field_type_common_integer_set_byte_order(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order);
+struct bt_field_type *bt_field_type_borrow_field_at_index(
+ struct bt_field_type *ft, int index);
BT_HIDDEN
-void bt_field_type_common_enumeration_set_byte_order_recursive(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_floating_point_set_byte_order(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_structure_set_byte_order_recursive(
- struct bt_field_type_common *ft,
- enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_variant_set_byte_order_recursive(
- struct bt_field_type_common *ft,
- enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_array_set_byte_order_recursive(
- struct bt_field_type_common *ft,
- enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_set_byte_order_recursive(
- struct bt_field_type_common *ft,
- enum bt_byte_order byte_order);
-
-BT_HIDDEN
-int bt_field_type_common_integer_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_compare(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_string_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_structure_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_variant_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_array_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-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_borrow_field_at_index(
- struct bt_field_type_common *ft, int index);
-
-BT_HIDDEN
-int bt_field_type_common_get_field_index(struct bt_field_type_common *ft,
+int bt_field_type_get_field_index(struct bt_field_type *ft,
const char *name);
BT_HIDDEN
-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_borrow_length_field_path(
- struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_validate_single_clock_class(
- struct bt_field_type_common *ft,
+int bt_field_type_validate_single_clock_class(
+ struct bt_field_type *ft,
struct bt_clock_class **expected_clock_class);
BT_HIDDEN
-int64_t bt_field_type_common_variant_find_choice_index(
- struct bt_field_type_common *ft, uint64_t uval,
+int64_t bt_field_type_variant_find_choice_index(
+ struct bt_field_type *ft, uint64_t uval,
bool is_signed);
#endif /* BABELTRACE_CTF_IR_FIELD_TYPES_INTERNAL_H */
struct bt_object base;
/* Owned by this */
- struct bt_field_common *field;
+ struct bt_field *field;
};
BT_HIDDEN
#include <stdbool.h>
#include <glib.h>
-#define BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name) \
+#define BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(_field, _type_id, _name) \
BT_ASSERT_PRE((_field)->type->id == ((int) (_type_id)), \
_name " has the wrong type ID: expected-type-id=%s, " \
- "%![field-]+_f", \
+ "%![field-]+f", \
bt_common_field_type_id_string((int) (_type_id)), (_field))
-#define BT_ASSERT_PRE_FIELD_COMMON_IS_SET(_field, _name) \
- BT_ASSERT_PRE(bt_field_common_is_set_recursive(_field), \
- _name " is not set: %!+_f", (_field))
+#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name) \
+ BT_ASSERT_PRE(bt_field_is_set_recursive(_field), \
+ _name " is not set: %!+f", (_field))
-#define BT_ASSERT_PRE_FIELD_COMMON_HOT(_field, _name) \
- BT_ASSERT_PRE_HOT((_field), (_name), ": %!+_f", (_field))
+#define BT_ASSERT_PRE_FIELD_HOT(_field, _name) \
+ BT_ASSERT_PRE_HOT((_field), (_name), ": %!+f", (_field))
struct bt_field;
-struct bt_field_common;
-typedef void (*bt_field_common_method_set_is_frozen)(struct bt_field_common *,
+typedef void (*bt_field_method_set_is_frozen)(struct bt_field *,
bool);
-typedef int (*bt_field_common_method_validate)(struct bt_field_common *);
-typedef struct bt_field_common *(*bt_field_common_method_copy)(
- struct bt_field_common *);
-typedef bt_bool (*bt_field_common_method_is_set)(struct bt_field_common *);
-typedef void (*bt_field_common_method_reset)(struct bt_field_common *);
-
-struct bt_field_common_methods {
- bt_field_common_method_set_is_frozen set_is_frozen;
- bt_field_common_method_validate validate;
- bt_field_common_method_copy copy;
- bt_field_common_method_is_set is_set;
- bt_field_common_method_reset reset;
+typedef int (*bt_field_method_validate)(struct bt_field *);
+typedef bt_bool (*bt_field_method_is_set)(struct bt_field *);
+typedef void (*bt_field_method_reset)(struct bt_field *);
+
+struct bt_field_methods {
+ bt_field_method_set_is_frozen set_is_frozen;
+ bt_field_method_validate validate;
+ bt_field_method_is_set is_set;
+ bt_field_method_reset reset;
};
-struct bt_field_common {
+struct bt_field {
struct bt_object base;
- struct bt_field_type_common *type;
- struct bt_field_common_methods *methods;
+ struct bt_field_type *type;
+ struct bt_field_methods *methods;
bool payload_set;
bool frozen;
-
- /*
- * Specialized data for either CTF IR or CTF writer APIs.
- * See comment in `field-types-internal.h` for more details.
- */
- union {
- struct {
- } ir;
- struct {
- void *serialize_func;
- } writer;
- } spec;
};
-struct bt_field_common_integer {
- struct bt_field_common common;
+struct bt_field_integer {
+ struct bt_field common;
union {
int64_t signd;
uint64_t unsignd;
} payload;
};
-struct bt_field_common_floating_point {
- struct bt_field_common common;
+struct bt_field_enumeration {
+ struct bt_field_integer common;
+};
+
+struct bt_field_floating_point {
+ struct bt_field common;
double payload;
};
-struct bt_field_common_structure {
- struct bt_field_common common;
+struct bt_field_structure {
+ struct bt_field common;
- /* Array of `struct bt_field_common *`, owned by this */
+ /* Array of `struct bt_field *`, owned by this */
GPtrArray *fields;
};
-struct bt_field_common_variant {
- struct bt_field_common common;
+struct bt_field_variant {
+ struct bt_field common;
union {
uint64_t u;
} tag_value;
/* Weak: belongs to `choices` below */
- struct bt_field_common *current_field;
+ struct bt_field *current_field;
- /* Array of `struct bt_field_common *`, owned by this */
+ /* Array of `struct bt_field *`, owned by this */
GPtrArray *fields;
};
-struct bt_field_common_array {
- struct bt_field_common common;
+struct bt_field_array {
+ struct bt_field common;
- /* Array of `struct bt_field_common *`, owned by this */
+ /* Array of `struct bt_field *`, owned by this */
GPtrArray *elements;
};
-struct bt_field_common_sequence {
- struct bt_field_common common;
+struct bt_field_sequence {
+ struct bt_field common;
/*
* This is the true sequence field's length: its value can be
*/
uint64_t length;
- /* Array of `struct bt_field_common *`, owned by this */
+ /* Array of `struct bt_field *`, owned by this */
GPtrArray *elements;
};
-struct bt_field_common_string {
- struct bt_field_common common;
+struct bt_field_string {
+ struct bt_field common;
GArray *buf;
size_t size;
};
-struct bt_field_enumeration {
- struct bt_field_common_integer common;
-};
-
-BT_HIDDEN
-struct bt_field_common *bt_field_common_copy(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_structure_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
- GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_field_common_array_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
- GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_field_common_sequence_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_field_common_variant_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
- GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_field_common_string_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods);
-
-BT_HIDDEN
-int bt_field_common_generic_validate(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_structure_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_variant_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_array_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_sequence_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_generic_reset(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_structure_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_variant_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_array_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_sequence_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_generic_set_is_frozen(struct bt_field_common *field,
- bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_structure_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_variant_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_array_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_sequence_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void _bt_field_common_set_is_frozen_recursive(struct bt_field_common *field,
- bool is_frozen);
-
-BT_HIDDEN
-bt_bool bt_field_common_generic_is_set(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_structure_is_set_recursive(
- struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_variant_is_set_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_array_is_set_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field);
-
#ifdef BT_DEV_MODE
-# define bt_field_common_validate_recursive _bt_field_common_validate_recursive
-# define bt_field_common_set_is_frozen_recursive _bt_field_common_set_is_frozen_recursive
-# define bt_field_common_is_set_recursive _bt_field_common_is_set_recursive
-# define bt_field_common_reset_recursive _bt_field_common_reset_recursive
-# define bt_field_common_set _bt_field_common_set
# define bt_field_validate_recursive _bt_field_validate_recursive
# define bt_field_set_is_frozen_recursive _bt_field_set_is_frozen_recursive
# define bt_field_is_set_recursive _bt_field_is_set_recursive
# define bt_field_reset_recursive _bt_field_reset_recursive
# define bt_field_set _bt_field_set
#else
-# define bt_field_common_validate_recursive(_field) (-1)
-# define bt_field_common_set_is_frozen_recursive(_field, _is_frozen)
-# define bt_field_common_is_set_recursive(_field) (BT_FALSE)
-# define bt_field_common_reset_recursive(_field)
-# define bt_field_common_set(_field, _val)
# define bt_field_validate_recursive(_field) (-1)
# define bt_field_set_is_frozen_recursive(_field, _is_frozen)
# define bt_field_is_set_recursive(_field) (BT_FALSE)
# define bt_field_set(_field, _val)
#endif
-BT_ASSERT_FUNC
-static inline bool field_type_common_has_known_id(
- struct bt_field_type_common *ft)
-{
- return (int) ft->id > BT_FIELD_TYPE_ID_UNKNOWN ||
- (int) ft->id < BT_FIELD_TYPE_ID_NR;
-}
+BT_HIDDEN
+void _bt_field_set_is_frozen_recursive(struct bt_field *field,
+ bool is_frozen);
static inline
-int _bt_field_common_validate_recursive(struct bt_field_common *field)
+int _bt_field_validate_recursive(struct bt_field *field)
{
int ret = 0;
goto end;
}
- BT_ASSERT(field_type_common_has_known_id(field->type));
+ BT_ASSERT(bt_field_type_has_known_id(field->type));
if (field->methods->validate) {
ret = field->methods->validate(field);
}
static inline
-void _bt_field_common_reset_recursive(struct bt_field_common *field)
+void _bt_field_reset_recursive(struct bt_field *field)
{
BT_ASSERT(field);
BT_ASSERT(field->methods->reset);
}
static inline
-void _bt_field_common_set(struct bt_field_common *field, bool value)
+void _bt_field_set(struct bt_field *field, bool value)
{
BT_ASSERT(field);
field->payload_set = value;
}
static inline
-bt_bool _bt_field_common_is_set_recursive(struct bt_field_common *field)
+bt_bool _bt_field_is_set_recursive(struct bt_field *field)
{
bt_bool is_set = BT_FALSE;
goto end;
}
- BT_ASSERT(field_type_common_has_known_id(field->type));
+ BT_ASSERT(bt_field_type_has_known_id(field->type));
BT_ASSERT(field->methods->is_set);
is_set = field->methods->is_set(field);
return is_set;
}
-static inline
-void bt_field_common_initialize(struct bt_field_common *field,
- struct bt_field_type_common *ft, bool is_shared,
- bt_object_release_func release_func,
- struct bt_field_common_methods *methods)
-{
- BT_ASSERT(field);
- BT_ASSERT(ft);
- bt_object_init(&field->base, is_shared, release_func);
- field->methods = methods;
- field->type = bt_get(ft);
-}
-
-static inline
-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 = field->type;
- return ret;
-}
-
-static inline
-int64_t bt_field_common_sequence_get_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 (int64_t) sequence->length;
-}
-
-static inline
-int bt_field_common_sequence_set_length(struct bt_field_common *field,
- uint64_t length, bt_field_common_create_func field_create_func)
-{
- int ret = 0;
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
- BT_ASSERT_PRE(((int64_t) length) >= 0,
- "Invalid sequence length (too large): length=%" PRId64,
- length);
- BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "Sequence field");
-
- if (unlikely(length > sequence->elements->len)) {
- /* Make more room */
- struct bt_field_type_common_sequence *sequence_ft;
- uint64_t cur_len = sequence->elements->len;
- uint64_t i;
-
- g_ptr_array_set_size(sequence->elements, length);
- sequence_ft = BT_FROM_COMMON(sequence->common.type);
-
- for (i = cur_len; i < sequence->elements->len; i++) {
- struct bt_field_common *elem_field =
- field_create_func(sequence_ft->element_ft);
-
- if (!elem_field) {
- ret = -1;
- goto end;
- }
-
- BT_ASSERT(!sequence->elements->pdata[i]);
- sequence->elements->pdata[i] = elem_field;
- }
- }
-
- sequence->length = length;
-
-end:
- return ret;
-}
-
-static inline
-struct bt_field_common *bt_field_common_structure_borrow_field_by_name(
- struct bt_field_common *field, const char *name)
-{
- struct bt_field_common *ret = NULL;
- GQuark field_quark;
- struct bt_field_type_common_structure *structure_ft;
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
- size_t index;
- GHashTable *field_name_to_index;
-
- BT_ASSERT_PRE_NON_NULL(field, "Structure field");
- BT_ASSERT_PRE_NON_NULL(name, "Field name");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRUCT, "Field");
- structure_ft = BT_FROM_COMMON(field->type);
- field_name_to_index = structure_ft->field_name_to_index;
- field_quark = g_quark_from_string(name);
- if (!g_hash_table_lookup_extended(field_name_to_index,
- GUINT_TO_POINTER(field_quark),
- NULL, (gpointer *) &index)) {
- BT_LOGV("Invalid parameter: no such field in structure field's type: "
- "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
- field, field->type, name);
- goto error;
- }
-
- ret = structure->fields->pdata[index];
- BT_ASSERT(ret);
-
-error:
- return ret;
-}
-
-static inline
-struct bt_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);
-
- BT_ASSERT_PRE_NON_NULL(field, "Structure field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRUCT, "Field");
- BT_ASSERT_PRE(index < structure->fields->len,
- "Index is out of bound: %![struct-field-]+_f, "
- "index=%" PRIu64 ", count=%u", field, index,
- structure->fields->len);
- return structure->fields->pdata[index];
-}
-
-static inline
-struct bt_field_common *bt_field_common_array_borrow_field(
- struct bt_field_common *field, uint64_t index)
-{
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Array field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_ARRAY,
- "Field");
- BT_ASSERT_PRE(index < array->elements->len,
- "Index is out of bound: %![array-field-]+_f, "
- "index=%" PRIu64 ", count=%u", field,
- index, array->elements->len);
- return array->elements->pdata[(size_t) index];
-}
-
-static inline
-struct bt_field_common *bt_field_common_sequence_borrow_field(
- struct bt_field_common *field, uint64_t index)
-{
- 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");
- BT_ASSERT_PRE(index < sequence->length,
- "Index is out of bound: %![seq-field-]+_f, "
- "index=%" PRIu64 ", count=%u", field, index,
- sequence->elements->len);
- return sequence->elements->pdata[(size_t) index];
-}
-
-static inline
-int bt_field_variant_common_set_tag(struct bt_field_common *variant_field,
- uint64_t tag_uval, bool is_signed)
-{
- int ret = 0;
- int64_t choice_index;
- 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");
-
- /* Find matching index in variant field's type */
- choice_index = bt_field_type_common_variant_find_choice_index(
- variant_field->type, tag_uval, is_signed);
- if (choice_index < 0) {
- ret = -1;
- goto end;
- }
-
- /* Select corresponding field */
- BT_ASSERT(choice_index < variant->fields->len);
- variant->current_field = variant->fields->pdata[choice_index];
- variant->tag_value.u = tag_uval;
-
-end:
- return ret;
-}
-
-static inline
-struct bt_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");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: %!+_f", variant_field);
- return variant->current_field;
-}
-
-static inline
-int bt_field_common_variant_get_tag_signed(struct bt_field_common *variant_field,
- int64_t *tag)
-{
- 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");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: %!+_f", variant_field);
- *tag = variant->tag_value.i;
- return 0;
-}
-
-static inline
-int bt_field_common_variant_get_tag_unsigned(struct bt_field_common *variant_field,
- uint64_t *tag)
-{
- 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");
- BT_ASSERT_PRE(variant->current_field,
- "Variant field has no current field: %!+_f", variant_field);
- *tag = variant->tag_value.u;
- return 0;
-}
-
-static inline
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_common_enumeration_get_mappings(struct bt_field_common *field,
- bt_field_common_create_func field_create_func,
- uint64_t uval)
-{
- struct bt_field_type_common_enumeration *enum_type = NULL;
- struct bt_field_type_common_integer *integer_type = NULL;
- struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
-
- BT_ASSERT(field);
- BT_ASSERT(field->type->id == BT_FIELD_TYPE_ID_ENUM);
- BT_ASSERT(field->payload_set);
- enum_type = BT_FROM_COMMON(field->type);
- integer_type = enum_type->container_ft;
-
- if (!integer_type->is_signed) {
- iter = bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
- field->type, uval);
- } else {
- iter = bt_field_type_common_enumeration_signed_find_mappings_by_value(
- field->type, (int64_t) uval);
- }
-
- return iter;
-}
-
-static inline
-int bt_field_common_floating_point_get_value(struct bt_field_common *field,
- double *value)
-{
- struct bt_field_common_floating_point *floating_point =
- BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_FIELD_COMMON_IS_SET(field, "Floating point number field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_FLOAT, "Field");
- *value = floating_point->payload;
- return 0;
-}
-
-static inline
-int bt_field_common_floating_point_set_value(struct bt_field_common *field,
- double value)
-{
- struct bt_field_common_floating_point *floating_point =
- BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "Floating point number field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_FLOAT, "Field");
- floating_point->payload = value;
- bt_field_common_set(field, true);
- return 0;
-}
-
-static inline
-const char *bt_field_common_string_get_value(struct bt_field_common *field)
-{
- struct bt_field_common_string *string = BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_IS_SET(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
- return (const char *) string->buf->data;
-}
-
-static inline
-int bt_field_common_string_clear(struct bt_field_common *field)
-{
- struct bt_field_common_string *string_field = BT_FROM_COMMON(field);
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
- string_field->size = 0;
- bt_field_common_set(field, true);
- return 0;
-}
-
-static inline
-int bt_field_common_string_append_len(struct bt_field_common *field,
- const char *value, unsigned int length)
-{
- struct bt_field_common_string *string_field = BT_FROM_COMMON(field);
- char *data;
- size_t new_size;
-
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
-
- /* Make sure no null bytes are appended */
- BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
- "String value to append contains a null character: "
- "partial-value=\"%.32s\", length=%u", value, length);
-
- new_size = string_field->size + length;
-
- if (unlikely(new_size + 1 > string_field->buf->len)) {
- g_array_set_size(string_field->buf, new_size + 1);
- }
-
- data = string_field->buf->data;
- memcpy(data + string_field->size, value, length);
- ((char *) string_field->buf->data)[new_size] = '\0';
- string_field->size = new_size;
- bt_field_common_set(field, true);
- return 0;
-}
-
-static inline
-int bt_field_common_string_append(struct bt_field_common *field,
- const char *value)
-{
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- return bt_field_common_string_append_len(field, value,
- strlen(value));
-}
-
-static inline
-int bt_field_common_string_set_value(struct bt_field_common *field,
- const char *value)
-{
- BT_ASSERT_PRE_NON_NULL(field, "String field");
- BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
- BT_FIELD_TYPE_ID_STRING, "Field");
- bt_field_common_string_clear(field);
- return bt_field_common_string_append_len(field,
- value, strlen(value));
-}
-
-static inline
-int _bt_field_validate_recursive(struct bt_field *field)
-{
- return _bt_field_common_validate_recursive((void *) field);
-}
-
-static inline
-void _bt_field_set_is_frozen_recursive(struct bt_field *field, bool is_frozen)
-{
- return _bt_field_common_set_is_frozen_recursive((void *) field,
- is_frozen);
-}
-
-static inline
-bt_bool _bt_field_is_set_recursive(struct bt_field *field)
-{
- return _bt_field_common_is_set_recursive((void *) field);
-}
-
-static inline
-void _bt_field_reset_recursive(struct bt_field *field)
-{
- _bt_field_common_reset_recursive((void *) field);
-}
-
-static inline
-void _bt_field_set(struct bt_field *field, bool value)
-{
- _bt_field_common_set((void *) field, value);
-}
-
-static inline
-void bt_field_common_finalize(struct bt_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD_STR("Putting field's type.");
- bt_put(field->type);
-}
-
-static inline
-void bt_field_common_integer_finalize(struct bt_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD("Finalizing common integer field object: addr=%p", field);
- bt_field_common_finalize(field);
-}
-
-static inline
-void bt_field_common_floating_point_finalize(struct bt_field_common *field)
-{
- BT_ASSERT(field);
- BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
- bt_field_common_finalize(field);
-}
-
-static inline
-void bt_field_common_structure_finalize_recursive(struct bt_field_common *field)
-{
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common structure field object: addr=%p", field);
- bt_field_common_finalize(field);
-
- if (structure->fields) {
- g_ptr_array_free(structure->fields, TRUE);
- }
-}
-
-static inline
-void bt_field_common_variant_finalize_recursive(struct bt_field_common *field)
-{
- struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common variant field object: addr=%p", field);
- bt_field_common_finalize(field);
-
- if (variant->fields) {
- g_ptr_array_free(variant->fields, TRUE);
- }
-}
-
-static inline
-void bt_field_common_array_finalize_recursive(struct bt_field_common *field)
-{
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common array field object: addr=%p", field);
- bt_field_common_finalize(field);
-
- if (array->elements) {
- g_ptr_array_free(array->elements, TRUE);
- }
-}
-
-static inline
-void bt_field_common_sequence_finalize_recursive(struct bt_field_common *field)
-{
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common sequence field object: addr=%p", field);
- bt_field_common_finalize(field);
-
- if (sequence->elements) {
- g_ptr_array_free(sequence->elements, TRUE);
- }
-}
-
-static inline
-void bt_field_common_string_finalize(struct bt_field_common *field)
-{
- struct bt_field_common_string *string = BT_FROM_COMMON(field);
-
- BT_ASSERT(field);
- BT_LOGD("Finalizing common string field object: addr=%p", field);
- bt_field_common_finalize(field);
-
- if (string->buf) {
- g_array_free(string->buf, TRUE);
- }
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
-{
- bool ret = true;
- int64_t min_value, max_value;
-
- min_value = -(1ULL << (size - 1));
- max_value = (1ULL << (size - 1)) - 1;
- if (value < min_value || value > max_value) {
- BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
- "min-value=%" PRId64 ", max-value=%" PRId64,
- value, min_value, max_value);
- ret = false;
- }
-
- return ret;
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
-{
- bool ret = true;
- int64_t max_value;
-
- max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
- if (value > max_value) {
- BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
- "max-value=%" PRIu64,
- value, max_value);
- ret = false;
- }
-
- return ret;
-}
-
BT_HIDDEN
struct bt_field *bt_field_create_recursive(struct bt_field_type *type);
*/
BT_HIDDEN
int bt_resolve_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type,
- struct bt_field_type_common *event_context_type,
- struct bt_field_type_common *event_payload_type,
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type,
+ struct bt_field_type *event_context_type,
+ struct bt_field_type *event_payload_type,
enum bt_resolve_flag flags);
#endif /* BABELTRACE_CTF_IR_RESOLVE_INTERNAL_H */
#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ctf-ir/utils-internal.h>
#include <babeltrace/ctf-ir/visitor.h>
+#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/object-pool-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <glib.h>
#include <inttypes.h>
-struct bt_stream_class_common {
+struct bt_stream_class {
struct bt_object base;
GString *name;
int id_set;
int64_t id;
int64_t next_event_id;
- struct bt_field_type_common *packet_context_field_type;
- struct bt_field_type_common *event_header_field_type;
- struct bt_field_type_common *event_context_field_type;
+ struct bt_field_type *packet_context_field_type;
+ struct bt_field_type *event_header_field_type;
+ struct bt_field_type *event_context_field_type;
int frozen;
int byte_order;
* backing clock class of the `clock` member above.
*/
struct bt_clock_class *clock_class;
-};
-
-struct bt_stream_class {
- struct bt_stream_class_common common;
/* Pool of `struct bt_field_wrapper *` */
struct bt_object_pool event_header_field_pool;
struct bt_object_pool packet_context_field_pool;
};
-struct bt_event_class_common;
-
-BT_HIDDEN
-int bt_stream_class_common_initialize(struct bt_stream_class_common *stream_class,
- const char *name, bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_stream_class_common_finalize(struct bt_stream_class_common *stream_class);
-
-BT_HIDDEN
-void bt_stream_class_common_freeze(struct bt_stream_class_common *stream_class);
+struct bt_event_class;
BT_HIDDEN
void bt_stream_class_freeze(struct bt_stream_class *stream_class);
-static inline
-const char *bt_stream_class_common_get_name(
- struct bt_stream_class_common *stream_class)
-{
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- return stream_class->name->len > 0 ? stream_class->name->str : NULL;
-}
-
-static inline
-int64_t bt_stream_class_common_get_id(
- struct bt_stream_class_common *stream_class)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->id_set) {
- BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
- stream_class,
- bt_stream_class_common_get_name(stream_class));
- ret = (int64_t) -1;
- goto end;
- }
-
- ret = stream_class->id;
-
-end:
- return ret;
-}
-
-BT_HIDDEN
-void bt_stream_class_common_set_byte_order(
- struct bt_stream_class_common *stream_class, int byte_order);
-
BT_HIDDEN
-int bt_stream_class_common_validate_single_clock_class(
- struct bt_stream_class_common *stream_class,
+int bt_stream_class_validate_single_clock_class(
+ struct bt_stream_class *stream_class,
struct bt_clock_class **expected_clock_class);
BT_HIDDEN
-int bt_stream_class_common_add_event_class(
- struct bt_stream_class_common *stream_class,
- struct bt_event_class_common *event_class,
- bt_validation_flag_copy_field_type_func copy_field_type_func);
-
-BT_HIDDEN
-int bt_stream_class_common_visit(struct bt_stream_class_common *stream_class,
+int bt_stream_class_visit(struct bt_stream_class *stream_class,
bt_visitor visitor, void *data);
static inline
-struct bt_trace_common *bt_stream_class_common_borrow_trace(
- struct bt_stream_class_common *stream_class)
-{
- BT_ASSERT(stream_class);
- return (void *) bt_object_borrow_parent(&stream_class->base);
-}
-
-static inline
-int bt_stream_class_common_set_name(struct bt_stream_class_common *stream_class,
- const char *name)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (!name) {
- g_string_assign(stream_class->name, "");
- } else {
- if (strlen(name) == 0) {
- BT_LOGW("Invalid parameter: name is empty.");
- ret = -1;
- goto end;
- }
-
- g_string_assign(stream_class->name, name);
- }
-
- BT_LOGV("Set stream class's name: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
-end:
- return ret;
-}
-
-static inline
-void _bt_stream_class_common_set_id(
- struct bt_stream_class_common *stream_class, int64_t id)
+void _bt_stream_class_set_id(
+ struct bt_stream_class *stream_class, int64_t id)
{
BT_ASSERT(stream_class);
stream_class->id = id;
stream_class->id_set = 1;
BT_LOGV("Set stream class's ID (internal): "
"addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
}
static inline
-int bt_stream_class_common_set_id_no_check(
- struct bt_stream_class_common *stream_class, int64_t id)
+int bt_stream_class_set_id_no_check(
+ struct bt_stream_class *stream_class, int64_t id)
{
- _bt_stream_class_common_set_id(stream_class, id);
+ _bt_stream_class_set_id(stream_class, id);
return 0;
}
-static inline
-int bt_stream_class_common_set_id(struct bt_stream_class_common *stream_class,
- uint64_t id_param)
-{
- int ret = 0;
- int64_t id = (int64_t) id_param;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (id < 0) {
- BT_LOGW("Invalid parameter: invalid stream class's ID: "
- "stream-class-addr=%p, stream-class-name=\"%s\", "
- "stream-class-id=%" PRId64 ", id=%" PRIu64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- id_param);
- ret = -1;
- goto end;
- }
-
- ret = bt_stream_class_common_set_id_no_check(stream_class, id);
- if (ret == 0) {
- BT_LOGV("Set stream class's ID: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- }
-end:
- return ret;
-}
-
-static inline
-int64_t bt_stream_class_common_get_event_class_count(
- struct bt_stream_class_common *stream_class)
-{
- int64_t ret;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = (int64_t) -1;
- goto end;
- }
-
- ret = (int64_t) stream_class->event_classes->len;
-end:
- return ret;
-}
-
-static inline
-struct bt_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");
- BT_ASSERT_PRE(index < stream_class->event_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, stream_class->event_classes->len);
- return g_ptr_array_index(stream_class->event_classes, index);
-}
-
-static inline
-struct bt_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 g_hash_table_lookup(stream_class->event_classes_ht,
- &id_key);
-}
-
-static inline
-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 stream_class->packet_context_field_type;
-}
-
-static inline
-int bt_stream_class_common_set_packet_context_field_type(
- struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (packet_context_type &&
- bt_field_type_common_get_type_id(packet_context_type) !=
- BT_FIELD_TYPE_ID_STRUCT) {
- /* A packet context must be a structure. */
- BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "packet-context-ft-addr=%p, packet-context-ft-id=%s",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- packet_context_type,
- bt_common_field_type_id_string(
- bt_field_type_common_get_type_id(packet_context_type)));
- ret = -1;
- goto end;
- }
-
- bt_put(stream_class->packet_context_field_type);
- bt_get(packet_context_type);
- stream_class->packet_context_field_type = packet_context_type;
- BT_LOGV("Set stream class's packet context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "packet-context-ft-addr=%p",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- packet_context_type);
-
-end:
- return ret;
-}
-
-static inline
-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;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->event_header_field_type) {
- BT_LOGV("Stream class has no event header field type: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- goto end;
- }
-
- ret = stream_class->event_header_field_type;
-
-end:
- return ret;
-}
-
-static inline
-int bt_stream_class_common_set_event_header_field_type(
- struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *event_header_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class,
- bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (event_header_type &&
- bt_field_type_common_get_type_id(event_header_type) !=
- BT_FIELD_TYPE_ID_STRUCT) {
- /* An event header must be a structure. */
- BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-header-ft-addr=%p, event-header-ft-id=%s",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- event_header_type,
- bt_common_field_type_id_string(
- bt_field_type_common_get_type_id(event_header_type)));
- ret = -1;
- goto end;
- }
-
- bt_put(stream_class->event_header_field_type);
- stream_class->event_header_field_type = bt_get(event_header_type);
- BT_LOGV("Set stream class's event header field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-header-ft-addr=%p",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- event_header_type);
-end:
- return ret;
-}
-
-static inline
-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;
-
- BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
- if (!stream_class->event_context_field_type) {
- goto end;
- }
-
- ret = stream_class->event_context_field_type;
-
-end:
- return ret;
-}
-
-static inline
-int bt_stream_class_common_set_event_context_field_type(
- struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *event_context_type)
-{
- int ret = 0;
-
- if (!stream_class) {
- BT_LOGW_STR("Invalid parameter: stream class is NULL.");
- ret = -1;
- goto end;
- }
-
- if (stream_class->frozen) {
- BT_LOGW("Invalid parameter: stream class is frozen: "
- "addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
- ret = -1;
- goto end;
- }
-
- if (event_context_type &&
- bt_field_type_common_get_type_id(event_context_type) !=
- BT_FIELD_TYPE_ID_STRUCT) {
- /* A packet context must be a structure. */
- BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-context-ft-addr=%p, event-context-ft-id=%s",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- event_context_type,
- bt_common_field_type_id_string(
- bt_field_type_common_get_type_id(event_context_type)));
- ret = -1;
- goto end;
- }
-
- bt_put(stream_class->event_context_field_type);
- stream_class->event_context_field_type = bt_get(event_context_type);
- BT_LOGV("Set stream class's event context field type: "
- "addr=%p, name=\"%s\", id=%" PRId64 ", "
- "event-context-ft-addr=%p",
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
- event_context_type);
-end:
- return ret;
-}
-
#endif /* BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H */
#include <glib.h>
struct bt_stream_class;
-struct bt_stream_common;
+struct bt_stream;
-struct bt_stream_common {
+struct bt_stream {
struct bt_object base;
int64_t id;
- struct bt_stream_class_common *stream_class;
+ struct bt_stream_class *stream_class;
GString *name;
-};
-
-struct bt_stream {
- struct bt_stream_common common;
/* Pool of `struct bt_packet *` */
struct bt_object_pool packet_pool;
};
-BT_HIDDEN
-int bt_stream_common_initialize(
- struct bt_stream_common *stream,
- struct bt_stream_class_common *stream_class, const char *name,
- uint64_t id, bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_stream_common_finalize(struct bt_stream_common *stream);
-
-static inline
-struct bt_stream_class_common *bt_stream_common_borrow_class(
- struct bt_stream_common *stream)
-{
- BT_ASSERT(stream);
- return stream->stream_class;
-}
-
-static inline
-const char *bt_stream_common_get_name(struct bt_stream_common *stream)
-{
- BT_ASSERT_PRE_NON_NULL(stream, "Stream");
- return stream->name ? stream->name->str : NULL;
-}
-
-static inline
-int64_t bt_stream_common_get_id(struct bt_stream_common *stream)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(stream, "Stream");
- ret = stream->id;
- if (ret < 0) {
- BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
- stream, bt_stream_common_get_name(stream));
- }
-
- return ret;
-}
-
#endif /* BABELTRACE_CTF_IR_STREAM_INTERNAL_H */
#include <sys/types.h>
#include <babeltrace/compat/uuid-internal.h>
-struct bt_trace_common {
+struct bt_trace {
struct bt_object base;
GString *name;
int frozen;
enum bt_byte_order native_byte_order;
struct bt_value *environment;
GPtrArray *clock_classes; /* Array of pointers to bt_clock_class */
- GPtrArray *stream_classes; /* Array of ptrs to bt_stream_class_common */
- GPtrArray *streams; /* Array of ptrs to bt_stream_common */
- struct bt_field_type_common *packet_header_field_type;
+ GPtrArray *stream_classes; /* Array of ptrs to bt_stream_class */
+ GPtrArray *streams; /* Array of ptrs to bt_stream */
+ struct bt_field_type *packet_header_field_type;
int64_t next_stream_id;
/*
* trace is _always_ frozen.
*/
int valid;
-};
-struct bt_trace {
- struct bt_trace_common common;
GPtrArray *listeners; /* Array of struct listener_wrapper */
GArray *is_static_listeners;
bt_bool is_static;
void *trace_ptr);
BT_HIDDEN
-bt_bool bt_trace_common_has_clock_class(struct bt_trace_common *trace,
+bt_bool bt_trace_has_clock_class(struct bt_trace *trace,
struct bt_clock_class *clock_class);
/**
int bt_trace_add_listener(struct bt_trace *trace_class,
bt_listener_cb listener, void *data);
-BT_HIDDEN
-int bt_trace_common_initialize(struct bt_trace_common *trace,
- bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_trace_common_finalize(struct bt_trace_common *trace);
-
-static inline
-const char *bt_trace_common_get_name(struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->name ? trace->name->str : NULL;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_name(struct bt_trace_common *trace, const char *name);
-
-static inline
-const unsigned char *bt_trace_common_get_uuid(struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->uuid_set ? trace->uuid : NULL;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_uuid(struct bt_trace_common *trace, const unsigned char *uuid);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
- const char *name, struct bt_value *value);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_string(struct bt_trace_common *trace,
- const char *name, const char *value);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_integer(struct bt_trace_common *trace,
- const char *name, int64_t value);
-
-static inline
-int64_t bt_trace_common_get_environment_field_count(
- struct bt_trace_common *trace)
-{
- int64_t ret;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- ret = bt_attributes_get_count(trace->environment);
- BT_ASSERT(ret >= 0);
- return ret;
-}
-
-static inline
-const char *
-bt_trace_common_get_environment_field_name_by_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_borrow_environment_field_value_by_index(
- struct bt_trace_common *trace, uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return bt_attributes_borrow_field_value(trace->environment, index);
-}
-
-static inline
-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_borrow_field_value_by_name(trace->environment,
- name);
-}
-
-BT_HIDDEN
-int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
- struct bt_clock_class *clock_class);
-
-static inline
-int64_t bt_trace_common_get_clock_class_count(struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->clock_classes->len;
-}
-
-static inline
-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");
- BT_ASSERT_PRE(index < trace->clock_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->clock_classes->len);
- return g_ptr_array_index(trace->clock_classes, index);
-}
-
static inline
-int64_t bt_trace_common_get_stream_count(struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (int64_t) trace->streams->len;
-}
-
-static inline
-struct bt_stream_common *bt_trace_common_borrow_stream_by_index(
- struct bt_trace_common *trace,
- uint64_t index)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(index < trace->streams->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->streams->len);
- return g_ptr_array_index(trace->streams, index);
-}
-
-static inline
-int64_t bt_trace_common_get_stream_class_count(struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return (int64_t) trace->stream_classes->len;
-}
-
-static inline
-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");
- BT_ASSERT_PRE(index < trace->stream_classes->len,
- "Index is out of bounds: index=%" PRIu64 ", "
- "count=%u",
- index, trace->stream_classes->len);
- return g_ptr_array_index(trace->stream_classes, index);
-}
-
-static inline
-struct bt_stream_class_common *bt_trace_common_borrow_stream_class_by_id(
- struct bt_trace_common *trace, uint64_t id_param)
-{
- int i;
- struct bt_stream_class_common *stream_class = NULL;
- int64_t id = (int64_t) id_param;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(id >= 0,
- "Invalid stream class ID: %" PRIu64, id_param);
-
- for (i = 0; i < trace->stream_classes->len; i++) {
- struct bt_stream_class_common *stream_class_candidate;
-
- stream_class_candidate =
- g_ptr_array_index(trace->stream_classes, i);
-
- if (bt_stream_class_common_get_id(stream_class_candidate) ==
- (int64_t) id) {
- stream_class = stream_class_candidate;
- goto end;
- }
- }
-
-end:
- return stream_class;
-}
-
-static inline
-struct bt_clock_class *bt_trace_common_borrow_clock_class_by_name(
- struct bt_trace_common *trace, const char *name)
-{
- size_t i;
- struct bt_clock_class *clock_class = NULL;
-
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE_NON_NULL(name, "Name");
-
- for (i = 0; i < trace->clock_classes->len; i++) {
- struct bt_clock_class *cur_clk =
- g_ptr_array_index(trace->clock_classes, i);
- const char *cur_clk_name = bt_clock_class_get_name(cur_clk);
-
- if (!cur_clk_name) {
- goto end;
- }
-
- if (!strcmp(cur_clk_name, name)) {
- clock_class = cur_clk;
- goto end;
- }
- }
-
-end:
- return clock_class;
-}
-
-static inline
-enum bt_byte_order bt_trace_common_get_native_byte_order(
- struct bt_trace_common *trace)
-{
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- return trace->native_byte_order;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
- enum bt_byte_order byte_order, bool allow_unspecified);
-
-static inline
-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 trace->packet_header_field_type;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
- struct bt_field_type_common *packet_header_field_type);
-
-static inline
-void bt_trace_common_freeze(struct bt_trace_common *trace)
+void bt_trace_freeze(struct bt_trace *trace)
{
int i;
}
BT_LOGD("Freezing trace: addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
+ trace, bt_trace_get_name(trace));
BT_LOGD_STR("Freezing packet header field type.");
- bt_field_type_common_freeze(trace->packet_header_field_type);
+ bt_field_type_freeze(trace->packet_header_field_type);
BT_LOGD_STR("Freezing environment attributes.");
bt_attributes_freeze(trace->environment);
trace->frozen = 1;
}
-BT_HIDDEN
-int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- bt_validation_flag_copy_field_type_func copy_field_type_func,
- struct bt_clock_class *init_expected_clock_class,
- int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_field_type,
- struct bt_field_type_common *event_header_field_type),
- bool check_ts_begin_end_mapped);
-
#endif /* BABELTRACE_CTF_IR_TRACE_INTERNAL_H */
#include <babeltrace/ctf-ir/field-types.h>
#include <stdint.h>
-#define BT_TO_COMMON(_obj) (&(_obj)->common)
-#define BT_FROM_COMMON(_obj) ((void *) _obj)
-
struct search_query {
gpointer value;
int found;
#include <babeltrace/values.h>
#include <babeltrace/babeltrace-internal.h>
-struct bt_trace_common;
-struct bt_stream_class_common;
-struct bt_event_class_common;
-struct bt_field_type_common;
+struct bt_trace;
+struct bt_stream_class;
+struct bt_event_class;
+struct bt_field_type;
-typedef struct bt_field_type_common *(*bt_validation_flag_copy_field_type_func)(
- struct bt_field_type_common *);
+typedef struct bt_field_type *(*bt_validation_flag_copy_field_type_func)(
+ struct bt_field_type *);
enum bt_validation_flag {
BT_VALIDATION_FLAG_TRACE = 1,
* `valid_flags` contains the results of the validation.
*/
struct bt_validation_output {
- struct bt_field_type_common *packet_header_type;
- struct bt_field_type_common *packet_context_type;
- struct bt_field_type_common *event_header_type;
- struct bt_field_type_common *stream_event_ctx_type;
- struct bt_field_type_common *event_context_type;
- struct bt_field_type_common *event_payload_type;
+ struct bt_field_type *packet_header_type;
+ struct bt_field_type *packet_context_type;
+ struct bt_field_type *event_header_type;
+ struct bt_field_type *stream_event_ctx_type;
+ struct bt_field_type *event_context_type;
+ struct bt_field_type *event_payload_type;
enum bt_validation_flag valid_flags;
};
*/
BT_HIDDEN
int bt_validate_class_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type,
- struct bt_field_type_common *event_context_type,
- struct bt_field_type_common *event_payload_type,
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type,
+ struct bt_field_type *event_context_type,
+ struct bt_field_type *event_payload_type,
int trace_valid, int stream_class_valid, int event_class_valid,
struct bt_validation_output *output,
enum bt_validation_flag validate_flags,
* All parameters are owned by the caller.
*/
BT_HIDDEN
-void bt_validation_replace_types(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- struct bt_event_class_common *event_class,
+void bt_validation_replace_types(struct bt_trace *trace,
+ struct bt_stream_class *stream_class,
+ struct bt_event_class *event_class,
struct bt_validation_output *output,
enum bt_validation_flag replace_flags);
* 3. Optional: `+` to print extended fields. This depends on the
* provided format specifier.
*
- * 4. Objet category: `_` for common objects, or nothing for default
- * objects (includes CTF IR).
- *
- * 5. Format specifier (see below).
+ * 4. Format specifier (see below).
*
* The available format specifiers are:
*
- * Default category:
* `r`:
* Reference count information. The parameter is any Babeltrace
* object.
* `o`:
* Object pool. The parameter type is `struct bt_object_pool *`.
*
- * Common category:
- * `F`:
- * Common field type. The parameter type is `struct bt_field_type *`.
- *
- * `f`:
- * Common field. The parameter type is `struct bt_field *`.
- *
- * `E`:
- * Common event class. The parameter type is
- * `struct bt_event_class *`.
- *
- * `e`:
- * Common event. The parameter type is `struct bt_event *`.
- *
- * `S`:
- * Common stream class. The parameter type is
- * `struct bt_stream_class *`.
- *
- * `s`:
- * Common stream. The parameter type is `struct bt_stream *`.
- *
- * `t`:
- * Common trace. The parameter type is `struct bt_trace *`.
- *
* Conversion specifier examples:
*
* %!f
* %![my-event-]+e
- * %!_t
- * %!+_F
+ * %!t
+ * %!+F
*
* The string `, ` is printed between individual fields, but not after
* the last one. Therefore you must put this separator in the format
#include <inttypes.h>
#include <stdlib.h>
-BT_HIDDEN
-void bt_event_class_common_finalize(struct bt_object *obj)
+static inline
+void bt_event_class_finalize(struct bt_object *obj)
{
- struct bt_event_class_common *event_class;
+ struct bt_event_class *event_class;
- event_class = container_of(obj, struct bt_event_class_common, base);
- BT_LOGD("Finalizing common event class: addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
+ event_class = container_of(obj, struct bt_event_class, base);
+ BT_LOGD("Finalizing event class: addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
if (event_class->name) {
g_string_free(event_class->name, TRUE);
bt_put(event_class->payload_field_type);
}
-BT_HIDDEN
-int bt_event_class_common_initialize(struct bt_event_class_common *event_class,
+static inline
+int bt_event_class_initialize(struct bt_event_class *event_class,
const char *name, bt_object_release_func release_func,
bt_field_type_structure_create_func ft_struct_create_func)
{
int ret = 0;
- BT_LOGD("Initializing common event class object: name=\"%s\"",
+ BT_LOGD("Initializing event class object: name=\"%s\"",
name);
bt_object_init_shared_with_parent(&event_class->base, release_func);
event_class->payload_field_type = ft_struct_create_func();
}
event_class->log_level = BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED;
- BT_LOGD("Initialized common event class object: addr=%p, name=\"%s\"",
- event_class, bt_event_class_common_get_name(event_class));
+ BT_LOGD("Initialized event class object: addr=%p, name=\"%s\"",
+ event_class, bt_event_class_get_name(event_class));
return ret;
error:
struct bt_event_class *event_class = (void *) obj;
BT_LOGD("Destroying event class: addr=%p", obj);
- bt_event_class_common_finalize(obj);
+ bt_event_class_finalize(obj);
bt_object_pool_finalize(&event_class->event_pool);
g_free(obj);
}
goto error;
}
- ret = bt_event_class_common_initialize(BT_TO_COMMON(event_class),
+ ret = bt_event_class_initialize(event_class,
name, bt_event_class_destroy,
(bt_field_type_structure_create_func)
bt_field_type_structure_create);
const char *bt_event_class_get_name(struct bt_event_class *event_class)
{
- return bt_event_class_common_get_name(BT_TO_COMMON(event_class));
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ BT_ASSERT(event_class->name);
+ return event_class->name->str;
}
int64_t bt_event_class_get_id(struct bt_event_class *event_class)
{
- return bt_event_class_common_get_id(BT_TO_COMMON(event_class));
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->id;
}
-int bt_event_class_set_id(struct bt_event_class *event_class, uint64_t id)
+int bt_event_class_set_id(struct bt_event_class *event_class,
+ uint64_t id_param)
{
- return bt_event_class_common_set_id(BT_TO_COMMON(event_class), id);
+ int ret = 0;
+ int64_t id = (int64_t) id_param;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class,
+ bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (id < 0) {
+ BT_LOGW("Invalid parameter: invalid event class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRIu64,
+ event_class,
+ bt_event_class_get_name(event_class),
+ id_param);
+ ret = -1;
+ goto end;
+ }
+
+ event_class->id = id;
+ BT_LOGV("Set event class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class), id);
+
+end:
+ return ret;
}
enum bt_event_class_log_level bt_event_class_get_log_level(
struct bt_event_class *event_class)
{
- return bt_event_class_common_get_log_level(BT_TO_COMMON(event_class));
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->log_level;
}
int bt_event_class_set_log_level(struct bt_event_class *event_class,
enum bt_event_class_log_level log_level)
{
- return bt_event_class_common_set_log_level(BT_TO_COMMON(event_class),
- log_level);
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class,
+ bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ switch (log_level) {
+ case BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
+ case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
+ case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
+ case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
+ case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
+ case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
+ case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
+ case BT_EVENT_CLASS_LOG_LEVEL_INFO:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
+ case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
+ break;
+ default:
+ BT_LOGW("Invalid parameter: unknown event class log level: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class), log_level);
+ ret = -1;
+ goto end;
+ }
+
+ event_class->log_level = log_level;
+ BT_LOGV("Set event class's log level: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class),
+ bt_common_event_class_log_level_string(log_level));
+
+end:
+ return ret;
}
const char *bt_event_class_get_emf_uri(struct bt_event_class *event_class)
{
- return bt_event_class_common_get_emf_uri(BT_TO_COMMON(event_class));
+ const char *emf_uri = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+ if (event_class->emf_uri->len > 0) {
+ emf_uri = event_class->emf_uri->str;
+ }
+
+ return emf_uri;
}
int bt_event_class_set_emf_uri(struct bt_event_class *event_class,
const char *emf_uri)
{
- return bt_event_class_common_set_emf_uri(BT_TO_COMMON(event_class),
- emf_uri);
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (emf_uri && strlen(emf_uri) == 0) {
+ BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (emf_uri) {
+ g_string_assign(event_class->emf_uri, emf_uri);
+ BT_LOGV("Set event class's EMF URI: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class), emf_uri);
+ } else {
+ g_string_assign(event_class->emf_uri, "");
+ BT_LOGV("Reset event class's EMF URI: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ }
+
+end:
+ return ret;
}
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_FROM_COMMON(
- bt_event_class_common_borrow_stream_class(BT_TO_COMMON(
- event_class)));
+ return (void *) bt_object_borrow_parent(&event_class->base);
}
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_borrow_payload_field_type(
- BT_TO_COMMON(event_class)));
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+ return event_class->payload_field_type;
}
int bt_event_class_set_payload_field_type(struct bt_event_class *event_class,
struct bt_field_type *field_type)
{
- return bt_event_class_common_set_payload_field_type(
- BT_TO_COMMON(event_class), (void *) field_type);
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (field_type && bt_field_type_get_type_id(field_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "payload-ft-addr=%p, payload-ft-id=%s",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class), field_type,
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(field_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(event_class->payload_field_type);
+ event_class->payload_field_type = bt_get(field_type);
+ BT_LOGV("Set event class's payload field type: "
+ "event-class-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", payload-ft-addr=%p",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class), field_type);
+end:
+ return ret;
}
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_borrow_context_field_type(
- BT_TO_COMMON(event_class)));
+ struct bt_field_type *context_ft = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+ if (!event_class->context_field_type) {
+ BT_LOGV("Event class has no context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ goto end;
+ }
+
+ context_ft = event_class->context_field_type;
+
+end:
+ return context_ft;
}
int bt_event_class_set_context_field_type(
struct bt_event_class *event_class,
struct bt_field_type *field_type)
{
- return bt_event_class_common_set_context_field_type(
- BT_TO_COMMON(event_class), (void *) field_type);
+ int ret = 0;
+
+ if (!event_class) {
+ BT_LOGW_STR("Invalid parameter: event class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (event_class->frozen) {
+ BT_LOGW("Invalid parameter: event class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (field_type && bt_field_type_get_type_id(field_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "context-ft-id=%s",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class),
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(field_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(event_class->context_field_type);
+ event_class->context_field_type = bt_get(field_type);
+ BT_LOGV("Set event class's context field type: "
+ "event-class-addr=%p, event-class-name=\"%s\", "
+ "event-class-id=%" PRId64 ", context-ft-addr=%p",
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class), field_type);
+
+end:
+ return ret;
}
BT_HIDDEN
-void bt_event_class_common_freeze(struct bt_event_class_common *event_class)
+void bt_event_class_freeze(struct bt_event_class *event_class)
{
BT_ASSERT(event_class);
}
BT_LOGD("Freezing event class: addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
event_class->frozen = 1;
BT_LOGD_STR("Freezing event class's context field type.");
- bt_field_type_common_freeze(event_class->context_field_type);
+ bt_field_type_freeze(event_class->context_field_type);
BT_LOGD_STR("Freezing event class's payload field type.");
- bt_field_type_common_freeze(event_class->payload_field_type);
+ bt_field_type_freeze(event_class->payload_field_type);
}
BT_HIDDEN
-int bt_event_class_common_validate_single_clock_class(
- struct bt_event_class_common *event_class,
+int bt_event_class_validate_single_clock_class(
+ struct bt_event_class *event_class,
struct bt_clock_class **expected_clock_class)
{
int ret = 0;
BT_ASSERT(event_class);
BT_ASSERT(expected_clock_class);
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
event_class->context_field_type,
expected_clock_class);
if (ret) {
"event-class-id=%" PRId64 ", "
"ft-addr=%p",
event_class,
- bt_event_class_common_get_name(event_class),
+ bt_event_class_get_name(event_class),
event_class->id,
event_class->context_field_type);
goto end;
}
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
event_class->payload_field_type,
expected_clock_class);
if (ret) {
"event-class-id=%" PRId64 ", "
"ft-addr=%p",
event_class,
- bt_event_class_common_get_name(event_class),
+ bt_event_class_get_name(event_class),
event_class->id,
event_class->payload_field_type);
goto end;
#include <babeltrace/assert-internal.h>
#include <inttypes.h>
-static
-int bt_event_common_validate_types_for_create(
- struct bt_event_class_common *event_class,
+static inline
+int bt_event_validate_types_for_create(
+ struct bt_event_class *event_class,
struct bt_validation_output *validation_output,
bt_validation_flag_copy_field_type_func copy_field_type_func)
{
enum bt_validation_flag validation_flags =
BT_VALIDATION_FLAG_STREAM |
BT_VALIDATION_FLAG_EVENT;
- struct bt_trace_common *trace = NULL;
- struct bt_stream_class_common *stream_class = NULL;
- struct bt_field_type_common *packet_header_type = NULL;
- struct bt_field_type_common *packet_context_type = NULL;
- struct bt_field_type_common *event_header_type = NULL;
- struct bt_field_type_common *stream_event_ctx_type = NULL;
- struct bt_field_type_common *event_context_type = NULL;
- struct bt_field_type_common *event_payload_type = NULL;
+ struct bt_trace *trace = NULL;
+ struct bt_stream_class *stream_class = NULL;
+ struct bt_field_type *packet_header_type = NULL;
+ struct bt_field_type *packet_context_type = NULL;
+ struct bt_field_type *event_header_type = NULL;
+ struct bt_field_type *stream_event_ctx_type = NULL;
+ struct bt_field_type *event_context_type = NULL;
+ struct bt_field_type *event_payload_type = NULL;
int trace_valid = 0;
struct bt_value *environment = NULL;
- stream_class = bt_event_class_common_borrow_stream_class(event_class);
+ stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT(stream_class);
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (trace) {
BT_LOGD_STR("Event class is part of a trace.");
packet_header_type =
- bt_trace_common_borrow_packet_header_field_type(trace);
+ bt_trace_borrow_packet_header_field_type(trace);
trace_valid = trace->valid;
BT_ASSERT(trace_valid);
environment = trace->environment;
}
packet_context_type =
- bt_stream_class_common_borrow_packet_context_field_type(
+ bt_stream_class_borrow_packet_context_field_type(
stream_class);
event_header_type =
- bt_stream_class_common_borrow_event_header_field_type(
+ bt_stream_class_borrow_event_header_field_type(
stream_class);
stream_event_ctx_type =
- bt_stream_class_common_borrow_event_context_field_type(
+ bt_stream_class_borrow_event_context_field_type(
stream_class);
event_context_type =
- bt_event_class_common_borrow_context_field_type(event_class);
+ bt_event_class_borrow_context_field_type(event_class);
event_payload_type =
- bt_event_class_common_borrow_payload_field_type(event_class);
+ bt_event_class_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,
}
static
-int bt_event_common_create_fields(
- struct bt_stream_class_common *stream_class,
+int bt_event_create_fields(
+ struct bt_stream_class *stream_class,
struct bt_validation_output *validation_output,
create_field_func create_field_func,
release_field_func release_field_func,
create_header_field_func create_header_field_func,
release_header_field_func release_header_field_func,
struct bt_field_wrapper **header_field,
- struct bt_field_common **stream_event_context_field,
- struct bt_field_common **context_field,
- struct bt_field_common **payload_field)
+ struct bt_field **stream_event_context_field,
+ struct bt_field **context_field,
+ struct bt_field **payload_field)
{
int ret = 0;
}
BT_HIDDEN
-int _bt_event_common_validate(struct bt_event_common *event)
+int _bt_event_validate(struct bt_event *event)
{
int ret = 0;
- struct bt_stream_class_common *stream_class;
+ struct bt_stream_class *stream_class;
BT_ASSERT(event);
if (event->header_field) {
- ret = bt_field_common_validate_recursive(
+ ret = bt_field_validate_recursive(
event->header_field->field);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid event's header field: "
- "%![event-]+_e, %![field-]+_f",
+ "%![event-]+e, %![field-]+f",
event, event->header_field->field);
goto end;
}
}
- stream_class = bt_event_class_common_borrow_stream_class(event->class);
+ stream_class = bt_event_class_borrow_stream_class(event->class);
/*
* We should not have been able to create the event without associating
BT_ASSERT(stream_class);
if (stream_class->event_context_field_type) {
- ret = bt_field_common_validate_recursive(
+ ret = bt_field_validate_recursive(
event->stream_event_context_field);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid event's stream event context field: "
- "%![event-]+_e, %![field-]+_f",
+ "%![event-]+e, %![field-]+f",
event, event->stream_event_context_field);
goto end;
}
}
if (event->class->context_field_type) {
- ret = bt_field_common_validate_recursive(event->context_field);
+ ret = bt_field_validate_recursive(event->context_field);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid event's payload field: "
- "%![event-]+_e, %![field-]+_f",
+ "%![event-]+e, %![field-]+f",
event, event->context_field);
goto end;
}
}
- ret = bt_field_common_validate_recursive(event->payload_field);
+ ret = bt_field_validate_recursive(event->payload_field);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid event's payload field: "
- "%![event-]+_e, %![field-]+_f",
+ "%![event-]+e, %![field-]+f",
event, event->payload_field);
goto end;
}
}
BT_HIDDEN
-void _bt_event_common_set_is_frozen(struct bt_event_common *event,
+void _bt_event_set_is_frozen(struct bt_event *event,
bool is_frozen)
{
BT_ASSERT(event);
BT_LOGD("Freezing event: addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
if (event->header_field) {
BT_LOGD_STR("Freezing event's header field.");
- bt_field_common_set_is_frozen_recursive(
+ bt_field_set_is_frozen_recursive(
event->header_field->field, is_frozen);
}
if (event->stream_event_context_field) {
BT_LOGD_STR("Freezing event's stream event context field.");
- bt_field_common_set_is_frozen_recursive(
+ bt_field_set_is_frozen_recursive(
event->stream_event_context_field, is_frozen);
}
if (event->context_field) {
BT_LOGD_STR("Freezing event's context field.");
- bt_field_common_set_is_frozen_recursive(event->context_field,
+ bt_field_set_is_frozen_recursive(event->context_field,
is_frozen);
}
if (event->payload_field) {
BT_LOGD_STR("Freezing event's payload field.");
- bt_field_common_set_is_frozen_recursive(event->payload_field,
+ bt_field_set_is_frozen_recursive(event->payload_field,
is_frozen);
}
event->frozen = is_frozen;
+ BT_LOGD_STR("Freezing event's packet.");
+ bt_packet_set_is_frozen(event->packet, is_frozen);
}
-BT_HIDDEN
-int bt_event_common_initialize(struct bt_event_common *event,
- struct bt_event_class_common *event_class,
- struct bt_clock_class *init_expected_clock_class,
- bool is_shared_with_parent, bt_object_release_func release_func,
+static inline
+int bt_event_initialize(struct bt_event *event,
+ struct bt_event_class *event_class,
bt_validation_flag_copy_field_type_func field_type_copy_func,
- bool must_be_in_trace,
- int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_field_type,
- struct bt_field_type_common *event_header_field_type),
create_field_func create_field_func,
release_field_func release_field_func,
create_header_field_func create_header_field_func,
release_header_field_func release_header_field_func)
{
int ret;
- struct bt_trace_common *trace = NULL;
- struct bt_stream_class_common *stream_class = NULL;
+ struct bt_trace *trace = NULL;
+ struct bt_stream_class *stream_class = NULL;
struct bt_field_wrapper *event_header = NULL;
- struct bt_field_common *stream_event_context = NULL;
- struct bt_field_common *event_context = NULL;
- struct bt_field_common *event_payload = NULL;
+ struct bt_field *stream_event_context = NULL;
+ struct bt_field *event_context = NULL;
+ struct bt_field *event_payload = NULL;
struct bt_validation_output validation_output = { 0 };
- struct bt_clock_class *expected_clock_class =
- init_expected_clock_class ? bt_get(init_expected_clock_class) :
- NULL;
+ struct bt_clock_class *expected_clock_class = NULL;
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- BT_LOGD("Initializing common event object: event-class-addr=%p, "
+ BT_LOGD("Initializing event object: event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
- stream_class = bt_event_class_common_borrow_stream_class(event_class);
+ stream_class = bt_event_class_borrow_stream_class(event_class);
BT_ASSERT_PRE(stream_class,
- "Event class is not part of a stream class: %!+_E", event_class);
+ "Event class is not part of a stream class: %!+E", event_class);
/* The event class was frozen when added to its stream class */
BT_ASSERT(event_class->frozen);
- trace = bt_stream_class_common_borrow_trace(stream_class);
-
- if (must_be_in_trace) {
- BT_ASSERT_PRE(trace,
- "Event class's stream class is not part of a trace: "
- "%![ec-]+_E, %![ec-]+_S", event_class, stream_class);
- }
+ trace = bt_stream_class_borrow_trace(stream_class);
+ BT_ASSERT_PRE(trace,
+ "Event class's stream class is not part of a trace: "
+ "%![ec-]+E, %![ec-]+S", event_class, stream_class);
/*
* This must be called before anything that can fail because on
* failure, the caller releases the reference to `event` to
* destroy it.
*/
- if (is_shared_with_parent) {
- bt_object_init_shared_with_parent(&event->base, release_func);
- } else {
- bt_object_init_unique(&event->base);
- }
+ bt_object_init_unique(&event->base);
if (!stream_class->frozen) {
/*
* single clock class so that we set its expected clock
* class for future checks.
*/
- ret = bt_stream_class_common_validate_single_clock_class(
+ ret = bt_stream_class_validate_single_clock_class(
stream_class, &expected_clock_class);
if (ret) {
BT_LOGW("Event class's stream class or one of its event "
"expected-clock-class-addr=%p, "
"expected-clock-class-name=\"%s\"",
stream_class,
- bt_stream_class_common_get_id(stream_class),
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ bt_stream_class_get_name(stream_class),
expected_clock_class,
expected_clock_class ?
bt_clock_class_get_name(expected_clock_class) :
}
/* Validate the trace, the stream class, and the event class */
- ret = bt_event_common_validate_types_for_create(
+ ret = bt_event_validate_types_for_create(
event_class, &validation_output, field_type_copy_func);
if (ret) {
- /* bt_event_common_validate_types_for_create() logs errors */
+ /* bt_event_validate_types_for_create() logs errors */
goto error;
}
- if (map_clock_classes_func) {
- /*
- * Safe to automatically map selected fields to the
- * stream's clock's class here because the stream class
- * is about to be frozen.
- */
- if (map_clock_classes_func(stream_class,
- validation_output.packet_context_type,
- validation_output.event_header_type)) {
- BT_LOGW_STR("Cannot automatically map selected stream class's "
- "field types to stream class's clock's class.");
- goto error;
- }
- }
-
/*
* event does not share a common ancestor with the event class; it has
* to guarantee its existence by holding a reference. This reference
* shall be released once the event is associated to a stream since,
* from that point, the event and its class will share the same
* lifetime.
+ *
+ * TODO: Is this still true now that this API and CTF writer are
+ * two different implementations?
*/
event->class = bt_get(event_class);
-
- ret = bt_event_common_create_fields(stream_class,
+ ret = bt_event_create_fields(stream_class,
&validation_output,
create_field_func, release_field_func,
create_header_field_func, release_header_field_func,
&event_header, &stream_event_context, &event_context,
&event_payload);
if (ret) {
- /* bt_event_common_create_fields() logs errors */
+ /* bt_event_create_fields() logs errors */
goto error;
}
* Freeze the stream class since the event header must not be changed
* anymore.
*/
- bt_stream_class_common_freeze(stream_class);
+ bt_stream_class_freeze(stream_class);
/*
* It is safe to set the stream class's unique clock class
/* Put stuff we borrowed from the event class */
BT_LOGD("Initialized event object: addr=%p, event-class-name=\"%s\", "
"event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->class),
- bt_event_class_common_get_id(event->class));
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
goto end;
error:
static
struct bt_field_wrapper *create_event_header_field(
struct bt_stream_class *stream_class,
- struct bt_field_type_common *ft)
+ struct bt_field_type *ft)
{
struct bt_field_wrapper *field_wrapper = NULL;
goto error;
}
- ret = bt_event_common_initialize(BT_TO_COMMON(event),
- BT_TO_COMMON(event_class), NULL, false, NULL,
+ ret = bt_event_initialize(event, event_class,
(bt_validation_flag_copy_field_type_func) bt_field_type_copy,
- true, NULL,
(create_field_func) bt_field_create_recursive,
(release_field_func) bt_field_destroy_recursive,
(create_header_field_func) create_event_header_field,
(release_header_field_func) bt_event_header_field_recycle);
if (ret) {
- /* bt_event_common_initialize() logs errors */
+ /* bt_event_initialize() logs errors */
goto error;
}
struct bt_event_class *bt_event_borrow_class(struct bt_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return BT_FROM_COMMON(
- bt_event_common_borrow_class(BT_TO_COMMON(event)));
+ return event->class;
}
struct bt_stream *bt_event_borrow_stream(struct bt_event *event)
struct bt_field *bt_event_borrow_payload(struct bt_event *event)
{
- return BT_FROM_COMMON(
- bt_event_common_borrow_payload(BT_TO_COMMON(event)));
+ struct bt_field *payload = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->payload_field) {
+ BT_LOGV("Event has no current payload field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
+ goto end;
+ }
+
+ payload = event->payload_field;
+
+end:
+ return payload;
}
struct bt_field *bt_event_borrow_header(struct bt_event *event)
{
- return BT_FROM_COMMON(
- bt_event_common_borrow_header(BT_TO_COMMON(event)));
+ struct bt_field *header = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->header_field) {
+ BT_LOGV("Event has no current header field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
+ goto end;
+ }
+
+ header = event->header_field->field;
+
+end:
+ return header;
}
struct bt_field *bt_event_borrow_context(struct bt_event *event)
{
- return BT_FROM_COMMON(
- bt_event_common_borrow_context(BT_TO_COMMON(event)));
+ struct bt_field *context = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->context_field) {
+ BT_LOGV("Event has no current context field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
+ goto end;
+ }
+
+ context = event->context_field;
+
+end:
+ return context;
}
struct bt_field *bt_event_borrow_stream_event_context(
struct bt_event *event)
{
- return BT_FROM_COMMON(bt_event_common_borrow_stream_event_context(
- BT_TO_COMMON(event)));
+ struct bt_field *stream_event_context = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+ if (!event->stream_event_context_field) {
+ BT_LOGV("Event has no current stream event context field: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
+ goto end;
+ }
+
+ stream_event_context = event->stream_event_context_field;
+
+end:
+ return stream_event_context;
}
static
void release_event_header_field(struct bt_field_wrapper *field_wrapper,
- struct bt_event_common *event_common)
+ struct bt_event *event)
{
- struct bt_event *event = BT_FROM_COMMON(event_common);
struct bt_event_class *event_class = bt_event_borrow_class(event);
if (!event_class) {
}
}
+static inline
+void bt_event_finalize(struct bt_object *obj,
+ void (*field_release_func)(void *),
+ void (*header_field_release_func)(void *, struct bt_event *))
+{
+ struct bt_event *event = (void *) obj;
+
+ BT_LOGD("Destroying event: addr=%p, "
+ "event-class-name=\"%s\", event-class-id=%" PRId64,
+ event,
+ event->class ? bt_event_class_get_name(event->class) : NULL,
+ event->class ? bt_event_class_get_id(event->class) : INT64_C(-1));
+
+ if (event->header_field) {
+ BT_LOGD_STR("Releasing event's header field.");
+ header_field_release_func(event->header_field, event);
+ }
+
+ if (event->stream_event_context_field) {
+ BT_LOGD_STR("Releasing event's stream event context field.");
+ field_release_func(event->stream_event_context_field);
+ }
+
+ if (event->context_field) {
+ BT_LOGD_STR("Releasing event's context field.");
+ field_release_func(event->context_field);
+ }
+
+ if (event->payload_field) {
+ BT_LOGD_STR("Releasing event's payload field.");
+ field_release_func(event->payload_field);
+ }
+
+ /*
+ * Leave this after calling header_field_release_func() because
+ * this function receives the event object and could need its
+ * class to perform some cleanup.
+ */
+ if (!event->base.parent) {
+ /*
+ * Event was keeping a reference to its class since it shared no
+ * common ancestor with it to guarantee they would both have the
+ * same lifetime.
+ */
+ bt_put(event->class);
+ }
+}
+
BT_HIDDEN
void bt_event_destroy(struct bt_event *event)
{
BT_ASSERT(event);
- bt_event_common_finalize((void *) event,
+ bt_event_finalize((void *) event,
(void *) bt_field_destroy_recursive,
(void *) release_event_header_field);
bt_clock_value_set_finalize(&event->cv_set);
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
- BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
+ BT_ASSERT_PRE_HOT(event, "Event", ": %!+e", event);
BT_ASSERT_PRE(is_default,
"You can only set a default clock value as of this version.");
return bt_clock_value_set_set_clock_value(&event->cv_set, clock_class,
if (!event->packet) {
BT_LOGV("Event has no current packet: addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
- event, bt_event_class_common_get_name(event->common.class),
- bt_event_class_common_get_id(event->common.class));
+ event, bt_event_class_get_name(event->class),
+ bt_event_class_get_id(event->class));
goto end;
}
return packet;
}
-BT_HIDDEN
-void _bt_event_set_is_frozen(struct bt_event *event, bool is_frozen)
-{
- bt_event_common_set_is_frozen(BT_TO_COMMON(event), is_frozen);
- BT_LOGD_STR("Freezing event's packet.");
- bt_packet_set_is_frozen(event->packet, is_frozen);
-}
-
int bt_event_move_header(struct bt_event *event,
struct bt_event_header_field *header_field)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
- BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
+ BT_ASSERT_PRE_HOT(event, "Event", ": %!+e", event);
stream_class = bt_event_class_borrow_stream_class(
bt_event_borrow_class(event));
- BT_ASSERT_PRE(stream_class->common.event_header_field_type,
+ BT_ASSERT_PRE(stream_class->event_header_field_type,
"Stream class has no event header field type: %!+S",
stream_class);
/* Recycle current header field: always exists */
- BT_ASSERT(event->common.header_field);
- bt_event_header_field_recycle(event->common.header_field,
+ BT_ASSERT(event->header_field);
+ bt_event_header_field_recycle(event->header_field,
stream_class);
/* Move new field */
- event->common.header_field = (void *) field_wrapper;
+ event->header_field = (void *) field_wrapper;
return 0;
}
static
struct bt_field_type *bt_field_type_string_copy(struct bt_field_type *ft);
-static struct bt_field_type_common_methods bt_field_type_integer_methods = {
- .freeze = bt_field_type_common_generic_freeze,
- .validate = bt_field_type_common_integer_validate,
- .set_byte_order = bt_field_type_common_integer_set_byte_order,
- .copy = (bt_field_type_common_method_copy)
+static
+int bt_field_type_integer_validate(struct bt_field_type *ft);
+
+static
+int bt_field_type_enumeration_validate_recursive(
+ struct bt_field_type *ft);
+static
+int bt_field_type_sequence_validate_recursive(
+ struct bt_field_type *ft);
+static
+int bt_field_type_array_validate_recursive(
+ struct bt_field_type *ft);
+static
+int bt_field_type_structure_validate_recursive(
+ struct bt_field_type *ft);
+static
+int bt_field_type_variant_validate_recursive(
+ struct bt_field_type *ft);
+
+static
+void bt_field_type_generic_freeze(struct bt_field_type *ft);
+
+static
+void bt_field_type_enumeration_freeze_recursive(
+ struct bt_field_type *ft);
+static
+void bt_field_type_structure_freeze_recursive(
+ struct bt_field_type *ft);
+static
+void bt_field_type_variant_freeze_recursive(
+ struct bt_field_type *ft);
+static
+void bt_field_type_array_freeze_recursive(
+ struct bt_field_type *ft);
+static
+void bt_field_type_sequence_freeze_recursive(
+ struct bt_field_type *ft);
+
+static
+void bt_field_type_integer_set_byte_order(
+ struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_enumeration_set_byte_order_recursive(
+ struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_floating_point_set_byte_order(
+ struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_structure_set_byte_order_recursive(
+ struct bt_field_type *ft,
+ enum bt_byte_order byte_order);
+static
+void bt_field_type_variant_set_byte_order_recursive(
+ struct bt_field_type *ft,
+ enum bt_byte_order byte_order);
+
+static
+void bt_field_type_array_set_byte_order_recursive(
+ struct bt_field_type *ft,
+ enum bt_byte_order byte_order);
+
+static
+void bt_field_type_sequence_set_byte_order_recursive(
+ struct bt_field_type *ft,
+ enum bt_byte_order byte_order);
+
+static
+int bt_field_type_integer_compare(struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_floating_point_compare(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_enumeration_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_string_compare(struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_structure_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_variant_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_array_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static
+int bt_field_type_sequence_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b);
+
+static struct bt_field_type_methods bt_field_type_integer_methods = {
+ .freeze = bt_field_type_generic_freeze,
+ .validate = bt_field_type_integer_validate,
+ .set_byte_order = bt_field_type_integer_set_byte_order,
+ .copy = (bt_field_type_method_copy)
bt_field_type_integer_copy,
- .compare = bt_field_type_common_integer_compare,
+ .compare = bt_field_type_integer_compare,
};
-static struct bt_field_type_common_methods bt_field_type_floating_point_methods = {
- .freeze = bt_field_type_common_generic_freeze,
+static struct bt_field_type_methods bt_field_type_floating_point_methods = {
+ .freeze = bt_field_type_generic_freeze,
.validate = NULL,
- .set_byte_order = bt_field_type_common_floating_point_set_byte_order,
- .copy = (bt_field_type_common_method_copy)
+ .set_byte_order = bt_field_type_floating_point_set_byte_order,
+ .copy = (bt_field_type_method_copy)
bt_field_type_floating_point_copy,
- .compare = bt_field_type_common_floating_point_compare,
+ .compare = bt_field_type_floating_point_compare,
};
-static struct bt_field_type_common_methods bt_field_type_enumeration_methods = {
- .freeze = bt_field_type_common_enumeration_freeze_recursive,
- .validate = bt_field_type_common_enumeration_validate_recursive,
- .set_byte_order = bt_field_type_common_enumeration_set_byte_order_recursive,
- .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_enumeration_methods = {
+ .freeze = bt_field_type_enumeration_freeze_recursive,
+ .validate = bt_field_type_enumeration_validate_recursive,
+ .set_byte_order = bt_field_type_enumeration_set_byte_order_recursive,
+ .copy = (bt_field_type_method_copy)
bt_field_type_enumeration_copy_recursive,
- .compare = bt_field_type_common_enumeration_compare_recursive,
+ .compare = bt_field_type_enumeration_compare_recursive,
};
-static struct bt_field_type_common_methods bt_field_type_string_methods = {
- .freeze = bt_field_type_common_generic_freeze,
+static struct bt_field_type_methods bt_field_type_string_methods = {
+ .freeze = bt_field_type_generic_freeze,
.validate = NULL,
.set_byte_order = NULL,
- .copy = (bt_field_type_common_method_copy)
+ .copy = (bt_field_type_method_copy)
bt_field_type_string_copy,
- .compare = bt_field_type_common_string_compare,
+ .compare = bt_field_type_string_compare,
};
-static struct bt_field_type_common_methods bt_field_type_array_methods = {
- .freeze = bt_field_type_common_array_freeze_recursive,
- .validate = bt_field_type_common_array_validate_recursive,
- .set_byte_order = bt_field_type_common_array_set_byte_order_recursive,
- .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_array_methods = {
+ .freeze = bt_field_type_array_freeze_recursive,
+ .validate = bt_field_type_array_validate_recursive,
+ .set_byte_order = bt_field_type_array_set_byte_order_recursive,
+ .copy = (bt_field_type_method_copy)
bt_field_type_array_copy_recursive,
- .compare = bt_field_type_common_array_compare_recursive,
+ .compare = bt_field_type_array_compare_recursive,
};
-static struct bt_field_type_common_methods bt_field_type_sequence_methods = {
- .freeze = bt_field_type_common_sequence_freeze_recursive,
- .validate = bt_field_type_common_sequence_validate_recursive,
- .set_byte_order = bt_field_type_common_sequence_set_byte_order_recursive,
- .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_sequence_methods = {
+ .freeze = bt_field_type_sequence_freeze_recursive,
+ .validate = bt_field_type_sequence_validate_recursive,
+ .set_byte_order = bt_field_type_sequence_set_byte_order_recursive,
+ .copy = (bt_field_type_method_copy)
bt_field_type_sequence_copy_recursive,
- .compare = bt_field_type_common_sequence_compare_recursive,
+ .compare = bt_field_type_sequence_compare_recursive,
};
-static struct bt_field_type_common_methods bt_field_type_structure_methods = {
- .freeze = bt_field_type_common_structure_freeze_recursive,
- .validate = bt_field_type_common_structure_validate_recursive,
- .set_byte_order = bt_field_type_common_structure_set_byte_order_recursive,
- .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_structure_methods = {
+ .freeze = bt_field_type_structure_freeze_recursive,
+ .validate = bt_field_type_structure_validate_recursive,
+ .set_byte_order = bt_field_type_structure_set_byte_order_recursive,
+ .copy = (bt_field_type_method_copy)
bt_field_type_structure_copy_recursive,
- .compare = bt_field_type_common_structure_compare_recursive,
+ .compare = bt_field_type_structure_compare_recursive,
};
-static struct bt_field_type_common_methods bt_field_type_variant_methods = {
- .freeze = bt_field_type_common_variant_freeze_recursive,
- .validate = bt_field_type_common_variant_validate_recursive,
- .set_byte_order = bt_field_type_common_variant_set_byte_order_recursive,
- .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_variant_methods = {
+ .freeze = bt_field_type_variant_freeze_recursive,
+ .validate = bt_field_type_variant_validate_recursive,
+ .set_byte_order = bt_field_type_variant_set_byte_order_recursive,
+ .copy = (bt_field_type_method_copy)
bt_field_type_variant_copy_recursive,
- .compare = bt_field_type_common_variant_compare_recursive,
+ .compare = bt_field_type_variant_compare_recursive,
};
static
g_free(mapping);
}
-BT_HIDDEN
-void bt_field_type_common_initialize(struct bt_field_type_common *ft,
+static
+void bt_field_type_initialize(struct bt_field_type *ft,
bool init_bo, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
BT_ASSERT(ft && (ft->id > BT_FIELD_TYPE_ID_UNKNOWN) &&
(ft->id < BT_FIELD_TYPE_ID_NR));
BT_LOGD("Setting initial field type's byte order: bo=%s",
bt_common_byte_order_string(bo));
- ret = bt_field_type_common_set_byte_order(ft, bo);
+ ret = bt_field_type_set_byte_order(ft, bo);
BT_ASSERT(ret == 0);
}
ft->alignment = 1;
}
-BT_HIDDEN
-void bt_field_type_common_integer_initialize(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_integer_initialize(
+ struct bt_field_type *ft,
unsigned int size, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT(size > 0);
- BT_LOGD("Initializing common integer field type object: size=%u",
+ BT_LOGD("Initializing integer field type object: size=%u",
size);
ft->id = BT_FIELD_TYPE_ID_INTEGER;
int_ft->size = size;
int_ft->base = BT_INTEGER_BASE_DECIMAL;
int_ft->encoding = BT_STRING_ENCODING_NONE;
- bt_field_type_common_initialize(ft, true, release_func, methods);
- BT_LOGD("Initialized common integer field type object: addr=%p, size=%u",
+ bt_field_type_initialize(ft, true, release_func, methods);
+ BT_LOGD("Initialized integer field type object: addr=%p, size=%u",
ft, size);
}
-BT_HIDDEN
-void bt_field_type_common_floating_point_initialize(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_floating_point_initialize(
+ struct bt_field_type *ft,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
- BT_LOGD_STR("Initializing common floating point number field type object.");
+ BT_LOGD_STR("Initializing floating point number field type object.");
ft->id = BT_FIELD_TYPE_ID_FLOAT;
flt_ft->exp_dig = sizeof(float) * CHAR_BIT - FLT_MANT_DIG;
flt_ft->mant_dig = FLT_MANT_DIG;
- bt_field_type_common_initialize(ft, true, release_func, methods);
- BT_LOGD("Initialized common floating point number field type object: addr=%p, "
+ bt_field_type_initialize(ft, true, release_func, methods);
+ BT_LOGD("Initialized floating point number field type object: addr=%p, "
"exp-size=%u, mant-size=%u", ft, flt_ft->exp_dig,
flt_ft->mant_dig);
}
-BT_HIDDEN
-void bt_field_type_common_enumeration_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *container_ft,
+static
+void bt_field_type_enumeration_initialize(
+ struct bt_field_type *ft,
+ struct bt_field_type *container_ft,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
BT_ASSERT(container_ft);
- BT_LOGD("Initializing common enumeration field type object: int-ft-addr=%p",
+ BT_LOGD("Initializing enumeration field type object: int-ft-addr=%p",
container_ft);
ft->id = BT_FIELD_TYPE_ID_ENUM;
enum_ft->container_ft = bt_get(container_ft);
enum_ft->entries = g_ptr_array_new_with_free_func(
(GDestroyNotify) destroy_enumeration_mapping);
- bt_field_type_common_initialize(ft, false, release_func, methods);
- BT_LOGD("Initialized common enumeration field type object: addr=%p, "
+ bt_field_type_initialize(ft, false, release_func, methods);
+ BT_LOGD("Initialized enumeration field type object: addr=%p, "
"int-ft-addr=%p, int-ft-size=%u", ft, container_ft,
- bt_field_type_common_integer_get_size(container_ft));
+ bt_field_type_integer_get_size(container_ft));
}
-BT_HIDDEN
-void bt_field_type_common_string_initialize(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_string_initialize(
+ struct bt_field_type *ft,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_string *string_ft = (void *) ft;
- BT_LOGD_STR("Initializing common string field type object.");
+ BT_LOGD_STR("Initializing string field type object.");
ft->id = BT_FIELD_TYPE_ID_STRING;
- bt_field_type_common_initialize(ft, true, release_func, methods);
+ bt_field_type_initialize(ft, true, release_func, methods);
string_ft->encoding = BT_STRING_ENCODING_UTF8;
ft->alignment = CHAR_BIT;
- BT_LOGD("Initialized common string field type object: addr=%p", ft);
+ BT_LOGD("Initialized string field type object: addr=%p", ft);
}
-BT_HIDDEN
-void bt_field_type_common_structure_initialize(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_structure_initialize(
+ struct bt_field_type *ft,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
- BT_LOGD_STR("Initializing common structure field type object.");
+ BT_LOGD_STR("Initializing structure field type object.");
ft->id = BT_FIELD_TYPE_ID_STRUCT;
struct_ft->fields = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_common_structure_field));
+ sizeof(struct bt_field_type_structure_field));
struct_ft->field_name_to_index = g_hash_table_new(NULL, NULL);
- bt_field_type_common_initialize(ft, true, release_func, methods);
- BT_LOGD("Initialized common structure field type object: addr=%p", ft);
+ bt_field_type_initialize(ft, true, release_func, methods);
+ BT_LOGD("Initialized structure field type object: addr=%p", ft);
}
-BT_HIDDEN
-void bt_field_type_common_array_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft,
+static
+void bt_field_type_array_initialize(
+ struct bt_field_type *ft,
+ struct bt_field_type *element_ft,
unsigned int length, bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
BT_ASSERT(element_ft);
- BT_LOGD("Initializing common array field type object: element-ft-addr=%p, "
+ BT_LOGD("Initializing array field type object: element-ft-addr=%p, "
"length=%u", element_ft, length);
ft->id = BT_FIELD_TYPE_ID_ARRAY;
array_ft->element_ft = bt_get(element_ft);
array_ft->length = length;
- bt_field_type_common_initialize(ft, false, release_func, methods);
- BT_LOGD("Initialized common array field type object: addr=%p, "
+ bt_field_type_initialize(ft, false, release_func, methods);
+ BT_LOGD("Initialized array field type object: addr=%p, "
"element-ft-addr=%p, length=%u", ft, element_ft, length);
}
-BT_HIDDEN
-void bt_field_type_common_sequence_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft,
+static
+void bt_field_type_sequence_initialize(
+ struct bt_field_type *ft,
+ struct bt_field_type *element_ft,
const char *length_field_name,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
BT_ASSERT(element_ft);
BT_ASSERT(length_field_name);
BT_ASSERT(bt_identifier_is_valid(length_field_name));
- BT_LOGD("Initializing common sequence field type object: element-ft-addr=%p, "
+ BT_LOGD("Initializing sequence field type object: element-ft-addr=%p, "
"length-field-name=\"%s\"", element_ft, length_field_name);
ft->id = BT_FIELD_TYPE_ID_SEQUENCE;
seq_ft->element_ft = bt_get(element_ft);
seq_ft->length_field_name = g_string_new(length_field_name);
- bt_field_type_common_initialize(ft, false, release_func, methods);
- BT_LOGD("Initialized common sequence field type object: addr=%p, "
+ bt_field_type_initialize(ft, false, release_func, methods);
+ BT_LOGD("Initialized sequence field type object: addr=%p, "
"element-ft-addr=%p, length-field-name=\"%s\"",
ft, element_ft, length_field_name);
}
-BT_HIDDEN
-void bt_field_type_common_variant_initialize(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *tag_ft,
+static
+void bt_field_type_variant_initialize(
+ struct bt_field_type *ft,
+ struct bt_field_type *tag_ft,
const char *tag_name,
bt_object_release_func release_func,
- struct bt_field_type_common_methods *methods)
+ struct bt_field_type_methods *methods)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
BT_ASSERT(!tag_name || bt_identifier_is_valid(tag_name));
- BT_LOGD("Initializing common variant field type object: "
+ BT_LOGD("Initializing variant field type object: "
"tag-ft-addr=%p, tag-field-name=\"%s\"",
tag_ft, tag_name);
ft->id = BT_FIELD_TYPE_ID_VARIANT;
var_ft->tag_name = g_string_new(tag_name);
var_ft->choice_name_to_index = g_hash_table_new(NULL, NULL);
var_ft->choices = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_common_variant_choice));
+ sizeof(struct bt_field_type_variant_choice));
if (tag_ft) {
var_ft->tag_ft = bt_get(tag_ft);
}
- bt_field_type_common_initialize(ft, true, release_func, methods);
+ bt_field_type_initialize(ft, true, release_func, methods);
/* A variant's alignment is undefined */
ft->alignment = 0;
- BT_LOGD("Initialized common variant field type object: addr=%p, "
+ BT_LOGD("Initialized variant field type object: addr=%p, "
"tag-ft-addr=%p, tag-field-name=\"%s\"",
ft, tag_ft, tag_name);
}
-BT_HIDDEN
-void bt_field_type_common_integer_destroy(struct bt_object *obj)
+static
+void bt_field_type_integer_destroy(struct bt_object *obj)
{
- struct bt_field_type_common_integer *ft = (void *) obj;
+ struct bt_field_type_integer *ft = (void *) obj;
if (!ft) {
return;
g_free(ft);
}
-BT_HIDDEN
-void bt_field_type_common_floating_point_destroy(struct bt_object *obj)
+static
+void bt_field_type_floating_point_destroy(struct bt_object *obj)
{
- struct bt_field_type_common_floating_point *ft = (void *) obj;
+ struct bt_field_type_floating_point *ft = (void *) obj;
if (!ft) {
return;
g_free(ft);
}
-BT_HIDDEN
-void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_enumeration_destroy_recursive(struct bt_object *obj)
{
- struct bt_field_type_common_enumeration *ft = (void *) obj;
+ struct bt_field_type_enumeration *ft = (void *) obj;
if (!ft) {
return;
g_free(ft);
}
-BT_HIDDEN
-void bt_field_type_common_string_destroy(struct bt_object *obj)
+static
+void bt_field_type_string_destroy(struct bt_object *obj)
{
- struct bt_field_type_common_string *ft = (void *) obj;
+ struct bt_field_type_string *ft = (void *) obj;
if (!ft) {
return;
}
static
-void bt_field_type_common_structure_field_finalize(
- struct bt_field_type_common_structure_field *field)
+void bt_field_type_structure_field_finalize(
+ struct bt_field_type_structure_field *field)
{
if (!field) {
return;
bt_put(field->type);
}
-BT_HIDDEN
-void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_structure_destroy_recursive(struct bt_object *obj)
{
- struct bt_field_type_common_structure *ft = (void *) obj;
+ struct bt_field_type_structure *ft = (void *) obj;
uint64_t i;
if (!ft) {
if (ft->fields) {
for (i = 0; i < ft->fields->len; i++) {
- bt_field_type_common_structure_field_finalize(
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ bt_field_type_structure_field_finalize(
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
ft, i));
}
g_free(ft);
}
-BT_HIDDEN
-void bt_field_type_common_array_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_array_destroy_recursive(struct bt_object *obj)
{
- struct bt_field_type_common_array *ft = (void *) obj;
+ struct bt_field_type_array *ft = (void *) obj;
if (!ft) {
return;
g_free(ft);
}
-BT_HIDDEN
-void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_sequence_destroy_recursive(struct bt_object *obj)
{
- struct bt_field_type_common_sequence *ft = (void *) obj;
+ struct bt_field_type_sequence *ft = (void *) obj;
if (!ft) {
return;
}
static
-void bt_field_type_common_variant_choice_finalize(
- struct bt_field_type_common_variant_choice *choice)
+void bt_field_type_variant_choice_finalize(
+ struct bt_field_type_variant_choice *choice)
{
if (!choice) {
return;
}
}
-BT_HIDDEN
-void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_variant_destroy_recursive(struct bt_object *obj)
{
- struct bt_field_type_common_variant *ft = (void *) obj;
+ struct bt_field_type_variant *ft = (void *) obj;
uint64_t i;
if (!ft) {
if (ft->choices) {
for (i = 0; i < ft->choices->len; i++) {
- bt_field_type_common_variant_choice_finalize(
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ bt_field_type_variant_choice_finalize(
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
ft, i));
}
GQuark mapping_name;
};
-static
-void check_ranges_overlap(gpointer element, gpointer query)
-{
- struct enumeration_mapping *mapping = element;
- struct range_overlap_query *overlap_query = query;
-
- if (mapping->range_start._signed <= overlap_query->range_end._signed
- && overlap_query->range_start._signed <=
- mapping->range_end._signed) {
- overlap_query->overlaps = 1;
- overlap_query->mapping_name = mapping->string;
- }
-
- overlap_query->overlaps |=
- mapping->string == overlap_query->mapping_name;
-
- if (overlap_query->overlaps) {
- BT_LOGV("Overlapping enumeration field type mappings: "
- "mapping-name=\"%s\", "
- "mapping-a-range-start=%" PRId64 ", "
- "mapping-a-range-end=%" PRId64 ", "
- "mapping-b-range-start=%" PRId64 ", "
- "mapping-b-range-end=%" PRId64,
- g_quark_to_string(mapping->string),
- mapping->range_start._signed,
- mapping->range_end._signed,
- overlap_query->range_start._signed,
- overlap_query->range_end._signed);
- }
-}
-
-static
-void check_ranges_overlap_unsigned(gpointer element, gpointer query)
-{
- struct enumeration_mapping *mapping = element;
- struct range_overlap_query *overlap_query = query;
-
- if (mapping->range_start._unsigned <= overlap_query->range_end._unsigned
- && overlap_query->range_start._unsigned <=
- mapping->range_end._unsigned) {
- overlap_query->overlaps = 1;
- overlap_query->mapping_name = mapping->string;
- }
-
- overlap_query->overlaps |=
- mapping->string == overlap_query->mapping_name;
-
- if (overlap_query->overlaps) {
- BT_LOGW("Overlapping enumeration field type mappings: "
- "mapping-name=\"%s\", "
- "mapping-a-range-start=%" PRIu64 ", "
- "mapping-a-range-end=%" PRIu64 ", "
- "mapping-b-range-start=%" PRIu64 ", "
- "mapping-b-range-end=%" PRIu64,
- g_quark_to_string(mapping->string),
- mapping->range_start._unsigned,
- mapping->range_end._unsigned,
- overlap_query->range_start._unsigned,
- overlap_query->range_end._unsigned);
- }
-}
-
static
gint compare_enumeration_mappings_signed(struct enumeration_mapping **a,
struct enumeration_mapping **b)
static
int add_structure_variant_member(GArray *members,
GHashTable *field_name_to_index,
- struct bt_field_type_common *field_type, const char *field_name,
+ struct bt_field_type *field_type, const char *field_name,
bool is_variant)
{
int ret = 0;
GQuark name_quark = g_quark_from_string(field_name);
- struct bt_field_type_common **member_ft;
+ struct bt_field_type **member_ft;
GQuark *member_name;
/* Make sure structure does not contain a field of the same name */
g_array_set_size(members, members->len + 1);
if (is_variant) {
- struct bt_field_type_common_variant_choice *choice =
+ struct bt_field_type_variant_choice *choice =
&g_array_index(members,
- struct bt_field_type_common_variant_choice,
+ struct bt_field_type_variant_choice,
members->len - 1);
member_ft = &choice->type;
member_name = &choice->name;
BT_ASSERT(!choice->ranges);
choice->ranges = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_common_variant_choice_range));
+ sizeof(struct bt_field_type_variant_choice_range));
BT_ASSERT(choice->ranges);
} else {
- struct bt_field_type_common_structure_field *field =
+ struct bt_field_type_structure_field *field =
&g_array_index(members,
- struct bt_field_type_common_structure_field,
+ struct bt_field_type_structure_field,
members->len - 1);
member_ft = &field->type;
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_integer_validate(struct bt_field_type_common *ft)
+static
+int bt_field_type_integer_validate(struct bt_field_type *ft)
{
int ret = 0;
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
if (int_ft->mapped_clock_class && int_ft->is_signed) {
BT_LOGW("Invalid integer field type: cannot be signed and have a mapped clock class: "
}
static
-struct enumeration_mapping *bt_field_type_common_enumeration_get_mapping_by_index(
- struct bt_field_type_common *ft, uint64_t index)
+struct enumeration_mapping *bt_field_type_enumeration_get_mapping_by_index(
+ struct bt_field_type *ft, uint64_t index)
{
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
struct enumeration_mapping *mapping = NULL;
if (index >= enum_ft->entries->len) {
* Only used when freezing an enumeration.
*/
static
-void bt_field_type_common_enumeration_set_range_overlap(
- struct bt_field_type_common_enumeration *ft)
+void bt_field_type_enumeration_set_range_overlap(
+ struct bt_field_type_enumeration *ft)
{
int64_t i, j, len;
int is_signed;
BT_LOGV("Setting enumeration field type's overlap flag: addr=%p",
ft);
len = ft->entries->len;
- is_signed = bt_field_type_common_integer_is_signed(
- BT_TO_COMMON(ft->container_ft));
+ is_signed = bt_field_type_integer_is_signed((void *) ft->container_ft);
for (i = 0; i < len; i++) {
for (j = i + 1; j < len; j++) {
struct enumeration_mapping *mapping[2];
- mapping[0] = bt_field_type_common_enumeration_get_mapping_by_index(
- BT_TO_COMMON(ft), i);
- mapping[1] = bt_field_type_common_enumeration_get_mapping_by_index(
- BT_TO_COMMON(ft), j);
+ mapping[0] = bt_field_type_enumeration_get_mapping_by_index(
+ (void *) ft, i);
+ mapping[1] = bt_field_type_enumeration_get_mapping_by_index(
+ (void *) ft, j);
if (is_signed) {
if (mapping[0]->range_start._signed
<= mapping[1]->range_end._signed
}
}
-BT_HIDDEN
-int bt_field_type_common_enumeration_validate_recursive(
- struct bt_field_type_common *ft)
+static
+int bt_field_type_enumeration_validate_recursive(
+ struct bt_field_type *ft)
{
int ret = 0;
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
- ret = bt_field_type_common_integer_validate(
- BT_TO_COMMON(enum_ft->container_ft));
+ ret = bt_field_type_integer_validate((void *) enum_ft->container_ft);
if (ret) {
BT_LOGW("Invalid enumeration field type: container type is invalid: "
"enum-ft-addr=%p, int-ft-addr=%p",
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_sequence_validate_recursive(
- struct bt_field_type_common *ft)
+static
+int bt_field_type_sequence_validate_recursive(
+ struct bt_field_type *ft)
{
int ret = 0;
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
/* Length field name should be set at this point */
if (seq_ft->length_field_name->len == 0) {
goto end;
}
- ret = bt_field_type_common_validate(seq_ft->element_ft);
+ ret = bt_field_type_validate(seq_ft->element_ft);
if (ret) {
BT_LOGW("Invalid sequence field type: invalid element field type: "
"seq-ft-addr=%p, element-ft-add=%p",
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_array_validate_recursive(
- struct bt_field_type_common *ft)
+static
+int bt_field_type_array_validate_recursive(
+ struct bt_field_type *ft)
{
int ret = 0;
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
- ret = bt_field_type_common_validate(array_ft->element_ft);
+ ret = bt_field_type_validate(array_ft->element_ft);
if (ret) {
BT_LOGW("Invalid array field type: invalid element field type: "
"array-ft-addr=%p, element-ft-add=%p",
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_structure_validate_recursive(
- struct bt_field_type_common *ft)
+static
+int bt_field_type_structure_validate_recursive(
+ struct bt_field_type *ft)
{
int ret = 0;
- struct bt_field_type_common *child_ft = NULL;
+ struct bt_field_type *child_ft = NULL;
int64_t field_count =
- bt_field_type_common_structure_get_field_count(ft);
+ bt_field_type_structure_get_field_count(ft);
int64_t i;
BT_ASSERT(field_count >= 0);
for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_structure_borrow_field_by_index(ft,
+ ret = bt_field_type_structure_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
- ret = bt_field_type_common_validate(child_ft);
+ ret = bt_field_type_validate(child_ft);
if (ret) {
BT_LOGW("Invalid structure field type: "
"a contained field type is invalid: "
}
static
-bt_bool bt_field_type_common_enumeration_has_overlapping_ranges(
- struct bt_field_type_common_enumeration *enum_ft)
+bt_bool bt_field_type_enumeration_has_overlapping_ranges(
+ struct bt_field_type_enumeration *enum_ft)
{
if (!enum_ft->common.frozen) {
- bt_field_type_common_enumeration_set_range_overlap(enum_ft);
+ bt_field_type_enumeration_set_range_overlap(enum_ft);
}
return enum_ft->has_overlapping_ranges;
}
-BT_HIDDEN
-int bt_field_type_common_variant_validate_recursive(
- struct bt_field_type_common *ft)
+static
+int bt_field_type_variant_validate_recursive(
+ struct bt_field_type *ft)
{
int ret = 0;
int64_t field_count;
- struct bt_field_type_common *child_ft = NULL;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type *child_ft = NULL;
+ struct bt_field_type_variant *var_ft = (void *) ft;
int64_t i;
if (var_ft->tag_name->len == 0) {
goto end;
}
- if (bt_field_type_common_enumeration_has_overlapping_ranges(var_ft->tag_ft)) {
+ if (bt_field_type_enumeration_has_overlapping_ranges(var_ft->tag_ft)) {
BT_LOGW("Invalid variant field type: enumeration tag field type has overlapping ranges: "
"variant-ft-addr=%p, tag-field-name=\"%s\", "
"enum-ft-addr=%p", ft, var_ft->tag_name->str,
* enumeration while reading a variant field, an error will be
* generated at that point (while reading the stream).
*/
- field_count = bt_field_type_common_variant_get_field_count(ft);
+ field_count = bt_field_type_variant_get_field_count(ft);
if (field_count < 0) {
BT_LOGW("Invalid variant field type: no fields: "
"addr=%p, tag-field-name=\"%s\"",
for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_variant_borrow_field_by_index(ft,
+ ret = bt_field_type_variant_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
- ret = bt_field_type_common_validate(child_ft);
+ ret = bt_field_type_validate(child_ft);
if (ret) {
BT_LOGW("Invalid variant field type: "
"a contained field type is invalid: "
* applicable.
*/
BT_HIDDEN
-int bt_field_type_common_validate(struct bt_field_type_common *ft)
+int bt_field_type_validate(struct bt_field_type *ft)
{
int ret = 0;
struct bt_field_type *bt_field_type_integer_create(unsigned int size)
{
- struct bt_field_type_common_integer *integer = NULL;
+ struct bt_field_type_integer *integer = NULL;
BT_LOGD("Creating integer field type object: size=%u", size);
goto error;
}
- integer = g_new0(struct bt_field_type_common_integer, 1);
+ integer = g_new0(struct bt_field_type_integer, 1);
if (!integer) {
BT_LOGE_STR("Failed to allocate one integer field type.");
goto error;
}
- bt_field_type_common_integer_initialize(BT_TO_COMMON(integer),
- size, bt_field_type_common_integer_destroy,
+ bt_field_type_integer_initialize((void *) integer,
+ size, bt_field_type_integer_destroy,
&bt_field_type_integer_methods);
BT_LOGD("Created integer field type object: addr=%p, size=%u",
integer, size);
return (void *) integer;
}
-BT_HIDDEN
-int bt_field_type_common_integer_get_size(struct bt_field_type_common *ft)
+
+int bt_field_type_integer_get_size(struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
return (int) int_ft->size;
}
-int bt_field_type_integer_get_size(struct bt_field_type *ft)
-{
- return bt_field_type_common_integer_get_size((void *) ft);
-}
-
-BT_HIDDEN
-bt_bool bt_field_type_common_integer_is_signed(struct bt_field_type_common *ft)
+bt_bool bt_field_type_integer_is_signed(struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
return int_ft->is_signed;
}
-bt_bool bt_field_type_integer_is_signed(struct bt_field_type *ft)
-{
- return bt_field_type_common_integer_is_signed((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_is_signed(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_is_signed(struct bt_field_type *ft,
bt_bool is_signed)
{
int ret = 0;
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_integer_set_is_signed(struct bt_field_type *ft,
- bt_bool is_signed)
-{
- return bt_field_type_common_integer_set_is_signed((void *) ft,
- is_signed);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_size(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_size(struct bt_field_type *ft,
unsigned int size)
{
int ret = 0;
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_integer_set_size(struct bt_field_type *ft,
- unsigned int size)
-{
- return bt_field_type_common_integer_set_size((void *) ft, size);
-}
-
-BT_HIDDEN
-enum bt_integer_base bt_field_type_common_integer_get_base(
- struct bt_field_type_common *ft)
+enum bt_integer_base bt_field_type_integer_get_base(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
return int_ft->base;
}
-enum bt_integer_base bt_field_type_integer_get_base(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_integer_get_base((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_base(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_base(struct bt_field_type *ft,
enum bt_integer_base base)
{
int ret = 0;
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_integer_set_base(struct bt_field_type *ft,
- enum bt_integer_base base)
-{
- return bt_field_type_common_integer_set_base((void *) ft, base);
-}
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_integer_get_encoding(
- struct bt_field_type_common *ft)
+enum bt_string_encoding bt_field_type_integer_get_encoding(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
return int_ft->encoding;
}
-enum bt_string_encoding bt_field_type_integer_get_encoding(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_integer_get_encoding((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_encoding(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_encoding(struct bt_field_type *ft,
enum bt_string_encoding encoding)
{
int ret = 0;
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_integer_set_encoding(struct bt_field_type *ft,
- enum bt_string_encoding encoding)
-{
- return bt_field_type_common_integer_set_encoding((void *) ft, encoding);
-}
-
-BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
- struct bt_field_type_common *ft)
+struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
return int_ft->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_borrow_mapped_clock_class(
- (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
- struct bt_field_type_common *ft,
+static
+int bt_field_type_integer_set_mapped_clock_class_no_check_frozen(
+ struct bt_field_type *ft,
struct bt_clock_class *clock_class)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
int ret = 0;
if (!clock_class) {
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class(
- struct bt_field_type_common *ft,
+int bt_field_type_integer_set_mapped_clock_class(struct bt_field_type *ft,
struct bt_clock_class *clock_class)
{
int ret = 0;
goto end;
}
- ret = bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
+ ret = bt_field_type_integer_set_mapped_clock_class_no_check_frozen(
ft, clock_class);
end:
return ret;
}
-int bt_field_type_integer_set_mapped_clock_class(struct bt_field_type *ft,
- struct bt_clock_class *clock_class)
-{
- return bt_field_type_common_integer_set_mapped_clock_class((void *) ft,
- clock_class);
-}
-
static
void bt_field_type_enum_iter_destroy(struct bt_object *obj)
{
static
struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_find_mappings_type(
- struct bt_field_type_common *ft,
+bt_field_type_enumeration_find_mappings_type(
+ struct bt_field_type *ft,
enum bt_field_type_enumeration_mapping_iterator_type iterator_type)
{
struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM,
"Field type");
iter = g_new0(struct bt_field_type_enumeration_mapping_iterator, 1);
if (!iter) {
return iter;
}
-BT_HIDDEN
struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_find_mappings_by_name(
- struct bt_field_type_common *ft, const char *name)
+bt_field_type_enumeration_find_mappings_by_name(
+ struct bt_field_type *ft, const char *name)
{
struct bt_field_type_enumeration_mapping_iterator *iter;
- iter = bt_field_type_common_enumeration_find_mappings_type(
+ iter = bt_field_type_enumeration_find_mappings_type(
ft, ITERATOR_BY_NAME);
if (!iter) {
BT_LOGW("Cannot create enumeration field type mapping iterator: "
return NULL;
}
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_find_mappings_by_name(
- struct bt_field_type *ft, const char *name)
-{
- return bt_field_type_common_enumeration_find_mappings_by_name(
- (void *) ft, name);
-}
-
int bt_field_type_enumeration_mapping_iterator_next(
struct bt_field_type_enumeration_mapping_iterator *iter)
{
- struct bt_field_type_common_enumeration *enum_ft = iter->enumeration_ft;
+ struct bt_field_type_enumeration *enum_ft = iter->enumeration_ft;
int i, ret = 0, len;
BT_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator");
len = enum_ft->entries->len;
for (i = iter->index + 1; i < len; i++) {
struct enumeration_mapping *mapping =
- bt_field_type_common_enumeration_get_mapping_by_index(
- BT_TO_COMMON(enum_ft), i);
+ bt_field_type_enumeration_get_mapping_by_index(
+ (void *) enum_ft, i);
switch (iter->type) {
case ITERATOR_BY_NAME:
return ret;
}
-BT_HIDDEN
struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_signed_find_mappings_by_value(
- struct bt_field_type_common *ft, int64_t value)
+bt_field_type_enumeration_signed_find_mappings_by_value(
+ struct bt_field_type *ft, int64_t value)
{
struct bt_field_type_enumeration_mapping_iterator *iter;
- iter = bt_field_type_common_enumeration_find_mappings_type(
+ iter = bt_field_type_enumeration_find_mappings_type(
ft, ITERATOR_BY_SIGNED_VALUE);
if (!iter) {
BT_LOGW("Cannot create enumeration field type mapping iterator: "
goto error;
}
- if (bt_field_type_common_integer_is_signed(
- BT_TO_COMMON(iter->enumeration_ft->container_ft)) != 1) {
+ if (bt_field_type_integer_is_signed(
+ (void *) iter->enumeration_ft->container_ft) != 1) {
BT_LOGW("Invalid parameter: enumeration field type is unsigned: "
"enum-ft-addr=%p, int-ft-addr=%p",
ft, iter->enumeration_ft->container_ft);
}
struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_signed_find_mappings_by_value(
- struct bt_field_type *ft, int64_t value)
-{
- return bt_field_type_common_enumeration_signed_find_mappings_by_value(
- (void *) ft, value);
-}
-
-BT_HIDDEN
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
- struct bt_field_type_common *ft, uint64_t value)
+bt_field_type_enumeration_unsigned_find_mappings_by_value(
+ struct bt_field_type *ft, uint64_t value)
{
struct bt_field_type_enumeration_mapping_iterator *iter;
- iter = bt_field_type_common_enumeration_find_mappings_type(
+ iter = bt_field_type_enumeration_find_mappings_type(
ft, ITERATOR_BY_UNSIGNED_VALUE);
if (!iter) {
BT_LOGW("Cannot create enumeration field type mapping iterator: "
goto error;
}
- if (bt_field_type_common_integer_is_signed(
- BT_TO_COMMON(iter->enumeration_ft->container_ft)) != 0) {
+ if (bt_field_type_integer_is_signed(
+ (void *) iter->enumeration_ft->container_ft) != 0) {
BT_LOGW("Invalid parameter: enumeration field type is signed: "
"enum-ft-addr=%p, int-ft-addr=%p",
ft, iter->enumeration_ft->container_ft);
return NULL;
}
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_unsigned_find_mappings_by_value(
- struct bt_field_type *ft, uint64_t value)
-{
- return bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
- (void *) ft, value);
-}
-
int bt_field_type_enumeration_mapping_iterator_signed_get(
struct bt_field_type_enumeration_mapping_iterator *iter,
const char **mapping_name, int64_t *range_begin,
BT_ASSERT_PRE(iter->index != -1,
"Invalid enumeration field type mapping iterator access: "
"addr=%p, position=-1", iter);
- return bt_field_type_common_enumeration_signed_get_mapping_by_index(
+ return bt_field_type_enumeration_signed_get_mapping_by_index(
(void *) iter->enumeration_ft, iter->index,
mapping_name, range_begin, range_end);
}
BT_ASSERT_PRE(iter->index != -1,
"Invalid enumeration field type mapping iterator access: "
"addr=%p, position=-1", iter);
- return bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
+ return bt_field_type_enumeration_unsigned_get_mapping_by_index(
(void *) iter->enumeration_ft, iter->index,
mapping_name, range_begin, range_end);
}
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_get_mapping_by_index(
- struct bt_field_type_common *ft, uint64_t index,
+int bt_field_type_enumeration_signed_get_mapping_by_index(
+ struct bt_field_type *ft, uint64_t index,
const char **mapping_name, int64_t *range_begin,
int64_t *range_end)
{
struct enumeration_mapping *mapping;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft,
+ BT_ASSERT_PRE_FT_HAS_ID(ft,
BT_FIELD_TYPE_ID_ENUM, "Field type");
- mapping = bt_field_type_common_enumeration_get_mapping_by_index(ft,
+ mapping = bt_field_type_enumeration_get_mapping_by_index(ft,
index);
if (!mapping) {
- /* bt_field_type_common_enumeration_get_mapping_by_index() logs errors */
+ /* bt_field_type_enumeration_get_mapping_by_index() logs errors */
ret = -1;
goto end;
}
return ret;
}
-int bt_field_type_enumeration_signed_get_mapping_by_index(
+int bt_field_type_enumeration_unsigned_get_mapping_by_index(
struct bt_field_type *ft, uint64_t index,
- const char **mapping_name, int64_t *range_begin,
- int64_t *range_end)
-{
- return bt_field_type_common_enumeration_signed_get_mapping_by_index(
- (void *) ft, index, mapping_name, range_begin, range_end);
-}
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
- struct bt_field_type_common *ft, uint64_t index,
const char **mapping_name, uint64_t *range_begin,
uint64_t *range_end)
{
struct enumeration_mapping *mapping;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
- mapping = bt_field_type_common_enumeration_get_mapping_by_index(
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+ mapping = bt_field_type_enumeration_get_mapping_by_index(
ft, index);
if (!mapping) {
- /* bt_field_type_common_enumeration_get_mapping_by_index() reports any error */
+ /* bt_field_type_enumeration_get_mapping_by_index() reports any error */
ret = -1;
goto end;
}
return ret;
}
-int bt_field_type_enumeration_unsigned_get_mapping_by_index(
- struct bt_field_type *ft, uint64_t index,
- const char **mapping_name, uint64_t *range_begin,
- uint64_t *range_end)
-{
- return bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
- (void *) ft, index, mapping_name, range_begin, range_end);
-}
-
struct bt_field_type *bt_field_type_enumeration_create(
struct bt_field_type *container_ft)
{
- struct bt_field_type_common_enumeration *enumeration = NULL;
- struct bt_field_type_common *int_ft = (void *) container_ft;
+ struct bt_field_type_enumeration *enumeration = NULL;
+ struct bt_field_type *int_ft = (void *) container_ft;
BT_LOGD("Creating enumeration field type object: int-ft-addr=%p",
container_ft);
goto error;
}
- enumeration = g_new0(struct bt_field_type_common_enumeration, 1);
+ enumeration = g_new0(struct bt_field_type_enumeration, 1);
if (!enumeration) {
BT_LOGE_STR("Failed to allocate one enumeration field type.");
goto error;
}
- bt_field_type_common_enumeration_initialize(BT_TO_COMMON(enumeration),
- int_ft, bt_field_type_common_enumeration_destroy_recursive,
+ bt_field_type_enumeration_initialize((void *) enumeration,
+ int_ft, bt_field_type_enumeration_destroy_recursive,
&bt_field_type_enumeration_methods);
BT_LOGD("Created enumeration field type object: addr=%p, "
"int-ft-addr=%p, int-ft-size=%u",
return (void *) enumeration;
}
-BT_HIDDEN
-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_TO_COMMON(enum_ft->container_ft);
-}
-
struct bt_field_type *bt_field_type_enumeration_borrow_container_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_enumeration_borrow_container_field_type(
- (void *) ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
+
+ BT_ASSERT_PRE_NON_NULL(ft, "Field type");
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+ return (void *) enum_ft->container_ft;
}
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_add_mapping(
- struct bt_field_type_common *ft, const char *string,
+int bt_field_type_enumeration_signed_add_mapping(
+ struct bt_field_type *ft, const char *string,
int64_t range_start, int64_t range_end)
{
int ret = 0;
GQuark mapping_name;
struct enumeration_mapping *mapping;
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
char *escaped_string;
if (!ft) {
return ret;
}
-int bt_field_type_enumeration_signed_add_mapping(
+int bt_field_type_enumeration_unsigned_add_mapping(
struct bt_field_type *ft, const char *string,
- int64_t range_start, int64_t range_end)
-{
- return bt_field_type_common_enumeration_signed_add_mapping(
- (void *) ft, string, range_start, range_end);
-}
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_add_mapping(
- struct bt_field_type_common *ft, const char *string,
uint64_t range_start, uint64_t range_end)
{
int ret = 0;
GQuark mapping_name;
struct enumeration_mapping *mapping;
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
char *escaped_string;
if (!ft) {
return ret;
}
-int bt_field_type_enumeration_unsigned_add_mapping(
- struct bt_field_type *ft, const char *string,
- uint64_t range_start, uint64_t range_end)
-{
- return bt_field_type_common_enumeration_unsigned_add_mapping(
- (void *) ft, string, range_start, range_end);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_enumeration_get_mapping_count(
- struct bt_field_type_common *ft)
+int64_t bt_field_type_enumeration_get_mapping_count(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
return (int64_t) enum_ft->entries->len;
}
-int64_t bt_field_type_enumeration_get_mapping_count(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_enumeration_get_mapping_count((void *) ft);
-}
-
struct bt_field_type *bt_field_type_floating_point_create(void)
{
- struct bt_field_type_common_floating_point *floating_point =
- g_new0(struct bt_field_type_common_floating_point, 1);
+ struct bt_field_type_floating_point *floating_point =
+ g_new0(struct bt_field_type_floating_point, 1);
BT_LOGD_STR("Creating floating point number field type object.");
goto end;
}
- bt_field_type_common_floating_point_initialize(
- BT_TO_COMMON(floating_point),
- bt_field_type_common_floating_point_destroy,
+ bt_field_type_floating_point_initialize(
+ (void *) floating_point,
+ bt_field_type_floating_point_destroy,
&bt_field_type_floating_point_methods);
BT_LOGD("Created floating point number field type object: addr=%p, "
"exp-size=%u, mant-size=%u", floating_point,
return (void *) floating_point;
}
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_exponent_digits(
- struct bt_field_type_common *ft)
+int bt_field_type_floating_point_get_exponent_digits(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
"Field type");
return (int) flt_ft->exp_dig;
}
-int bt_field_type_floating_point_get_exponent_digits(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_floating_point_get_exponent_digits(
- (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_exponent_digits(
- struct bt_field_type_common *ft,
- unsigned int exponent_digits)
+int bt_field_type_floating_point_set_exponent_digits(
+ struct bt_field_type *ft, unsigned int exponent_digits)
{
int ret = 0;
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_floating_point_set_exponent_digits(
- struct bt_field_type *ft, unsigned int exponent_digits)
-{
- return bt_field_type_common_floating_point_set_exponent_digits(
- (void *) ft, exponent_digits);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_mantissa_digits(
- struct bt_field_type_common *ft)
+int bt_field_type_floating_point_get_mantissa_digits(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
"Field type");
return (int) flt_ft->mant_dig;
}
-int bt_field_type_floating_point_get_mantissa_digits(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_floating_point_get_mantissa_digits(
- (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_mantissa_digits(
- struct bt_field_type_common *ft, unsigned int mantissa_digits)
+int bt_field_type_floating_point_set_mantissa_digits(
+ struct bt_field_type *ft, unsigned int mantissa_digits)
{
int ret = 0;
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_floating_point_set_mantissa_digits(
- struct bt_field_type *ft, unsigned int mantissa_digits)
-{
- return bt_field_type_common_floating_point_set_mantissa_digits(
- (void *) ft, mantissa_digits);
-}
-
struct bt_field_type *bt_field_type_structure_create(void)
{
- struct bt_field_type_common_structure *structure =
- g_new0(struct bt_field_type_common_structure, 1);
+ struct bt_field_type_structure *structure =
+ g_new0(struct bt_field_type_structure, 1);
BT_LOGD_STR("Creating structure field type object.");
goto error;
}
- bt_field_type_common_structure_initialize(BT_TO_COMMON(structure),
- bt_field_type_common_structure_destroy_recursive,
+ bt_field_type_structure_initialize((void *) structure,
+ bt_field_type_structure_destroy_recursive,
&bt_field_type_structure_methods);
BT_LOGD("Created structure field type object: addr=%p",
structure);
return (void *) structure;
}
-BT_HIDDEN
-int bt_field_type_common_structure_replace_field(
- struct bt_field_type_common *ft,
- const char *field_name,
- struct bt_field_type_common *field_type)
-{
- int ret = 0;
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
- GQuark name_quark;
- uint64_t i;
-
- BT_ASSERT(ft);
- BT_ASSERT(field_name);
- BT_ASSERT(field_type);
- BT_ASSERT(ft->id == BT_FIELD_TYPE_ID_STRUCT);
- name_quark = g_quark_from_string(field_name);
-
- for (i = 0; i < struct_ft->fields->len; i++) {
- struct bt_field_type_common_structure_field *field =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i);
-
- if (field->name == name_quark) {
- bt_put(field->type);
- field->type = bt_get(field_type);
- }
- }
-
- return ret;
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft,
- struct bt_field_type_common *field_type,
+int bt_field_type_structure_add_field(struct bt_field_type *ft,
+ struct bt_field_type *field_type,
const char *field_name)
{
int ret = 0;
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
/*
* TODO: check that `field_type` does not contain `type`,
return ret;
}
-int bt_field_type_structure_add_field(struct bt_field_type *ft,
- struct bt_field_type *field_type,
- const char *field_name)
-{
- return bt_field_type_common_structure_add_field((void *) ft,
- (void *) field_type, field_name);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_structure_get_field_count(
- struct bt_field_type_common *ft)
+int64_t bt_field_type_structure_get_field_count(struct bt_field_type *ft)
{
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
"Field type");
return (int64_t) struct_ft->fields->len;
}
-int64_t bt_field_type_structure_get_field_count(struct bt_field_type *ft)
-{
- return bt_field_type_common_structure_get_field_count((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_borrow_field_by_index(
- struct bt_field_type_common *ft,
+int bt_field_type_structure_borrow_field_by_index(
+ struct bt_field_type *ft,
const char **field_name,
- struct bt_field_type_common **field_type, uint64_t index)
+ struct bt_field_type **field_type, uint64_t index)
{
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common_structure_field *field;
+ struct bt_field_type_structure *struct_ft = (void *) ft;
+ struct bt_field_type_structure_field *field;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
"Field type");
BT_ASSERT_PRE(index < struct_ft->fields->len,
"Index is out of bounds: index=%" PRIu64 ", "
- "count=%u, %![ft-]+_F",
+ "count=%u, %![ft-]+F",
index, struct_ft->fields->len, ft);
- field = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(struct_ft, index);
+ field = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(struct_ft, index);
if (field_type) {
*field_type = field->type;
return 0;
}
-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_borrow_field_by_index(
- (void *) ft, field_name, (void *) field_type, index);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_structure_borrow_field_type_by_name(
- struct bt_field_type_common *ft, const char *name)
+struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
+ struct bt_field_type *ft, const char *name)
{
size_t index;
GQuark name_quark;
- struct bt_field_type_common_structure_field *field;
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type_structure_field *field;
+ struct bt_field_type_structure *struct_ft = (void *) ft;
+ struct bt_field_type *field_type = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
"Field type");
name_quark = g_quark_try_string(name);
if (!name_quark) {
goto end;
}
- field = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, index);
+ field = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(ft, index);
field_type = field->type;
end:
return field_type;
}
-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_borrow_field_type_by_name(
- (void *) ft, name);
-}
-
struct bt_field_type *bt_field_type_variant_create(
struct bt_field_type *tag_ft, const char *tag_name)
{
- struct bt_field_type_common_variant *var_ft = NULL;
+ struct bt_field_type_variant *var_ft = NULL;
BT_LOGD("Creating variant field type object: "
"tag-ft-addr=%p, tag-field-name=\"%s\"",
goto error;
}
- var_ft = g_new0(struct bt_field_type_common_variant, 1);
+ var_ft = g_new0(struct bt_field_type_variant, 1);
if (!var_ft) {
BT_LOGE_STR("Failed to allocate one variant field type.");
goto error;
}
- bt_field_type_common_variant_initialize(BT_TO_COMMON(var_ft),
+ bt_field_type_variant_initialize((void *) var_ft,
(void *) tag_ft, tag_name,
- bt_field_type_common_variant_destroy_recursive,
+ bt_field_type_variant_destroy_recursive,
&bt_field_type_variant_methods);
BT_LOGD("Created variant field type object: addr=%p, "
"tag-ft-addr=%p, tag-field-name=\"%s\"",
return (void *) var_ft;
}
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_tag_field_type(
- struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common *tag_ft = NULL;
+ struct bt_field_type_variant *var_ft = (void *) ft;
+ struct bt_field_type *tag_ft = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
if (!var_ft->tag_ft) {
goto end;
}
- tag_ft = BT_TO_COMMON(var_ft->tag_ft);
+ tag_ft = (void *) var_ft->tag_ft;
end:
return tag_ft;
}
-struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
- struct bt_field_type *ft)
-{
- return (void *) bt_field_type_common_variant_borrow_tag_field_type(
- (void *) ft);
-}
-
-BT_HIDDEN
-const char *bt_field_type_common_variant_get_tag_name(
- struct bt_field_type_common *ft)
+const char *bt_field_type_variant_get_tag_name(struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
const char *tag_name = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
if (var_ft->tag_name->len == 0) {
return tag_name;
}
-const char *bt_field_type_variant_get_tag_name(struct bt_field_type *ft)
-{
- return bt_field_type_common_variant_get_tag_name((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_variant_set_tag_name(
- struct bt_field_type_common *ft, const char *name)
+int bt_field_type_variant_set_tag_name(
+ struct bt_field_type *ft, const char *name)
{
int ret = 0;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_variant_set_tag_name(
- struct bt_field_type *ft, const char *name)
-{
- return bt_field_type_common_variant_set_tag_name((void *) ft, name);
-}
-
-BT_HIDDEN
-int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft,
- struct bt_field_type_common *field_type,
+int bt_field_type_variant_add_field(struct bt_field_type *ft,
+ struct bt_field_type *field_type,
const char *field_name)
{
size_t i;
int ret = 0;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
GQuark field_name_quark = g_quark_from_string(field_name);
/*
return ret;
}
-int bt_field_type_variant_add_field(struct bt_field_type *ft,
- struct bt_field_type *field_type,
- const char *field_name)
-{
- return bt_field_type_common_variant_add_field((void *) ft,
- (void *) field_type, field_name);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_by_name(
- struct bt_field_type_common *ft,
+struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
+ struct bt_field_type *ft,
const char *field_name)
{
size_t index;
GQuark name_quark;
- struct bt_field_type_common_variant_choice *choice;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type_variant_choice *choice;
+ struct bt_field_type_variant *var_ft = (void *) ft;
+ struct bt_field_type *field_type = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_NON_NULL(field_name, "Name");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
name_quark = g_quark_try_string(field_name);
if (!name_quark) {
goto end;
}
- choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, index);
+ choice = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, index);
field_type = choice->type;
end:
return field_type;
}
-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_borrow_field_type_by_name(
- (void *) ft, field_name);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_variant_get_field_count(
- struct bt_field_type_common *ft)
+int64_t bt_field_type_variant_get_field_count(struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Variant field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
return (int64_t) var_ft->choices->len;
}
-int64_t bt_field_type_variant_get_field_count(struct bt_field_type *ft)
-{
- return bt_field_type_common_variant_get_field_count((void *) ft);
-}
-
-BT_HIDDEN
-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)
+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)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common_variant_choice *choice;
+ struct bt_field_type_variant *var_ft = (void *) ft;
+ struct bt_field_type_variant_choice *choice;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
BT_ASSERT_PRE(index < var_ft->choices->len,
"Index is out of bounds: index=%" PRIu64 ", "
- "count=%u, %![ft-]+_F",
+ "count=%u, %![ft-]+F",
index, var_ft->choices->len, ft);
- choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, index);
+ choice = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, index);
if (field_type) {
*field_type = choice->type;
return 0;
}
-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_borrow_field_by_index((void *) ft,
- field_name, (void *) field_type, index);
-}
-
BT_HIDDEN
-int64_t bt_field_type_common_variant_find_choice_index(
- struct bt_field_type_common *ft, uint64_t uval,
+int64_t bt_field_type_variant_find_choice_index(
+ struct bt_field_type *ft, uint64_t uval,
bool is_signed)
{
int64_t ret;
uint64_t i;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
BT_ASSERT(ft);
BT_ASSERT(ft->id == BT_FIELD_TYPE_ID_VARIANT);
- if (bt_field_type_common_variant_update_choices(ft)) {
+ if (bt_field_type_variant_update_choices(ft)) {
ret = INT64_C(-1);
goto end;
}
for (i = 0; i < var_ft->choices->len; i++) {
uint64_t range_i;
- struct bt_field_type_common_variant_choice *choice =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ struct bt_field_type_variant_choice *choice =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
var_ft, i);
for (range_i = 0; range_i < choice->ranges->len; range_i++) {
- struct bt_field_type_common_variant_choice_range *range =
+ struct bt_field_type_variant_choice_range *range =
&g_array_index(
choice->ranges,
- struct bt_field_type_common_variant_choice_range,
+ struct bt_field_type_variant_choice_range,
range_i);
if (is_signed) {
struct bt_field_type *bt_field_type_array_create(
struct bt_field_type *element_ft, unsigned int length)
{
- struct bt_field_type_common_array *array = NULL;
+ struct bt_field_type_array *array = NULL;
BT_LOGD("Creating array field type object: element-ft-addr=%p, "
"length=%u", element_ft, length);
goto error;
}
- if (length == 0) {
- BT_LOGW_STR("Invalid parameter: length is zero.");
- goto error;
- }
-
- array = g_new0(struct bt_field_type_common_array, 1);
- if (!array) {
- BT_LOGE_STR("Failed to allocate one array field type.");
- goto error;
- }
-
- bt_field_type_common_array_initialize(BT_TO_COMMON(array),
- (void *) element_ft, length,
- bt_field_type_common_array_destroy_recursive,
- &bt_field_type_array_methods);
- BT_LOGD("Created array field type object: addr=%p, "
- "element-ft-addr=%p, length=%u",
- array, element_ft, length);
- goto end;
-
-error:
- BT_PUT(array);
-
-end:
- return (void *) array;
-}
-
-BT_HIDDEN
-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_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
- "Field type");
- BT_ASSERT(array_ft && array_ft->element_ft);
- return array_ft->element_ft;
-}
-
-struct bt_field_type *bt_field_type_array_borrow_element_field_type(
- struct bt_field_type *ft)
-{
- return (void *) bt_field_type_common_array_borrow_element_field_type(
- (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_array_set_element_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft)
-{
- int ret = 0;
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
-
- if (!ft) {
- BT_LOGW_STR("Invalid parameter: array field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!element_ft) {
- BT_LOGW_STR("Invalid parameter: element field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (ft->id != BT_FIELD_TYPE_ID_ARRAY) {
- BT_LOGW("Invalid parameter: field type is not an array field type: "
- "addr=%p, ft-id=%s", ft,
- bt_common_field_type_id_string(ft->id));
- ret = -1;
- goto end;
+ if (length == 0) {
+ BT_LOGW_STR("Invalid parameter: length is zero.");
+ goto error;
}
- if (array_ft->element_ft) {
- BT_PUT(array_ft->element_ft);
+ array = g_new0(struct bt_field_type_array, 1);
+ if (!array) {
+ BT_LOGE_STR("Failed to allocate one array field type.");
+ goto error;
}
- array_ft->element_ft = bt_get(element_ft);
- BT_LOGV("Set array field type's element field type: array-ft-addr=%p, "
- "element-ft-addr=%p", ft, element_ft);
+ bt_field_type_array_initialize((void *) array,
+ (void *) element_ft, length,
+ bt_field_type_array_destroy_recursive,
+ &bt_field_type_array_methods);
+ BT_LOGD("Created array field type object: addr=%p, "
+ "element-ft-addr=%p, length=%u",
+ array, element_ft, length);
+ goto end;
+
+error:
+ BT_PUT(array);
end:
- return ret;
+ return (void *) array;
}
-BT_HIDDEN
-int64_t bt_field_type_common_array_get_length(struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_array_borrow_element_field_type(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
"Field type");
- return (int64_t) array_ft->length;
+ BT_ASSERT(array_ft && array_ft->element_ft);
+ return array_ft->element_ft;
}
int64_t bt_field_type_array_get_length(struct bt_field_type *ft)
{
- return bt_field_type_common_array_get_length((void *) ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
+
+ BT_ASSERT_PRE_NON_NULL(ft, "Field type");
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
+ "Field type");
+ return (int64_t) array_ft->length;
}
struct bt_field_type *bt_field_type_sequence_create(
struct bt_field_type *element_ft,
const char *length_field_name)
{
- struct bt_field_type_common_sequence *sequence = NULL;
+ struct bt_field_type_sequence *sequence = NULL;
BT_LOGD("Creating sequence field type object: element-ft-addr=%p, "
"length-field-name=\"%s\"", element_ft, length_field_name);
goto error;
}
- sequence = g_new0(struct bt_field_type_common_sequence, 1);
+ sequence = g_new0(struct bt_field_type_sequence, 1);
if (!sequence) {
BT_LOGE_STR("Failed to allocate one sequence field type.");
goto error;
}
- bt_field_type_common_sequence_initialize(BT_TO_COMMON(sequence),
+ bt_field_type_sequence_initialize((void *) sequence,
(void *) element_ft, length_field_name,
- bt_field_type_common_sequence_destroy_recursive,
+ bt_field_type_sequence_destroy_recursive,
&bt_field_type_sequence_methods);
BT_LOGD("Created sequence field type object: addr=%p, "
"element-ft-addr=%p, length-field-name=\"%s\"",
return (void *) sequence;
}
-BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_sequence_borrow_element_field_type(
- struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
return seq_ft->element_ft;
}
-struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
+const char *bt_field_type_sequence_get_length_field_name(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_sequence_borrow_element_field_type(
- (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_sequence_set_element_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *element_ft)
-{
- int ret = 0;
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
-
- if (!ft) {
- BT_LOGW_STR("Invalid parameter: sequence field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!element_ft) {
- BT_LOGW_STR("Invalid parameter: element field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (ft->id != BT_FIELD_TYPE_ID_SEQUENCE) {
- BT_LOGW("Invalid parameter: field type is not a sequence field type: "
- "addr=%p, ft-id=%s", ft,
- bt_common_field_type_id_string(ft->id));
- ret = -1;
- goto end;
- }
-
- if (seq_ft->element_ft) {
- BT_PUT(seq_ft->element_ft);
- }
-
- seq_ft->element_ft = element_ft;
- bt_get(seq_ft->element_ft);
- BT_LOGV("Set sequence field type's element field type: sequence-ft-addr=%p, "
- "element-ft-addr=%p", ft, element_ft);
-
-end:
- return ret;
-}
-
-BT_HIDDEN
-const char *bt_field_type_common_sequence_get_length_field_name(
- struct bt_field_type_common *ft)
-{
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
return seq_ft->length_field_name ?
seq_ft->length_field_name->str : NULL;
}
-const char *bt_field_type_sequence_get_length_field_name(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_sequence_get_length_field_name((void *) ft);
-}
-
struct bt_field_type *bt_field_type_string_create(void)
{
- struct bt_field_type_common_string *string =
- g_new0(struct bt_field_type_common_string, 1);
+ struct bt_field_type_string *string =
+ g_new0(struct bt_field_type_string, 1);
BT_LOGD_STR("Creating string field type object.");
return NULL;
}
- bt_field_type_common_string_initialize(BT_TO_COMMON(string),
- bt_field_type_common_string_destroy,
+ bt_field_type_string_initialize((void *) string,
+ bt_field_type_string_destroy,
&bt_field_type_string_methods);
BT_LOGD("Created string field type object: addr=%p", string);
return (void *) string;
}
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_string_get_encoding(
- struct bt_field_type_common *ft)
+enum bt_string_encoding bt_field_type_string_get_encoding(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_string *string_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRING,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRING,
"Field type");
return string_ft->encoding;
}
-enum bt_string_encoding bt_field_type_string_get_encoding(
- struct bt_field_type *ft)
-{
- return bt_field_type_common_string_get_encoding((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_string_set_encoding(struct bt_field_type_common *ft,
+int bt_field_type_string_set_encoding(struct bt_field_type *ft,
enum bt_string_encoding encoding)
{
int ret = 0;
- struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_string *string_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
return ret;
}
-int bt_field_type_string_set_encoding(struct bt_field_type *ft,
- enum bt_string_encoding encoding)
-{
- return bt_field_type_common_string_set_encoding((void *) ft, encoding);
-}
-
-BT_HIDDEN
-int bt_field_type_common_get_alignment(struct bt_field_type_common *ft)
+int bt_field_type_get_alignment(struct bt_field_type *ft)
{
int ret;
enum bt_field_type_id type_id;
goto end;
}
- type_id = bt_field_type_common_get_type_id(ft);
+ type_id = bt_field_type_get_type_id(ft);
switch (type_id) {
case BT_FIELD_TYPE_ID_SEQUENCE:
{
- struct bt_field_type_common *element_ft =
- bt_field_type_common_sequence_borrow_element_field_type(ft);
+ struct bt_field_type *element_ft =
+ bt_field_type_sequence_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
- ret = bt_field_type_common_get_alignment(element_ft);
+ ret = bt_field_type_get_alignment(element_ft);
break;
}
case BT_FIELD_TYPE_ID_ARRAY:
{
- struct bt_field_type_common *element_ft =
- bt_field_type_common_array_borrow_element_field_type(ft);
+ struct bt_field_type *element_ft =
+ bt_field_type_array_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
- ret = bt_field_type_common_get_alignment(element_ft);
+ ret = bt_field_type_get_alignment(element_ft);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
{
int64_t i, element_count;
- element_count = bt_field_type_common_structure_get_field_count(
+ element_count = bt_field_type_structure_get_field_count(
ft);
BT_ASSERT(element_count >= 0);
for (i = 0; i < element_count; i++) {
- struct bt_field_type_common *field = NULL;
+ struct bt_field_type *field = NULL;
int field_alignment;
- ret = bt_field_type_common_structure_borrow_field_by_index(
+ ret = bt_field_type_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_alignment = bt_field_type_get_alignment(
field);
if (field_alignment < 0) {
ret = field_alignment;
return ret;
}
-int bt_field_type_get_alignment(struct bt_field_type *ft)
-{
- return bt_field_type_common_get_alignment((void *) ft);
-}
-
static inline
int is_power_of_two(unsigned int value)
{
return ((value & (value - 1)) == 0) && value > 0;
}
-BT_HIDDEN
-int bt_field_type_common_set_alignment(struct bt_field_type_common *ft,
+int bt_field_type_set_alignment(struct bt_field_type *ft,
unsigned int alignment)
{
int ret = 0;
goto end;
}
- type_id = bt_field_type_common_get_type_id(ft);
+ type_id = bt_field_type_get_type_id(ft);
if (type_id == BT_FIELD_TYPE_ID_UNKNOWN) {
BT_LOGW("Invalid parameter: unknown field type ID: "
"addr=%p, ft-id=%d", ft, type_id);
return ret;
}
-int bt_field_type_set_alignment(struct bt_field_type *ft,
- unsigned int alignment)
-{
- return bt_field_type_common_set_alignment((void *) ft, alignment);
-}
-
-BT_HIDDEN
-enum bt_byte_order bt_field_type_common_get_byte_order(
- struct bt_field_type_common *ft)
+enum bt_byte_order bt_field_type_get_byte_order(struct bt_field_type *ft)
{
enum bt_byte_order ret = BT_BYTE_ORDER_UNKNOWN;
switch (ft->id) {
case BT_FIELD_TYPE_ID_INTEGER:
{
- struct bt_field_type_common_integer *integer =
- BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *integer = (void *) ft;
ret = integer->user_byte_order;
break;
}
case BT_FIELD_TYPE_ID_ENUM:
{
- struct bt_field_type_common_enumeration *enum_ft =
- BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
- ret = bt_field_type_common_get_byte_order(
- BT_TO_COMMON(enum_ft->container_ft));
+ ret = bt_field_type_get_byte_order(
+ (void *) enum_ft->container_ft);
break;
}
case BT_FIELD_TYPE_ID_FLOAT:
{
- struct bt_field_type_common_floating_point *floating_point =
- BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *floating_point = (void *) ft;
ret = floating_point->user_byte_order;
break;
}
return ret;
}
-enum bt_byte_order bt_field_type_get_byte_order(struct bt_field_type *ft)
-{
- return bt_field_type_common_get_byte_order((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_set_byte_order(struct bt_field_type_common *ft,
+int bt_field_type_set_byte_order(struct bt_field_type *ft,
enum bt_byte_order byte_order)
{
int ret = 0;
return ret;
}
-int bt_field_type_set_byte_order(struct bt_field_type *ft,
- enum bt_byte_order byte_order)
-{
- return bt_field_type_common_set_byte_order((void *) ft, byte_order);
-}
-
-BT_HIDDEN
-enum bt_field_type_id bt_field_type_common_get_type_id(
- struct bt_field_type_common *ft)
+enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
{
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
return ft->id;
}
-enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
-{
- return bt_field_type_common_get_type_id((void *) ft);
-}
-
BT_HIDDEN
-void bt_field_type_common_freeze(struct bt_field_type_common *ft)
+void bt_field_type_freeze(struct bt_field_type *ft)
{
if (!ft || ft->frozen) {
return;
ft->methods->freeze(ft);
}
-BT_HIDDEN
-void bt_field_type_freeze(struct bt_field_type *ft)
-{
- bt_field_type_common_freeze((void *) ft);
-}
-
-BT_HIDDEN
-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)
-{
- struct bt_field_type_common *field_type = NULL;
- GQuark field_name_quark;
- gpointer index;
- struct bt_field_type_common_variant_choice *choice;
- struct range_overlap_query query = {
- .range_start._signed = tag_value,
- .range_end._signed = tag_value,
- .mapping_name = 0,
- .overlaps = 0,
- };
-
- g_ptr_array_foreach(var_ft->tag_ft->entries, check_ranges_overlap,
- &query);
- if (!query.overlaps) {
- goto end;
- }
-
- field_name_quark = query.mapping_name;
- if (!g_hash_table_lookup_extended(var_ft->choice_name_to_index,
- GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
- goto end;
- }
-
- choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft,
- (size_t) index);
- field_type = choice->type;
-
-end:
- return field_type;
-}
-
-BT_HIDDEN
-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)
-{
- struct bt_field_type_common *field_type = NULL;
- GQuark field_name_quark;
- gpointer index;
- struct bt_field_type_common_variant_choice *choice;
- struct range_overlap_query query = {
- .range_start._unsigned = tag_value,
- .range_end._unsigned = tag_value,
- .mapping_name = 0,
- .overlaps = 0,
- };
-
- g_ptr_array_foreach(var_ft->tag_ft->entries,
- check_ranges_overlap_unsigned, &query);
- if (!query.overlaps) {
- goto end;
- }
-
- field_name_quark = query.mapping_name;
- if (!g_hash_table_lookup_extended(var_ft->choice_name_to_index,
- GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
- goto end;
- }
-
- choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft,
- (size_t) index);
- field_type = choice->type;
-
-end:
- return field_type;
-}
-
-BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_copy(
- struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_copy(struct bt_field_type *ft)
{
- struct bt_field_type_common *ft_copy = NULL;
+ struct bt_field_type *ft_copy = NULL;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT(ft->methods->copy);
return ft_copy;
}
-struct bt_field_type *bt_field_type_copy(struct bt_field_type *ft)
-{
- return (void *) bt_field_type_common_copy((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_get_field_name_index(
- struct bt_field_type_common *ft, const char *name)
+static inline
+int bt_field_type_structure_get_field_name_index(
+ struct bt_field_type *ft, const char *name)
{
int ret;
size_t index;
GQuark name_quark;
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
"Field type");
name_quark = g_quark_try_string(name);
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_variant_get_field_name_index(
- struct bt_field_type_common *ft, const char *name)
+static inline
+int bt_field_type_variant_get_field_name_index(
+ struct bt_field_type *ft, const char *name)
{
int ret;
size_t index;
GQuark name_quark;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
name_quark = g_quark_try_string(name);
if (!name_quark) {
}
BT_HIDDEN
-int bt_field_type_common_sequence_set_length_field_path(
- struct bt_field_type_common *ft, struct bt_field_path *path)
+int bt_field_type_sequence_set_length_field_path(
+ struct bt_field_type *ft, struct bt_field_path *path)
{
int ret = 0;
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
}
BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_path(
- struct bt_field_type_common *ft,
+int bt_field_type_variant_set_tag_field_path(
+ struct bt_field_type *ft,
struct bt_field_path *path)
{
int ret = 0;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: field type is NULL.");
}
BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_type(
- struct bt_field_type_common *ft,
- struct bt_field_type_common *tag_ft)
+int bt_field_type_variant_set_tag_field_type(
+ struct bt_field_type *ft,
+ struct bt_field_type *tag_ft)
{
int ret = 0;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
if (!ft) {
BT_LOGW_STR("Invalid parameter: variant field type is NULL.");
return ret;
}
-BT_HIDDEN
-void bt_field_type_common_generic_freeze(struct bt_field_type_common *ft)
+static
+void bt_field_type_generic_freeze(struct bt_field_type *ft)
{
ft->frozen = 1;
}
-BT_HIDDEN
-void bt_field_type_common_enumeration_freeze_recursive(
- struct bt_field_type_common *ft)
+static
+void bt_field_type_enumeration_freeze_recursive(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
BT_LOGD("Freezing enumeration field type object: addr=%p", ft);
- bt_field_type_common_enumeration_set_range_overlap(enum_ft);
- bt_field_type_common_generic_freeze(ft);
+ bt_field_type_enumeration_set_range_overlap(enum_ft);
+ bt_field_type_generic_freeze(ft);
BT_LOGD("Freezing enumeration field type object's container field type: int-ft-addr=%p",
enum_ft->container_ft);
- bt_field_type_common_freeze(BT_TO_COMMON(enum_ft->container_ft));
+ bt_field_type_freeze((void *) enum_ft->container_ft);
}
-BT_HIDDEN
-void bt_field_type_common_structure_freeze_recursive(
- struct bt_field_type_common *ft)
+static
+void bt_field_type_structure_freeze_recursive(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
uint64_t i;
/* Cache the alignment */
BT_LOGD("Freezing structure field type object: addr=%p", ft);
- ft->alignment = bt_field_type_common_get_alignment(ft);
- bt_field_type_common_generic_freeze(ft);
+ ft->alignment = bt_field_type_get_alignment(ft);
+ bt_field_type_generic_freeze(ft);
for (i = 0; i < struct_ft->fields->len; i++) {
- struct bt_field_type_common_structure_field *field =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i);
+ struct bt_field_type_structure_field *field =
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(ft, i);
BT_LOGD("Freezing structure field type field: "
"ft-addr=%p, name=\"%s\"",
field->type, g_quark_to_string(field->name));
- bt_field_type_common_freeze(field->type);
+ bt_field_type_freeze(field->type);
}
}
BT_HIDDEN
-int bt_field_type_common_variant_update_choices(struct bt_field_type_common *ft)
+int bt_field_type_variant_update_choices(struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
uint64_t i;
int ret = 0;
bool is_signed;
is_signed = !!var_ft->tag_ft->container_ft->is_signed;
for (i = 0; i < var_ft->choices->len; i++) {
- struct bt_field_type_common_variant_choice *choice =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, i);
+ struct bt_field_type_variant_choice *choice =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, i);
const char *choice_name = g_quark_to_string(choice->name);
struct bt_field_type_enumeration_mapping_iterator *iter =
- bt_field_type_common_enumeration_find_mappings_by_name(
- BT_TO_COMMON(var_ft->tag_ft), choice_name);
+ bt_field_type_enumeration_find_mappings_by_name(
+ (void *) var_ft->tag_ft, choice_name);
if (!iter) {
ret = -1;
g_array_set_size(choice->ranges, 0);
while (bt_field_type_enumeration_mapping_iterator_next(iter) == 0) {
- struct bt_field_type_common_variant_choice_range range;
+ struct bt_field_type_variant_choice_range range;
if (is_signed) {
ret = bt_field_type_enumeration_mapping_iterator_signed_get(
return ret;
}
-BT_HIDDEN
-void bt_field_type_common_variant_freeze_recursive(
- struct bt_field_type_common *ft)
+static
+void bt_field_type_variant_freeze_recursive(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
uint64_t i;
BT_LOGD("Freezing variant field type object: addr=%p", ft);
- bt_field_type_common_generic_freeze(ft);
+ bt_field_type_generic_freeze(ft);
for (i = 0; i < var_ft->choices->len; i++) {
- struct bt_field_type_common_variant_choice *choice =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, i);
+ struct bt_field_type_variant_choice *choice =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, i);
BT_LOGD("Freezing variant field type member: "
"ft-addr=%p, name=\"%s\"",
choice->type, g_quark_to_string(choice->name));
- bt_field_type_common_freeze(choice->type);
+ bt_field_type_freeze(choice->type);
}
}
-BT_HIDDEN
-void bt_field_type_common_array_freeze_recursive(
- struct bt_field_type_common *ft)
+static
+void bt_field_type_array_freeze_recursive(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
/* Cache the alignment */
BT_LOGD("Freezing array field type object: addr=%p", ft);
- ft->alignment = bt_field_type_common_get_alignment(ft);
- bt_field_type_common_generic_freeze(ft);
+ ft->alignment = bt_field_type_get_alignment(ft);
+ bt_field_type_generic_freeze(ft);
BT_LOGD("Freezing array field type object's element field type: element-ft-addr=%p",
array_ft->element_ft);
- bt_field_type_common_freeze(array_ft->element_ft);
+ bt_field_type_freeze(array_ft->element_ft);
}
-BT_HIDDEN
-void bt_field_type_common_sequence_freeze_recursive(
- struct bt_field_type_common *ft)
+static
+void bt_field_type_sequence_freeze_recursive(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
/* Cache the alignment */
BT_LOGD("Freezing sequence field type object: addr=%p", ft);
- ft->alignment = bt_field_type_common_get_alignment(ft);
- bt_field_type_common_generic_freeze(ft);
+ ft->alignment = bt_field_type_get_alignment(ft);
+ bt_field_type_generic_freeze(ft);
BT_LOGD("Freezing sequence field type object's element field type: element-ft-addr=%p",
seq_ft->element_ft);
- bt_field_type_common_freeze(seq_ft->element_ft);
+ bt_field_type_freeze(seq_ft->element_ft);
}
-BT_HIDDEN
-void bt_field_type_common_integer_set_byte_order(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_integer_set_byte_order(
+ struct bt_field_type *ft, enum bt_byte_order byte_order)
{
- struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_integer *int_ft = (void *) ft;
int_ft->user_byte_order = byte_order;
}
-BT_HIDDEN
-void bt_field_type_common_enumeration_set_byte_order_recursive(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_enumeration_set_byte_order_recursive(
+ struct bt_field_type *ft, enum bt_byte_order byte_order)
{
- struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
- bt_field_type_common_set_byte_order(BT_TO_COMMON(enum_ft->container_ft),
+ bt_field_type_set_byte_order((void *) enum_ft->container_ft,
byte_order);
}
-BT_HIDDEN
-void bt_field_type_common_floating_point_set_byte_order(
- struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_floating_point_set_byte_order(
+ struct bt_field_type *ft, enum bt_byte_order byte_order)
{
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
flt_ft->user_byte_order = byte_order;
}
-BT_HIDDEN
-void bt_field_type_common_structure_set_byte_order_recursive(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_structure_set_byte_order_recursive(
+ struct bt_field_type *ft,
enum bt_byte_order byte_order)
{
int i;
- struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_structure *struct_ft = (void *) ft;
for (i = 0; i < struct_ft->fields->len; i++) {
- struct bt_field_type_common_structure_field *field =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ struct bt_field_type_structure_field *field =
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
struct_ft, i);
- struct bt_field_type_common *field_type = field->type;
+ struct bt_field_type *field_type = field->type;
- bt_field_type_common_set_byte_order(field_type, byte_order);
+ bt_field_type_set_byte_order(field_type, byte_order);
}
}
-BT_HIDDEN
-void bt_field_type_common_variant_set_byte_order_recursive(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_variant_set_byte_order_recursive(
+ struct bt_field_type *ft,
enum bt_byte_order byte_order)
{
int i;
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
for (i = 0; i < var_ft->choices->len; i++) {
- struct bt_field_type_common_variant_choice *choice =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ struct bt_field_type_variant_choice *choice =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
var_ft, i);
- struct bt_field_type_common *field_type = choice->type;
+ struct bt_field_type *field_type = choice->type;
- bt_field_type_common_set_byte_order(field_type, byte_order);
+ bt_field_type_set_byte_order(field_type, byte_order);
}
}
-BT_HIDDEN
-void bt_field_type_common_array_set_byte_order_recursive(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_array_set_byte_order_recursive(
+ struct bt_field_type *ft,
enum bt_byte_order byte_order)
{
- struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_array *array_ft = (void *) ft;
- bt_field_type_common_set_byte_order(array_ft->element_ft, byte_order);
+ bt_field_type_set_byte_order(array_ft->element_ft, byte_order);
}
-BT_HIDDEN
-void bt_field_type_common_sequence_set_byte_order_recursive(
- struct bt_field_type_common *ft,
+static
+void bt_field_type_sequence_set_byte_order_recursive(
+ struct bt_field_type *ft,
enum bt_byte_order byte_order)
{
- struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
- bt_field_type_common_set_byte_order(seq_ft->element_ft, byte_order);
+ bt_field_type_set_byte_order(seq_ft->element_ft, byte_order);
}
-BT_HIDDEN
-int bt_field_type_common_integer_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_integer_compare(struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
- struct bt_field_type_common_integer *int_ft_a = BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_integer *int_ft_b = BT_FROM_COMMON(ft_b);
+ struct bt_field_type_integer *int_ft_a = (void *) ft_a;
+ struct bt_field_type_integer *int_ft_b = (void *) ft_b;
/* Length */
if (int_ft_a->size != int_ft_b->size) {
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_floating_point_compare(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_floating_point_compare(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
- struct bt_field_type_common_floating_point *flt_ft_a =
- BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_floating_point *flt_ft_b =
- BT_FROM_COMMON(ft_b);
+ struct bt_field_type_floating_point *flt_ft_a = (void *) ft_a;
+ struct bt_field_type_floating_point *flt_ft_b = (void *) ft_b;
/* Byte order */
if (flt_ft_a->user_byte_order != flt_ft_b->user_byte_order) {
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_enumeration_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_enumeration_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
int i;
- struct bt_field_type_common_enumeration *enum_ft_a =
- BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_enumeration *enum_ft_b =
- BT_FROM_COMMON(ft_b);
+ struct bt_field_type_enumeration *enum_ft_a = (void *) ft_a;
+ struct bt_field_type_enumeration *enum_ft_b = (void *) ft_b;
/* Container field type */
- ret = bt_field_type_common_compare(
- BT_TO_COMMON(enum_ft_a->container_ft),
- BT_TO_COMMON(enum_ft_b->container_ft));
+ ret = bt_field_type_compare((void *) enum_ft_a->container_ft,
+ (void *) enum_ft_b->container_ft);
if (ret) {
BT_LOGV("Enumeration field types differ: different container field types: "
"ft-a-container-ft-addr=%p, ft-b-container-ft-addr=%p",
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_string_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_string_compare(struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
- struct bt_field_type_common_string *string_ft_a = BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_string *string_ft_b = BT_FROM_COMMON(ft_b);
+ struct bt_field_type_string *string_ft_a = (void *) ft_a;
+ struct bt_field_type_string *string_ft_b = (void *) ft_b;
/* Encoding */
if (string_ft_a->encoding != string_ft_b->encoding) {
static
int compare_structure_variant_members(
- struct bt_field_type_common *member_a_ft,
- struct bt_field_type_common *member_b_ft,
+ struct bt_field_type *member_a_ft,
+ struct bt_field_type *member_b_ft,
GQuark member_a_name, GQuark member_b_name)
{
int ret = 1;
}
/* Type */
- ret = bt_field_type_common_compare(member_a_ft, member_b_ft);
+ ret = bt_field_type_compare(member_a_ft, member_b_ft);
if (ret == 1) {
BT_LOGV("Structure/variant field type fields differ: different field types: "
"field-name=\"%s\", field-a-ft-addr=%p, field-b-ft-addr=%p",
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_structure_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_structure_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
int i;
- struct bt_field_type_common_structure *struct_ft_a =
- BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_structure *struct_ft_b =
- BT_FROM_COMMON(ft_b);
+ struct bt_field_type_structure *struct_ft_a = (void *) ft_a;
+ struct bt_field_type_structure *struct_ft_b = (void *) ft_b;
/* Alignment */
- if (bt_field_type_common_get_alignment(ft_a) !=
- bt_field_type_common_get_alignment(ft_b)) {
+ if (bt_field_type_get_alignment(ft_a) !=
+ bt_field_type_get_alignment(ft_b)) {
BT_LOGV("Structure field types differ: different alignments: "
"ft-a-align=%u, ft-b-align=%u",
- bt_field_type_common_get_alignment(ft_a),
- bt_field_type_common_get_alignment(ft_b));
+ bt_field_type_get_alignment(ft_a),
+ bt_field_type_get_alignment(ft_b));
goto end;
}
}
for (i = 0; i < struct_ft_a->fields->len; ++i) {
- struct bt_field_type_common_structure_field *field_a =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ struct bt_field_type_structure_field *field_a =
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
struct_ft_a, i);
- struct bt_field_type_common_structure_field *field_b =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ struct bt_field_type_structure_field *field_b =
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
struct_ft_b, i);
ret = compare_structure_variant_members(field_a->type,
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_variant_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_variant_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
int i;
- struct bt_field_type_common_variant *var_ft_a = BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_variant *var_ft_b = BT_FROM_COMMON(ft_b);
+ struct bt_field_type_variant *var_ft_a = (void *) ft_a;
+ struct bt_field_type_variant *var_ft_b = (void *) ft_b;
/* Tag name */
if (strcmp(var_ft_a->tag_name->str, var_ft_b->tag_name->str)) {
}
/* Tag type */
- ret = bt_field_type_common_compare(BT_TO_COMMON(var_ft_a->tag_ft),
- BT_TO_COMMON(var_ft_b->tag_ft));
+ ret = bt_field_type_compare((void *) var_ft_a->tag_ft,
+ (void *) var_ft_b->tag_ft);
if (ret) {
BT_LOGV("Variant field types differ: different tag field types: "
"ft-a-tag-ft-addr=%p, ft-b-tag-ft-addr=%p",
}
for (i = 0; i < var_ft_a->choices->len; ++i) {
- struct bt_field_type_common_variant_choice *choice_a =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ struct bt_field_type_variant_choice *choice_a =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
var_ft_a, i);
- struct bt_field_type_common_variant_choice *choice_b =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ struct bt_field_type_variant_choice *choice_b =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
var_ft_b, i);
ret = compare_structure_variant_members(choice_a->type,
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_array_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_array_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
- struct bt_field_type_common_array *array_ft_a = BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_array *array_ft_b = BT_FROM_COMMON(ft_b);
+ struct bt_field_type_array *array_ft_a = (void *) ft_a;
+ struct bt_field_type_array *array_ft_b = (void *) ft_b;
/* Length */
if (array_ft_a->length != array_ft_b->length) {
}
/* Element type */
- ret = bt_field_type_common_compare(array_ft_a->element_ft,
+ ret = bt_field_type_compare(array_ft_a->element_ft,
array_ft_b->element_ft);
if (ret == 1) {
BT_LOGV("Array field types differ: different element field types: "
return ret;
}
-BT_HIDDEN
-int bt_field_type_common_sequence_compare_recursive(
- struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+static
+int bt_field_type_sequence_compare_recursive(
+ struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = -1;
- struct bt_field_type_common_sequence *seq_ft_a = BT_FROM_COMMON(ft_a);
- struct bt_field_type_common_sequence *seq_ft_b = BT_FROM_COMMON(ft_b);
+ struct bt_field_type_sequence *seq_ft_a = (void *) ft_a;
+ struct bt_field_type_sequence *seq_ft_b = (void *) ft_b;
/* Length name */
if (strcmp(seq_ft_a->length_field_name->str,
}
/* Element type */
- ret = bt_field_type_common_compare(seq_ft_a->element_ft,
+ ret = bt_field_type_compare(seq_ft_a->element_ft,
seq_ft_b->element_ft);
if (ret == 1) {
BT_LOGV("Sequence field types differ: different element field types: "
}
BT_HIDDEN
-int bt_field_type_common_compare(struct bt_field_type_common *ft_a,
- struct bt_field_type_common *ft_b)
+int bt_field_type_compare(struct bt_field_type *ft_a,
+ struct bt_field_type *ft_b)
{
int ret = 1;
return ret;
}
-int bt_field_type_compare(struct bt_field_type *ft_a,
- struct bt_field_type *ft_b)
-{
- return bt_field_type_common_compare((void *) ft_a, (void *) ft_b);
-}
-
BT_HIDDEN
-int64_t bt_field_type_common_get_field_count(struct bt_field_type_common *ft)
+int64_t bt_field_type_get_field_count(struct bt_field_type *ft)
{
int64_t field_count = -1;
switch (ft->id) {
case BT_FIELD_TYPE_ID_STRUCT:
field_count =
- bt_field_type_common_structure_get_field_count(ft);
+ bt_field_type_structure_get_field_count(ft);
break;
case BT_FIELD_TYPE_ID_VARIANT:
field_count =
- bt_field_type_common_variant_get_field_count(ft);
+ bt_field_type_variant_get_field_count(ft);
break;
case BT_FIELD_TYPE_ID_ARRAY:
case BT_FIELD_TYPE_ID_SEQUENCE:
}
BT_HIDDEN
-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 *bt_field_type_borrow_field_at_index(
+ struct bt_field_type *ft, int index)
{
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type *field_type = NULL;
switch (ft->id) {
case BT_FIELD_TYPE_ID_STRUCT:
{
- int ret = bt_field_type_common_structure_borrow_field_by_index(
+ int ret = bt_field_type_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_borrow_field_by_index(
+ int ret = bt_field_type_variant_borrow_field_by_index(
ft, NULL, &field_type, index);
if (ret) {
field_type = NULL;
}
case BT_FIELD_TYPE_ID_ARRAY:
field_type =
- bt_field_type_common_array_borrow_element_field_type(ft);
+ bt_field_type_array_borrow_element_field_type(ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
field_type =
- bt_field_type_common_sequence_borrow_element_field_type(ft);
+ bt_field_type_sequence_borrow_element_field_type(ft);
break;
default:
break;
}
BT_HIDDEN
-int bt_field_type_common_get_field_index(struct bt_field_type_common *ft,
+int bt_field_type_get_field_index(struct bt_field_type *ft,
const char *name)
{
int field_index = -1;
switch (ft->id) {
case BT_FIELD_TYPE_ID_STRUCT:
- field_index = bt_field_type_common_structure_get_field_name_index(
+ field_index = bt_field_type_structure_get_field_name_index(
ft, name);
break;
case BT_FIELD_TYPE_ID_VARIANT:
- field_index = bt_field_type_common_variant_get_field_name_index(
+ field_index = bt_field_type_variant_get_field_name_index(
ft, name);
break;
default:
return field_index;
}
-BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
- struct bt_field_type_common *ft)
+struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
+ struct bt_field_type *ft)
{
- struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+ struct bt_field_type_variant *var_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
return var_ft->tag_field_path;
}
-struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
+struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
struct bt_field_type *ft)
{
- return bt_field_type_common_variant_borrow_tag_field_path((void *) ft);
-}
-
-BT_HIDDEN
-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);
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
- BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+ BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
return seq_ft->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_borrow_length_field_path(
- (void *) ft);
-}
-
BT_HIDDEN
-int bt_field_type_common_validate_single_clock_class(
- struct bt_field_type_common *ft,
+int bt_field_type_validate_single_clock_class(
+ struct bt_field_type *ft,
struct bt_clock_class **expected_clock_class)
{
int ret = 0;
case BT_FIELD_TYPE_ID_INTEGER:
{
struct bt_clock_class *mapped_clock_class =
- bt_field_type_common_integer_borrow_mapped_clock_class(ft);
+ bt_field_type_integer_borrow_mapped_clock_class(ft);
if (!mapped_clock_class) {
goto end;
case BT_FIELD_TYPE_ID_ARRAY:
case BT_FIELD_TYPE_ID_SEQUENCE:
{
- struct bt_field_type_common *sub_ft = NULL;
+ struct bt_field_type *sub_ft = NULL;
switch (ft->id) {
case BT_FIELD_TYPE_ID_ENUM:
- sub_ft = bt_field_type_common_enumeration_borrow_container_field_type(
+ sub_ft = bt_field_type_enumeration_borrow_container_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_ARRAY:
- sub_ft = bt_field_type_common_array_borrow_element_field_type(
+ sub_ft = bt_field_type_array_borrow_element_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
- sub_ft = bt_field_type_common_sequence_borrow_element_field_type(
+ sub_ft = bt_field_type_sequence_borrow_element_field_type(
ft);
break;
default:
}
BT_ASSERT(sub_ft);
- ret = bt_field_type_common_validate_single_clock_class(sub_ft,
+ ret = bt_field_type_validate_single_clock_class(sub_ft,
expected_clock_class);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
{
uint64_t i;
- int64_t count = bt_field_type_common_structure_get_field_count(
+ int64_t count = bt_field_type_structure_get_field_count(
ft);
for (i = 0; i < count; i++) {
const char *name;
- struct bt_field_type_common *member_type;
+ struct bt_field_type *member_type;
- ret = bt_field_type_common_structure_borrow_field_by_index(
+ ret = bt_field_type_structure_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
member_type, expected_clock_class);
if (ret) {
BT_LOGW("Structure field type's field's type "
case BT_FIELD_TYPE_ID_VARIANT:
{
uint64_t i;
- int64_t count = bt_field_type_common_variant_get_field_count(
+ int64_t count = bt_field_type_variant_get_field_count(
ft);
for (i = 0; i < count; i++) {
const char *name;
- struct bt_field_type_common *member_type;
+ struct bt_field_type *member_type;
- ret = bt_field_type_common_variant_borrow_field_by_index(
+ ret = bt_field_type_variant_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
member_type, expected_clock_class);
if (ret) {
BT_LOGW("Variant field type's field's type "
struct bt_field_type *bt_field_type_integer_copy(
struct bt_field_type *ft)
{
- struct bt_field_type_common_integer *int_ft = (void *) ft;
- struct bt_field_type_common_integer *copy_ft;
+ struct bt_field_type_integer *int_ft = (void *) ft;
+ struct bt_field_type_integer *copy_ft;
BT_LOGD("Copying integer field type's: addr=%p", ft);
copy_ft = (void *) bt_field_type_integer_create(int_ft->size);
struct bt_field_type *ft)
{
size_t i;
- struct bt_field_type_common_enumeration *enum_ft = (void *) ft;
- struct bt_field_type_common_enumeration *copy_ft = NULL;
- struct bt_field_type_common_enumeration *container_copy_ft;
+ struct bt_field_type_enumeration *enum_ft = (void *) ft;
+ struct bt_field_type_enumeration *copy_ft = NULL;
+ struct bt_field_type_enumeration *container_copy_ft;
BT_LOGD("Copying enumeration field type's: addr=%p", ft);
/* Copy the source enumeration's container */
BT_LOGD_STR("Copying enumeration field type's container field type.");
- container_copy_ft = BT_FROM_COMMON(bt_field_type_common_copy(
- BT_TO_COMMON(enum_ft->container_ft)));
+ container_copy_ft =
+ (void *) bt_field_type_copy((void *) enum_ft->container_ft);
if (!container_copy_ft) {
BT_LOGE_STR("Cannot copy enumeration field type's container field type.");
goto end;
struct bt_field_type *bt_field_type_floating_point_copy(
struct bt_field_type *ft)
{
- struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
- struct bt_field_type_common_floating_point *copy_ft;
+ struct bt_field_type_floating_point *flt_ft = (void *) ft;
+ struct bt_field_type_floating_point *copy_ft;
BT_LOGD("Copying floating point number field type's: addr=%p", ft);
copy_ft = (void *) bt_field_type_floating_point_create();
int64_t i;
GHashTableIter iter;
gpointer key, value;
- struct bt_field_type_common_structure *struct_ft = (void *) ft;
- struct bt_field_type_common_structure *copy_ft;
+ struct bt_field_type_structure *struct_ft = (void *) ft;
+ struct bt_field_type_structure *copy_ft;
BT_LOGD("Copying structure field type's: addr=%p", ft);
copy_ft = (void *) bt_field_type_structure_create();
g_array_set_size(copy_ft->fields, struct_ft->fields->len);
for (i = 0; i < struct_ft->fields->len; i++) {
- struct bt_field_type_common_structure_field *entry, *copy_entry;
- struct bt_field_type_common *field_ft_copy;
+ struct bt_field_type_structure_field *entry, *copy_entry;
+ struct bt_field_type *field_ft_copy;
- entry = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
struct_ft, i);
- copy_entry = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ copy_entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
copy_ft, i);
BT_LOGD("Copying structure field type's field: "
"index=%" PRId64 ", "
int64_t i;
GHashTableIter iter;
gpointer key, value;
- struct bt_field_type_common *tag_ft_copy = NULL;
- struct bt_field_type_common_variant *var_ft = (void *) ft;
- struct bt_field_type_common_variant *copy_ft = NULL;
+ struct bt_field_type *tag_ft_copy = NULL;
+ struct bt_field_type_variant *var_ft = (void *) ft;
+ struct bt_field_type_variant *copy_ft = NULL;
BT_LOGD("Copying variant field type's: addr=%p", ft);
if (var_ft->tag_ft) {
BT_LOGD_STR("Copying variant field type's tag field type.");
- tag_ft_copy = bt_field_type_common_copy(
- BT_TO_COMMON(var_ft->tag_ft));
+ tag_ft_copy = bt_field_type_copy((void *) var_ft->tag_ft);
if (!tag_ft_copy) {
BT_LOGE_STR("Cannot copy variant field type's tag field type.");
goto end;
g_array_set_size(copy_ft->choices, var_ft->choices->len);
for (i = 0; i < var_ft->choices->len; i++) {
- struct bt_field_type_common_variant_choice *entry, *copy_entry;
- struct bt_field_type_common *field_ft_copy;
+ struct bt_field_type_variant_choice *entry, *copy_entry;
+ struct bt_field_type *field_ft_copy;
uint64_t range_i;
- entry = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft, i);
- copy_entry = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ entry = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(var_ft, i);
+ copy_entry = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
copy_ft, i);
BT_LOGD("Copying variant field type's field: "
"index=%" PRId64 ", "
/* Copy ranges */
copy_entry->ranges = g_array_new(FALSE, TRUE,
- sizeof(struct bt_field_type_common_variant_choice_range));
+ sizeof(struct bt_field_type_variant_choice_range));
BT_ASSERT(copy_entry->ranges);
g_array_set_size(copy_entry->ranges, entry->ranges->len);
struct bt_field_type *bt_field_type_array_copy_recursive(
struct bt_field_type *ft)
{
- struct bt_field_type_common *container_ft_copy = NULL;
- struct bt_field_type_common_array *array_ft = (void *) ft;
- struct bt_field_type_common_array *copy_ft = NULL;
+ struct bt_field_type *container_ft_copy = NULL;
+ struct bt_field_type_array *array_ft = (void *) ft;
+ struct bt_field_type_array *copy_ft = NULL;
BT_LOGD("Copying array field type's: addr=%p", ft);
BT_LOGD_STR("Copying array field type's element field type.");
- container_ft_copy = bt_field_type_common_copy(array_ft->element_ft);
+ container_ft_copy = bt_field_type_copy(array_ft->element_ft);
if (!container_ft_copy) {
BT_LOGE_STR("Cannot copy array field type's element field type.");
goto end;
struct bt_field_type *bt_field_type_sequence_copy_recursive(
struct bt_field_type *ft)
{
- struct bt_field_type_common *container_ft_copy = NULL;
- struct bt_field_type_common_sequence *seq_ft = (void *) ft;
- struct bt_field_type_common_sequence *copy_ft = NULL;
+ struct bt_field_type *container_ft_copy = NULL;
+ struct bt_field_type_sequence *seq_ft = (void *) ft;
+ struct bt_field_type_sequence *copy_ft = NULL;
BT_LOGD("Copying sequence field type's: addr=%p", ft);
BT_LOGD_STR("Copying sequence field type's element field type.");
- container_ft_copy = bt_field_type_common_copy(seq_ft->element_ft);
+ container_ft_copy = bt_field_type_copy(seq_ft->element_ft);
if (!container_ft_copy) {
BT_LOGE_STR("Cannot copy sequence field type's element field type.");
goto end;
static
struct bt_field_type *bt_field_type_string_copy(struct bt_field_type *ft)
{
- struct bt_field_type_common_string *string_ft = (void *) ft;
- struct bt_field_type_common_string *copy_ft = NULL;
+ struct bt_field_type_string *string_ft = (void *) ft;
+ struct bt_field_type_string *copy_ft = NULL;
BT_LOGD("Copying string field type's: addr=%p", ft);
copy_ft = (void *) bt_field_type_string_create();
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/fields-internal.h>
#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/object-internal.h>
_name " is not an integer or an enumeration field: " \
"%!+f", (_field))
-static struct bt_field_common_methods bt_field_integer_methods = {
- .set_is_frozen = bt_field_common_generic_set_is_frozen,
- .validate = bt_field_common_generic_validate,
- .copy = NULL,
- .is_set = bt_field_common_generic_is_set,
- .reset = bt_field_common_generic_reset,
+static
+int bt_field_generic_validate(struct bt_field *field);
+
+static
+int bt_field_structure_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_variant_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_array_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_sequence_validate_recursive(struct bt_field *field);
+
+static
+void bt_field_generic_reset(struct bt_field *field);
+
+static
+void bt_field_structure_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_variant_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_array_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_sequence_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_generic_set_is_frozen(struct bt_field *field,
+ bool is_frozen);
+
+static
+void bt_field_structure_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_variant_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_array_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_sequence_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen);
+
+static
+bt_bool bt_field_generic_is_set(struct bt_field *field);
+
+static
+bt_bool bt_field_structure_is_set_recursive(
+ struct bt_field *field);
+
+static
+bt_bool bt_field_variant_is_set_recursive(struct bt_field *field);
+
+static
+bt_bool bt_field_array_is_set_recursive(struct bt_field *field);
+
+static
+bt_bool bt_field_sequence_is_set_recursive(struct bt_field *field);
+
+static struct bt_field_methods bt_field_integer_methods = {
+ .set_is_frozen = bt_field_generic_set_is_frozen,
+ .validate = bt_field_generic_validate,
+ .is_set = bt_field_generic_is_set,
+ .reset = bt_field_generic_reset,
};
-static struct bt_field_common_methods bt_field_floating_point_methods = {
- .set_is_frozen = bt_field_common_generic_set_is_frozen,
- .validate = bt_field_common_generic_validate,
- .copy = NULL,
- .is_set = bt_field_common_generic_is_set,
- .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_floating_point_methods = {
+ .set_is_frozen = bt_field_generic_set_is_frozen,
+ .validate = bt_field_generic_validate,
+ .is_set = bt_field_generic_is_set,
+ .reset = bt_field_generic_reset,
};
-static struct bt_field_common_methods bt_field_enumeration_methods = {
- .set_is_frozen = bt_field_common_generic_set_is_frozen,
- .validate = bt_field_common_generic_validate,
- .copy = NULL,
- .is_set = bt_field_common_generic_is_set,
- .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_enumeration_methods = {
+ .set_is_frozen = bt_field_generic_set_is_frozen,
+ .validate = bt_field_generic_validate,
+ .is_set = bt_field_generic_is_set,
+ .reset = bt_field_generic_reset,
};
-static struct bt_field_common_methods bt_field_string_methods = {
- .set_is_frozen = bt_field_common_generic_set_is_frozen,
- .validate = bt_field_common_generic_validate,
- .copy = NULL,
- .is_set = bt_field_common_generic_is_set,
- .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_string_methods = {
+ .set_is_frozen = bt_field_generic_set_is_frozen,
+ .validate = bt_field_generic_validate,
+ .is_set = bt_field_generic_is_set,
+ .reset = bt_field_generic_reset,
};
-static struct bt_field_common_methods bt_field_structure_methods = {
- .set_is_frozen = bt_field_common_structure_set_is_frozen_recursive,
- .validate = bt_field_common_structure_validate_recursive,
- .copy = NULL,
- .is_set = bt_field_common_structure_is_set_recursive,
- .reset = bt_field_common_structure_reset_recursive,
+static struct bt_field_methods bt_field_structure_methods = {
+ .set_is_frozen = bt_field_structure_set_is_frozen_recursive,
+ .validate = bt_field_structure_validate_recursive,
+ .is_set = bt_field_structure_is_set_recursive,
+ .reset = bt_field_structure_reset_recursive,
};
-static struct bt_field_common_methods bt_field_sequence_methods = {
- .set_is_frozen = bt_field_common_sequence_set_is_frozen_recursive,
- .validate = bt_field_common_sequence_validate_recursive,
- .copy = NULL,
- .is_set = bt_field_common_sequence_is_set_recursive,
- .reset = bt_field_common_sequence_reset_recursive,
+static struct bt_field_methods bt_field_sequence_methods = {
+ .set_is_frozen = bt_field_sequence_set_is_frozen_recursive,
+ .validate = bt_field_sequence_validate_recursive,
+ .is_set = bt_field_sequence_is_set_recursive,
+ .reset = bt_field_sequence_reset_recursive,
};
-static struct bt_field_common_methods bt_field_array_methods = {
- .set_is_frozen = bt_field_common_array_set_is_frozen_recursive,
- .validate = bt_field_common_array_validate_recursive,
- .copy = NULL,
- .is_set = bt_field_common_array_is_set_recursive,
- .reset = bt_field_common_array_reset_recursive,
+static struct bt_field_methods bt_field_array_methods = {
+ .set_is_frozen = bt_field_array_set_is_frozen_recursive,
+ .validate = bt_field_array_validate_recursive,
+ .is_set = bt_field_array_is_set_recursive,
+ .reset = bt_field_array_reset_recursive,
};
-static struct bt_field_common_methods bt_field_variant_methods = {
- .set_is_frozen = bt_field_common_variant_set_is_frozen_recursive,
- .validate = bt_field_common_variant_validate_recursive,
- .copy = NULL,
- .is_set = bt_field_common_variant_is_set_recursive,
- .reset = bt_field_common_variant_reset_recursive,
+static struct bt_field_methods bt_field_variant_methods = {
+ .set_is_frozen = bt_field_variant_set_is_frozen_recursive,
+ .validate = bt_field_variant_validate_recursive,
+ .is_set = bt_field_variant_is_set_recursive,
+ .reset = bt_field_variant_reset_recursive,
};
static
[BT_FIELD_TYPE_ID_STRING] = bt_field_string_destroy,
};
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
+{
+ bool ret = true;
+ int64_t min_value, max_value;
+
+ min_value = -(1ULL << (size - 1));
+ max_value = (1ULL << (size - 1)) - 1;
+ if (value < min_value || value > max_value) {
+ BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
+ "min-value=%" PRId64 ", max-value=%" PRId64,
+ value, min_value, max_value);
+ ret = false;
+ }
+
+ return ret;
+}
+
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
+{
+ bool ret = true;
+ int64_t max_value;
+
+ max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
+ if (value > max_value) {
+ BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
+ "max-value=%" PRIu64,
+ value, max_value);
+ ret = false;
+ }
+
+ return ret;
+}
+
BT_HIDDEN
struct bt_field *bt_field_create_recursive(struct bt_field_type *type)
{
enum bt_field_type_id type_id;
BT_ASSERT_PRE_NON_NULL(type, "Field type");
- BT_ASSERT(field_type_common_has_known_id((void *) type));
- BT_ASSERT_PRE(bt_field_type_common_validate((void *) type) == 0,
+ BT_ASSERT(bt_field_type_has_known_id((void *) type));
+ BT_ASSERT_PRE(bt_field_type_validate((void *) type) == 0,
"Field type is invalid: %!+F", type);
type_id = bt_field_type_get_type_id(type);
field = field_create_funcs[type_id](type);
struct bt_field_type *bt_field_borrow_type(struct bt_field *field)
{
- return (void *) bt_field_common_borrow_type((void *) field);
+ struct bt_field_type *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Field");
+ ret = field->type;
+ return ret;
}
enum bt_field_type_id bt_field_get_type_id(struct bt_field *field)
{
- struct bt_field_common *field_common = (void *) field;
-
BT_ASSERT_PRE_NON_NULL(field, "Field");
- return field_common->type->id;
+ return field->type->id;
}
int64_t bt_field_sequence_get_length(struct bt_field *field)
{
- return bt_field_common_sequence_get_length((void *) field);
+ struct bt_field_sequence *sequence = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
+ "Field");
+ return (int64_t) sequence->length;
}
int bt_field_sequence_set_length(struct bt_field *field, uint64_t length)
{
- return bt_field_common_sequence_set_length((void *) field,
- length, (bt_field_common_create_func) bt_field_create_recursive);
+ int ret = 0;
+ struct bt_field_sequence *sequence = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE(((int64_t) length) >= 0,
+ "Invalid sequence length (too large): length=%" PRId64,
+ length);
+ BT_ASSERT_PRE_FIELD_HOT(field, "Sequence field");
+
+ if (unlikely(length > sequence->elements->len)) {
+ /* Make more room */
+ struct bt_field_type_sequence *sequence_ft;
+ uint64_t cur_len = sequence->elements->len;
+ uint64_t i;
+
+ g_ptr_array_set_size(sequence->elements, length);
+ sequence_ft = (void *) sequence->common.type;
+
+ for (i = cur_len; i < sequence->elements->len; i++) {
+ struct bt_field *elem_field =
+ bt_field_create_recursive(
+ sequence_ft->element_ft);
+
+ if (!elem_field) {
+ ret = -1;
+ goto end;
+ }
+
+ BT_ASSERT(!sequence->elements->pdata[i]);
+ sequence->elements->pdata[i] = elem_field;
+ }
+ }
+
+ sequence->length = length;
+
+end:
+ return ret;
}
struct bt_field *bt_field_structure_borrow_field_by_index(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_structure_borrow_field_by_index(
- (void *) field, index);
+ struct bt_field_structure *structure = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRUCT, "Field");
+ BT_ASSERT_PRE(index < structure->fields->len,
+ "Index is out of bound: %![struct-field-]+f, "
+ "index=%" PRIu64 ", count=%u", field, index,
+ structure->fields->len);
+ return structure->fields->pdata[index];
}
struct bt_field *bt_field_structure_borrow_field_by_name(
struct bt_field *field, const char *name)
{
- return (void *) bt_field_common_structure_borrow_field_by_name(
- (void *) field, name);
+ struct bt_field *ret = NULL;
+ GQuark field_quark;
+ struct bt_field_type_structure *structure_ft;
+ struct bt_field_structure *structure = (void *) field;
+ size_t index;
+ GHashTable *field_name_to_index;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+ BT_ASSERT_PRE_NON_NULL(name, "Field name");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRUCT, "Field");
+ structure_ft = (void *) field->type;
+ field_name_to_index = structure_ft->field_name_to_index;
+ field_quark = g_quark_from_string(name);
+ if (!g_hash_table_lookup_extended(field_name_to_index,
+ GUINT_TO_POINTER(field_quark),
+ NULL, (gpointer *) &index)) {
+ BT_LOGV("Invalid parameter: no such field in structure field's type: "
+ "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
+ field, field->type, name);
+ goto error;
+ }
+
+ ret = structure->fields->pdata[index];
+ BT_ASSERT(ret);
+
+error:
+ return ret;
}
struct bt_field *bt_field_array_borrow_field(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_array_borrow_field((void *) field,
- index);
+ struct bt_field_array *array = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Array field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_ARRAY,
+ "Field");
+ BT_ASSERT_PRE(index < array->elements->len,
+ "Index is out of bound: %![array-field-]+f, "
+ "index=%" PRIu64 ", count=%u", field,
+ index, array->elements->len);
+ return array->elements->pdata[(size_t) index];
}
struct bt_field *bt_field_sequence_borrow_field(
struct bt_field *field, uint64_t index)
{
- return (void *) bt_field_common_sequence_borrow_field((void *) field,
- index);
+ struct bt_field_sequence *sequence = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
+ "Field");
+ BT_ASSERT_PRE(index < sequence->length,
+ "Index is out of bound: %![seq-field-]+f, "
+ "index=%" PRIu64 ", count=%u", field, index,
+ sequence->elements->len);
+ return sequence->elements->pdata[(size_t) index];
}
struct bt_field *bt_field_variant_borrow_current_field(
- struct bt_field *variant_field)
+ struct bt_field *field)
{
- return (void *) bt_field_common_variant_borrow_current_field(
- (void *) variant_field);
+ struct bt_field_variant *variant = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: %!+f", field);
+ return variant->current_field;
+}
+
+static inline
+int bt_field_variant_set_tag(struct bt_field *field,
+ uint64_t tag_uval, bool is_signed)
+{
+ int ret = 0;
+ int64_t choice_index;
+ struct bt_field_variant *variant = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_VARIANT, "Field");
+
+ /* Find matching index in variant field's type */
+ choice_index = bt_field_type_variant_find_choice_index(
+ field->type, tag_uval, is_signed);
+ if (choice_index < 0) {
+ ret = -1;
+ goto end;
+ }
+
+ /* Select corresponding field */
+ BT_ASSERT(choice_index < variant->fields->len);
+ variant->current_field = variant->fields->pdata[choice_index];
+ variant->tag_value.u = tag_uval;
+
+end:
+ return ret;
}
int bt_field_variant_set_tag_signed(struct bt_field *variant_field,
int64_t tag)
{
- return bt_field_variant_common_set_tag((void *) variant_field,
+ return bt_field_variant_set_tag((void *) variant_field,
(uint64_t) tag, true);
}
int bt_field_variant_set_tag_unsigned(struct bt_field *variant_field,
uint64_t tag)
{
- return bt_field_variant_common_set_tag((void *) variant_field,
+ return bt_field_variant_set_tag((void *) variant_field,
(uint64_t) tag, false);
}
-int bt_field_variant_get_tag_signed(struct bt_field *variant_field,
+int bt_field_variant_get_tag_signed(struct bt_field *field,
int64_t *tag)
{
- return bt_field_common_variant_get_tag_signed((void *) variant_field, tag);
+ struct bt_field_variant *variant = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: %!+f", field);
+ *tag = variant->tag_value.i;
+ return 0;
}
-int bt_field_variant_get_tag_unsigned(struct bt_field *variant_field,
+int bt_field_variant_get_tag_unsigned(struct bt_field *field,
uint64_t *tag)
{
- return bt_field_common_variant_get_tag_unsigned((void *) variant_field, tag);
+ struct bt_field_variant *variant = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_VARIANT, "Field");
+ BT_ASSERT_PRE(variant->current_field,
+ "Variant field has no current field: %!+f", field);
+ *tag = variant->tag_value.u;
+ return 0;
}
struct bt_field_type_enumeration_mapping_iterator *
bt_field_enumeration_get_mappings(struct bt_field *field)
{
struct bt_field_enumeration *enum_field = (void *) field;
+ struct bt_field_type_enumeration *enum_type = NULL;
+ struct bt_field_type_integer *integer_type = NULL;
+ struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
+ BT_ASSERT(field);
+ BT_ASSERT(field->type->id == BT_FIELD_TYPE_ID_ENUM);
+ BT_ASSERT(field->payload_set);
BT_ASSERT_PRE_NON_NULL(field, "Enumeration field");
- BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID((struct bt_field_common *) field,
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID((struct bt_field *) field,
BT_FIELD_TYPE_ID_ENUM, "Field");
- BT_ASSERT_PRE_FIELD_COMMON_IS_SET((struct bt_field_common *) field,
+ BT_ASSERT_PRE_FIELD_IS_SET((struct bt_field *) field,
"Enumeration field");
- return bt_field_common_enumeration_get_mappings((void *) field,
- (bt_field_common_create_func) bt_field_create_recursive,
- enum_field->common.payload.unsignd);
+ enum_type = (void *) field->type;
+ integer_type = enum_type->container_ft;
+
+ if (!integer_type->is_signed) {
+ iter = bt_field_type_enumeration_unsigned_find_mappings_by_value(
+ field->type,
+ enum_field->common.payload.unsignd);
+ } else {
+ iter = bt_field_type_enumeration_signed_find_mappings_by_value(
+ field->type,
+ enum_field->common.payload.signd);
+ }
+
+ return iter;
}
BT_ASSERT_PRE_FUNC
static inline
-struct bt_field_type_common_integer *get_int_enum_int_ft(
+struct bt_field_type_integer *get_int_enum_int_ft(
struct bt_field *field)
{
- struct bt_field_common_integer *int_field = (void *) field;
- struct bt_field_type_common_integer *int_ft = NULL;
+ struct bt_field_integer *int_field = (void *) field;
+ struct bt_field_type_integer *int_ft = NULL;
if (int_field->common.type->id == BT_FIELD_TYPE_ID_INTEGER) {
- int_ft = BT_FROM_COMMON(int_field->common.type);
+ int_ft = (void *) int_field->common.type;
} else if (int_field->common.type->id == BT_FIELD_TYPE_ID_ENUM) {
- struct bt_field_type_common_enumeration *enum_ft =
- BT_FROM_COMMON(int_field->common.type);
+ struct bt_field_type_enumeration *enum_ft =
+ (void *) int_field->common.type;
int_ft = enum_ft->container_ft;
+ } else {
+ abort();
}
BT_ASSERT(int_ft);
int bt_field_integer_signed_get_value(struct bt_field *field, int64_t *value)
{
- struct bt_field_common_integer *integer = (void *) field;
+ struct bt_field_integer *integer = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Integer/enumeration field");
BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_FIELD_COMMON_IS_SET(BT_TO_COMMON(integer),
+ BT_ASSERT_PRE_FIELD_IS_SET(field,
"Integer/enumeration field");
- BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
- BT_ASSERT_PRE(bt_field_type_common_integer_is_signed(
- BT_TO_COMMON(get_int_enum_int_ft(field))),
+ BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+ BT_ASSERT_PRE(bt_field_type_integer_is_signed(
+ (void *) get_int_enum_int_ft(field)),
"Field's type is unsigned: %!+f", field);
*value = integer->payload.signd;
return 0;
int bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
{
int ret = 0;
- struct bt_field_common_integer *integer = (void *) field;
+ struct bt_field_integer *integer = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Integer field");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(BT_TO_COMMON(integer), "Integer field");
- BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
- BT_ASSERT_PRE(bt_field_type_common_integer_is_signed(
- BT_FROM_COMMON(get_int_enum_int_ft(field))),
+ BT_ASSERT_PRE_FIELD_HOT(field, "Integer field");
+ BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+ BT_ASSERT_PRE(bt_field_type_integer_is_signed(
+ (void *) get_int_enum_int_ft(field)),
"Field's type is unsigned: %!+f", field);
BT_ASSERT_PRE(value_is_in_range_signed(
get_int_enum_int_ft(field)->size, value),
int bt_field_integer_unsigned_get_value(struct bt_field *field, uint64_t *value)
{
- struct bt_field_common_integer *integer = (void *) field;
+ struct bt_field_integer *integer = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Integer field");
BT_ASSERT_PRE_NON_NULL(value, "Value");
- BT_ASSERT_PRE_FIELD_COMMON_IS_SET(BT_TO_COMMON(integer), "Integer field");
- BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
- BT_ASSERT_PRE(!bt_field_type_common_integer_is_signed(
- BT_FROM_COMMON(get_int_enum_int_ft(field))),
+ BT_ASSERT_PRE_FIELD_IS_SET(field, "Integer field");
+ BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+ BT_ASSERT_PRE(!bt_field_type_integer_is_signed(
+ (void *) get_int_enum_int_ft(field)),
"Field's type is signed: %!+f", field);
*value = integer->payload.unsignd;
return 0;
int bt_field_integer_unsigned_set_value(struct bt_field *field,
uint64_t value)
{
- struct bt_field_common_integer *integer = (void *) field;
+ struct bt_field_integer *integer = (void *) field;
BT_ASSERT_PRE_NON_NULL(field, "Integer field");
- BT_ASSERT_PRE_FIELD_COMMON_HOT(BT_TO_COMMON(integer), "Integer field");
- BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
- BT_ASSERT_PRE(!bt_field_type_common_integer_is_signed(
- BT_FROM_COMMON(get_int_enum_int_ft(field))),
+ BT_ASSERT_PRE_FIELD_HOT(field, "Integer field");
+ BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+ BT_ASSERT_PRE(!bt_field_type_integer_is_signed(
+ (void *) get_int_enum_int_ft(field)),
"Field's type is signed: %!+f", field);
BT_ASSERT_PRE(value_is_in_range_unsigned(
get_int_enum_int_ft(field)->size, value),
int bt_field_floating_point_get_value(struct bt_field *field,
double *value)
{
- return bt_field_common_floating_point_get_value((void *) field, value);
+ struct bt_field_floating_point *floating_point = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_FIELD_IS_SET(field, "Floating point number field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_FLOAT, "Field");
+ *value = floating_point->payload;
+ return 0;
}
int bt_field_floating_point_set_value(struct bt_field *field,
double value)
{
- return bt_field_common_floating_point_set_value((void *) field, value);
+ struct bt_field_floating_point *floating_point = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+ BT_ASSERT_PRE_FIELD_HOT(field, "Floating point number field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_FLOAT, "Field");
+ floating_point->payload = value;
+ bt_field_set(field, true);
+ return 0;
}
const char *bt_field_string_get_value(struct bt_field *field)
{
- return bt_field_common_string_get_value((void *) field);
+ struct bt_field_string *string = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_FIELD_IS_SET(field, "String field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRING, "Field");
+ return (const char *) string->buf->data;
}
int bt_field_string_set_value(struct bt_field *field, const char *value)
{
- return bt_field_common_string_set_value((void *) field, value);
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRING, "Field");
+ bt_field_string_clear(field);
+ return bt_field_string_append_len(field,
+ value, strlen(value));
}
int bt_field_string_append(struct bt_field *field, const char *value)
{
- return bt_field_common_string_append((void *) field, value);
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ return bt_field_string_append_len(field, value,
+ strlen(value));
}
int bt_field_string_append_len(struct bt_field *field,
const char *value, unsigned int length)
{
- return bt_field_common_string_append_len((void *) field, value, length);
-}
+ struct bt_field_string *string_field = (void *) field;
+ char *data;
+ size_t new_size;
-int bt_field_string_clear(struct bt_field *string_field)
-{
- return bt_field_common_string_clear((void *) string_field);
-}
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_NON_NULL(value, "Value");
+ BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRING, "Field");
-BT_HIDDEN
-struct bt_field_common *bt_field_common_copy(struct bt_field_common *field)
-{
- struct bt_field_common *copy = NULL;
+ /* Make sure no null bytes are appended */
+ BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+ "String value to append contains a null character: "
+ "partial-value=\"%.32s\", length=%u", value, length);
- BT_ASSERT_PRE_NON_NULL(field, "Field");
- BT_ASSERT(field_type_common_has_known_id(field->type));
- BT_ASSERT(field->methods->copy);
- copy = field->methods->copy(field);
- if (!copy) {
- BT_LOGW("Cannot create field: ft-addr=%p", field->type);
- goto end;
+ new_size = string_field->size + length;
+
+ if (unlikely(new_size + 1 > string_field->buf->len)) {
+ g_array_set_size(string_field->buf, new_size + 1);
}
- bt_field_common_set(copy, field->payload_set);
+ data = string_field->buf->data;
+ memcpy(data + string_field->size, value, length);
+ ((char *) string_field->buf->data)[new_size] = '\0';
+ string_field->size = new_size;
+ bt_field_set(field, true);
+ return 0;
+}
-end:
- return copy;
+int bt_field_string_clear(struct bt_field *field)
+{
+ struct bt_field_string *string_field = (void *) field;
+
+ BT_ASSERT_PRE_NON_NULL(field, "String field");
+ BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+ BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+ BT_FIELD_TYPE_ID_STRING, "Field");
+ string_field->size = 0;
+ bt_field_set(field, true);
+ return 0;
+}
+
+static inline
+void bt_field_finalize(struct bt_field *field)
+{
+ BT_ASSERT(field);
+ BT_LOGD_STR("Putting field's type.");
+ bt_put(field->type);
}
static
void bt_field_integer_destroy(struct bt_field *field)
{
+ BT_ASSERT(field);
BT_LOGD("Destroying integer field object: addr=%p", field);
- bt_field_common_integer_finalize((void *) field);
+ bt_field_finalize(field);
g_free(field);
}
static
void bt_field_floating_point_destroy(struct bt_field *field)
{
+ BT_ASSERT(field);
BT_LOGD("Destroying floating point field object: addr=%p", field);
- bt_field_common_floating_point_finalize((void *) field);
+ bt_field_finalize(field);
g_free(field);
}
void bt_field_enumeration_destroy(struct bt_field *field)
{
BT_LOGD("Destroying enumeration field object: addr=%p", field);
- bt_field_common_finalize((void *) field);
+ bt_field_finalize((void *) field);
g_free(field);
}
static
void bt_field_structure_destroy_recursive(struct bt_field *field)
{
+ struct bt_field_structure *structure = (void *) field;
+
+ BT_ASSERT(field);
BT_LOGD("Destroying structure field object: addr=%p", field);
- bt_field_common_structure_finalize_recursive((void *) field);
+ bt_field_finalize(field);
+
+ if (structure->fields) {
+ g_ptr_array_free(structure->fields, TRUE);
+ }
+
g_free(field);
}
static
void bt_field_variant_destroy_recursive(struct bt_field *field)
{
+ struct bt_field_variant *variant = (void *) field;
+
+ BT_ASSERT(field);
BT_LOGD("Destroying variant field object: addr=%p", field);
- bt_field_common_variant_finalize_recursive((void *) field);
+ bt_field_finalize(field);
+
+ if (variant->fields) {
+ g_ptr_array_free(variant->fields, TRUE);
+ }
+
g_free(field);
}
static
void bt_field_array_destroy_recursive(struct bt_field *field)
{
+ struct bt_field_array *array = (void *) field;
+
+ BT_ASSERT(field);
BT_LOGD("Destroying array field object: addr=%p", field);
- bt_field_common_array_finalize_recursive((void *) field);
+ bt_field_finalize(field);
+
+ if (array->elements) {
+ g_ptr_array_free(array->elements, TRUE);
+ }
+
g_free(field);
}
static
void bt_field_sequence_destroy_recursive(struct bt_field *field)
{
+ struct bt_field_sequence *sequence = (void *) field;
+
+ BT_ASSERT(field);
BT_LOGD("Destroying sequence field object: addr=%p", field);
- bt_field_common_sequence_finalize_recursive((void *) field);
+ bt_field_finalize(field);
+
+ if (sequence->elements) {
+ g_ptr_array_free(sequence->elements, TRUE);
+ }
g_free(field);
}
static
void bt_field_string_destroy(struct bt_field *field)
{
+ struct bt_field_string *string = (void *) field;
+
BT_LOGD("Destroying string field object: addr=%p", field);
- bt_field_common_string_finalize((void *) field);
+ BT_ASSERT(field);
+ bt_field_finalize(field);
+
+ if (string->buf) {
+ g_array_free(string->buf, TRUE);
+ }
+
g_free(field);
}
BT_HIDDEN
void bt_field_destroy_recursive(struct bt_field *field)
{
- struct bt_field_common *field_common = (void *) field;
-
if (!field) {
return;
}
- BT_ASSERT(field_type_common_has_known_id((void *) field_common->type));
- field_destroy_funcs[field_common->type->id](field);
+ BT_ASSERT(bt_field_type_has_known_id((void *) field->type));
+ field_destroy_funcs[field->type->id](field);
+}
+
+static inline
+void bt_field_initialize(struct bt_field *field,
+ struct bt_field_type *ft,
+ struct bt_field_methods *methods)
+{
+ BT_ASSERT(field);
+ BT_ASSERT(ft);
+ bt_object_init_unique(&field->base);
+ field->methods = methods;
+ field->type = bt_get(ft);
}
static
struct bt_field *bt_field_integer_create(struct bt_field_type *type)
{
- struct bt_field_common_integer *integer =
- g_new0(struct bt_field_common_integer, 1);
+ struct bt_field_integer *integer =
+ g_new0(struct bt_field_integer, 1);
BT_LOGD("Creating integer field object: ft-addr=%p", type);
if (integer) {
- bt_field_common_initialize(BT_TO_COMMON(integer), (void *) type,
- false, NULL, &bt_field_integer_methods);
+ bt_field_initialize((void *) integer, (void *) type,
+ &bt_field_integer_methods);
BT_LOGD("Created integer field object: addr=%p, ft-addr=%p",
integer, type);
} else {
BT_LOGD("Creating enumeration field object: ft-addr=%p", type);
if (enumeration) {
- bt_field_common_initialize(
- BT_TO_COMMON(BT_TO_COMMON(enumeration)),
- (void *) type, false, NULL,
- &bt_field_enumeration_methods);
+ bt_field_initialize((void *) enumeration,
+ (void *) type, &bt_field_enumeration_methods);
BT_LOGD("Created enumeration field object: addr=%p, ft-addr=%p",
enumeration, type);
} else {
static
struct bt_field *bt_field_floating_point_create(struct bt_field_type *type)
{
- struct bt_field_common_floating_point *floating_point;
+ struct bt_field_floating_point *floating_point;
BT_LOGD("Creating floating point number field object: ft-addr=%p", type);
- floating_point = g_new0(struct bt_field_common_floating_point, 1);
+ floating_point = g_new0(struct bt_field_floating_point, 1);
if (floating_point) {
- bt_field_common_initialize(BT_TO_COMMON(floating_point),
- (void *) type, false, NULL,
- &bt_field_floating_point_methods);
+ bt_field_initialize((void *) floating_point,
+ (void *) type, &bt_field_floating_point_methods);
BT_LOGD("Created floating point number field object: addr=%p, ft-addr=%p",
floating_point, type);
} else {
return (void *) floating_point;
}
-BT_HIDDEN
-int bt_field_common_structure_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
+static inline
+int bt_field_structure_initialize(struct bt_field *field,
+ struct bt_field_type *type,
+ struct bt_field_methods *methods,
+ bt_field_create_func field_create_func,
GDestroyNotify field_release_func)
{
int ret = 0;
- struct bt_field_type_common_structure *structure_type =
- BT_FROM_COMMON(type);
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+ struct bt_field_type_structure *structure_type = (void *) type;
+ struct bt_field_structure *structure = (void *) field;
size_t i;
- BT_LOGD("Initializing common structure field object: ft-addr=%p", type);
- bt_field_common_initialize(field, type, is_shared,
- release_func, methods);
+ BT_LOGD("Initializing structure field object: ft-addr=%p", type);
+ bt_field_initialize(field, type, methods);
structure->fields = g_ptr_array_new_with_free_func(field_release_func);
g_ptr_array_set_size(structure->fields, structure_type->fields->len);
/* Create all fields contained in the structure field. */
for (i = 0; i < structure_type->fields->len; i++) {
- struct bt_field_common *field;
- struct bt_field_type_common_structure_field *struct_field =
- BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+ struct bt_field *field;
+ struct bt_field_type_structure_field *struct_field =
+ BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
structure_type, i);
field = field_create_func(struct_field->type);
if (!field) {
g_ptr_array_index(structure->fields, i) = field;
}
- BT_LOGD("Initialized common structure field object: addr=%p, ft-addr=%p",
+ BT_LOGD("Initialized structure field object: addr=%p, ft-addr=%p",
field, type);
end:
static
struct bt_field *bt_field_structure_create(struct bt_field_type *type)
{
- struct bt_field_common_structure *structure = g_new0(
- struct bt_field_common_structure, 1);
+ struct bt_field_structure *structure = g_new0(
+ struct bt_field_structure, 1);
int iret;
BT_LOGD("Creating structure field object: ft-addr=%p", type);
goto end;
}
- iret = bt_field_common_structure_initialize(BT_TO_COMMON(structure),
- (void *) type, false, NULL, &bt_field_structure_methods,
- (bt_field_common_create_func) bt_field_create_recursive,
+ iret = bt_field_structure_initialize((void *) structure,
+ (void *) type, &bt_field_structure_methods,
+ (bt_field_create_func) bt_field_create_recursive,
(GDestroyNotify) bt_field_destroy_recursive);
if (iret) {
BT_PUT(structure);
return (void *) structure;
}
-BT_HIDDEN
-int bt_field_common_variant_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
+static inline
+int bt_field_variant_initialize(struct bt_field *field,
+ struct bt_field_type *type,
+ struct bt_field_methods *methods,
+ bt_field_create_func field_create_func,
GDestroyNotify field_release_func)
{
int ret = 0;
- struct bt_field_type_common_variant *variant_type =
- BT_FROM_COMMON(type);
- struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+ struct bt_field_type_variant *variant_type = (void *) type;
+ struct bt_field_variant *variant = (void *) field;
size_t i;
- BT_LOGD("Initializing common variant field object: ft-addr=%p", type);
- bt_field_common_initialize(field, type, is_shared,
- release_func, methods);
- ret = bt_field_type_common_variant_update_choices(type);
+ BT_LOGD("Initializing variant field object: ft-addr=%p", type);
+ bt_field_initialize(field, type, methods);
+ ret = bt_field_type_variant_update_choices(type);
if (ret) {
- BT_LOGE("Cannot update common variant field type choices: "
+ BT_LOGE("Cannot update variant field type choices: "
"ret=%d", ret);
goto end;
}
/* Create all fields contained in the variant field. */
for (i = 0; i < variant_type->choices->len; i++) {
- struct bt_field_common *field;
- struct bt_field_type_common_variant_choice *var_choice =
- BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+ struct bt_field *field;
+ struct bt_field_type_variant_choice *var_choice =
+ BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
variant_type, i);
field = field_create_func(var_choice->type);
g_ptr_array_index(variant->fields, i) = field;
}
- BT_LOGD("Initialized common variant field object: addr=%p, ft-addr=%p",
+ BT_LOGD("Initialized variant field object: addr=%p, ft-addr=%p",
field, type);
end:
return ret;
}
-BT_HIDDEN
-int bt_field_common_string_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods)
+static inline
+int bt_field_string_initialize(struct bt_field *field,
+ struct bt_field_type *type,
+ struct bt_field_methods *methods)
{
int ret = 0;
- struct bt_field_common_string *string = BT_FROM_COMMON(field);
+ struct bt_field_string *string = (void *) field;
- BT_LOGD("Initializing common string field object: ft-addr=%p", type);
- bt_field_common_initialize(field, type, is_shared,
- release_func, methods);
+ BT_LOGD("Initializing string field object: ft-addr=%p", type);
+ bt_field_initialize(field, type, methods);
string->buf = g_array_sized_new(FALSE, FALSE, sizeof(char), 1);
if (!string->buf) {
ret = -1;
}
g_array_index(string->buf, char, 0) = '\0';
- BT_LOGD("Initialized common string field object: addr=%p, ft-addr=%p",
+ BT_LOGD("Initialized string field object: addr=%p, ft-addr=%p",
field, type);
end:
static
struct bt_field *bt_field_variant_create(struct bt_field_type *type)
{
- struct bt_field_common_variant *variant = g_new0(
- struct bt_field_common_variant, 1);
+ struct bt_field_variant *variant = g_new0(
+ struct bt_field_variant, 1);
int iret;
BT_LOGD("Creating variant field object: ft-addr=%p", type);
goto end;
}
- iret = bt_field_common_variant_initialize(BT_TO_COMMON(variant),
- (void *) type, false, NULL, &bt_field_variant_methods,
- (bt_field_common_create_func) bt_field_create_recursive,
+ iret = bt_field_variant_initialize((void *) variant,
+ (void *) type, &bt_field_variant_methods,
+ (bt_field_create_func) bt_field_create_recursive,
(GDestroyNotify) bt_field_destroy_recursive);
if (iret) {
BT_PUT(variant);
return (void *) variant;
}
-BT_HIDDEN
-int bt_field_common_array_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
- bt_field_common_create_func field_create_func,
+static inline
+int bt_field_array_initialize(struct bt_field *field,
+ struct bt_field_type *type,
+ struct bt_field_methods *methods,
+ bt_field_create_func field_create_func,
GDestroyNotify field_destroy_func)
{
- struct bt_field_type_common_array *array_type = BT_FROM_COMMON(type);
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
+ struct bt_field_type_array *array_type = (void *) type;
+ struct bt_field_array *array = (void *) field;
unsigned int array_length;
int ret = 0;
uint64_t i;
- BT_LOGD("Initializing common array field object: ft-addr=%p", type);
+ BT_LOGD("Initializing array field object: ft-addr=%p", type);
BT_ASSERT(type);
- bt_field_common_initialize(field, type, is_shared,
- release_func, methods);
+ bt_field_initialize(field, type, methods);
array_length = array_type->length;
array->elements = g_ptr_array_sized_new(array_length);
if (!array->elements) {
}
}
- BT_LOGD("Initialized common array field object: addr=%p, ft-addr=%p",
+ BT_LOGD("Initialized array field object: addr=%p, ft-addr=%p",
field, type);
end:
static
struct bt_field *bt_field_array_create(struct bt_field_type *type)
{
- struct bt_field_common_array *array =
- g_new0(struct bt_field_common_array, 1);
+ struct bt_field_array *array =
+ g_new0(struct bt_field_array, 1);
int ret;
BT_LOGD("Creating array field object: ft-addr=%p", type);
goto end;
}
- ret = bt_field_common_array_initialize(BT_TO_COMMON(array),
- (void *) type, false, NULL, &bt_field_array_methods,
- (bt_field_common_create_func) bt_field_create_recursive,
+ ret = bt_field_array_initialize((void *) array,
+ (void *) type, &bt_field_array_methods,
+ (bt_field_create_func) bt_field_create_recursive,
(GDestroyNotify) bt_field_destroy_recursive);
if (ret) {
BT_PUT(array);
return (void *) array;
}
-BT_HIDDEN
-int bt_field_common_sequence_initialize(struct bt_field_common *field,
- struct bt_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
- struct bt_field_common_methods *methods,
+static inline
+int bt_field_sequence_initialize(struct bt_field *field,
+ struct bt_field_type *type,
+ struct bt_field_methods *methods,
GDestroyNotify field_destroy_func)
{
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+ struct bt_field_sequence *sequence = (void *) field;
int ret = 0;
- BT_LOGD("Initializing common sequence field object: ft-addr=%p", type);
+ BT_LOGD("Initializing sequence field object: ft-addr=%p", type);
BT_ASSERT(type);
- bt_field_common_initialize(field, type, is_shared,
- release_func, methods);
+ bt_field_initialize(field, type, methods);
sequence->elements = g_ptr_array_new();
if (!sequence->elements) {
ret = -1;
}
g_ptr_array_set_free_func(sequence->elements, field_destroy_func);
- BT_LOGD("Initialized common sequence field object: addr=%p, ft-addr=%p",
+ BT_LOGD("Initialized sequence field object: addr=%p, ft-addr=%p",
field, type);
end:
static
struct bt_field *bt_field_sequence_create(struct bt_field_type *type)
{
- struct bt_field_common_sequence *sequence =
- g_new0(struct bt_field_common_sequence, 1);
+ struct bt_field_sequence *sequence =
+ g_new0(struct bt_field_sequence, 1);
int ret;
BT_LOGD("Creating sequence field object: ft-addr=%p", type);
goto end;
}
- ret = bt_field_common_sequence_initialize(BT_TO_COMMON(sequence),
- (void *) type, false, NULL, &bt_field_sequence_methods,
+ ret = bt_field_sequence_initialize((void *) sequence,
+ (void *) type, &bt_field_sequence_methods,
(GDestroyNotify) bt_field_destroy_recursive);
if (ret) {
BT_PUT(sequence);
static
struct bt_field *bt_field_string_create(struct bt_field_type *type)
{
- struct bt_field_common_string *string = g_new0(
- struct bt_field_common_string, 1);
+ struct bt_field_string *string = g_new0(
+ struct bt_field_string, 1);
BT_LOGD("Creating string field object: ft-addr=%p", type);
if (string) {
- bt_field_common_string_initialize(BT_TO_COMMON(string),
- (void *) type, false, NULL, &bt_field_string_methods);
+ bt_field_string_initialize((void *) string,
+ (void *) type, &bt_field_string_methods);
BT_LOGD("Created string field object: addr=%p, ft-addr=%p",
string, type);
} else {
return (void *) string;
}
-BT_HIDDEN
-int bt_field_common_generic_validate(struct bt_field_common *field)
+static
+int bt_field_generic_validate(struct bt_field *field)
{
return (field && field->payload_set) ? 0 : -1;
}
-BT_HIDDEN
-int bt_field_common_structure_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_structure_validate_recursive(struct bt_field *field)
{
int64_t i;
int ret = 0;
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+ struct bt_field_structure *structure = (void *) field;
BT_ASSERT(field);
for (i = 0; i < structure->fields->len; i++) {
- ret = bt_field_common_validate_recursive(
+ ret = bt_field_validate_recursive(
(void *) structure->fields->pdata[i]);
if (ret) {
int this_ret;
const char *name;
- this_ret = bt_field_type_common_structure_borrow_field_by_index(
+ this_ret = bt_field_type_structure_borrow_field_by_index(
field->type, &name, NULL, i);
BT_ASSERT(this_ret == 0);
BT_ASSERT_PRE_MSG("Invalid structure field's field: "
- "%![struct-field-]+_f, field-name=\"%s\", "
- "index=%" PRId64 ", %![field-]+_f",
+ "%![struct-field-]+f, field-name=\"%s\", "
+ "index=%" PRId64 ", %![field-]+f",
field, name, i, structure->fields->pdata[i]);
goto end;
}
return ret;
}
-BT_HIDDEN
-int bt_field_common_variant_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_variant_validate_recursive(struct bt_field *field)
{
int ret = 0;
- struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+ struct bt_field_variant *variant = (void *) field;
BT_ASSERT(field);
goto end;
}
- ret = bt_field_common_validate_recursive(variant->current_field);
+ ret = bt_field_validate_recursive(variant->current_field);
end:
return ret;
}
-BT_HIDDEN
-int bt_field_common_array_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_array_validate_recursive(struct bt_field *field)
{
int64_t i;
int ret = 0;
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
+ struct bt_field_array *array = (void *) field;
BT_ASSERT(field);
for (i = 0; i < array->elements->len; i++) {
- ret = bt_field_common_validate_recursive((void *) array->elements->pdata[i]);
+ ret = bt_field_validate_recursive((void *) array->elements->pdata[i]);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid array field's element field: "
- "%![array-field-]+_f, " PRId64 ", "
- "%![elem-field-]+_f",
+ "%![array-field-]+f, " PRId64 ", "
+ "%![elem-field-]+f",
field, i, array->elements->pdata[i]);
goto end;
}
return ret;
}
-BT_HIDDEN
-int bt_field_common_sequence_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_sequence_validate_recursive(struct bt_field *field)
{
size_t i;
int ret = 0;
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+ struct bt_field_sequence *sequence = (void *) field;
BT_ASSERT(field);
for (i = 0; i < sequence->elements->len; i++) {
- ret = bt_field_common_validate_recursive(
+ ret = bt_field_validate_recursive(
(void *) sequence->elements->pdata[i]);
if (ret) {
BT_ASSERT_PRE_MSG("Invalid sequence field's element field: "
- "%![seq-field-]+_f, " PRId64 ", "
- "%![elem-field-]+_f",
+ "%![seq-field-]+f, " PRId64 ", "
+ "%![elem-field-]+f",
field, i, sequence->elements->pdata[i]);
goto end;
}
return ret;
}
-BT_HIDDEN
-void bt_field_common_generic_reset(struct bt_field_common *field)
+static
+void bt_field_generic_reset(struct bt_field *field)
{
BT_ASSERT(field);
field->payload_set = false;
}
-BT_HIDDEN
-void bt_field_common_structure_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_structure_reset_recursive(struct bt_field *field)
{
int64_t i;
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+ struct bt_field_structure *structure = (void *) field;
BT_ASSERT(field);
for (i = 0; i < structure->fields->len; i++) {
- struct bt_field_common *member = structure->fields->pdata[i];
+ struct bt_field *member = structure->fields->pdata[i];
if (!member) {
/*
continue;
}
- bt_field_common_reset_recursive(member);
+ bt_field_reset_recursive(member);
}
}
-BT_HIDDEN
-void bt_field_common_variant_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_variant_reset_recursive(struct bt_field *field)
{
- struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+ struct bt_field_variant *variant = (void *) field;
BT_ASSERT(field);
variant->current_field = NULL;
}
-BT_HIDDEN
-void bt_field_common_array_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_array_reset_recursive(struct bt_field *field)
{
size_t i;
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
+ struct bt_field_array *array = (void *) field;
BT_ASSERT(field);
for (i = 0; i < array->elements->len; i++) {
- struct bt_field_common *member = array->elements->pdata[i];
+ struct bt_field *member = array->elements->pdata[i];
if (!member) {
/*
continue;
}
- bt_field_common_reset_recursive(member);
+ bt_field_reset_recursive(member);
}
}
-BT_HIDDEN
-void bt_field_common_sequence_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_sequence_reset_recursive(struct bt_field *field)
{
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+ struct bt_field_sequence *sequence = (void *) field;
uint64_t i;
BT_ASSERT(field);
for (i = 0; i < sequence->elements->len; i++) {
if (sequence->elements->pdata[i]) {
- bt_field_common_reset_recursive(
+ bt_field_reset_recursive(
sequence->elements->pdata[i]);
}
}
sequence->length = 0;
}
-BT_HIDDEN
-void bt_field_common_generic_set_is_frozen(struct bt_field_common *field,
+static
+void bt_field_generic_set_is_frozen(struct bt_field *field,
bool is_frozen)
{
field->frozen = is_frozen;
}
-BT_HIDDEN
-void bt_field_common_structure_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_structure_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen)
{
uint64_t i;
- struct bt_field_common_structure *structure_field =
- BT_FROM_COMMON(field);
+ struct bt_field_structure *structure_field = (void *) field;
BT_LOGD("Freezing structure field object: addr=%p", field);
for (i = 0; i < structure_field->fields->len; i++) {
- struct bt_field_common *struct_field =
+ struct bt_field *struct_field =
g_ptr_array_index(structure_field->fields, i);
BT_LOGD("Freezing structure field's field: field-addr=%p, index=%" PRId64,
struct_field, i);
- bt_field_common_set_is_frozen_recursive(struct_field,
+ bt_field_set_is_frozen_recursive(struct_field,
is_frozen);
}
- bt_field_common_generic_set_is_frozen(field, is_frozen);
+ bt_field_generic_set_is_frozen(field, is_frozen);
}
-BT_HIDDEN
-void bt_field_common_variant_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_variant_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen)
{
uint64_t i;
- struct bt_field_common_variant *variant_field = BT_FROM_COMMON(field);
+ struct bt_field_variant *variant_field = (void *) field;
BT_LOGD("Freezing variant field object: addr=%p", field);
for (i = 0; i < variant_field->fields->len; i++) {
- struct bt_field_common *var_field =
+ struct bt_field *var_field =
g_ptr_array_index(variant_field->fields, i);
BT_LOGD("Freezing variant field's field: field-addr=%p, index=%" PRId64,
var_field, i);
- bt_field_common_set_is_frozen_recursive(var_field, is_frozen);
+ bt_field_set_is_frozen_recursive(var_field, is_frozen);
}
- bt_field_common_generic_set_is_frozen(field, is_frozen);
+ bt_field_generic_set_is_frozen(field, is_frozen);
}
-BT_HIDDEN
-void bt_field_common_array_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_array_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen)
{
int64_t i;
- struct bt_field_common_array *array_field = BT_FROM_COMMON(field);
+ struct bt_field_array *array_field = (void *) field;
BT_LOGD("Freezing array field object: addr=%p", field);
for (i = 0; i < array_field->elements->len; i++) {
- struct bt_field_common *elem_field =
+ struct bt_field *elem_field =
g_ptr_array_index(array_field->elements, i);
BT_LOGD("Freezing array field object's element field: "
"element-field-addr=%p, index=%" PRId64,
elem_field, i);
- bt_field_common_set_is_frozen_recursive(elem_field, is_frozen);
+ bt_field_set_is_frozen_recursive(elem_field, is_frozen);
}
- bt_field_common_generic_set_is_frozen(field, is_frozen);
+ bt_field_generic_set_is_frozen(field, is_frozen);
}
-BT_HIDDEN
-void bt_field_common_sequence_set_is_frozen_recursive(
- struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_sequence_set_is_frozen_recursive(
+ struct bt_field *field, bool is_frozen)
{
int64_t i;
- struct bt_field_common_sequence *sequence_field =
- BT_FROM_COMMON(field);
+ struct bt_field_sequence *sequence_field = (void *) field;
BT_LOGD("Freezing sequence field object: addr=%p", field);
for (i = 0; i < sequence_field->length; i++) {
- struct bt_field_common *elem_field =
+ struct bt_field *elem_field =
g_ptr_array_index(sequence_field->elements, i);
BT_LOGD("Freezing sequence field object's element field: "
"element-field-addr=%p, index=%" PRId64,
elem_field, i);
- bt_field_common_set_is_frozen_recursive(elem_field, is_frozen);
+ bt_field_set_is_frozen_recursive(elem_field, is_frozen);
}
- bt_field_common_generic_set_is_frozen(field, is_frozen);
+ bt_field_generic_set_is_frozen(field, is_frozen);
}
BT_HIDDEN
-void _bt_field_common_set_is_frozen_recursive(struct bt_field_common *field,
+void _bt_field_set_is_frozen_recursive(struct bt_field *field,
bool is_frozen)
{
if (!field) {
BT_LOGD("Setting field object's frozen state: addr=%p, is-frozen=%d",
field, is_frozen);
- BT_ASSERT(field_type_common_has_known_id(field->type));
+ BT_ASSERT(bt_field_type_has_known_id(field->type));
BT_ASSERT(field->methods->set_is_frozen);
field->methods->set_is_frozen(field, is_frozen);
return;
}
-BT_HIDDEN
-bt_bool bt_field_common_generic_is_set(struct bt_field_common *field)
+static
+bt_bool bt_field_generic_is_set(struct bt_field *field)
{
return field && field->payload_set;
}
-BT_HIDDEN
-bt_bool bt_field_common_structure_is_set_recursive(
- struct bt_field_common *field)
+static
+bt_bool bt_field_structure_is_set_recursive(
+ struct bt_field *field)
{
bt_bool is_set = BT_FALSE;
size_t i;
- struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+ struct bt_field_structure *structure = (void *) field;
BT_ASSERT(field);
for (i = 0; i < structure->fields->len; i++) {
- is_set = bt_field_common_is_set_recursive(
+ is_set = bt_field_is_set_recursive(
structure->fields->pdata[i]);
if (!is_set) {
goto end;
return is_set;
}
-BT_HIDDEN
-bt_bool bt_field_common_variant_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_variant_is_set_recursive(struct bt_field *field)
{
- struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+ struct bt_field_variant *variant = (void *) field;
bt_bool is_set = BT_FALSE;
BT_ASSERT(field);
if (variant->current_field) {
- is_set = bt_field_common_is_set_recursive(
+ is_set = bt_field_is_set_recursive(
variant->current_field);
}
return is_set;
}
-BT_HIDDEN
-bt_bool bt_field_common_array_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_array_is_set_recursive(struct bt_field *field)
{
size_t i;
bt_bool is_set = BT_FALSE;
- struct bt_field_common_array *array = BT_FROM_COMMON(field);
+ struct bt_field_array *array = (void *) field;
BT_ASSERT(field);
for (i = 0; i < array->elements->len; i++) {
- is_set = bt_field_common_is_set_recursive(array->elements->pdata[i]);
+ is_set = bt_field_is_set_recursive(array->elements->pdata[i]);
if (!is_set) {
goto end;
}
return is_set;
}
-BT_HIDDEN
-bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_sequence_is_set_recursive(struct bt_field *field)
{
size_t i;
bt_bool is_set = BT_FALSE;
- struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+ struct bt_field_sequence *sequence = (void *) field;
BT_ASSERT(field);
}
for (i = 0; i < sequence->elements->len; i++) {
- is_set = bt_field_common_is_set_recursive(
+ is_set = bt_field_is_set_recursive(
sequence->elements->pdata[i]);
if (!is_set) {
goto end;
BT_ASSERT(stream);
packet->stream = NULL;
bt_object_pool_recycle_object(&stream->packet_pool, packet);
- bt_object_put_no_null_check(&stream->common.base);
+ bt_object_put_no_null_check(&stream->base);
}
BT_HIDDEN
"stream-name=\"%s\", stream-class-addr=%p, "
"stream-class-name=\"%s\", stream-class-id=%" PRId64,
stream, bt_stream_get_name(stream),
- 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->stream_class,
+ bt_stream_class_get_name(stream->stream_class),
+ bt_stream_class_get_id(stream->stream_class));
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
trace = bt_stream_class_borrow_trace(stream_class);
(bt_object_release_func) bt_packet_recycle);
packet->stream = bt_get(stream);
- if (trace->common.packet_header_field_type) {
+ if (trace->packet_header_field_type) {
BT_LOGD("Creating initial packet header field: ft-addr=%p",
- trace->common.packet_header_field_type);
+ trace->packet_header_field_type);
packet->header = bt_field_wrapper_create(
&trace->packet_header_field_pool,
- (void *) trace->common.packet_header_field_type);
+ (void *) trace->packet_header_field_type);
if (!packet->header) {
BT_LOGE("Cannot create packet header field wrapper.");
BT_PUT(packet);
}
}
- if (stream->common.stream_class->packet_context_field_type) {
+ if (stream->stream_class->packet_context_field_type) {
BT_LOGD("Creating initial packet context field: ft-addr=%p",
- stream->common.stream_class->packet_context_field_type);
+ stream->stream_class->packet_context_field_type);
packet->context = bt_field_wrapper_create(
&stream_class->packet_context_field_pool,
- (void *) stream->common.stream_class->packet_context_field_type);
+ (void *) stream->stream_class->packet_context_field_type);
if (!packet->context) {
BT_LOGE("Cannot create packet context field wrapper.");
BT_PUT(packet);
if (unlikely(!packet->stream)) {
packet->stream = stream;
bt_object_get_no_null_check_no_parent_check(
- &packet->stream->common.base);
+ &packet->stream->base);
}
ret = snapshot_prev_packet_properties(packet, prev_packet_avail,
BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
trace = bt_stream_class_borrow_trace(
bt_stream_borrow_class(packet->stream));
- BT_ASSERT_PRE(trace->common.packet_header_field_type,
+ BT_ASSERT_PRE(trace->packet_header_field_type,
"Trace has no packet header field type: %!+t",
trace);
BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field");
BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
stream_class = bt_stream_borrow_class(packet->stream);
- BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
+ BT_ASSERT_PRE(stream_class->packet_context_field_type,
"Stream class has no packet context field type: %!+S",
stream_class);
* `type` is owned by the stack frame.
*/
struct type_stack_frame {
- struct bt_field_type_common *type;
+ struct bt_field_type *type;
int index;
};
*/
struct resolve_context {
struct bt_value *environment;
- struct bt_field_type_common *scopes[6];
+ struct bt_field_type *scopes[6];
/* Root scope being visited */
enum bt_scope root_scope;
type_stack *type_stack;
- struct bt_field_type_common *cur_field_type;
+ struct bt_field_type *cur_field_type;
};
/* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
* `type` is owned by the caller (stack frame gets a new reference).
*/
static
-int type_stack_push(type_stack *stack, struct bt_field_type_common *type)
+int type_stack_push(type_stack *stack, struct bt_field_type *type)
{
int ret = 0;
struct type_stack_frame *frame = NULL;
* Return value is owned by `ctx` on success.
*/
static
-struct bt_field_type_common *get_type_from_ctx(struct resolve_context *ctx,
+struct bt_field_type *get_type_from_ctx(struct resolve_context *ctx,
enum bt_scope scope)
{
BT_ASSERT(scope >= BT_SCOPE_TRACE_PACKET_HEADER &&
*/
static
int ptokens_to_field_path(GList *ptokens, struct bt_field_path *field_path,
- struct bt_field_type_common *type, int src_index)
+ struct bt_field_type *type, int src_index)
{
int ret = 0;
GList *cur_ptoken = ptokens;
/* Locate target */
while (cur_ptoken) {
int child_index;
- struct bt_field_type_common *child_type;
+ struct bt_field_type *child_type;
const char *field_name = ptoken_get_string(cur_ptoken);
enum bt_field_type_id type_id =
- bt_field_type_common_get_type_id(type);
+ bt_field_type_get_type_id(type);
BT_LOGV("Current path token: token=\"%s\"", field_name);
type_id == BT_FIELD_TYPE_ID_SEQUENCE) {
child_index = -1;
} else {
- child_index = bt_field_type_common_get_field_index(type,
+ child_index = bt_field_type_get_field_index(type,
field_name);
if (child_index < 0) {
/*
g_array_append_val(field_path->indexes, child_index);
/* Get child field type */
- child_type = bt_field_type_common_borrow_field_at_index(type,
+ child_type = bt_field_type_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get child field type: "
{
int ret = 0;
GList *cur_ptoken;
- struct bt_field_type_common *type;
+ struct bt_field_type *type;
/* Skip absolute path tokens */
cur_ptoken = g_list_nth(ptokens,
parent_pos_in_stack = type_stack_size(ctx->type_stack) - 1;
while (parent_pos_in_stack >= 0) {
- struct bt_field_type_common *parent_type =
+ struct bt_field_type *parent_type =
type_stack_at(ctx->type_stack,
parent_pos_in_stack)->type;
int cur_index = type_stack_at(ctx->type_stack,
tail_field_path->indexes->len;
while (BT_TRUE) {
- struct bt_field_type_common *cur_type =
+ struct bt_field_type *cur_type =
type_stack_at(ctx->type_stack, i)->type;
int index = type_stack_at(
ctx->type_stack, i)->index;
field_path->root--;
while (field_path->root >= BT_SCOPE_TRACE_PACKET_HEADER) {
- struct bt_field_type_common *root_type;
+ struct bt_field_type *root_type;
bt_field_path_clear(field_path);
BT_LOGV("Looking into potential root scope: scope=%s",
* Return value is owned by the caller on success.
*/
static
-struct bt_field_type_common *field_path_to_field_type(
+struct bt_field_type *field_path_to_field_type(
struct bt_field_path *field_path,
struct resolve_context *ctx)
{
int i;
- struct bt_field_type_common *type;
+ struct bt_field_type *type;
/* Start with root type */
type = get_type_from_ctx(ctx, field_path->root);
/* Locate target */
for (i = 0; i < field_path->indexes->len; i++) {
- struct bt_field_type_common *child_type;
+ struct bt_field_type *child_type;
int child_index =
g_array_index(field_path->indexes, int, i);
/* Get child field type */
- child_type = bt_field_type_common_borrow_field_at_index(type,
+ child_type = bt_field_type_borrow_field_at_index(type,
child_index);
if (!child_type) {
BT_LOGW("Cannot get field type: "
*/
static
int validate_target_field_path(struct bt_field_path *target_field_path,
- struct bt_field_type_common *target_type,
+ struct bt_field_type *target_type,
struct resolve_context *ctx)
{
int ret = 0;
/*
* Make sure the target type has the right type and properties.
*/
- ctx_cur_field_type_id = bt_field_type_common_get_type_id(
+ ctx_cur_field_type_id = bt_field_type_get_type_id(
ctx->cur_field_type);
- target_type_id = bt_field_type_common_get_type_id(target_type);
+ target_type_id = bt_field_type_get_type_id(target_type);
switch (ctx_cur_field_type_id) {
case BT_FIELD_TYPE_ID_VARIANT:
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
if (target_type_id != BT_FIELD_TYPE_ID_INTEGER ||
- bt_field_type_common_integer_is_signed(target_type)) {
+ bt_field_type_integer_is_signed(target_type)) {
BT_LOGW("Sequence field type's length field type is not an unsigned integer field type: "
"length-ft-addr=%p, length-ft-id=%s",
target_type,
* `type` is owned by the caller.
*/
static
-int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
+int resolve_sequence_or_variant_type(struct bt_field_type *type,
struct resolve_context *ctx)
{
int ret = 0;
const char *pathstr;
- enum bt_field_type_id type_id = bt_field_type_common_get_type_id(type);
+ enum bt_field_type_id type_id = bt_field_type_get_type_id(type);
struct bt_field_path *target_field_path = NULL;
- struct bt_field_type_common *target_type = NULL;
+ struct bt_field_type *target_type = NULL;
GString *target_field_path_pretty = NULL;
const char *target_field_path_pretty_str;
switch (type_id) {
case BT_FIELD_TYPE_ID_SEQUENCE:
pathstr =
- bt_field_type_common_sequence_get_length_field_name(type);
+ bt_field_type_sequence_get_length_field_name(type);
break;
case BT_FIELD_TYPE_ID_VARIANT:
pathstr =
- bt_field_type_common_variant_get_tag_name(type);
+ bt_field_type_variant_get_tag_name(type);
break;
default:
abort();
/* Set target field path and target field type */
switch (type_id) {
case BT_FIELD_TYPE_ID_SEQUENCE:
- ret = bt_field_type_common_sequence_set_length_field_path(
+ ret = bt_field_type_sequence_set_length_field_path(
type, target_field_path);
if (ret) {
BT_LOGW("Cannot set sequence field type's length field path: "
}
break;
case BT_FIELD_TYPE_ID_VARIANT:
- ret = bt_field_type_common_variant_set_tag_field_path(
+ ret = bt_field_type_variant_set_tag_field_path(
type, target_field_path);
if (ret) {
BT_LOGW("Cannot set varaint field type's tag field path: "
goto end;
}
- ret = bt_field_type_common_variant_set_tag_field_type(
+ ret = bt_field_type_variant_set_tag_field_type(
type, target_type);
if (ret) {
BT_LOGW("Cannot set varaint field type's tag field type: "
* `type` is owned by the caller.
*/
static
-int resolve_type(struct bt_field_type_common *type, struct resolve_context *ctx)
+int resolve_type(struct bt_field_type *type, struct resolve_context *ctx)
{
int ret = 0;
enum bt_field_type_id type_id;
goto end;
}
- type_id = bt_field_type_common_get_type_id(type);
+ type_id = bt_field_type_get_type_id(type);
ctx->cur_field_type = type;
/* Resolve sequence/variant field type */
goto end;
}
- field_count = bt_field_type_common_get_field_count(type);
+ field_count = bt_field_type_get_field_count(type);
if (field_count < 0) {
BT_LOGW("Cannot get field type's field count: "
"ret=%" PRId64 ", ft-addr=%p",
}
for (f_index = 0; f_index < field_count; f_index++) {
- struct bt_field_type_common *child_type =
- bt_field_type_common_borrow_field_at_index(type,
+ struct bt_field_type *child_type =
+ bt_field_type_borrow_field_at_index(type,
f_index);
if (!child_type) {
BT_HIDDEN
int bt_resolve_types(
struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type,
- struct bt_field_type_common *event_context_type,
- struct bt_field_type_common *event_payload_type,
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type,
+ struct bt_field_type *event_context_type,
+ struct bt_field_type *event_payload_type,
enum bt_resolve_flag flags)
{
int ret = 0;
#include <stdint.h>
#include <stdbool.h>
-BT_HIDDEN
-int bt_stream_class_common_initialize(struct bt_stream_class_common *stream_class,
+static inline
+int bt_stream_class_initialize(struct bt_stream_class *stream_class,
const char *name, bt_object_release_func release_func)
{
- BT_LOGD("Initializing common stream class object: name=\"%s\"", name);
+ BT_LOGD("Initializing stream class object: name=\"%s\"", name);
bt_object_init_shared_with_parent(&stream_class->base, release_func);
stream_class->name = g_string_new(name);
goto error;
}
- BT_LOGD("Initialized common stream class object: addr=%p, name=\"%s\"",
+ BT_LOGD("Initialized stream class object: addr=%p, name=\"%s\"",
stream_class, name);
return 0;
return -1;
}
-BT_HIDDEN
-void bt_stream_class_common_finalize(struct bt_stream_class_common *stream_class)
+static
+void bt_stream_class_destroy(struct bt_object *obj)
{
- BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
+ struct bt_stream_class *stream_class = (void *) obj;
+
+ BT_LOGD("Destroying stream class: addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
bt_put(stream_class->clock_class);
if (stream_class->event_classes_ht) {
bt_put(stream_class->packet_context_field_type);
BT_LOGD_STR("Putting event context field type.");
bt_put(stream_class->event_context_field_type);
-}
-
-static
-void bt_stream_class_destroy(struct bt_object *obj)
-{
- struct bt_stream_class *stream_class;
-
- stream_class = (void *) obj;
- BT_LOGD("Destroying stream class: addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_get_name(stream_class),
- bt_stream_class_get_id(stream_class));
-
- /*
- * IMPORTANT: Finalize the common stream class BEFORE finalizing
- * the pools because otherwise this scenario is possible:
- *
- * 1. Event header field object pool is finalized, thus
- * destroying its internal array and state.
- *
- * 2. Stream class is finalized: each event class is destroyed.
- *
- * 3. Destroying an event class finalizes its event pool,
- * destroying each contained event.
- *
- * 4. Destroying an event makes it recycle its event header
- * field to its stream class's event header field pool. But
- * said pool is already finalized.
- */
- bt_stream_class_common_finalize(BT_TO_COMMON(stream_class));
bt_object_pool_finalize(&stream_class->event_header_field_pool);
bt_object_pool_finalize(&stream_class->packet_context_field_pool);
g_free(stream_class);
goto error;
}
- ret = bt_stream_class_common_initialize(BT_TO_COMMON(stream_class),
- name, bt_stream_class_destroy);
+ ret = bt_stream_class_initialize(stream_class, name,
+ bt_stream_class_destroy);
if (ret) {
- /* bt_stream_class_common_initialize() logs errors */
+ /* bt_stream_class_initialize() logs errors */
goto error;
}
struct bt_field_wrapper *field_wrapper;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE(stream_class->common.frozen,
+ BT_ASSERT_PRE(stream_class->frozen,
"Stream class is not part of a trace: %!+S", stream_class);
- BT_ASSERT_PRE(stream_class->common.event_header_field_type,
+ BT_ASSERT_PRE(stream_class->event_header_field_type,
"Stream class has no event header field type: %!+S",
stream_class);
field_wrapper = bt_field_wrapper_create(
&stream_class->event_header_field_pool,
- (void *) stream_class->common.event_header_field_type);
+ (void *) stream_class->event_header_field_type);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one event header field from stream class: "
"%![sc-]+S", stream_class);
struct bt_field_wrapper *field_wrapper;
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
- BT_ASSERT_PRE(stream_class->common.frozen,
+ BT_ASSERT_PRE(stream_class->frozen,
"Stream class is not part of a trace: %!+S", stream_class);
- BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
+ BT_ASSERT_PRE(stream_class->packet_context_field_type,
"Stream class has no packet context field type: %!+S",
stream_class);
field_wrapper = bt_field_wrapper_create(
&stream_class->packet_context_field_pool,
- (void *) stream_class->common.packet_context_field_type);
+ (void *) stream_class->packet_context_field_type);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one packet context field from stream class: "
"%![sc-]+S", stream_class);
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)));
+ BT_ASSERT(stream_class);
+ return (void *) bt_object_borrow_parent(&stream_class->base);
}
const char *bt_stream_class_get_name(struct bt_stream_class *stream_class)
{
- return bt_stream_class_common_get_name(BT_TO_COMMON(stream_class));
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return stream_class->name->len > 0 ? stream_class->name->str : NULL;
}
int bt_stream_class_set_name(struct bt_stream_class *stream_class,
const char *name)
{
- return bt_stream_class_common_set_name(BT_TO_COMMON(stream_class),
- name);
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (!name) {
+ g_string_assign(stream_class->name, "");
+ } else {
+ if (strlen(name) == 0) {
+ BT_LOGW("Invalid parameter: name is empty.");
+ ret = -1;
+ goto end;
+ }
+
+ g_string_assign(stream_class->name, name);
+ }
+
+ BT_LOGV("Set stream class's name: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+end:
+ return ret;
}
int64_t bt_stream_class_get_id(struct bt_stream_class *stream_class)
{
- return bt_stream_class_common_get_id(BT_TO_COMMON(stream_class));
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->id_set) {
+ BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
+ stream_class,
+ bt_stream_class_get_name(stream_class));
+ ret = (int64_t) -1;
+ goto end;
+ }
+
+ ret = stream_class->id;
+
+end:
+ return ret;
}
-int bt_stream_class_set_id(struct bt_stream_class *stream_class, uint64_t id)
+int bt_stream_class_set_id(struct bt_stream_class *stream_class,
+ uint64_t id_param)
{
- return bt_stream_class_common_set_id(BT_TO_COMMON(stream_class), id);
+ int ret = 0;
+ int64_t id = (int64_t) id_param;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (id < 0) {
+ BT_LOGW("Invalid parameter: invalid stream class's ID: "
+ "stream-class-addr=%p, stream-class-name=\"%s\", "
+ "stream-class-id=%" PRId64 ", id=%" PRIu64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ id_param);
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_stream_class_set_id_no_check(stream_class, id);
+ if (ret == 0) {
+ BT_LOGV("Set stream class's ID: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ }
+end:
+ return ret;
}
static
void event_class_exists(gpointer element, gpointer query)
{
- struct bt_event_class_common *event_class_a = element;
+ struct bt_event_class *event_class_a = element;
struct search_query *search_query = query;
- struct bt_event_class_common *event_class_b = search_query->value;
+ struct bt_event_class *event_class_b = search_query->value;
int64_t id_a, id_b;
if (search_query->value == element) {
* Two event classes cannot share the same ID in a given
* stream class.
*/
- id_a = bt_event_class_common_get_id(event_class_a);
- id_b = bt_event_class_common_get_id(event_class_b);
+ id_a = bt_event_class_get_id(event_class_a);
+ id_b = bt_event_class_get_id(event_class_b);
if (id_a < 0 || id_b < 0) {
/* at least one ID is not set: will be automatically set later */
if (id_a == id_b) {
BT_LOGW("Event class with this ID already exists in the stream class: "
"id=%" PRId64 ", name=\"%s\"",
- id_a, bt_event_class_common_get_name(event_class_a));
+ id_a, bt_event_class_get_name(event_class_a));
search_query->found = 1;
goto end;
}
return;
}
-BT_HIDDEN
-int bt_stream_class_common_add_event_class(
- struct bt_stream_class_common *stream_class,
- struct bt_event_class_common *event_class,
- bt_validation_flag_copy_field_type_func copy_field_type_func)
+int bt_stream_class_add_event_class(struct bt_stream_class *stream_class,
+ struct bt_event_class *event_class)
{
int ret = 0;
int64_t *event_id = NULL;
- struct bt_trace_common *trace = NULL;
- struct bt_stream_class_common *old_stream_class = NULL;
+ struct bt_trace *trace = NULL;
+ struct bt_stream_class *old_stream_class = NULL;
struct bt_validation_output validation_output = { 0 };
- struct bt_field_type_common *packet_header_type = NULL;
- struct bt_field_type_common *packet_context_type = NULL;
- struct bt_field_type_common *event_header_type = NULL;
- struct bt_field_type_common *stream_event_ctx_type = NULL;
- struct bt_field_type_common *event_context_type = NULL;
- struct bt_field_type_common *event_payload_type = NULL;
+ struct bt_field_type *packet_header_type = NULL;
+ struct bt_field_type *packet_context_type = NULL;
+ struct bt_field_type *event_header_type = NULL;
+ struct bt_field_type *stream_event_ctx_type = NULL;
+ struct bt_field_type *event_context_type = NULL;
+ struct bt_field_type *event_payload_type = NULL;
const enum bt_validation_flag validation_flags =
BT_VALIDATION_FLAG_EVENT;
struct bt_clock_class *expected_clock_class = NULL;
- BT_ASSERT(copy_field_type_func);
+ if (!stream_class) {
+ BT_LOGW("Invalid parameter: stream class is NULL: "
+ "stream-class-addr=%p", stream_class);
+ ret = -1;
+ goto end;
+ }
+
+ trace = bt_stream_class_borrow_trace(stream_class);
+ if (trace && trace->is_static) {
+ BT_LOGW("Invalid parameter: stream class's trace is static: "
+ "trace-addr=%p, trace-name=\"%s\"",
+ trace, bt_trace_get_name(trace));
+ ret = -1;
+ goto end;
+ }
if (!stream_class || !event_class) {
BT_LOGW("Invalid parameter: stream class or event class is NULL: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64 ", event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(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_borrow_trace(stream_class);
+ bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
+ trace = bt_stream_class_borrow_trace(stream_class);
if (stream_class->frozen) {
/*
* and bt_event_class_validate_single_clock_class()
* below can set it.
*/
- ret = bt_event_class_common_validate_single_clock_class(
+ ret = bt_event_class_validate_single_clock_class(
event_class, &expected_clock_class);
if (ret) {
BT_LOGW("Event class contains a field type which is not "
"expected-clock-class-addr=%p, "
"expected-clock-class-name=\"%s\"",
stream_class,
- bt_stream_class_common_get_id(stream_class),
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ bt_stream_class_get_name(stream_class),
expected_clock_class,
expected_clock_class ?
bt_clock_class_get_name(expected_clock_class) :
goto end;
}
- old_stream_class = bt_event_class_common_borrow_stream_class(event_class);
+ old_stream_class = bt_event_class_borrow_stream_class(event_class);
if (old_stream_class) {
/* Event class is already associated to a stream class. */
BT_LOGW("Event class is already part of another stream class: "
"event-class-stream-class-name=\"%s\", "
"event-class-stream-class-id=%" PRId64,
old_stream_class,
- bt_stream_class_common_get_name(old_stream_class),
- bt_stream_class_common_get_id(old_stream_class));
+ bt_stream_class_get_name(old_stream_class),
+ bt_stream_class_get_id(old_stream_class));
ret = -1;
goto end;
}
BT_ASSERT(trace->valid);
BT_ASSERT(stream_class->valid);
packet_header_type =
- bt_trace_common_borrow_packet_header_field_type(trace);
+ bt_trace_borrow_packet_header_field_type(trace);
packet_context_type =
- bt_stream_class_common_borrow_packet_context_field_type(
+ bt_stream_class_borrow_packet_context_field_type(
stream_class);
event_header_type =
- bt_stream_class_common_borrow_event_header_field_type(
+ bt_stream_class_borrow_event_header_field_type(
stream_class);
stream_event_ctx_type =
- bt_stream_class_common_borrow_event_context_field_type(
+ bt_stream_class_borrow_event_context_field_type(
stream_class);
event_context_type =
- bt_event_class_common_borrow_context_field_type(
+ bt_event_class_borrow_context_field_type(
event_class);
event_payload_type =
- bt_event_class_common_borrow_payload_field_type(
+ bt_event_class_borrow_payload_field_type(
event_class);
ret = bt_validate_class_types(
trace->environment, packet_header_type,
event_payload_type, trace->valid,
stream_class->valid, event_class->valid,
&validation_output, validation_flags,
- copy_field_type_func);
+ bt_field_type_copy);
if (ret) {
/*
}
/* Only set an event ID if none was explicitly set before */
- *event_id = bt_event_class_common_get_id(event_class);
+ *event_id = bt_event_class_get_id(event_class);
if (*event_id < 0) {
BT_LOGV("Event class has no ID: automatically setting it: "
"id=%" PRId64, stream_class->next_event_id);
- if (bt_event_class_common_set_id(event_class,
+ if (bt_event_class_set_id(event_class,
stream_class->next_event_id)) {
BT_LOGE("Cannot set event class's ID: id=%" PRId64,
stream_class->next_event_id);
event_id = NULL;
/* Freeze the event class */
- bt_event_class_common_freeze(event_class);
+ bt_event_class_freeze(event_class);
/*
* It is safe to set the stream class's unique clock class
BT_MOVE(stream_class->clock_class, expected_clock_class);
}
+ /* Notifiy listeners of the trace's schema modification. */
+ if (trace) {
+ struct bt_visitor_object obj = { .object = event_class,
+ .type = BT_VISITOR_OBJECT_TYPE_EVENT_CLASS };
+
+ (void) bt_trace_object_modification(&obj, trace);
+ }
+
BT_LOGD("Added event class to stream class: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64 ", event-class-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class),
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
event_class,
- bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
+ bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
end:
bt_validation_output_put_types(&validation_output);
return ret;
}
-int bt_stream_class_add_event_class(struct bt_stream_class *stream_class,
- struct bt_event_class *event_class)
+int64_t bt_stream_class_get_event_class_count(
+ struct bt_stream_class *stream_class)
{
- struct bt_trace *trace;
- int ret = 0;
+ int64_t ret;
if (!stream_class) {
- BT_LOGW("Invalid parameter: stream class is NULL: "
- "stream-class-addr=%p", stream_class);
- ret = -1;
- goto end;
- }
-
- trace = BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
- BT_TO_COMMON(stream_class)));
- if (trace && trace->is_static) {
- BT_LOGW("Invalid parameter: stream class's trace is static: "
- "trace-addr=%p, trace-name=\"%s\"",
- trace, bt_trace_get_name(trace));
- ret = -1;
- goto end;
- }
-
- ret = bt_stream_class_common_add_event_class(
- BT_TO_COMMON(stream_class), BT_TO_COMMON(event_class),
- (bt_validation_flag_copy_field_type_func) bt_field_type_copy);
- if (ret) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = (int64_t) -1;
goto end;
}
- /* Notifiy listeners of the trace's schema modification. */
- if (trace) {
- struct bt_visitor_object obj = { .object = event_class,
- .type = BT_VISITOR_OBJECT_TYPE_EVENT_CLASS };
-
- (void) bt_trace_object_modification(&obj, trace);
- }
-
+ ret = (int64_t) stream_class->event_classes->len;
end:
return ret;
}
-int64_t bt_stream_class_get_event_class_count(
- struct bt_stream_class *stream_class)
-{
- return bt_stream_class_common_get_event_class_count(
- BT_TO_COMMON(stream_class));
-}
-
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_borrow_event_class_by_index(
- BT_TO_COMMON(stream_class), index));
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(index < stream_class->event_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, stream_class->event_classes->len);
+ return g_ptr_array_index(stream_class->event_classes, index);
}
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_borrow_event_class_by_id(
- BT_TO_COMMON(stream_class), id));
+ int64_t id_key = (int64_t) id;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE(id_key >= 0,
+ "Invalid event class ID: %" PRIu64, id);
+ return g_hash_table_lookup(stream_class->event_classes_ht,
+ &id_key);
}
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_borrow_packet_context_field_type(
- BT_TO_COMMON(stream_class)));
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return stream_class->packet_context_field_type;
}
int bt_stream_class_set_packet_context_field_type(
struct bt_stream_class *stream_class,
struct bt_field_type *packet_context_type)
{
- return bt_stream_class_common_set_packet_context_field_type(
- BT_TO_COMMON(stream_class), (void *) packet_context_type);
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (packet_context_type &&
+ bt_field_type_get_type_id(packet_context_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p, packet-context-ft-id=%s",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ packet_context_type,
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(packet_context_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(stream_class->packet_context_field_type);
+ bt_get(packet_context_type);
+ stream_class->packet_context_field_type = packet_context_type;
+ BT_LOGV("Set stream class's packet context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "packet-context-ft-addr=%p",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ packet_context_type);
+
+end:
+ return ret;
}
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_borrow_event_header_field_type(
- BT_TO_COMMON(stream_class)));
+ struct bt_field_type *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->event_header_field_type) {
+ BT_LOGV("Stream class has no event header field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ goto end;
+ }
+
+ ret = stream_class->event_header_field_type;
+
+end:
+ return ret;
}
int bt_stream_class_set_event_header_field_type(
struct bt_stream_class *stream_class,
struct bt_field_type *event_header_type)
{
- return bt_stream_class_common_set_event_header_field_type(
- BT_TO_COMMON(stream_class), (void *) event_header_type);
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class,
+ bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (event_header_type &&
+ bt_field_type_get_type_id(event_header_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ /* An event header must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-header-ft-addr=%p, event-header-ft-id=%s",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ event_header_type,
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(event_header_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(stream_class->event_header_field_type);
+ stream_class->event_header_field_type = bt_get(event_header_type);
+ BT_LOGV("Set stream class's event header field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-header-ft-addr=%p",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ event_header_type);
+end:
+ return ret;
}
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_borrow_event_context_field_type(
- BT_TO_COMMON(stream_class)));
+ struct bt_field_type *ret = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+ if (!stream_class->event_context_field_type) {
+ goto end;
+ }
+
+ ret = stream_class->event_context_field_type;
+
+end:
+ return ret;
}
int bt_stream_class_set_event_context_field_type(
struct bt_stream_class *stream_class,
struct bt_field_type *event_context_type)
{
- return bt_stream_class_common_set_event_context_field_type(
- BT_TO_COMMON(stream_class), (void *) event_context_type);
+ int ret = 0;
+
+ if (!stream_class) {
+ BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+ ret = -1;
+ goto end;
+ }
+
+ if (stream_class->frozen) {
+ BT_LOGW("Invalid parameter: stream class is frozen: "
+ "addr=%p, name=\"%s\", id=%" PRId64,
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
+ ret = -1;
+ goto end;
+ }
+
+ if (event_context_type &&
+ bt_field_type_get_type_id(event_context_type) !=
+ BT_FIELD_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
+ BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-context-ft-addr=%p, event-context-ft-id=%s",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ event_context_type,
+ bt_common_field_type_id_string(
+ bt_field_type_get_type_id(event_context_type)));
+ ret = -1;
+ goto end;
+ }
+
+ bt_put(stream_class->event_context_field_type);
+ stream_class->event_context_field_type = bt_get(event_context_type);
+ BT_LOGV("Set stream class's event context field type: "
+ "addr=%p, name=\"%s\", id=%" PRId64 ", "
+ "event-context-ft-addr=%p",
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class),
+ event_context_type);
+end:
+ return ret;
}
static
}
BT_HIDDEN
-int bt_stream_class_common_visit(struct bt_stream_class_common *stream_class,
+int bt_stream_class_visit(struct bt_stream_class *stream_class,
bt_visitor visitor, void *data)
{
int ret;
return ret;
}
-int bt_stream_class_visit(struct bt_stream_class *stream_class,
- bt_visitor visitor, void *data)
-{
- return bt_stream_class_common_visit(BT_FROM_COMMON(stream_class),
- visitor, data);
-}
-
BT_HIDDEN
-void bt_stream_class_common_freeze(struct bt_stream_class_common *stream_class)
+void bt_stream_class_freeze(struct bt_stream_class *stream_class)
{
if (!stream_class || stream_class->frozen) {
return;
}
BT_LOGD("Freezing stream class: addr=%p, name=\"%s\", id=%" PRId64,
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
stream_class->frozen = 1;
- bt_field_type_common_freeze(stream_class->event_header_field_type);
- bt_field_type_common_freeze(stream_class->packet_context_field_type);
- bt_field_type_common_freeze(stream_class->event_context_field_type);
+ bt_field_type_freeze(stream_class->event_header_field_type);
+ bt_field_type_freeze(stream_class->packet_context_field_type);
+ bt_field_type_freeze(stream_class->event_context_field_type);
bt_clock_class_freeze(stream_class->clock_class);
}
-void bt_stream_class_freeze(struct bt_stream_class *stream_class)
-{
- bt_stream_class_common_freeze(BT_TO_COMMON(stream_class));
-}
-
BT_HIDDEN
-int bt_stream_class_common_validate_single_clock_class(
- struct bt_stream_class_common *stream_class,
+int bt_stream_class_validate_single_clock_class(
+ struct bt_stream_class *stream_class,
struct bt_clock_class **expected_clock_class)
{
int ret;
BT_ASSERT(stream_class);
BT_ASSERT(expected_clock_class);
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
stream_class->packet_context_field_type,
expected_clock_class);
if (ret) {
"stream-class-id=%" PRId64 ", "
"ft-addr=%p",
stream_class,
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_name(stream_class),
stream_class->id,
stream_class->packet_context_field_type);
goto end;
}
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
stream_class->event_header_field_type,
expected_clock_class);
if (ret) {
"stream-class-id=%" PRId64 ", "
"ft-addr=%p",
stream_class,
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_name(stream_class),
stream_class->id,
stream_class->event_header_field_type);
goto end;
}
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
stream_class->event_context_field_type,
expected_clock_class);
if (ret) {
"stream-class-id=%" PRId64 ", "
"ft-addr=%p",
stream_class,
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_name(stream_class),
stream_class->id,
stream_class->event_context_field_type);
goto end;
}
for (i = 0; i < stream_class->event_classes->len; i++) {
- struct bt_event_class_common *event_class =
+ struct bt_event_class *event_class =
g_ptr_array_index(stream_class->event_classes, i);
BT_ASSERT(event_class);
- ret = bt_event_class_common_validate_single_clock_class(
+ ret = bt_event_class_validate_single_clock_class(
event_class, expected_clock_class);
if (ret) {
BT_LOGW("Stream class's event class contains a "
"stream-class-name=\"%s\", "
"stream-class-id=%" PRId64,
stream_class,
- bt_stream_class_common_get_name(stream_class),
+ bt_stream_class_get_name(stream_class),
stream_class->id);
goto end;
}
#include <inttypes.h>
#include <unistd.h>
-BT_HIDDEN
-void bt_stream_common_finalize(struct bt_stream_common *stream)
+static inline
+void bt_stream_finalize(struct bt_stream *stream)
{
- BT_LOGD("Finalizing common stream object: addr=%p, name=\"%s\"",
- stream, bt_stream_common_get_name(stream));
+ BT_LOGD("Finalizing stream object: addr=%p, name=\"%s\"",
+ stream, bt_stream_get_name(stream));
if (stream->name) {
g_string_free(stream->name, TRUE);
BT_LOGD("Destroying stream object: addr=%p, name=\"%s\"",
stream, bt_stream_get_name(stream));
bt_object_pool_finalize(&stream->packet_pool);
- bt_stream_common_finalize((void *) obj);
+ bt_stream_finalize((void *) obj);
g_free(stream);
}
-BT_HIDDEN
-int bt_stream_common_initialize(
- struct bt_stream_common *stream,
- struct bt_stream_class_common *stream_class, const char *name,
+static inline
+int bt_stream_initialize(
+ struct bt_stream *stream,
+ struct bt_stream_class *stream_class, const char *name,
uint64_t id, bt_object_release_func release_func)
{
int ret = 0;
- struct bt_trace_common *trace = NULL;
+ struct bt_trace *trace = NULL;
bt_object_init_shared_with_parent(&stream->base, release_func);
goto error;
}
- BT_LOGD("Initializing common stream object: stream-class-addr=%p, "
+ BT_LOGD("Initializing stream object: stream-class-addr=%p, "
"stream-class-name=\"%s\", stream-name=\"%s\", "
"stream-id=%" PRIu64,
- stream_class, bt_stream_class_common_get_name(stream_class),
+ stream_class, bt_stream_class_get_name(stream_class),
name, id);
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-name=\"%s\"",
stream_class,
- bt_stream_class_common_get_name(stream_class), name);
+ bt_stream_class_get_name(stream_class), name);
goto error;
}
size_t i;
for (i = 0; i < trace->streams->len; i++) {
- struct bt_stream_common *trace_stream =
+ struct bt_stream *trace_stream =
g_ptr_array_index(trace->streams, i);
if (trace_stream->stream_class != (void *) stream_class) {
}
}
- BT_LOGD("Set common stream's trace parent: trace-addr=%p", trace);
+ BT_LOGD("Set stream's trace parent: trace-addr=%p", trace);
/* Add this stream to the trace's streams */
- BT_LOGD("Created common stream object: addr=%p", stream);
+ BT_LOGD("Created stream object: addr=%p", stream);
goto end;
error:
stream_class, bt_stream_class_get_name(stream_class),
name, id);
- trace = BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
- BT_TO_COMMON(stream_class)));
+ trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
goto error;
}
- ret = bt_stream_common_initialize(BT_TO_COMMON(stream),
- BT_TO_COMMON(stream_class), name, id, bt_stream_destroy);
+ ret = bt_stream_initialize(stream, stream_class, name,
+ id, bt_stream_destroy);
if (ret) {
- /* bt_stream_common_initialize() logs errors */
+ /* bt_stream_initialize() logs errors */
goto error;
}
goto error;
}
- g_ptr_array_add(trace->common.streams, stream);
+ g_ptr_array_add(trace->streams, stream);
BT_LOGD("Created stream object: addr=%p", stream);
goto end;
struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
{
- return BT_FROM_COMMON(bt_stream_common_borrow_class(BT_TO_COMMON(stream)));
+ BT_ASSERT(stream);
+ return stream->stream_class;
}
const char *bt_stream_get_name(struct bt_stream *stream)
{
- return bt_stream_common_get_name(BT_TO_COMMON(stream));
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+ return stream->name ? stream->name->str : NULL;
}
int64_t bt_stream_get_id(struct bt_stream *stream)
{
- return bt_stream_common_get_id(BT_TO_COMMON(stream));
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+ ret = stream->id;
+ if (ret < 0) {
+ BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
+ stream, bt_stream_get_name(stream));
+ }
+
+ return ret;
}
void *data;
};
+static inline
+void bt_trace_finalize(struct bt_trace *trace)
+{
+ BT_LOGD("Finalizing trace object: addr=%p, name=\"%s\"",
+ trace, bt_trace_get_name(trace));
+
+ if (trace->environment) {
+ BT_LOGD_STR("Destroying environment attributes.");
+ bt_attributes_destroy(trace->environment);
+ }
+
+ if (trace->name) {
+ g_string_free(trace->name, TRUE);
+ }
+
+ if (trace->clock_classes) {
+ BT_LOGD_STR("Putting clock classes.");
+ g_ptr_array_free(trace->clock_classes, TRUE);
+ }
+
+ if (trace->streams) {
+ BT_LOGD_STR("Destroying streams.");
+ g_ptr_array_free(trace->streams, TRUE);
+ }
+
+ if (trace->stream_classes) {
+ BT_LOGD_STR("Destroying stream classes.");
+ g_ptr_array_free(trace->stream_classes, TRUE);
+ }
+
+ BT_LOGD_STR("Putting packet header field type.");
+ bt_put(trace->packet_header_field_type);
+}
+
static
void bt_trace_destroy(struct bt_object *obj)
{
}
bt_object_pool_finalize(&trace->packet_header_field_pool);
- bt_trace_common_finalize(BT_TO_COMMON(trace));
+ bt_trace_finalize(trace);
g_free(trace);
}
-BT_HIDDEN
-int bt_trace_common_initialize(struct bt_trace_common *trace,
+static inline
+int bt_trace_initialize(struct bt_trace *trace,
bt_object_release_func release_func)
{
int ret = 0;
- BT_LOGD_STR("Initializing common trace object.");
+ BT_LOGD_STR("Initializing trace object.");
trace->native_byte_order = BT_BYTE_ORDER_UNSPECIFIED;
bt_object_init_shared_with_parent(&trace->base, release_func);
trace->clock_classes = g_ptr_array_new_with_free_func(
goto error;
}
- BT_LOGD("Initialized common trace object: addr=%p", trace);
+ BT_LOGD("Initialized trace object: addr=%p", trace);
goto end;
error:
return ret;
}
-BT_HIDDEN
-void bt_trace_common_finalize(struct bt_trace_common *trace)
-{
- BT_LOGD("Finalizing common trace object: addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
-
- if (trace->environment) {
- BT_LOGD_STR("Destroying environment attributes.");
- bt_attributes_destroy(trace->environment);
- }
-
- if (trace->name) {
- g_string_free(trace->name, TRUE);
- }
-
- if (trace->clock_classes) {
- BT_LOGD_STR("Putting clock classes.");
- g_ptr_array_free(trace->clock_classes, TRUE);
- }
-
- if (trace->streams) {
- BT_LOGD_STR("Destroying streams.");
- g_ptr_array_free(trace->streams, TRUE);
- }
-
- if (trace->stream_classes) {
- BT_LOGD_STR("Destroying stream classes.");
- g_ptr_array_free(trace->stream_classes, TRUE);
- }
-
- BT_LOGD_STR("Putting packet header field type.");
- bt_put(trace->packet_header_field_type);
-}
-
static
void free_packet_header_field(struct bt_field_wrapper *field_wrapper,
struct bt_trace *trace)
goto error;
}
- ret = bt_trace_common_initialize(BT_TO_COMMON(trace), bt_trace_destroy);
+ ret = bt_trace_initialize(trace, bt_trace_destroy);
if (ret) {
- /* bt_trace_common_initialize() logs errors */
+ /* bt_trace_initialize() logs errors */
goto error;
}
const char *bt_trace_get_name(struct bt_trace *trace)
{
- return bt_trace_common_get_name(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->name ? trace->name->str : NULL;
}
-BT_HIDDEN
-int bt_trace_common_set_name(struct bt_trace_common *trace, const char *name)
+int bt_trace_set_name(struct bt_trace *trace, const char *name)
{
int ret = 0;
if (trace->frozen) {
BT_LOGW("Invalid parameter: trace is frozen: "
"addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
+ trace, bt_trace_get_name(trace));
ret = -1;
goto end;
}
return ret;
}
-int bt_trace_set_name(struct bt_trace *trace, const char *name)
-{
- return bt_trace_common_set_name(BT_TO_COMMON(trace), name);
-}
-
const unsigned char *bt_trace_get_uuid(struct bt_trace *trace)
{
- return bt_trace_common_get_uuid(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->uuid_set ? trace->uuid : NULL;
}
-BT_HIDDEN
-int bt_trace_common_set_uuid(struct bt_trace_common *trace,
+int bt_trace_set_uuid(struct bt_trace *trace,
const unsigned char *uuid)
{
int ret = 0;
if (trace->frozen) {
BT_LOGW("Invalid parameter: trace is frozen: "
"addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
+ trace, bt_trace_get_name(trace));
ret = -1;
goto end;
}
trace->uuid_set = BT_TRUE;
BT_LOGV("Set trace's UUID: addr=%p, name=\"%s\", "
"uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
(unsigned int) uuid[0],
(unsigned int) uuid[1],
(unsigned int) uuid[2],
return ret;
}
-int bt_trace_set_uuid(struct bt_trace *trace,
- const unsigned char *uuid)
-{
- return bt_trace_common_set_uuid(BT_TO_COMMON(trace), uuid);
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
+int bt_trace_set_environment_field(struct bt_trace *trace,
const char *name, struct bt_value *value)
{
int ret = 0;
goto end;
}
+ if (trace->is_static) {
+ BT_LOGW("Invalid parameter: trace is static: "
+ "addr=%p, name=\"%s\"",
+ trace, bt_trace_get_name(trace));
+ ret = -1;
+ goto end;
+ }
+
if (!bt_identifier_is_valid(name)) {
BT_LOGW("Invalid parameter: environment field's name is not a valid CTF identifier: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\"",
- trace, bt_trace_common_get_name(trace), name);
+ trace, bt_trace_get_name(trace), name);
ret = -1;
goto end;
}
BT_LOGW("Invalid parameter: environment field's value is not an integer or string value: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\", env-value-type=%s",
- trace, bt_trace_common_get_name(trace), name,
+ trace, bt_trace_get_name(trace), name,
bt_value_type_string(bt_value_get_type(value)));
ret = -1;
goto end;
BT_LOGW("Invalid parameter: trace is frozen and environment field already exists with this name: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\"",
- trace, bt_trace_common_get_name(trace), name);
+ trace, bt_trace_get_name(trace), name);
ret = -1;
goto end;
}
BT_LOGE("Cannot set environment field's value: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\"",
- trace, bt_trace_common_get_name(trace), name);
+ trace, bt_trace_get_name(trace), name);
} else {
BT_LOGV("Set environment field's value: "
"trace-addr=%p, trace-name=\"%s\", "
"env-name=\"%s\", value-addr=%p",
- trace, bt_trace_common_get_name(trace), name, value);
+ trace, bt_trace_get_name(trace), name, value);
}
end:
return ret;
}
-int bt_trace_set_environment_field(struct bt_trace *trace,
- const char *name, struct bt_value *value)
-{
- int ret;
-
- if (trace->is_static) {
- BT_LOGW("Invalid parameter: trace is static: "
- "addr=%p, name=\"%s\"",
- trace, bt_trace_get_name(trace));
- ret = -1;
- goto end;
- }
-
- ret = bt_trace_common_set_environment_field(BT_TO_COMMON(trace),
- name, value);
-
-end:
- return ret;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_string(struct bt_trace_common *trace,
+int bt_trace_set_environment_field_string(struct bt_trace *trace,
const char *name, const char *value)
{
int ret = 0;
goto end;
}
- /* bt_trace_common_set_environment_field() logs errors */
- ret = bt_trace_common_set_environment_field(trace, name,
+ /* bt_trace_set_environment_field() logs errors */
+ ret = bt_trace_set_environment_field(trace, name,
env_value_string_obj);
end:
return ret;
}
-int bt_trace_set_environment_field_string(struct bt_trace *trace,
- const char *name, const char *value)
-{
- return bt_trace_common_set_environment_field_string(BT_TO_COMMON(trace),
- name, value);
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_integer(
- struct bt_trace_common *trace, const char *name, int64_t value)
+int bt_trace_set_environment_field_integer(
+ struct bt_trace *trace, const char *name, int64_t value)
{
int ret = 0;
struct bt_value *env_value_integer_obj = NULL;
goto end;
}
- /* bt_trace_common_set_environment_field() logs errors */
- ret = bt_trace_common_set_environment_field(trace, name,
+ /* bt_trace_set_environment_field() logs errors */
+ ret = bt_trace_set_environment_field(trace, name,
env_value_integer_obj);
end:
return ret;
}
-int bt_trace_set_environment_field_integer(
- struct bt_trace *trace, const char *name, int64_t value)
-{
- return bt_trace_common_set_environment_field_integer(
- BT_TO_COMMON(trace), name, value);
-}
-
int64_t bt_trace_get_environment_field_count(struct bt_trace *trace)
{
- return bt_trace_common_get_environment_field_count(BT_TO_COMMON(trace));
+ int64_t ret;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ ret = bt_attributes_get_count(trace->environment);
+ BT_ASSERT(ret >= 0);
+ return ret;
}
const char *
bt_trace_get_environment_field_name_by_index(struct bt_trace *trace,
uint64_t index)
{
- return bt_trace_common_get_environment_field_name_by_index(
- BT_TO_COMMON(trace), index);
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return bt_attributes_get_field_name(trace->environment, index);
}
struct bt_value *bt_trace_borrow_environment_field_value_by_index(
struct bt_trace *trace, uint64_t index)
{
- return bt_trace_common_borrow_environment_field_value_by_index(
- BT_TO_COMMON(trace), index);
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return bt_attributes_borrow_field_value(trace->environment, index);
}
struct bt_value *bt_trace_borrow_environment_field_value_by_name(
struct bt_trace *trace, const char *name)
{
- return bt_trace_common_borrow_environment_field_value_by_name(
- BT_TO_COMMON(trace), name);
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+ return bt_attributes_borrow_field_value_by_name(trace->environment,
+ name);
}
-BT_HIDDEN
-int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
+int bt_trace_add_clock_class(struct bt_trace *trace,
struct bt_clock_class *clock_class)
{
int ret = 0;
goto end;
}
+ if (trace->is_static) {
+ BT_LOGW("Invalid parameter: trace is static: "
+ "addr=%p, name=\"%s\"",
+ trace, bt_trace_get_name(trace));
+ ret = -1;
+ goto end;
+ }
+
if (!bt_clock_class_is_valid(clock_class)) {
BT_LOGW("Invalid parameter: clock class is invalid: "
"trace-addr=%p, trace-name=\"%s\", "
"clock-class-addr=%p, clock-class-name=\"%s\"",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
clock_class, bt_clock_class_get_name(clock_class));
ret = -1;
goto end;
}
/* Check for duplicate clock classes */
- if (bt_trace_common_has_clock_class(trace, clock_class)) {
+ if (bt_trace_has_clock_class(trace, clock_class)) {
BT_LOGW("Invalid parameter: clock class already exists in trace: "
"trace-addr=%p, trace-name=\"%s\", "
"clock-class-addr=%p, clock-class-name=\"%s\"",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
clock_class, bt_clock_class_get_name(clock_class));
ret = -1;
goto end;
BT_LOGV("Added clock class to trace: "
"trace-addr=%p, trace-name=\"%s\", "
"clock-class-addr=%p, clock-class-name=\"%s\"",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
clock_class, bt_clock_class_get_name(clock_class));
end:
return ret;
}
-int bt_trace_add_clock_class(struct bt_trace *trace,
- struct bt_clock_class *clock_class)
-{
- int ret;
-
- if (trace->is_static) {
- BT_LOGW("Invalid parameter: trace is static: "
- "addr=%p, name=\"%s\"",
- trace, bt_trace_get_name(trace));
- ret = -1;
- goto end;
- }
-
- ret = bt_trace_common_add_clock_class(BT_TO_COMMON(trace),
- clock_class);
-
-end:
- return ret;
-}
-
int64_t bt_trace_get_clock_class_count(struct bt_trace *trace)
{
- return bt_trace_common_get_clock_class_count(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->clock_classes->len;
}
struct bt_clock_class *bt_trace_borrow_clock_class_by_index(
struct bt_trace *trace, uint64_t index)
{
- return bt_trace_common_borrow_clock_class_by_index(
- BT_TO_COMMON(trace), index);
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->clock_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->clock_classes->len);
+ return g_ptr_array_index(trace->clock_classes, index);
}
static
-bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
- struct bt_field_type_common *packet_header_type)
+bool packet_header_field_type_is_valid(struct bt_trace *trace,
+ struct bt_field_type *packet_header_type)
{
int ret;
bool is_valid = true;
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type *field_type = NULL;
if (!packet_header_type) {
/*
* integer field type. Also it must be the first field of the
* packet header field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_header_type, "magic");
if (field_type) {
const char *field_name;
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet header field type: `magic` field must be an unsigned integer field type: "
"magic-ft-addr=%p", field_type);
goto invalid;
}
- if (bt_field_type_common_integer_get_size(field_type) != 32) {
+ if (bt_field_type_integer_get_size(field_type) != 32) {
BT_LOGW("Invalid packet header field type: `magic` field must be a 32-bit unsigned integer field type: "
"magic-ft-addr=%p, magic-ft-size=%u",
field_type,
- bt_field_type_common_integer_get_size(field_type));
+ bt_field_type_integer_get_size(field_type));
goto invalid;
}
- ret = bt_field_type_common_structure_borrow_field_by_index(
+ ret = bt_field_type_structure_borrow_field_by_index(
packet_header_type, &field_name, NULL, 0);
BT_ASSERT(ret == 0);
* 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_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_header_type, "uuid");
if (field_type) {
- struct bt_field_type_common *elem_ft;
+ struct bt_field_type *elem_ft;
if (field_type->id != BT_FIELD_TYPE_ID_ARRAY) {
BT_LOGW("Invalid packet header field type: `uuid` field must be an array field type: "
goto invalid;
}
- if (bt_field_type_common_array_get_length(field_type) != 16) {
+ if (bt_field_type_array_get_length(field_type) != 16) {
BT_LOGW("Invalid packet header field type: `uuid` array field type's length must be 16: "
"uuid-ft-addr=%p, uuid-ft-length=%" PRId64,
field_type,
- bt_field_type_common_array_get_length(field_type));
+ bt_field_type_array_get_length(field_type));
goto invalid;
}
- elem_ft = bt_field_type_common_array_borrow_element_field_type(field_type);
+ elem_ft = bt_field_type_array_borrow_element_field_type(field_type);
BT_ASSERT(elem_ft);
if (elem_ft->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(elem_ft)) {
+ if (bt_field_type_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);
goto invalid;
}
- if (bt_field_type_common_integer_get_size(elem_ft) != 8) {
+ if (bt_field_type_integer_get_size(elem_ft) != 8) {
BT_LOGW("Invalid packet header field type: `uuid` field's element field type must be an 8-bit unsigned integer field type: "
"elem-ft-addr=%p, elem-ft-size=%u",
elem_ft,
- bt_field_type_common_integer_get_size(elem_ft));
+ bt_field_type_integer_get_size(elem_ft));
goto invalid;
}
}
* The `stream_id` field must exist if there's more than one
* stream classes in the trace.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_header_type, "stream_id");
if (!field_type && trace->stream_classes->len >= 1) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet header field type: `stream_id` field must be an unsigned integer field type: "
"stream-id-ft-addr=%p", field_type);
goto invalid;
* If there's a `packet_seq_num` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_header_type, "packet_seq_num");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet header field type: `packet_seq_num` field must be an unsigned integer field type: "
"packet-seq-num-ft-addr=%p", field_type);
goto invalid;
}
static
-bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_type,
+bool packet_context_field_type_is_valid(struct bt_trace *trace,
+ struct bt_stream_class *stream_class,
+ struct bt_field_type *packet_context_type,
bool check_ts_begin_end_mapped)
{
bool is_valid = true;
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type *field_type = NULL;
if (!packet_context_type) {
/* No packet context field type: valid at this point */
* If there's a `packet_size` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_context_type, "packet_size");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet context field type: `packet_size` field must be an unsigned integer field type: "
"packet-size-ft-addr=%p", field_type);
goto invalid;
* If there's a `content_size` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_context_type, "content_size");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet context field type: `content_size` field must be an unsigned integer field type: "
"content-size-ft-addr=%p", field_type);
goto invalid;
* If there's a `events_discarded` field, it must be an unsigned
* integer field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_context_type, "events_discarded");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet context field type: `events_discarded` field must be an unsigned integer field type: "
"events-discarded-ft-addr=%p", field_type);
goto invalid;
* 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_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_context_type, "timestamp_begin");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet context field type: `timestamp_begin` field must be an unsigned integer field type: "
"timestamp-begin-ft-addr=%p", field_type);
goto invalid;
if (check_ts_begin_end_mapped) {
struct bt_clock_class *clock_class =
- bt_field_type_common_integer_borrow_mapped_clock_class(
+ bt_field_type_integer_borrow_mapped_clock_class(
field_type);
if (!clock_class) {
* 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_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
packet_context_type, "timestamp_end");
if (field_type) {
if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
goto invalid;
}
- if (bt_field_type_common_integer_is_signed(field_type)) {
+ if (bt_field_type_integer_is_signed(field_type)) {
BT_LOGW("Invalid packet context field type: `timestamp_end` field must be an unsigned integer field type: "
"timestamp-end-ft-addr=%p", field_type);
goto invalid;
if (check_ts_begin_end_mapped) {
struct bt_clock_class *clock_class =
- bt_field_type_common_integer_borrow_mapped_clock_class(
+ bt_field_type_integer_borrow_mapped_clock_class(
field_type);
if (!clock_class) {
}
static
-bool event_header_field_type_is_valid(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *event_header_type)
+bool event_header_field_type_is_valid(struct bt_trace *trace,
+ struct bt_stream_class *stream_class,
+ struct bt_field_type *event_header_type)
{
bool is_valid = true;
- struct bt_field_type_common *field_type = NULL;
+ struct bt_field_type *field_type = NULL;
/*
* We do not validate that the `timestamp` field exists here
* No event header field type: stream class must have
* only one event class.
*/
- if (bt_stream_class_common_get_event_class_count(stream_class) > 1) {
+ if (bt_stream_class_get_event_class_count(stream_class) > 1) {
BT_LOGW_STR("Invalid event header field type: "
"event header field type does not exist but there's more than one event class in the stream class.");
goto invalid;
* field type or an enumeration field type with an unsigned
* integer container field type.
*/
- field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+ field_type = bt_field_type_structure_borrow_field_type_by_name(
event_header_type, "id");
if (field_type) {
- struct bt_field_type_common *int_ft;
+ struct bt_field_type *int_ft;
if (field_type->id == BT_FIELD_TYPE_ID_INTEGER) {
int_ft = field_type;
} else if (field_type->id == BT_FIELD_TYPE_ID_ENUM) {
- int_ft = bt_field_type_common_enumeration_borrow_container_field_type(
+ int_ft = bt_field_type_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: "
}
BT_ASSERT(int_ft);
- if (bt_field_type_common_integer_is_signed(int_ft)) {
+ if (bt_field_type_integer_is_signed(int_ft)) {
BT_LOGW("Invalid event header field type: `id` field must be an unsigned integer or enumeration field type: "
"id-ft-addr=%p", int_ft);
goto invalid;
}
static
-int check_packet_header_type_has_no_clock_class(struct bt_trace_common *trace)
+int check_packet_header_type_has_no_clock_class(struct bt_trace *trace)
{
int ret = 0;
if (trace->packet_header_field_type) {
struct bt_clock_class *clock_class = NULL;
- ret = bt_field_type_common_validate_single_clock_class(
+ ret = bt_field_type_validate_single_clock_class(
trace->packet_header_field_type,
&clock_class);
bt_put(clock_class);
"a clock class: "
"trace-addr=%p, trace-name=\"%s\", "
"clock-class-name=\"%s\"",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
clock_class ?
bt_clock_class_get_name(clock_class) :
NULL);
return ret;
}
-BT_HIDDEN
-int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- bt_validation_flag_copy_field_type_func copy_field_type_func,
- struct bt_clock_class *init_expected_clock_class,
- int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
- struct bt_field_type_common *packet_context_field_type,
- struct bt_field_type_common *event_header_field_type),
- bool check_ts_begin_end_mapped)
+int bt_trace_add_stream_class(struct bt_trace *trace,
+ struct bt_stream_class *stream_class)
{
int ret;
int64_t i;
BT_VALIDATION_FLAG_STREAM;
const enum bt_validation_flag ec_validation_flags =
BT_VALIDATION_FLAG_EVENT;
- struct bt_field_type_common *packet_header_type = NULL;
- struct bt_field_type_common *packet_context_type = NULL;
- struct bt_field_type_common *event_header_type = NULL;
- struct bt_field_type_common *stream_event_ctx_type = NULL;
+ struct bt_field_type *packet_header_type = NULL;
+ struct bt_field_type *packet_context_type = NULL;
+ struct bt_field_type *event_header_type = NULL;
+ struct bt_field_type *stream_event_ctx_type = NULL;
int64_t event_class_count;
- struct bt_trace_common *current_parent_trace = NULL;
- struct bt_clock_class *expected_clock_class =
- bt_get(init_expected_clock_class);
-
- BT_ASSERT(copy_field_type_func);
+ struct bt_trace *current_parent_trace = NULL;
+ struct bt_clock_class *expected_clock_class = NULL;
if (!trace) {
BT_LOGW_STR("Invalid parameter: trace is NULL.");
goto end;
}
+ if (trace->is_static) {
+ BT_LOGW_STR("Invalid parameter: trace is static.");
+ ret = -1;
+ goto end;
+ }
+
if (!stream_class) {
BT_LOGW_STR("Invalid parameter: stream class is NULL.");
ret = -1;
"trace-addr=%p, trace-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64,
- trace, bt_trace_common_get_name(trace),
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
+ trace, bt_trace_get_name(trace),
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
- current_parent_trace = bt_stream_class_common_borrow_trace(stream_class);
+ current_parent_trace = bt_stream_class_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: "
"stream-class-trace-addr=%p, "
"stream-class-trace-name=\"%s\"",
current_parent_trace,
- bt_trace_common_get_name(current_parent_trace));
+ bt_trace_get_name(current_parent_trace));
ret = -1;
goto end;
}
event_class_count =
- bt_stream_class_common_get_event_class_count(stream_class);
+ bt_stream_class_get_event_class_count(stream_class);
BT_ASSERT(event_class_count >= 0);
if (!stream_class->frozen) {
* Stream class is not frozen yet. Validate that the
* stream class contains at most a single clock class
* because the previous
- * bt_stream_class_common_add_event_class() calls did
+ * bt_stream_class_add_event_class() calls did
* not make this validation since the stream class's
* direct field types (packet context, event header,
* event context) could change afterwards. This stream
* At this point we're also sure that the stream class's
* clock, if any, has the same class as the stream
* class's expected clock class, if any. This is why, if
- * bt_stream_class_common_validate_single_clock_class()
+ * bt_stream_class_validate_single_clock_class()
* succeeds below, the call to
* bt_stream_class_map_clock_class() at the end of this
* function is safe because it maps to the same, single
* clock class.
*/
- ret = bt_stream_class_common_validate_single_clock_class(
+ ret = bt_stream_class_validate_single_clock_class(
stream_class, &expected_clock_class);
if (ret) {
BT_LOGW("Invalid parameter: stream class or one of its "
"stream-class-name=\"%s\", "
"expected-clock-class-addr=%p, "
"expected-clock-class-name=\"%s\"",
- stream_class, bt_stream_class_common_get_id(stream_class),
- bt_stream_class_common_get_name(stream_class),
+ stream_class, bt_stream_class_get_id(stream_class),
+ bt_stream_class_get_name(stream_class),
expected_clock_class,
expected_clock_class ?
bt_clock_class_get_name(expected_clock_class) :
* class of this stream class can be validated individually.
*/
packet_header_type =
- bt_trace_common_borrow_packet_header_field_type(trace);
+ bt_trace_borrow_packet_header_field_type(trace);
packet_context_type =
- bt_stream_class_common_borrow_packet_context_field_type(stream_class);
+ bt_stream_class_borrow_packet_context_field_type(stream_class);
event_header_type =
- bt_stream_class_common_borrow_event_header_field_type(stream_class);
+ bt_stream_class_borrow_event_header_field_type(stream_class);
stream_event_ctx_type =
- bt_stream_class_common_borrow_event_context_field_type(stream_class);
+ bt_stream_class_borrow_event_context_field_type(stream_class);
BT_LOGD("Validating trace and stream class field types.");
ret = bt_validate_class_types(trace->environment,
packet_header_type, packet_context_type, event_header_type,
stream_event_ctx_type, NULL, NULL, trace->valid,
stream_class->valid, 1, &trace_sc_validation_output,
- trace_sc_validation_flags, copy_field_type_func);
+ trace_sc_validation_flags, bt_field_type_copy);
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_borrow_event_class_by_index(
+ struct bt_event_class *event_class =
+ bt_stream_class_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;
+ struct bt_field_type *event_context_type = NULL;
+ struct bt_field_type *event_payload_type = NULL;
event_context_type =
- bt_event_class_common_borrow_context_field_type(
+ bt_event_class_borrow_context_field_type(
event_class);
event_payload_type =
- bt_event_class_common_borrow_payload_field_type(
+ bt_event_class_borrow_payload_field_type(
event_class);
/*
*/
BT_LOGD("Validating event class's field types: "
"addr=%p, name=\"%s\", id=%" PRId64,
- event_class, bt_event_class_common_get_name(event_class),
- bt_event_class_common_get_id(event_class));
+ event_class, bt_event_class_get_name(event_class),
+ bt_event_class_get_id(event_class));
ret = bt_validate_class_types(trace->environment,
trace_sc_validation_output.packet_header_type,
trace_sc_validation_output.packet_context_type,
trace_sc_validation_output.stream_event_ctx_type,
event_context_type, event_payload_type,
1, 1, event_class->valid, &ec_validation_outputs[i],
- ec_validation_flags, copy_field_type_func);
+ ec_validation_flags, bt_field_type_copy);
if (ret) {
BT_LOGE("Failed to validate event class field types: "
}
}
- stream_id = bt_stream_class_common_get_id(stream_class);
+ stream_id = bt_stream_class_get_id(stream_class);
if (stream_id < 0) {
stream_id = trace->next_stream_id++;
if (stream_id < 0) {
/* Try to assign a new stream id */
for (i = 0; i < trace->stream_classes->len; i++) {
- if (stream_id == bt_stream_class_common_get_id(
+ if (stream_id == bt_stream_class_get_id(
trace->stream_classes->pdata[i])) {
/* Duplicate stream id found */
BT_LOGW("Duplicate stream class ID: "
}
}
- if (bt_stream_class_common_set_id_no_check(stream_class,
+ if (bt_stream_class_set_id_no_check(stream_class,
stream_id)) {
/* TODO Should retry with a different stream id */
BT_LOGE("Cannot set stream class's ID: "
if (!packet_context_field_type_is_valid(trace,
stream_class,
- trace_sc_validation_output.packet_context_type,
- check_ts_begin_end_mapped)) {
+ trace_sc_validation_output.packet_context_type, true)) {
BT_LOGW_STR("Invalid stream class's packet context field type.");
ret = -1;
goto end;
goto end;
}
- /*
- * Now is the time to automatically map specific field types of
- * the stream class's packet context and event header field
- * types to the stream class's clock's class if they are not
- * mapped to a clock class yet. We do it here because we know
- * that after this point, everything is frozen so it won't be
- * possible for the user to modify the stream class's clock, or
- * to map those field types to other clock classes.
- */
- if (map_clock_classes_func) {
- if (map_clock_classes_func(stream_class,
- trace_sc_validation_output.packet_context_type,
- trace_sc_validation_output.event_header_type)) {
- /* map_clock_classes_func() logs errors */
- ret = -1;
- goto end;
- }
- }
-
bt_object_set_parent(&stream_class->base, &trace->base);
g_ptr_array_add(trace->stream_classes, stream_class);
bt_validation_output_put_types(&trace_sc_validation_output);
for (i = 0; i < event_class_count; i++) {
- struct bt_event_class_common *event_class =
- bt_stream_class_common_borrow_event_class_by_index(
+ struct bt_event_class *event_class =
+ bt_stream_class_borrow_event_class_by_index(
stream_class, i);
bt_validation_replace_types(NULL, NULL, event_class,
/*
* Freeze the trace and the stream class.
*/
- bt_stream_class_common_freeze(stream_class);
- bt_trace_common_freeze(trace);
+ bt_stream_class_freeze(stream_class);
+ bt_trace_freeze(trace);
/*
* It is safe to set the stream class's unique clock class
BT_MOVE(stream_class->clock_class, expected_clock_class);
}
+ /* Notify listeners of the trace's schema modification. */
+ bt_stream_class_visit(stream_class,
+ bt_trace_object_modification, trace);
BT_LOGD("Added stream class to trace: "
"trace-addr=%p, trace-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64,
- trace, bt_trace_common_get_name(trace),
- stream_class, bt_stream_class_common_get_name(stream_class),
- bt_stream_class_common_get_id(stream_class));
+ trace, bt_trace_get_name(trace),
+ stream_class, bt_stream_class_get_name(stream_class),
+ bt_stream_class_get_id(stream_class));
end:
if (ret) {
return ret;
}
-int bt_trace_add_stream_class(struct bt_trace *trace,
- struct bt_stream_class *stream_class)
-{
- int ret = 0;
-
- if (!trace) {
- BT_LOGW_STR("Invalid parameter: trace is NULL.");
- ret = -1;
- goto end;
- }
-
- if (trace->is_static) {
- BT_LOGW_STR("Invalid parameter: trace is static.");
- ret = -1;
- goto end;
- }
-
- ret = bt_trace_common_add_stream_class(BT_TO_COMMON(trace),
- BT_TO_COMMON(stream_class),
- (bt_validation_flag_copy_field_type_func) bt_field_type_copy,
- NULL, NULL, true);
- if (ret) {
- goto end;
- }
-
- /* Notifiy listeners of the trace's schema modification. */
- bt_stream_class_common_visit(BT_TO_COMMON(stream_class),
- bt_trace_object_modification, trace);
-
-end:
- return ret;
-}
-
int64_t bt_trace_get_stream_count(struct bt_trace *trace)
{
- return bt_trace_common_get_stream_count(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return (int64_t) trace->streams->len;
}
struct bt_stream *bt_trace_borrow_stream_by_index(
struct bt_trace *trace, uint64_t index)
{
- return BT_FROM_COMMON(bt_trace_common_borrow_stream_by_index(
- BT_TO_COMMON(trace), index));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->streams->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->streams->len);
+ return g_ptr_array_index(trace->streams, index);
}
int64_t bt_trace_get_stream_class_count(struct bt_trace *trace)
{
- return bt_trace_common_get_stream_class_count(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return (int64_t) trace->stream_classes->len;
}
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_borrow_stream_class_by_index(
- BT_TO_COMMON(trace), index));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(index < trace->stream_classes->len,
+ "Index is out of bounds: index=%" PRIu64 ", "
+ "count=%u",
+ index, trace->stream_classes->len);
+ return g_ptr_array_index(trace->stream_classes, index);
}
struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
- struct bt_trace *trace, uint64_t id)
+ struct bt_trace *trace, uint64_t id_param)
{
- return BT_FROM_COMMON(
- bt_trace_common_borrow_stream_class_by_id(
- BT_TO_COMMON(trace), id));
+ int i;
+ struct bt_stream_class *stream_class = NULL;
+ int64_t id = (int64_t) id_param;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE(id >= 0,
+ "Invalid stream class ID: %" PRIu64, id_param);
+
+ for (i = 0; i < trace->stream_classes->len; i++) {
+ struct bt_stream_class *stream_class_candidate;
+
+ stream_class_candidate =
+ g_ptr_array_index(trace->stream_classes, i);
+
+ if (bt_stream_class_get_id(stream_class_candidate) ==
+ (int64_t) id) {
+ stream_class = stream_class_candidate;
+ goto end;
+ }
+ }
+
+end:
+ return stream_class;
}
struct bt_clock_class *bt_trace_borrow_clock_class_by_name(
struct bt_trace *trace, const char *name)
{
- return bt_trace_common_borrow_clock_class_by_name(BT_TO_COMMON(trace),
- name);
+ size_t i;
+ struct bt_clock_class *clock_class = NULL;
+
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE_NON_NULL(name, "Name");
+
+ for (i = 0; i < trace->clock_classes->len; i++) {
+ struct bt_clock_class *cur_clk =
+ g_ptr_array_index(trace->clock_classes, i);
+ const char *cur_clk_name = bt_clock_class_get_name(cur_clk);
+
+ if (!cur_clk_name) {
+ goto end;
+ }
+
+ if (!strcmp(cur_clk_name, name)) {
+ clock_class = cur_clk;
+ goto end;
+ }
+ }
+
+end:
+ return clock_class;
}
BT_HIDDEN
-bt_bool bt_trace_common_has_clock_class(struct bt_trace_common *trace,
+bt_bool bt_trace_has_clock_class(struct bt_trace *trace,
struct bt_clock_class *clock_class)
{
struct search_query query = { .value = clock_class, .found = 0 };
enum bt_byte_order bt_trace_get_native_byte_order(
struct bt_trace *trace)
{
- return bt_trace_common_get_native_byte_order(BT_TO_COMMON(trace));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->native_byte_order;
}
-BT_HIDDEN
-int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
- enum bt_byte_order byte_order, bool allow_unspecified)
+int bt_trace_set_native_byte_order(struct bt_trace *trace,
+ enum bt_byte_order byte_order)
{
int ret = 0;
if (trace->frozen) {
BT_LOGW("Invalid parameter: trace is frozen: "
"addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
- ret = -1;
- goto end;
- }
-
- if (byte_order == BT_BYTE_ORDER_UNSPECIFIED && !allow_unspecified) {
- BT_LOGW("Invalid parameter: BT_BYTE_ORDER_UNSPECIFIED byte order is not allowed: "
- "addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
+ trace, bt_trace_get_name(trace));
ret = -1;
goto end;
}
byte_order != BT_BYTE_ORDER_NETWORK) {
BT_LOGW("Invalid parameter: invalid byte order: "
"addr=%p, name=\"%s\", bo=%s",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
bt_common_byte_order_string(byte_order));
ret = -1;
goto end;
trace->native_byte_order = byte_order;
BT_LOGV("Set trace's native byte order: "
"addr=%p, name=\"%s\", bo=%s",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
bt_common_byte_order_string(byte_order));
end:
return ret;
}
-int bt_trace_set_native_byte_order(struct bt_trace *trace,
- enum bt_byte_order byte_order)
-{
- return bt_trace_common_set_native_byte_order(BT_TO_COMMON(trace),
- byte_order, true);
-}
-
struct bt_field_type *bt_trace_borrow_packet_header_field_type(
struct bt_trace *trace)
{
- return BT_FROM_COMMON(bt_trace_common_borrow_packet_header_field_type(
- BT_TO_COMMON(trace)));
+ BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ return trace->packet_header_field_type;
}
-BT_HIDDEN
-int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
- struct bt_field_type_common *packet_header_type)
+int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
+ struct bt_field_type *packet_header_type)
{
int ret = 0;
if (trace->frozen) {
BT_LOGW("Invalid parameter: trace is frozen: "
"addr=%p, name=\"%s\"",
- trace, bt_trace_common_get_name(trace));
+ trace, bt_trace_get_name(trace));
ret = -1;
goto end;
}
packet_header_type->id != BT_FIELD_TYPE_ID_STRUCT) {
BT_LOGW("Invalid parameter: packet header field type must be a structure field type if it exists: "
"addr=%p, name=\"%s\", ft-addr=%p, ft-id=%s",
- trace, bt_trace_common_get_name(trace),
+ trace, bt_trace_get_name(trace),
packet_header_type,
bt_common_field_type_id_string(packet_header_type->id));
ret = -1;
trace->packet_header_field_type = bt_get(packet_header_type);
BT_LOGV("Set trace's packet header field type: "
"addr=%p, name=\"%s\", packet-context-ft-addr=%p",
- trace, bt_trace_common_get_name(trace), packet_header_type);
+ trace, bt_trace_get_name(trace), packet_header_type);
end:
return ret;
}
-int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
- struct bt_field_type *packet_header_type)
-{
- return bt_trace_common_set_packet_header_field_type(BT_TO_COMMON(trace),
- (void *) packet_header_type);
-}
-
static
int64_t get_stream_class_count(void *element)
{
goto end;
}
- ret = check_packet_header_type_has_no_clock_class(BT_TO_COMMON(trace));
+ ret = check_packet_header_type_has_no_clock_class(trace);
if (ret) {
/* check_packet_header_type_has_no_clock_class() logs errors */
goto end;
}
trace->is_static = BT_TRUE;
- bt_trace_common_freeze(BT_TO_COMMON(trace));
+ bt_trace_freeze(trace);
BT_LOGV("Set trace static: addr=%p, name=\"%s\"",
trace, bt_trace_get_name(trace));
struct bt_field_wrapper *field_wrapper;
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
- BT_ASSERT_PRE(trace->common.packet_header_field_type,
+ BT_ASSERT_PRE(trace->packet_header_field_type,
"Trace has no packet header field type: %!+t",
trace);
field_wrapper = bt_field_wrapper_create(
&trace->packet_header_field_pool,
- (void *) trace->common.packet_header_field_type);
+ (void *) trace->packet_header_field_type);
if (!field_wrapper) {
BT_LIB_LOGE("Cannot allocate one packet header field from trace: "
"%![trace-]+t", trace);
}
BT_ASSERT(field_wrapper->field);
- bt_trace_common_freeze(BT_TO_COMMON(trace));
+ bt_trace_freeze(trace);
goto end;
error:
*/
static
int validate_event_class_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type,
- struct bt_field_type_common *event_context_type,
- struct bt_field_type_common *event_payload_type)
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type,
+ struct bt_field_type *event_context_type,
+ struct bt_field_type *event_payload_type)
{
int ret = 0;
/* Validate field types individually */
if (event_context_type) {
- ret = bt_field_type_common_validate(event_context_type);
+ ret = bt_field_type_validate(event_context_type);
if (ret) {
BT_LOGW("Invalid event class's context field type: "
"ret=%d", ret);
}
if (event_payload_type) {
- ret = bt_field_type_common_validate(event_payload_type);
+ ret = bt_field_type_validate(event_payload_type);
if (ret) {
BT_LOGW("Invalid event class's payload field type: "
"ret=%d", ret);
*/
static
int validate_stream_class_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type)
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type)
{
int ret = 0;
/* Validate field types individually */
if (packet_context_type) {
- ret = bt_field_type_common_validate(packet_context_type);
+ ret = bt_field_type_validate(packet_context_type);
if (ret) {
BT_LOGW("Invalid stream class's packet context field type: "
"ret=%d", ret);
}
if (event_header_type) {
- ret = bt_field_type_common_validate(event_header_type);
+ ret = bt_field_type_validate(event_header_type);
if (ret) {
BT_LOGW("Invalid stream class's event header field type: "
"ret=%d", ret);
}
if (stream_event_ctx_type) {
- ret = bt_field_type_common_validate(
+ ret = bt_field_type_validate(
stream_event_ctx_type);
if (ret) {
BT_LOGW("Invalid stream class's event context field type: "
*/
static
int validate_trace_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type)
+ struct bt_field_type *packet_header_type)
{
int ret = 0;
/* Validate field types individually */
if (packet_header_type) {
- ret = bt_field_type_common_validate(packet_header_type);
+ ret = bt_field_type_validate(packet_header_type);
if (ret) {
BT_LOGW("Invalid trace's packet header field type: "
"ret=%d", ret);
* `field_type` is owned by the caller.
*/
static
-int field_type_contains_sequence_or_variant_ft(struct bt_field_type_common *type)
+int field_type_contains_sequence_or_variant_ft(struct bt_field_type *type)
{
int ret = 0;
- enum bt_field_type_id type_id = bt_field_type_common_get_type_id(type);
+ enum bt_field_type_id type_id = bt_field_type_get_type_id(type);
switch (type_id) {
case BT_FIELD_TYPE_ID_SEQUENCE:
case BT_FIELD_TYPE_ID_STRUCT:
{
int i;
- int field_count = bt_field_type_common_get_field_count(type);
+ int field_count = bt_field_type_get_field_count(type);
if (field_count < 0) {
ret = -1;
}
for (i = 0; i < field_count; ++i) {
- struct bt_field_type_common *child_type =
- bt_field_type_common_borrow_field_at_index(
+ struct bt_field_type *child_type =
+ bt_field_type_borrow_field_at_index(
type, i);
ret = field_type_contains_sequence_or_variant_ft(
BT_HIDDEN
int bt_validate_class_types(struct bt_value *environment,
- struct bt_field_type_common *packet_header_type,
- struct bt_field_type_common *packet_context_type,
- struct bt_field_type_common *event_header_type,
- struct bt_field_type_common *stream_event_ctx_type,
- struct bt_field_type_common *event_context_type,
- struct bt_field_type_common *event_payload_type,
+ struct bt_field_type *packet_header_type,
+ struct bt_field_type *packet_context_type,
+ struct bt_field_type *event_header_type,
+ struct bt_field_type *stream_event_ctx_type,
+ struct bt_field_type *event_context_type,
+ struct bt_field_type *event_payload_type,
int trace_valid, int stream_class_valid, int event_class_valid,
struct bt_validation_output *output,
enum bt_validation_flag validate_flags,
/* Validate trace */
if ((validate_flags & BT_VALIDATION_FLAG_TRACE) && !trace_valid) {
- struct bt_field_type_common *packet_header_type_copy = NULL;
+ struct bt_field_type *packet_header_type_copy = NULL;
/* Create field type copies */
if (packet_header_type) {
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(packet_header_type_copy);
+ bt_field_type_freeze(packet_header_type_copy);
}
skip_packet_header_type_copy:
/* Validate stream class */
if ((validate_flags & BT_VALIDATION_FLAG_STREAM) &&
!stream_class_valid) {
- struct bt_field_type_common *packet_context_type_copy = NULL;
- struct bt_field_type_common *event_header_type_copy = NULL;
- struct bt_field_type_common *stream_event_ctx_type_copy = NULL;
+ struct bt_field_type *packet_context_type_copy = NULL;
+ struct bt_field_type *event_header_type_copy = NULL;
+ struct bt_field_type *stream_event_ctx_type_copy = NULL;
if (packet_context_type) {
contains_seq_var =
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(packet_context_type_copy);
+ bt_field_type_freeze(packet_context_type_copy);
}
skip_packet_context_type_copy:
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(event_header_type_copy);
+ bt_field_type_freeze(event_header_type_copy);
}
skip_event_header_type_copy:
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(stream_event_ctx_type_copy);
+ bt_field_type_freeze(stream_event_ctx_type_copy);
}
skip_stream_event_ctx_type_copy:
/* Validate event class */
if ((validate_flags & BT_VALIDATION_FLAG_EVENT) &&
!event_class_valid) {
- struct bt_field_type_common *event_context_type_copy = NULL;
- struct bt_field_type_common *event_payload_type_copy = NULL;
+ struct bt_field_type *event_context_type_copy = NULL;
+ struct bt_field_type *event_payload_type_copy = NULL;
if (event_context_type) {
contains_seq_var =
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(event_context_type_copy);
+ bt_field_type_freeze(event_context_type_copy);
}
skip_event_context_type_copy:
* caller, it cannot be modified any way since
* it will be resolved.
*/
- bt_field_type_common_freeze(event_payload_type_copy);
+ bt_field_type_freeze(event_payload_type_copy);
}
skip_event_payload_type_copy:
}
BT_HIDDEN
-void bt_validation_replace_types(struct bt_trace_common *trace,
- struct bt_stream_class_common *stream_class,
- struct bt_event_class_common *event_class,
+void bt_validation_replace_types(struct bt_trace *trace,
+ struct bt_stream_class *stream_class,
+ struct bt_event_class *event_class,
struct bt_validation_output *output,
enum bt_validation_flag replace_flags)
{
if ((replace_flags & BT_VALIDATION_FLAG_TRACE) && trace) {
- bt_field_type_common_freeze(trace->packet_header_field_type);
+ bt_field_type_freeze(trace->packet_header_field_type);
BT_MOVE(trace->packet_header_field_type,
output->packet_header_type);
}
if ((replace_flags & BT_VALIDATION_FLAG_STREAM) && stream_class) {
- bt_field_type_common_freeze(stream_class->packet_context_field_type);
- bt_field_type_common_freeze(stream_class->event_header_field_type);
- bt_field_type_common_freeze(stream_class->event_context_field_type);
+ bt_field_type_freeze(stream_class->packet_context_field_type);
+ bt_field_type_freeze(stream_class->event_header_field_type);
+ bt_field_type_freeze(stream_class->event_context_field_type);
BT_MOVE(stream_class->packet_context_field_type,
output->packet_context_type);
BT_MOVE(stream_class->event_header_field_type,
}
if ((replace_flags & BT_VALIDATION_FLAG_EVENT) && event_class) {
- bt_field_type_common_freeze(event_class->context_field_type);
- bt_field_type_common_freeze(event_class->payload_field_type);
+ bt_field_type_freeze(event_class->context_field_type);
+ bt_field_type_freeze(event_class->payload_field_type);
BT_MOVE(event_class->context_field_type, output->event_context_type);
BT_MOVE(event_class->payload_field_type, output->event_payload_type);
}
strcat(tmp_prefix, (_prefix2)); \
} while (0)
-typedef void (*format_func)(char **, bool, const char *, void *);
-
static inline void format_component(char **buf_ch, bool extended,
const char *prefix, struct bt_component *component);
}
}
-static inline void format_field_type_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_type_common *field_type)
+static inline void format_field_type(char **buf_ch, bool extended,
+ const char *prefix, struct bt_field_type *field_type)
{
BUF_APPEND(", %stype-id=%s, %salignment=%u",
PRFIELD(bt_common_field_type_id_string(field_type->id)),
switch (field_type->id) {
case BT_FIELD_TYPE_ID_INTEGER:
{
- struct bt_field_type_common_integer *integer =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_integer *integer = (void *) field_type;
BUF_APPEND(", %ssize=%u, %sis-signed=%d, %sbyte-order=%s, "
"%sbase=%d, %sencoding=%s, "
"%smapped-clock-class-addr=%p",
PRFIELD(integer->size), PRFIELD(integer->is_signed),
- PRFIELD(bt_common_byte_order_string(integer->user_byte_order)),
+ PRFIELD(bt_common_byte_order_string(
+ integer->user_byte_order)),
PRFIELD(integer->base),
- PRFIELD(bt_common_string_encoding_string(integer->encoding)),
+ PRFIELD(bt_common_string_encoding_string(
+ integer->encoding)),
PRFIELD(integer->mapped_clock_class));
if (integer->mapped_clock_class) {
BUF_APPEND(", %smapped-clock-class-name=\"%s\"",
- PRFIELD(bt_clock_class_get_name(integer->mapped_clock_class)));
+ PRFIELD(bt_clock_class_get_name(
+ integer->mapped_clock_class)));
}
break;
}
case BT_FIELD_TYPE_ID_FLOAT:
{
- struct bt_field_type_common_floating_point *flt =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_floating_point *flt = (void *) field_type;
BUF_APPEND(", %sexp-dig=%u, %smant-dig=%u, %sbyte-order=%s",
PRFIELD(flt->exp_dig), PRFIELD(flt->mant_dig),
- PRFIELD(bt_common_byte_order_string(flt->user_byte_order)));
+ PRFIELD(bt_common_byte_order_string(
+ flt->user_byte_order)));
break;
}
case BT_FIELD_TYPE_ID_ENUM:
{
- struct bt_field_type_common_enumeration *enm =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_enumeration *enm = (void *) field_type;
BUF_APPEND(", %smapping-count=%u",
PRFIELD(enm->entries->len));
}
case BT_FIELD_TYPE_ID_STRING:
{
- struct bt_field_type_common_string *str =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_string *str = (void *) field_type;
BUF_APPEND(", %sencoding=%s",
- PRFIELD(bt_common_string_encoding_string(str->encoding)));
+ PRFIELD(bt_common_string_encoding_string(
+ str->encoding)));
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
{
- struct bt_field_type_common_structure *structure =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_structure *structure = (void *) field_type;
BUF_APPEND(", %sfield-count=%u",
PRFIELD(structure->fields->len));
}
case BT_FIELD_TYPE_ID_SEQUENCE:
{
- struct bt_field_type_common_sequence *seq =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_sequence *seq = (void *) field_type;
BUF_APPEND(", %slength-ft-addr=\"%s\", %selem-ft-addr=%p",
PRFIELD(seq->length_field_name->str),
}
case BT_FIELD_TYPE_ID_VARIANT:
{
- struct bt_field_type_common_variant *variant =
- BT_FROM_COMMON(field_type);
+ struct bt_field_type_variant *variant = (void *) field_type;
BUF_APPEND(", %stag-name=\"%s\", %sfield-count=%u",
PRFIELD(variant->tag_name->str),
}
}
-static inline void format_field_type(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_type *field_type)
-{
- format_field_type_common(buf_ch, extended, prefix,
- (void *) field_type);
-}
-
-static inline void format_field_common_integer_extended(char **buf_ch,
- const char *prefix, struct bt_field_common *field)
+static inline void format_field_integer_extended(char **buf_ch,
+ const char *prefix, struct bt_field *field)
{
- struct bt_field_common_integer *integer = BT_FROM_COMMON(field);
- struct bt_field_type_common_integer *field_type =
- BT_FROM_COMMON(field->type);
+ struct bt_field_integer *integer = (void *) field;
+ struct bt_field_type_integer *field_type = (void *) field->type;
const char *fmt = NULL;
BT_ASSERT(field_type);
}
}
-static inline void format_field_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_field_common *field)
+static inline void format_field(char **buf_ch, bool extended,
+ const char *prefix, struct bt_field *field)
{
+ struct bt_field *common_field = (void *) field;
+
BUF_APPEND(", %sis-set=%d", PRFIELD(field->payload_set));
if (extended) {
switch (field->type->id) {
case BT_FIELD_TYPE_ID_INTEGER:
{
- format_field_common_integer_extended(buf_ch, prefix, field);
+ format_field_integer_extended(buf_ch, prefix, field);
break;
}
case BT_FIELD_TYPE_ID_FLOAT:
{
- struct bt_field_common_floating_point *flt =
- BT_FROM_COMMON(field);
+ struct bt_field_floating_point *flt = (void *) field;
BUF_APPEND(", %svalue=%f", PRFIELD(flt->payload));
break;
}
case BT_FIELD_TYPE_ID_STRING:
{
- struct bt_field_common_string *str =
- BT_FROM_COMMON(field);
+ struct bt_field_string *str = (void *) field;
if (str->buf) {
BT_ASSERT(str->buf->data);
}
case BT_FIELD_TYPE_ID_SEQUENCE:
{
- struct bt_field_common_sequence *seq =
- BT_FROM_COMMON(field);
+ struct bt_field_sequence *seq = (void *) field;
BUF_APPEND(", %slength=%" PRIu64, PRFIELD(seq->length));
}
case BT_FIELD_TYPE_ID_VARIANT:
{
- struct bt_field_common_variant *variant =
- BT_FROM_COMMON(field);
+ struct bt_field_variant *variant = (void *) field;
BUF_APPEND(", %scur-field-addr=%p",
PRFIELD(variant->current_field));
default:
break;
}
-}
-
-static inline void format_field(char **buf_ch, bool extended,
- const char *prefix, struct bt_field *field)
-{
- struct bt_field_common *common_field = (void *) field;
-
- format_field_common(buf_ch, extended, prefix, (void *) field);
-
- if (!extended) {
- return;
- }
if (!common_field->type) {
return;
switch (common_field->type->id) {
case BT_FIELD_TYPE_ID_ENUM:
{
- struct bt_field_common_integer *integer = (void *) field;
- struct bt_field_type_common_enumeration *enum_ft =
- BT_FROM_COMMON(common_field->type);
+ struct bt_field_integer *integer = (void *) field;
+ struct bt_field_type_enumeration *enum_ft =
+ (void *) common_field->type;
if (enum_ft->container_ft) {
if (enum_ft->container_ft->is_signed) {
if (field_path->indexes) {
BT_ASSERT(field_path->indexes);
- BUF_APPEND(", %sindex-count=%u", PRFIELD(field_path->indexes->len));
+ BUF_APPEND(", %sindex-count=%u",
+ PRFIELD(field_path->indexes->len));
}
if (!extended || !field_path->indexes) {
return;
}
- BUF_APPEND(", %spath=[%s", PRFIELD(bt_common_scope_string(field_path->root)));
+ BUF_APPEND(", %spath=[%s",
+ PRFIELD(bt_common_scope_string(field_path->root)));
for (i = 0; i < field_path->indexes->len; i++) {
int index = g_array_index(field_path->indexes, int, i);
BUF_APPEND("%s", "]");
}
-static inline void format_trace_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_trace_common *trace)
+static inline void format_trace(char **buf_ch, bool extended,
+ const char *prefix, struct bt_trace *trace)
{
+ char tmp_prefix[64];
+
if (trace->name) {
BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name->str));
}
BUF_APPEND(", %spacket-header-ft-addr=%p",
PRFIELD(trace->packet_header_field_type));
-}
-
-static inline void format_trace(char **buf_ch, bool extended,
- const char *prefix, struct bt_trace *trace)
-{
- char tmp_prefix[64];
-
- format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace));
-
- if (!extended) {
- return;
- }
-
BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static));
SET_TMP_PREFIX("phf-pool-");
format_object_pool(buf_ch, extended, prefix,
&trace->packet_header_field_pool);
}
-static inline void format_stream_class_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream_class_common *stream_class,
- format_func trace_format_func)
+static inline void format_stream_class(char **buf_ch, bool extended,
+ const char *prefix, struct bt_stream_class *stream_class)
{
- struct bt_trace_common *trace;
+ struct bt_trace *trace;
char tmp_prefix[64];
if (stream_class->id_set) {
PRFIELD(stream_class->packet_context_field_type),
PRFIELD(stream_class->event_header_field_type),
PRFIELD(stream_class->event_context_field_type));
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
return;
}
BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
SET_TMP_PREFIX("trace-");
- trace_format_func(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_stream_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream_class *stream_class)
-{
- char tmp_prefix[64];
-
- format_stream_class_common(buf_ch, extended, prefix,
- BT_TO_COMMON(stream_class), (format_func) format_trace);
-
- if (!extended) {
- return;
- }
-
+ format_trace(buf_ch, false, tmp_prefix, trace);
SET_TMP_PREFIX("ehf-pool-");
format_object_pool(buf_ch, extended, prefix,
&stream_class->event_header_field_pool);
&stream_class->packet_context_field_pool);
}
-static inline void format_event_class_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_event_class_common *event_class,
- format_func format_stream_class_func,
- format_func format_trace_func)
+static inline void format_event_class(char **buf_ch, bool extended,
+ const char *prefix, struct bt_event_class *event_class)
{
- struct bt_stream_class_common *stream_class;
- struct bt_trace_common *trace;
+ struct bt_stream_class *stream_class;
+ struct bt_trace *trace;
char tmp_prefix[64];
BUF_APPEND(", %sid=%" PRId64, PRFIELD(event_class->id));
if (event_class->name) {
- BUF_APPEND(", %sname=\"%s\"", PRFIELD(event_class->name->str));
+ BUF_APPEND(", %sname=\"%s\"",
+ PRFIELD(event_class->name->str));
}
if (!extended) {
BUF_APPEND(", %sis-frozen=%d, %slog-level=%s",
PRFIELD(event_class->frozen),
- PRFIELD(bt_common_event_class_log_level_string(event_class->log_level)));
+ PRFIELD(bt_common_event_class_log_level_string(
+ event_class->log_level)));
if (event_class->emf_uri) {
BUF_APPEND(", %semf-uri=\"%s\"",
PRFIELD(event_class->context_field_type),
PRFIELD(event_class->payload_field_type));
- stream_class = bt_event_class_common_borrow_stream_class(event_class);
+ stream_class = bt_event_class_borrow_stream_class(event_class);
if (!stream_class) {
return;
}
BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
SET_TMP_PREFIX("stream-class-");
- format_stream_class_func(buf_ch, false, tmp_prefix, stream_class);
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ format_stream_class(buf_ch, false, tmp_prefix, stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
return;
}
BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
SET_TMP_PREFIX("trace-");
- format_trace_func(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_event_class(char **buf_ch, bool extended,
- const char *prefix, struct bt_event_class *event_class)
-{
- char tmp_prefix[64];
-
- format_event_class_common(buf_ch, extended, prefix,
- BT_TO_COMMON(event_class), (format_func) format_stream_class,
- (format_func) format_trace);
-
- if (!extended) {
- return;
- }
-
+ format_trace(buf_ch, false, tmp_prefix, trace);
SET_TMP_PREFIX("event-pool-");
format_object_pool(buf_ch, extended, prefix, &event_class->event_pool);
}
-static inline void format_stream_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream_common *stream,
- format_func format_stream_class_func,
- format_func format_trace_func)
+static inline void format_stream(char **buf_ch, bool extended,
+ const char *prefix, struct bt_stream *stream)
{
- struct bt_stream_class_common *stream_class;
- struct bt_trace_common *trace;
+ struct bt_stream_class *stream_class;
+ struct bt_trace *trace;
char tmp_prefix[64];
BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream->id));
return;
}
- stream_class = bt_stream_common_borrow_class(stream);
+ stream_class = bt_stream_borrow_class(stream);
if (!stream_class) {
return;
}
BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
SET_TMP_PREFIX("stream-class-");
- format_stream_class_func(buf_ch, false, tmp_prefix, stream_class);
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ format_stream_class(buf_ch, false, tmp_prefix, stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (!trace) {
return;
}
BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
SET_TMP_PREFIX("trace-");
- format_trace_common(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_stream(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream *stream)
-{
- char tmp_prefix[64];
-
- format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream),
- (format_func) format_stream_class,
- (format_func) format_trace);
+ format_trace(buf_ch, false, tmp_prefix, trace);
SET_TMP_PREFIX("packet-pool-");
format_object_pool(buf_ch, extended, prefix, &stream->packet_pool);
}
BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream));
SET_TMP_PREFIX("stream-");
format_stream(buf_ch, false, tmp_prefix, stream);
- trace = (struct bt_trace *) bt_object_borrow_parent(&stream->common.base);
+ trace = (struct bt_trace *)
+ bt_object_borrow_parent(&stream->base);
if (!trace) {
return;
}
format_trace(buf_ch, false, tmp_prefix, trace);
}
-static inline void format_event_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_event_common *event,
- format_func format_event_class_func,
- format_func format_stream_class_func,
- format_func format_trace_func)
+static inline void format_event(char **buf_ch, bool extended,
+ const char *prefix, struct bt_event *event)
{
- struct bt_trace_common *trace;
- struct bt_stream_class_common *stream_class;
+ struct bt_packet *packet;
+ struct bt_stream *stream;
+ struct bt_trace *trace;
+ struct bt_stream_class *stream_class;
char tmp_prefix[64];
if (!extended) {
"%sstream-context-field-addr=%p, "
"%scontext-field-addr=%p, %spayload-field-addr=%p, ",
PRFIELD(event->frozen),
- PRFIELD(event->header_field ? event->header_field->field : NULL),
+ PRFIELD(event->header_field ?
+ event->header_field->field : NULL),
PRFIELD(event->stream_event_context_field),
PRFIELD(event->context_field),
PRFIELD(event->payload_field));
}
SET_TMP_PREFIX("event-class-");
- format_event_class_func(buf_ch, false, tmp_prefix, event->class);
- stream_class = bt_event_class_common_borrow_stream_class(event->class);
+ format_event_class(buf_ch, false, tmp_prefix, event->class);
+ stream_class = bt_event_class_borrow_stream_class(event->class);
if (stream_class) {
BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
SET_TMP_PREFIX("stream-class-");
- format_stream_class_func(buf_ch, false, tmp_prefix,
+ format_stream_class(buf_ch, false, tmp_prefix,
stream_class);
- trace = bt_stream_class_common_borrow_trace(stream_class);
+ trace = bt_stream_class_borrow_trace(stream_class);
if (trace) {
BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
SET_TMP_PREFIX("trace-");
- format_trace_func(buf_ch, false, tmp_prefix, trace);
+ format_trace(buf_ch, false, tmp_prefix, trace);
}
}
-}
-
-static inline void format_event(char **buf_ch, bool extended,
- const char *prefix, struct bt_event *event)
-{
- struct bt_packet *packet;
- struct bt_stream *stream;
- char tmp_prefix[64];
-
- format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event),
- (format_func) format_event_class,
- (format_func) format_stream_class, (format_func) format_trace);
-
- if (!extended) {
- return;
- }
SET_TMP_PREFIX("cvs-");
format_clock_value_set(buf_ch, extended, tmp_prefix, &event->cv_set);
}
}
-static inline void format_stream_class_common_common(char **buf_ch,
- bool extended, const char *prefix,
- struct bt_stream_class_common *stream_class)
-{
- format_stream_class_common(buf_ch, extended, prefix, stream_class,
- (format_func) format_trace_common);
-}
-
-static inline void format_event_class_common_common(char **buf_ch,
- bool extended, const char *prefix,
- struct bt_event_class_common *event_class)
-{
- format_event_class_common(buf_ch, extended, prefix, event_class,
- (format_func) format_stream_class_common,
- (format_func) format_trace_common);
-}
-
-static inline void format_event_common_common(char **buf_ch,
- bool extended, const char *prefix,
- struct bt_event_common *event)
-{
- format_event_common(buf_ch, extended, prefix, event,
- (format_func) format_event_class_common,
- (format_func) format_stream_class_common,
- (format_func) format_trace_common);
-}
-
-static inline void format_stream_common_common(char **buf_ch, bool extended,
- const char *prefix, struct bt_stream_common *stream)
-{
- format_stream_common(buf_ch, extended, prefix, stream,
- (format_func) format_stream_class_common,
- (format_func) format_trace_common);
-}
-
static inline void handle_conversion_specifier_bt(void *priv_data,
char **buf_ch, size_t avail_size,
const char **out_fmt_ch, va_list *args)
char prefix[64];
char *prefix_ch = prefix;
void *obj;
- enum {
- CAT_DEFAULT,
- CAT_COMMON,
- } cat = CAT_DEFAULT;
/* skip "%!" */
fmt_ch += 2;
fmt_ch++;
}
- if (*fmt_ch == '_') {
- cat = CAT_COMMON;
- fmt_ch++;
- }
-
obj = va_arg(*args, void *);
BUF_APPEND("%saddr=%p", prefix, obj);
goto update_fmt;
}
- switch (cat) {
- case CAT_DEFAULT:
- switch (*fmt_ch) {
- case 'F':
- format_field_type(buf_ch, extended, prefix, obj);
- break;
- case 'f':
- format_field(buf_ch, extended, prefix, obj);
- break;
- case 'P':
- format_field_path(buf_ch, extended, prefix, obj);
- break;
- case 'E':
- format_event_class(buf_ch, extended, prefix, obj);
- break;
- case 'e':
- format_event(buf_ch, extended, prefix, obj);
- break;
- case 'S':
- format_stream_class(buf_ch, extended, prefix, obj);
- break;
- case 's':
- format_stream(buf_ch, extended, prefix, obj);
- break;
- case 'a':
- format_packet(buf_ch, extended, prefix, obj);
- break;
- case 't':
- format_trace(buf_ch, extended, prefix, obj);
- break;
- case 'K':
- format_clock_class(buf_ch, extended, prefix, obj);
- break;
- case 'k':
- format_clock_value(buf_ch, extended, prefix, obj);
- break;
- case 'v':
- format_value(buf_ch, extended, prefix, obj);
- break;
- case 'n':
- format_notification(buf_ch, extended, prefix, obj);
- break;
- case 'i':
- format_notification_iterator(buf_ch, extended, prefix, obj);
- break;
- case 'C':
- format_component_class(buf_ch, extended, prefix, obj);
- break;
- case 'c':
- format_component(buf_ch, extended, prefix, obj);
- break;
- case 'p':
- format_port(buf_ch, extended, prefix, obj);
- break;
- case 'x':
- format_connection(buf_ch, extended, prefix, obj);
- break;
- case 'u':
- format_plugin(buf_ch, extended, prefix, obj);
- break;
- case 'g':
- format_graph(buf_ch, extended, prefix, obj);
- break;
- case 'o':
- format_object_pool(buf_ch, extended, prefix, obj);
- break;
- case 'O':
- format_object(buf_ch, extended, prefix, obj);
- break;
- default:
- abort();
- }
+ switch (*fmt_ch) {
+ case 'F':
+ format_field_type(buf_ch, extended, prefix, obj);
break;
- case CAT_COMMON:
- switch (*fmt_ch) {
- case 'F':
- format_field_type_common(buf_ch, extended, prefix, obj);
- break;
- case 'f':
- format_field_common(buf_ch, extended, prefix, obj);
- break;
- case 'E':
- format_event_class_common_common(buf_ch, extended, prefix, obj);
- break;
- case 'e':
- format_event_common_common(buf_ch, extended, prefix, obj);
- break;
- case 'S':
- format_stream_class_common_common(buf_ch, extended, prefix, obj);
- break;
- case 's':
- format_stream_common_common(buf_ch, extended, prefix, obj);
- break;
- case 't':
- format_trace_common(buf_ch, extended, prefix, obj);
- break;
- default:
- abort();
- }
+ case 'f':
+ format_field(buf_ch, extended, prefix, obj);
+ break;
+ case 'P':
+ format_field_path(buf_ch, extended, prefix, obj);
+ break;
+ case 'E':
+ format_event_class(buf_ch, extended, prefix, obj);
+ break;
+ case 'e':
+ format_event(buf_ch, extended, prefix, obj);
+ break;
+ case 'S':
+ format_stream_class(buf_ch, extended, prefix, obj);
break;
+ case 's':
+ format_stream(buf_ch, extended, prefix, obj);
+ break;
+ case 'a':
+ format_packet(buf_ch, extended, prefix, obj);
+ break;
+ case 't':
+ format_trace(buf_ch, extended, prefix, obj);
+ break;
+ case 'K':
+ format_clock_class(buf_ch, extended, prefix, obj);
+ break;
+ case 'k':
+ format_clock_value(buf_ch, extended, prefix, obj);
+ break;
+ case 'v':
+ format_value(buf_ch, extended, prefix, obj);
+ break;
+ case 'n':
+ format_notification(buf_ch, extended, prefix, obj);
+ break;
+ case 'i':
+ format_notification_iterator(buf_ch, extended, prefix, obj);
+ break;
+ case 'C':
+ format_component_class(buf_ch, extended, prefix, obj);
+ break;
+ case 'c':
+ format_component(buf_ch, extended, prefix, obj);
+ break;
+ case 'p':
+ format_port(buf_ch, extended, prefix, obj);
+ break;
+ case 'x':
+ format_connection(buf_ch, extended, prefix, obj);
+ break;
+ case 'u':
+ format_plugin(buf_ch, extended, prefix, obj);
+ break;
+ case 'g':
+ format_graph(buf_ch, extended, prefix, obj);
+ break;
+ case 'o':
+ format_object_pool(buf_ch, extended, prefix, obj);
+ break;
+ case 'O':
+ format_object(buf_ch, extended, prefix, obj);
+ break;
+ default:
+ abort();
}
update_fmt: