3 #include <ltt/LTTTypes.h>
7 static unsigned intSizes
[] = {
8 sizeof(int8_t), sizeof(int16_t), sizeof(int32_t), sizeof(int64_t),
11 static unsigned floatSizes
[] = {
12 0, 0, sizeof(float), sizeof(double), 0, sizeof(float), sizeof(double) };
15 /*****************************************************************************
17 * ltt_eventtype_name : get the name of the event type
21 * char * : the name of the event type
22 ****************************************************************************/
24 char *ltt_eventtype_name(ltt_eventtype
*et
)
29 /*****************************************************************************
31 * ltt_eventtype_description : get the description of the event type
35 * char * : the description of the event type
36 ****************************************************************************/
38 char *ltt_eventtype_description(ltt_eventtype
*et
)
40 return et
->description
;
43 /*****************************************************************************
45 * ltt_eventtype_type : get the type of the event type
49 * ltt_type * : the type of the event type
50 ****************************************************************************/
52 ltt_type
*ltt_eventtype_type(ltt_eventtype
*et
)
54 return et
->root_field
->field_type
;
57 /*****************************************************************************
59 * ltt_type_name : get the name of the type
63 * char * : the name of the type
64 ****************************************************************************/
66 char *ltt_type_name(ltt_type
*t
)
68 return t
->element_name
;
71 /*****************************************************************************
73 * ltt_type_class : get the type class of the type
77 * ltt_type_enum : the type class of the type
78 ****************************************************************************/
80 ltt_type_enum
ltt_type_class(ltt_type
*t
)
85 /*****************************************************************************
87 * ltt_type_size : obtain the type size. The size is the number of bytes
88 * for primitive types (INT, UINT, FLOAT, ENUM), or the
89 * size for the unsigned integer length count for sequences
94 * unsigned : the type size
95 ****************************************************************************/
97 unsigned ltt_type_size(ltt_tracefile
* tf
, ltt_type
*t
)
99 if(t
->type_class
==LTT_STRUCT
|| t
->type_class
==LTT_ARRAY
||
100 t
->type_class
==LTT_STRING
) return 0;
102 if(t
->type_class
== LTT_FLOAT
){
103 return floatSizes
[t
->size
];
105 if(t
->size
< sizeof(intSizes
)/sizeof(unsigned))
106 return intSizes
[t
->size
];
108 ltt_arch_size size
= tf
->trace_header
->arch_size
;
110 return sizeof(int16_t);
111 else if(size
== LTT_ILP32
|| size
== LTT_LP64
)
112 return sizeof(int32_t);
113 else if(size
== LTT_ILP64
)
114 return sizeof(int64_t);
119 /*****************************************************************************
121 * ltt_type_element_type : obtain the type of nested elements for arrays
126 * ltt_type : the type of nested element of array or sequence
127 ****************************************************************************/
129 ltt_type
*ltt_type_element_type(ltt_type
*t
)
131 if(t
->type_class
!= LTT_ARRAY
|| t
->type_class
!= LTT_SEQUENCE
)
133 return t
->element_type
[0];
136 /*****************************************************************************
138 * ltt_type_element_number : obtain the number of elements for arrays
142 * unsigned : the number of elements for arrays
143 ****************************************************************************/
145 unsigned ltt_type_element_number(ltt_type
*t
)
147 if(t
->type_class
!= LTT_ARRAY
)
149 return t
->element_number
;
152 /*****************************************************************************
154 * ltt_type_member_number : obtain the number of data members for structure
158 * unsigned : the number of members for structure
159 ****************************************************************************/
161 unsigned ltt_type_member_number(ltt_type
*t
)
163 if(t
->type_class
!= LTT_STRUCT
)
165 return t
->element_number
;
168 /*****************************************************************************
170 * ltt_type_member_type : obtain the type of a data members in a structure
173 * i : index of the member
175 * ltt_type * : the type of structure member
176 ****************************************************************************/
178 ltt_type
*ltt_type_member_type(ltt_type
*t
, unsigned i
)
180 if(t
->type_class
!= LTT_STRUCT
) return NULL
;
181 if(i
> t
->element_number
|| i
== 0 ) return NULL
;
182 return t
->element_type
[i
-1];
185 /*****************************************************************************
187 * ltt_enum_string_get : for enumerations, obtain the symbolic string
188 * associated with a value (0 to n - 1 for an
189 * enumeration of n elements)
192 * i : index of the member
194 * char * : symbolic string associated with a value
195 ****************************************************************************/
197 char *ltt_enum_string_get(ltt_type
*t
, unsigned i
)
199 if(t
->type_class
!= LTT_ENUM
) return NULL
;
200 if(i
> t
->element_number
|| i
== 0 ) return NULL
;
201 return t
->enum_strings
[i
-1];
204 /*****************************************************************************
206 * ltt_field_element : obtain the field of nested elements for arrays and
211 * ltt_field * : the field of the nested element
212 ****************************************************************************/
214 ltt_field
*ltt_field_element(ltt_field
*f
)
216 if(f
->field_type
->type_class
!= LTT_ARRAY
||
217 f
->field_type
->type_class
!= LTT_SEQUENCE
)
223 /*****************************************************************************
225 * ltt_field_member : obtain the filed of data members for structure
228 * i : index of member field
230 * ltt_field * : the field of the nested element
231 ****************************************************************************/
233 ltt_field
*ltt_field_member(ltt_field
*f
, unsigned i
)
235 if(f
->field_type
->type_class
!= LTT_STRUCT
) return NULL
;
236 if(i
==0 || i
>f
->field_type
->element_number
) return NULL
;
237 return f
->child
[i
-1];
240 /*****************************************************************************
242 * ltt_field_type : obtain the type of the field
246 * ltt_tyoe * : the type of field
247 ****************************************************************************/
249 ltt_type
*ltt_field_type(ltt_field
*f
)
251 return f
->field_type
;
This page took 0.036339 seconds and 4 git commands to generate.