struct declaration_struct *struct_declaration =
container_of(declaration, struct declaration_struct, p);
struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
- uint64_t len = struct_declaration_len(struct_declaration);
+ uint64_t len = bt_struct_declaration_len(struct_declaration);
int field_nr_saved;
int ret;
}
field_nr_saved = pos->field_nr;
pos->field_nr = 0;
- ret = struct_rw(ppos, definition);
+ ret = bt_struct_rw(ppos, definition);
if (!pos->dummy) {
pos->depth--;
if (pos->depth >= 0 && (pos->print_names || len > 1)) {
ret = generic_rw(&pos->parent, &file_stream->parent.trace_packet_header->p);
if (ret)
return ret;
- len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("magic"));
if (len_index >= 0) {
struct definition *field;
uint64_t magic;
- field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
magic = bt_get_unsigned_int(field);
if (magic != CTF_MAGIC) {
fprintf(stderr, "[error] Invalid magic number 0x%" PRIX64 " at packet %u (file offset %zd).\n",
}
/* check uuid */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("uuid"));
if (len_index >= 0) {
struct definition_array *defarray;
struct definition *field;
uint64_t i;
uint8_t uuidval[BABELTRACE_UUID_LEN];
- field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
assert(field->declaration->id == CTF_TYPE_ARRAY);
defarray = container_of(field, struct definition_array, p);
assert(bt_array_len(defarray) == BABELTRACE_UUID_LEN);
}
- len_index = struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.trace_packet_header->declaration, g_quark_from_static_string("stream_id"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
stream_id = bt_get_unsigned_int(field);
}
}
if (ret)
return ret;
/* read content size from header */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
packet_index.content_size = bt_get_unsigned_int(field);
} else {
/* Use file size for packet size */
}
/* read packet size from header */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
packet_index.packet_size = bt_get_unsigned_int(field);
} else {
/* Use content size if non-zero, else file size */
}
/* read timestamp begin from header */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_begin"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
packet_index.timestamp_begin = bt_get_unsigned_int(field);
if (file_stream->parent.stream_class->trace->collection) {
packet_index.timestamp_begin =
}
/* read timestamp end from header */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("timestamp_end"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
packet_index.timestamp_end = bt_get_unsigned_int(field);
if (file_stream->parent.stream_class->trace->collection) {
packet_index.timestamp_end =
}
/* read events discarded from header */
- len_index = struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("events_discarded"));
+ len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("events_discarded"));
if (len_index >= 0) {
struct definition *field;
- field = struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
+ field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
packet_index.events_discarded = bt_get_unsigned_int(field);
packet_index.events_discarded_len = bt_get_int_len(field);
}
}
/* Check if field with same name already exists */
- if (struct_declaration_lookup_field_index(struct_declaration, field_name) >= 0) {
+ if (bt_struct_declaration_lookup_field_index(struct_declaration, field_name) >= 0) {
fprintf(fd, "[error] %s: duplicate field %s in struct\n", __func__, g_quark_to_string(field_name));
return -EINVAL;
}
- struct_declaration_add_field(struct_declaration,
+ bt_struct_declaration_add_field(struct_declaration,
g_quark_to_string(field_name),
field_declaration);
bt_declaration_unref(field_declaration);
if (!has_body) {
assert(name);
struct_declaration =
- lookup_struct_declaration(g_quark_from_string(name),
+ bt_lookup_struct_declaration(g_quark_from_string(name),
declaration_scope);
bt_declaration_ref(&struct_declaration->p);
return &struct_declaration->p;
/* For unnamed struct, create type */
/* For named struct (with body), create type and add to declaration scope */
if (name) {
- if (lookup_struct_declaration(g_quark_from_string(name),
+ if (bt_lookup_struct_declaration(g_quark_from_string(name),
declaration_scope)) {
fprintf(fd, "[error] %s: struct %s already declared in scope\n", __func__, name);
goto error;
}
}
- struct_declaration = struct_declaration_new(declaration_scope,
+ struct_declaration = bt_struct_declaration_new(declaration_scope,
min_align_value);
bt_list_for_each_entry(iter, declaration_list, siblings) {
int ret;
if (name) {
int ret;
- ret = register_struct_declaration(g_quark_from_string(name),
+ ret = bt_register_struct_declaration(g_quark_from_string(name),
struct_declaration,
declaration_scope);
assert(!ret);
if (CTF_STREAM_FIELD_IS_SET(stream, stream_id)) {
/* check that packet header has stream_id field. */
if (!trace->packet_header_decl
- || struct_declaration_lookup_field_index(trace->packet_header_decl, g_quark_from_static_string("stream_id")) < 0) {
+ || bt_struct_declaration_lookup_field_index(trace->packet_header_decl, g_quark_from_static_string("stream_id")) < 0) {
ret = -EPERM;
fprintf(fd, "[error] %s: missing stream_id field in packet header declaration, but stream_id attribute is declared for stream.\n", __func__);
goto error;
if (!CTF_TRACE_FIELD_IS_SET(trace, byte_order)) {
/* check that the packet header contains a "magic" field */
if (!trace->packet_header_decl
- || struct_declaration_lookup_field_index(trace->packet_header_decl, g_quark_from_static_string("magic")) < 0) {
+ || bt_struct_declaration_lookup_field_index(trace->packet_header_decl, g_quark_from_static_string("magic")) < 0) {
ret = -EPERM;
fprintf(fd, "[error] %s: missing both byte_order and packet header magic number in trace declaration\n", __func__);
goto error;
struct ctf_stream_pos *pos = ctf_pos(ppos);
ctf_align_pos(pos, declaration->alignment);
- return struct_rw(ppos, definition);
+ return bt_struct_rw(ppos, definition);
}
* that a named variant can be declared without specifying its target
* "choice" tag field immediately.
*/
-int register_struct_declaration(GQuark struct_name,
+int bt_register_struct_declaration(GQuark struct_name,
struct declaration_struct *struct_declaration,
struct declaration_scope *scope);
struct declaration_struct *
- lookup_struct_declaration(GQuark struct_name,
+ bt_lookup_struct_declaration(GQuark struct_name,
struct declaration_scope *scope);
int register_variant_declaration(GQuark variant_name,
struct declaration_untagged_variant *untagged_variant_declaration,
enum ctf_string_encoding bt_get_string_encoding(const struct definition *field);
struct declaration_struct *
- struct_declaration_new(struct declaration_scope *parent_scope,
+ bt_struct_declaration_new(struct declaration_scope *parent_scope,
uint64_t min_align);
-void struct_declaration_add_field(struct declaration_struct *struct_declaration,
+void bt_struct_declaration_add_field(struct declaration_struct *struct_declaration,
const char *field_name,
struct declaration *field_declaration);
/*
* Returns the index of a field within a structure.
*/
-int struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
+int bt_struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
GQuark field_name);
/*
* field returned only valid as long as the field structure is not appended to.
*/
struct declaration_field *
-struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
+bt_struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
int index);
struct definition *
-struct_definition_get_field_from_index(struct definition_struct *struct_definition,
+bt_struct_definition_get_field_from_index(struct definition_struct *struct_definition,
int index);
-int struct_rw(struct stream_pos *pos, struct definition *definition);
-uint64_t struct_declaration_len(struct declaration_struct *struct_declaration);
+int bt_struct_rw(struct stream_pos *pos, struct definition *definition);
+uint64_t bt_struct_declaration_len(struct declaration_struct *struct_declaration);
/*
* The tag enumeration is validated to ensure that it contains only mappings
static
void _struct_definition_free(struct definition *definition);
-int struct_rw(struct stream_pos *ppos, struct definition *definition)
+int bt_struct_rw(struct stream_pos *ppos, struct definition *definition)
{
struct definition_struct *struct_definition =
container_of(definition, struct definition_struct, p);
}
struct declaration_struct *
- struct_declaration_new(struct declaration_scope *parent_scope,
+ bt_struct_declaration_new(struct declaration_scope *parent_scope,
uint64_t min_align)
{
struct declaration_struct *struct_declaration;
g_free(_struct);
}
-void struct_declaration_add_field(struct declaration_struct *struct_declaration,
+void bt_struct_declaration_add_field(struct declaration_struct *struct_declaration,
const char *field_name,
struct declaration *field_declaration)
{
}
/*
- * struct_declaration_lookup_field_index - returns field index
+ * bt_struct_declaration_lookup_field_index - returns field index
*
* Returns the index of a field in a structure, or -1 if it does not
* exist.
*/
-int struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
+int bt_struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
GQuark field_name)
{
gpointer index;
* field returned only valid as long as the field structure is not appended to.
*/
struct declaration_field *
- struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
+ bt_struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration,
int index)
{
if (index < 0)
* field returned only valid as long as the field structure is not appended to.
*/
struct definition *
-struct_definition_get_field_from_index(struct definition_struct *_struct,
+bt_struct_definition_get_field_from_index(struct definition_struct *_struct,
int index)
{
if (index < 0)
return g_ptr_array_index(_struct->fields, index);
}
-uint64_t struct_declaration_len(struct declaration_struct *struct_declaration)
+uint64_t bt_struct_declaration_len(struct declaration_struct *struct_declaration)
{
return struct_declaration->fields->len;
}
}
static
-struct declaration_struct *lookup_struct_declaration_scope(GQuark struct_name,
+struct declaration_struct *bt_lookup_struct_declaration_scope(GQuark struct_name,
struct declaration_scope *scope)
{
return g_hash_table_lookup(scope->struct_declarations,
(gconstpointer) (unsigned long) struct_name);
}
-struct declaration_struct *lookup_struct_declaration(GQuark struct_name,
+struct declaration_struct *bt_lookup_struct_declaration(GQuark struct_name,
struct declaration_scope *scope)
{
struct declaration_struct *declaration;
while (scope) {
- declaration = lookup_struct_declaration_scope(struct_name, scope);
+ declaration = bt_lookup_struct_declaration_scope(struct_name, scope);
if (declaration)
return declaration;
scope = scope->parent_scope;
return NULL;
}
-int register_struct_declaration(GQuark struct_name,
+int bt_register_struct_declaration(GQuark struct_name,
struct declaration_struct *struct_declaration,
struct declaration_scope *scope)
{
return -EPERM;
/* Only lookup in local scope */
- if (lookup_struct_declaration_scope(struct_name, scope))
+ if (bt_lookup_struct_declaration_scope(struct_name, scope))
return -EEXIST;
g_hash_table_insert(scope->struct_declarations,