X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fctf-writer%2Ffields.c;h=a0f00a9bcb143301e69276d867f43362e45caf3c;hb=3fadfbc0c91f82c46bd36e6e0657ea93570c9db1;hp=7583ad5b2ff4dc668a5f1af8196874cbf2511ca9;hpb=65300d60e4b4f167e5fc8f584677757ce09a3844;p=babeltrace.git diff --git a/lib/ctf-writer/fields.c b/lib/ctf-writer/fields.c index 7583ad5b..a0f00a9b 100644 --- a/lib/ctf-writer/fields.c +++ b/lib/ctf-writer/fields.c @@ -23,19 +23,19 @@ */ #define BT_LOG_TAG "CTF-WRITER-FIELDS" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -70,7 +70,7 @@ end: BT_HIDDEN int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field, struct bt_ctf_field_type_common *type, - bool is_shared, bt_object_release_func release_func, + bool is_shared, bt_ctf_object_release_func release_func, struct bt_ctf_field_common_methods *methods, bt_ctf_field_common_create_func field_create_func, GDestroyNotify field_release_func) @@ -114,7 +114,7 @@ end: BT_HIDDEN int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field, struct bt_ctf_field_type_common *type, - bool is_shared, bt_object_release_func release_func, + bool is_shared, bt_ctf_object_release_func release_func, struct bt_ctf_field_common_methods *methods, bt_ctf_field_common_create_func field_create_func, GDestroyNotify field_release_func) @@ -166,7 +166,7 @@ end: BT_HIDDEN int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field, struct bt_ctf_field_type_common *type, - bool is_shared, bt_object_release_func release_func, + bool is_shared, bt_ctf_object_release_func release_func, struct bt_ctf_field_common_methods *methods) { int ret = 0; @@ -192,7 +192,7 @@ end: BT_HIDDEN int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field, struct bt_ctf_field_type_common *type, - bool is_shared, bt_object_release_func release_func, + bool is_shared, bt_ctf_object_release_func release_func, struct bt_ctf_field_common_methods *methods, bt_ctf_field_common_create_func field_create_func, GDestroyNotify field_destroy_func) @@ -236,7 +236,7 @@ end: BT_HIDDEN int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field, struct bt_ctf_field_type_common *type, - bool is_shared, bt_object_release_func release_func, + bool is_shared, bt_ctf_object_release_func release_func, struct bt_ctf_field_common_methods *methods, GDestroyNotify field_destroy_func) { @@ -778,7 +778,7 @@ struct bt_ctf_field *(* const field_create_funcs[])(struct bt_ctf_field_type *) }; typedef int (*bt_ctf_field_serialize_recursive_func)( - struct bt_ctf_field_common *, struct bt_ctf_stream_pos *, + struct bt_ctf_field_common *, struct bt_ctfser *, enum bt_ctf_byte_order); static @@ -806,7 +806,7 @@ void bt_ctf_field_enumeration_destroy_recursive(struct bt_ctf_field *field) BT_LOGD("Destroying CTF writer enumeration field object: addr=%p", field); BT_LOGD_STR("Putting container field."); - bt_object_put_ref(enumeration->container); + bt_ctf_object_put_ref(enumeration->container); bt_ctf_field_common_finalize((void *) field); g_free(field); } @@ -826,7 +826,7 @@ void bt_ctf_field_variant_destroy_recursive(struct bt_ctf_field *field) BT_LOGD("Destroying CTF writer variant field object: addr=%p", field); BT_LOGD_STR("Putting tag field."); - bt_object_put_ref(variant->tag); + bt_ctf_object_put_ref(variant->tag); bt_ctf_field_common_variant_finalize_recursive((void *) field); g_free(field); } @@ -857,91 +857,58 @@ void bt_ctf_field_string_destroy(struct bt_ctf_field *field) BT_HIDDEN int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { struct bt_ctf_field_common *field_common = (void *) field; bt_ctf_field_serialize_recursive_func serialize_func; - BT_ASSERT(pos); + BT_ASSERT(ctfser); BT_ASSERT_PRE_NON_NULL(field, "Field"); BT_ASSERT(field_common->spec.writer.serialize_func); serialize_func = field_common->spec.writer.serialize_func; - return serialize_func(field_common, pos, + return serialize_func(field_common, ctfser, native_byte_order); } static -int increase_packet_size(struct bt_ctf_stream_pos *pos) +int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field, + struct bt_ctfser *ctfser, + enum bt_ctf_byte_order native_byte_order) { int ret; + struct bt_ctf_field_type_common_integer *int_type = + BT_CTF_FROM_COMMON(field->type); + struct bt_ctf_field_common_integer *int_field = + BT_CTF_FROM_COMMON(field); + enum bt_ctf_byte_order byte_order; - BT_ASSERT(pos); - BT_LOGV("Increasing packet size: pos-offset=%" PRId64 ", " - "cur-packet-size=%" PRIu64, - pos->offset, pos->packet_size); - ret = munmap_align(pos->base_mma); - if (ret) { - BT_LOGE_ERRNO("Failed to perform an aligned memory unmapping", - ": ret=%d", ret); - goto end; - } - - pos->packet_size += PACKET_LEN_INCREMENT; - do { - ret = bt_posix_fallocate(pos->fd, pos->mmap_offset, - pos->packet_size / CHAR_BIT); - } while (ret == EINTR); - if (ret) { - BT_LOGE_ERRNO("Failed to preallocate memory space", - ": ret=%d", ret); - errno = EINTR; - ret = -1; - goto end; + BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field"); + BT_LOGV("Serializing CTF writer integer field: addr=%p, native-bo=%s", + field, + bt_ctf_byte_order_string(native_byte_order)); + byte_order = int_type->user_byte_order; + if (byte_order == BT_CTF_BYTE_ORDER_NATIVE) { + byte_order = native_byte_order; } - pos->base_mma = mmap_align(pos->packet_size / CHAR_BIT, pos->prot, - pos->flags, pos->fd, pos->mmap_offset); - if (pos->base_mma == MAP_FAILED) { - BT_LOGE_ERRNO("Failed to perform an aligned memory mapping", - ": ret=%d", ret); - ret = -1; + if (int_type->is_signed) { + ret = bt_ctfser_write_signed_int(ctfser, + int_field->payload.signd, int_type->common.alignment, + int_type->size, + byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ? + LITTLE_ENDIAN : BIG_ENDIAN); + } else { + ret = bt_ctfser_write_unsigned_int(ctfser, + int_field->payload.unsignd, int_type->common.alignment, + int_type->size, + byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ? + LITTLE_ENDIAN : BIG_ENDIAN); } - BT_LOGV("Increased packet size: pos-offset=%" PRId64 ", " - "new-packet-size=%" PRIu64, - pos->offset, pos->packet_size); - BT_ASSERT(pos->packet_size % 8 == 0); - -end: - return ret; -} - -static -int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, - enum bt_ctf_byte_order native_byte_order) -{ - int ret = 0; - - BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field"); - BT_LOGV("Serializing CTF writer integer field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); - -retry: - ret = bt_ctf_field_integer_write(field, pos, native_byte_order); - if (ret == -EFAULT) { - /* - * The field is too large to fit in the current packet's - * remaining space. Bump the packet size and retry. - */ - ret = increase_packet_size(pos); - if (ret) { - BT_LOGE("Cannot increase packet size: ret=%d", ret); - goto end; - } - goto retry; + if (unlikely(ret)) { + BT_LOGE("Cannot serialize integer field: ret=%d", ret); + goto end; } end: @@ -949,46 +916,58 @@ end: } static -int bt_ctf_field_enumeration_serialize_recursive(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, +int bt_ctf_field_enumeration_serialize_recursive( + struct bt_ctf_field_common *field, struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { struct bt_ctf_field_enumeration *enumeration = (void *) field; - BT_LOGV("Serializing enumeration field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); + BT_LOGV("Serializing enumeration field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string(native_byte_order)); BT_LOGV_STR("Serializing enumeration field's payload field."); return bt_ctf_field_serialize_recursive( - (void *) enumeration->container, pos, native_byte_order); + (void *) enumeration->container, ctfser, native_byte_order); } static int bt_ctf_field_floating_point_serialize(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { - int ret = 0; + int ret = -1; + struct bt_ctf_field_type_common_floating_point *flt_type = + BT_CTF_FROM_COMMON(field->type); + struct bt_ctf_field_common_floating_point *flt_field = BT_CTF_FROM_COMMON(field); + enum bt_ctf_byte_order byte_order; BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field"); - BT_LOGV("Serializing floating point number field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); + BT_LOGV("Serializing floating point number field: " + "addr=%p, native-bo=%s", field, + bt_ctf_byte_order_string(native_byte_order)); -retry: - ret = bt_ctf_field_floating_point_write(field, pos, - native_byte_order); - if (ret == -EFAULT) { - /* - * The field is too large to fit in the current packet's - * remaining space. Bump the packet size and retry. - */ - ret = increase_packet_size(pos); - if (ret) { - BT_LOGE("Cannot increase packet size: ret=%d", ret); - goto end; - } - goto retry; + byte_order = flt_type->user_byte_order; + if (byte_order == BT_CTF_BYTE_ORDER_NATIVE) { + byte_order = native_byte_order; + } + + if (flt_type->mant_dig == FLT_MANT_DIG) { + ret = bt_ctfser_write_float32(ctfser, flt_field->payload, + flt_type->common.alignment, + byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ? + LITTLE_ENDIAN : BIG_ENDIAN); + } else if (flt_type->mant_dig == DBL_MANT_DIG) { + ret = bt_ctfser_write_float64(ctfser, flt_field->payload, + flt_type->common.alignment, + byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ? + LITTLE_ENDIAN : BIG_ENDIAN); + } else { + abort(); + } + + if (unlikely(ret)) { + BT_LOGE("Cannot serialize floating point number field: " + "ret=%d", ret); + goto end; } end: @@ -997,30 +976,20 @@ end: static int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { int64_t i; - int ret = 0; + int ret; struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field); - BT_LOGV("Serializing structure field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); - - while (!bt_ctf_stream_pos_access_ok(pos, - offset_align(pos->offset, field->type->alignment))) { - ret = increase_packet_size(pos); - if (ret) { - BT_LOGE("Cannot increase packet size: ret=%d", ret); - goto end; - } - } - - if (!bt_ctf_stream_pos_align(pos, field->type->alignment)) { - BT_LOGE("Cannot align packet's position: pos-offset=%" PRId64 ", " - "align=%u", pos->offset, field->type->alignment); - ret = -1; + BT_LOGV("Serializing structure field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string(native_byte_order)); + ret = bt_ctfser_align_offset_in_current_packet(ctfser, + field->type->alignment); + if (unlikely(ret)) { + BT_LOGE("Cannot align offset before serializing structure field: " + "ret=%d", ret); goto end; } @@ -1029,11 +998,12 @@ int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field structure->fields, i); const char *field_name = NULL; - BT_LOGV("Serializing structure field's field: pos-offset=%" PRId64 ", " - "field-addr=%p, index=%" PRId64, - pos->offset, member, i); + BT_LOGV("Serializing structure field's field: ser-offset=%" PRIu64 ", " + "field-addr=%p, index=%" PRIu64, + bt_ctfser_get_offset_in_current_packet_bits(ctfser), + member, i); - if (!member) { + if (unlikely(!member)) { ret = bt_ctf_field_type_common_structure_borrow_field_by_index( field->type, &field_name, NULL, i); BT_ASSERT(ret == 0); @@ -1045,9 +1015,9 @@ int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field goto end; } - ret = bt_ctf_field_serialize_recursive((void *) member, pos, + ret = bt_ctf_field_serialize_recursive((void *) member, ctfser, native_byte_order); - if (ret) { + if (unlikely(ret)) { ret = bt_ctf_field_type_common_structure_borrow_field_by_index( field->type, &field_name, NULL, i); BT_ASSERT(ret == 0); @@ -1065,42 +1035,41 @@ end: static int bt_ctf_field_variant_serialize_recursive(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field); - BT_LOGV("Serializing variant field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); + BT_LOGV("Serializing variant field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string(native_byte_order)); BT_LOGV_STR("Serializing variant field's payload field."); return bt_ctf_field_serialize_recursive( - (void *) variant->current_field, pos, native_byte_order); + (void *) variant->current_field, ctfser, native_byte_order); } static int bt_ctf_field_array_serialize_recursive(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { int64_t i; int ret = 0; struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field); - BT_LOGV("Serializing array field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); + BT_LOGV("Serializing array field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string(native_byte_order)); for (i = 0; i < array->elements->len; i++) { struct bt_ctf_field_common *elem_field = g_ptr_array_index(array->elements, i); BT_LOGV("Serializing array field's element field: " - "pos-offset=%" PRId64 ", field-addr=%p, index=%" PRId64, - pos->offset, elem_field, i); + "ser-offset=%" PRIu64 ", field-addr=%p, index=%" PRId64, + bt_ctfser_get_offset_in_current_packet_bits(ctfser), + elem_field, i); ret = bt_ctf_field_serialize_recursive( - (void *) elem_field, pos, native_byte_order); - if (ret) { + (void *) elem_field, ctfser, native_byte_order); + if (unlikely(ret)) { BT_LOGW("Cannot serialize array field's element field: " "array-field-addr=%p, field-addr=%p, " "index=%" PRId64, field, elem_field, i); @@ -1114,27 +1083,27 @@ end: static int bt_ctf_field_sequence_serialize_recursive(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { int64_t i; int ret = 0; struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field); - BT_LOGV("Serializing sequence field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); + BT_LOGV("Serializing sequence field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string(native_byte_order)); for (i = 0; i < sequence->elements->len; i++) { struct bt_ctf_field_common *elem_field = g_ptr_array_index(sequence->elements, i); BT_LOGV("Serializing sequence field's element field: " - "pos-offset=%" PRId64 ", field-addr=%p, index=%" PRId64, - pos->offset, elem_field, i); + "ser-offset=%" PRIu64 ", field-addr=%p, index=%" PRId64, + bt_ctfser_get_offset_in_current_packet_bits(ctfser), + elem_field, i); ret = bt_ctf_field_serialize_recursive( - (void *) elem_field, pos, native_byte_order); - if (ret) { + (void *) elem_field, ctfser, native_byte_order); + if (unlikely(ret)) { BT_LOGW("Cannot serialize sequence field's element field: " "sequence-field-addr=%p, field-addr=%p, " "index=%" PRId64, field, elem_field, i); @@ -1148,44 +1117,22 @@ end: static int bt_ctf_field_string_serialize(struct bt_ctf_field_common *field, - struct bt_ctf_stream_pos *pos, + struct bt_ctfser *ctfser, enum bt_ctf_byte_order native_byte_order) { - int64_t i; - int ret = 0; + int ret; struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field); - struct bt_ctf_field_type *character_type = - get_field_type(FIELD_TYPE_ALIAS_UINT8_T); - struct bt_ctf_field *character; BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field"); - BT_LOGV("Serializing string field: addr=%p, pos-offset=%" PRId64 ", " - "native-bo=%s", field, pos->offset, - bt_ctf_byte_order_string((int) native_byte_order)); - - BT_LOGV_STR("Creating character field from string field's character field type."); - character = bt_ctf_field_create(character_type); - - for (i = 0; i < string->size + 1; i++) { - const uint64_t chr = (uint64_t) ((char *) string->buf->data)[i]; - - ret = bt_ctf_field_integer_unsigned_set_value(character, chr); - BT_ASSERT(ret == 0); - BT_LOGV("Serializing string field's character field: " - "pos-offset=%" PRId64 ", field-addr=%p, " - "index=%" PRId64 ", char-int=%" PRIu64, - pos->offset, character, i, chr); - ret = bt_ctf_field_integer_serialize( - (void *) character, pos, native_byte_order); - if (ret) { - BT_LOGW_STR("Cannot serialize character field."); - goto end; - } + BT_LOGV("Serializing string field: addr=%p, native-bo=%s", + field, bt_ctf_byte_order_string((int) native_byte_order)); + ret = bt_ctfser_write_string(ctfser, (const char *) string->buf->data); + if (unlikely(ret)) { + BT_LOGE("Cannot serialize string field: ret=%d", ret); + goto end; } end: - bt_object_put_ref(character); - bt_object_put_ref(character_type); return ret; } @@ -1212,7 +1159,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field) { - return bt_object_get_ref(bt_ctf_field_common_borrow_type((void *) field)); + return bt_ctf_object_get_ref(bt_ctf_field_common_borrow_type((void *) field)); } enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field) @@ -1253,28 +1200,28 @@ int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field, struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index( struct bt_ctf_field *field, uint64_t index) { - return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index( + return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index( (void *) field, index)); } struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name( struct bt_ctf_field *field, const char *name) { - return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name( + return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name( (void *) field, name)); } struct bt_ctf_field *bt_ctf_field_array_get_field( struct bt_ctf_field *field, uint64_t index) { - return bt_object_get_ref( + return bt_ctf_object_get_ref( bt_ctf_field_common_array_borrow_field((void *) field, index)); } struct bt_ctf_field *bt_ctf_field_sequence_get_field( struct bt_ctf_field *field, uint64_t index) { - return bt_object_get_ref( + return bt_ctf_object_get_ref( bt_ctf_field_common_sequence_borrow_field((void *) field, index)); } @@ -1329,8 +1276,8 @@ struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *field, goto end; } - bt_object_put_ref(variant_field->tag); - variant_field->tag = bt_object_get_ref(tag_field); + bt_ctf_object_put_ref(variant_field->tag); + variant_field->tag = bt_ctf_object_get_ref(tag_field); current_field = bt_ctf_field_variant_get_current_field(field); BT_ASSERT(current_field); @@ -1341,7 +1288,7 @@ end: struct bt_ctf_field *bt_ctf_field_variant_get_current_field( struct bt_ctf_field *variant_field) { - return bt_object_get_ref(bt_ctf_field_common_variant_borrow_current_field( + return bt_ctf_object_get_ref(bt_ctf_field_common_variant_borrow_current_field( (void *) variant_field)); } @@ -1361,7 +1308,7 @@ struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container( struct bt_ctf_field *bt_ctf_field_enumeration_get_container( struct bt_ctf_field *field) { - return bt_object_get_ref(bt_ctf_field_enumeration_borrow_container(field)); + return bt_ctf_object_get_ref(bt_ctf_field_enumeration_borrow_container(field)); } int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field, @@ -1492,7 +1439,7 @@ struct bt_ctf_field *bt_ctf_field_integer_create(struct bt_ctf_field_type *type) if (integer) { bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(integer), (void *) type, true, - (bt_object_release_func) bt_ctf_field_integer_destroy, + (bt_ctf_object_release_func) bt_ctf_field_integer_destroy, &bt_ctf_field_integer_methods); integer->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_integer_serialize; @@ -1522,13 +1469,13 @@ struct bt_ctf_field *bt_ctf_field_enumeration_create( bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(enumeration), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_enumeration_destroy_recursive, &bt_ctf_field_enumeration_methods); enumeration->container = (void *) bt_ctf_field_create( BT_CTF_FROM_COMMON(enum_ft->container_ft)); if (!enumeration->container) { - BT_OBJECT_PUT_REF_AND_RESET(enumeration); + BT_CTF_OBJECT_PUT_REF_AND_RESET(enumeration); goto end; } @@ -1554,7 +1501,7 @@ struct bt_ctf_field *bt_ctf_field_floating_point_create( if (floating_point) { bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(floating_point), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_floating_point_destroy, &bt_ctf_field_floating_point_methods); floating_point->common.spec.writer.serialize_func = @@ -1585,15 +1532,15 @@ struct bt_ctf_field *bt_ctf_field_structure_create( iret = bt_ctf_field_common_structure_initialize(BT_CTF_TO_COMMON(structure), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_structure_destroy_recursive, &bt_ctf_field_structure_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_object_put_ref); + (GDestroyNotify) bt_ctf_object_put_ref); structure->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_structure_serialize_recursive; if (iret) { - BT_OBJECT_PUT_REF_AND_RESET(structure); + BT_CTF_OBJECT_PUT_REF_AND_RESET(structure); goto end; } @@ -1620,11 +1567,11 @@ struct bt_ctf_field *bt_ctf_field_variant_create(struct bt_ctf_field_type *type) bt_ctf_field_common_variant_initialize(BT_CTF_TO_COMMON(BT_CTF_TO_COMMON(variant)), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_variant_destroy_recursive, &bt_ctf_field_variant_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_object_put_ref); + (GDestroyNotify) bt_ctf_object_put_ref); variant->tag = (void *) bt_ctf_field_create( BT_CTF_FROM_COMMON(var_ft->tag_ft)); variant->common.common.spec.writer.serialize_func = @@ -1653,15 +1600,15 @@ struct bt_ctf_field *bt_ctf_field_array_create(struct bt_ctf_field_type *type) ret = bt_ctf_field_common_array_initialize(BT_CTF_TO_COMMON(array), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_array_destroy_recursive, &bt_ctf_field_array_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_object_put_ref); + (GDestroyNotify) bt_ctf_object_put_ref); array->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_array_serialize_recursive; if (ret) { - BT_OBJECT_PUT_REF_AND_RESET(array); + BT_CTF_OBJECT_PUT_REF_AND_RESET(array); goto end; } @@ -1683,10 +1630,10 @@ struct bt_ctf_field *bt_ctf_field_sequence_create(struct bt_ctf_field_type *type if (sequence) { bt_ctf_field_common_sequence_initialize(BT_CTF_TO_COMMON(sequence), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_sequence_destroy_recursive, &bt_ctf_field_sequence_methods, - (GDestroyNotify) bt_object_put_ref); + (GDestroyNotify) bt_ctf_object_put_ref); sequence->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_sequence_serialize_recursive; BT_LOGD("Created CTF writer sequence field object: addr=%p, ft-addr=%p", @@ -1709,7 +1656,7 @@ struct bt_ctf_field *bt_ctf_field_string_create(struct bt_ctf_field_type *type) if (string) { bt_ctf_field_common_string_initialize(BT_CTF_TO_COMMON(string), (void *) type, - true, (bt_object_release_func) + true, (bt_ctf_object_release_func) bt_ctf_field_string_destroy, &bt_ctf_field_string_methods); string->common.spec.writer.serialize_func = @@ -1905,8 +1852,8 @@ int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field, ret = -1; goto end; } - bt_object_get_ref(value); - BT_OBJECT_MOVE_REF(structure->fields->pdata[index], value); + bt_ctf_object_get_ref(value); + BT_CTF_OBJECT_MOVE_REF(structure->fields->pdata[index], value); end: return ret;