Start packet mmap work
[babeltrace.git] / include / babeltrace / types.h
index 9704efed5e08229bc82243b30e715b1e2316e86e..d01b672437c5512017c09fa017b55c97dfd51ec3 100644 (file)
 /* Preallocate this many fields for structures */
 #define DEFAULT_NR_STRUCT_FIELDS 8
 
-/*
- * Always update stream_pos with move_pos and init_pos.
- */
-struct stream_pos {
-       char *base;             /* Base address */
-       size_t offset;          /* Offset from base, in bits */
-       int dummy;              /* Dummy position, for length calculation */
-};
-
-static inline
-void init_pos(struct stream_pos *pos, char *base)
-{
-       pos->base = base;       /* initial base, page-aligned */
-       pos->offset = 0;
-       pos->dummy = false;
-}
-
-/*
- * move_pos - move position of a relative bit offset
- *
- * TODO: allow larger files by updating base too.
- */
-static inline
-void move_pos(struct stream_pos *pos, size_t offset)
-{
-       pos->offset = pos->offset + offset;
-}
-
-/*
- * align_pos - align position on a bit offset (> 0)
- *
- * TODO: allow larger files by updating base too.
- */
-static inline
-void align_pos(struct stream_pos *pos, size_t offset)
-{
-       pos->offset += offset_align(pos->offset, offset);
-}
-
-static inline
-void copy_pos(struct stream_pos *dest, struct stream_pos *src)
-{
-       memcpy(dest, src, sizeof(struct stream_pos));
-}
-
-static inline
-char *get_pos_addr(struct stream_pos *pos)
-{
-       /* Only makes sense to get the address after aligning on CHAR_BIT */
-       assert(!(pos->offset % CHAR_BIT));
-       return pos->base + (pos->offset / CHAR_BIT);
-}
-
+struct stream_pos;
 struct format;
 struct definition;
 
@@ -327,7 +275,7 @@ struct definition_array {
        struct definition p;
        struct declaration_array *declaration;
        struct definition_scope *scope;
-       struct field current_element;           /* struct field */
+       GArray *elems;                  /* struct field */
 };
 
 struct declaration_sequence {
@@ -342,7 +290,7 @@ struct definition_sequence {
        struct declaration_sequence *declaration;
        struct definition_scope *scope;
        struct definition_integer *len;
-       struct field current_element;           /* struct field */
+       GArray *elems;                  /* struct field */
 };
 
 int register_declaration(GQuark declaration_name,
@@ -461,17 +409,17 @@ void struct_declaration_add_field(struct declaration_struct *struct_declaration,
 /*
  * Returns the index of a field within a structure.
  */
-unsigned long struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration,
+int 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,
-                                       unsigned long index);
+                                       int index);
 struct field *
-struct_get_field_from_index(struct definition_struct *struct_definition,
-                           unsigned long index);
+struct_definition_get_field_from_index(struct definition_struct *struct_definition,
+                                      int index);
 
 /*
  * The tag enumeration is validated to ensure that it contains only mappings
@@ -509,6 +457,7 @@ struct field *variant_get_current_field(struct definition_variant *variant);
 struct declaration_array *
        array_declaration_new(size_t len, struct declaration *elem_declaration,
                struct declaration_scope *parent_scope);
+struct definition *array_index(struct definition_array *array, uint64_t i);
 
 /*
  * int_declaration and elem_declaration passed as parameter now belong
@@ -518,6 +467,7 @@ struct declaration_sequence *
        sequence_declaration_new(struct declaration_integer *len_declaration, 
                struct declaration *elem_declaration,
                struct declaration_scope *parent_scope);
+struct definition *sequence_index(struct definition_sequence *sequence, uint64_t i);
 
 /*
  * in: path (dot separated), out: q (GArray of GQuark)
This page took 0.026926 seconds and 4 git commands to generate.