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(LttEventType
*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(LttEventType
*et
)
40 return et
->description
;
43 /*****************************************************************************
45 * ltt_eventtype_facility : get the facility which contains the event type
49 * LttFacility * : the facility
50 ****************************************************************************/
52 LttFacility
*ltt_eventtype_facility(LttEventType
*et
)
57 /*****************************************************************************
59 * ltt_eventtype_relative_id : get the relative id of the event type
63 * unsigned * : the relative id
64 ****************************************************************************/
66 unsigned *ltt_eventtype_relative_id(LttEventType
*et
)
68 return (unsigned*)&et
->index
;
71 /*****************************************************************************
73 * ltt_eventtype_id : get the id of the event type
78 ****************************************************************************/
80 unsigned *ltt_eventtype_id(LttEventType
*et
)
82 unsigned *id
= g_new(unsigned,1);
83 *id
= et
->facility
->base_id
+ et
->index
;
87 /*****************************************************************************
89 * ltt_eventtype_type : get the type of the event type
93 * LttType * : the type of the event type
94 ****************************************************************************/
96 LttType
*ltt_eventtype_type(LttEventType
*et
)
98 return et
->root_field
->field_type
;
101 /*****************************************************************************
103 * ltt_eventtype_field : get the root filed of the event type
107 * LttField * : the root filed of the event type
108 ****************************************************************************/
110 LttField
*ltt_eventtype_field(LttEventType
*et
)
112 return et
->root_field
;
115 /*****************************************************************************
117 * ltt_type_name : get the name of the type
121 * char * : the name of the type
122 ****************************************************************************/
124 char *ltt_type_name(LttType
*t
)
126 return t
->element_name
;
129 /*****************************************************************************
131 * ltt_type_class : get the type class of the type
135 * LttTypeEnum : the type class of the type
136 ****************************************************************************/
138 LttTypeEnum
ltt_type_class(LttType
*t
)
140 return t
->type_class
;
143 /*****************************************************************************
145 * ltt_type_size : obtain the type size. The size is the number of bytes
146 * for primitive types (INT, UINT, FLOAT, ENUM), or the
147 * size for the unsigned integer length count for sequences
152 * unsigned : the type size
153 ****************************************************************************/
155 unsigned ltt_type_size(LttTrace
* trace
, LttType
*t
)
157 if(t
->type_class
==LTT_STRUCT
|| t
->type_class
==LTT_ARRAY
||
158 t
->type_class
==LTT_STRING
) return 0;
160 if(t
->type_class
== LTT_FLOAT
){
161 return floatSizes
[t
->size
];
163 if(t
->size
< sizeof(intSizes
)/sizeof(unsigned))
164 return intSizes
[t
->size
];
166 LttArchSize size
= trace
->system_description
->size
;
168 return sizeof(int16_t);
169 else if(size
== LTT_ILP32
|| size
== LTT_LP64
)
170 return sizeof(int32_t);
171 else if(size
== LTT_ILP64
)
172 return sizeof(int64_t);
177 /*****************************************************************************
179 * ltt_type_element_type : obtain the type of nested elements for arrays
184 * LttType : the type of nested element of array or sequence
185 ****************************************************************************/
187 LttType
*ltt_type_element_type(LttType
*t
)
189 if(t
->type_class
!= LTT_ARRAY
|| t
->type_class
!= LTT_SEQUENCE
)
191 return t
->element_type
[0];
194 /*****************************************************************************
196 * ltt_type_element_number : obtain the number of elements for arrays
200 * unsigned : the number of elements for arrays
201 ****************************************************************************/
203 unsigned ltt_type_element_number(LttType
*t
)
205 if(t
->type_class
!= LTT_ARRAY
)
207 return t
->element_number
;
210 /*****************************************************************************
212 * ltt_type_member_number : obtain the number of data members for structure
216 * unsigned : the number of members for structure
217 ****************************************************************************/
219 unsigned ltt_type_member_number(LttType
*t
)
221 if(t
->type_class
!= LTT_STRUCT
|| t
->type_class
!= LTT_UNION
)
223 return t
->element_number
;
226 /*****************************************************************************
228 * ltt_type_member_type : obtain the type of a data members in a structure
231 * i : index of the member
233 * LttType * : the type of structure member
234 ****************************************************************************/
236 LttType
*ltt_type_member_type(LttType
*t
, unsigned i
)
238 if(t
->type_class
!= LTT_STRUCT
) return NULL
;
239 if(i
> t
->element_number
|| i
== 0 ) return NULL
;
240 return t
->element_type
[i
-1];
243 /*****************************************************************************
245 * ltt_enum_string_get : for enumerations, obtain the symbolic string
246 * associated with a value (0 to n - 1 for an
247 * enumeration of n elements)
250 * i : index of the member
252 * char * : symbolic string associated with a value
253 ****************************************************************************/
255 char *ltt_enum_string_get(LttType
*t
, unsigned i
)
257 if(t
->type_class
!= LTT_ENUM
) return NULL
;
258 if(i
> t
->element_number
|| i
== 0 ) return NULL
;
259 return t
->enum_strings
[i
-1];
262 /*****************************************************************************
264 * ltt_field_element : obtain the field of nested elements for arrays and
269 * LttField * : the field of the nested element
270 ****************************************************************************/
272 LttField
*ltt_field_element(LttField
*f
)
274 if(f
->field_type
->type_class
!= LTT_ARRAY
||
275 f
->field_type
->type_class
!= LTT_SEQUENCE
)
281 /*****************************************************************************
283 * ltt_field_member : obtain the filed of data members for structure
286 * i : index of member field
288 * LttField * : the field of the nested element
289 ****************************************************************************/
291 LttField
*ltt_field_member(LttField
*f
, unsigned i
)
293 if(f
->field_type
->type_class
!= LTT_STRUCT
) return NULL
;
294 if(i
==0 || i
>f
->field_type
->element_number
) return NULL
;
295 return f
->child
[i
-1];
298 /*****************************************************************************
300 * ltt_field_type : obtain the type of the field
304 * ltt_tyoe * : the type of field
305 ****************************************************************************/
307 LttType
*ltt_field_type(LttField
*f
)
309 return f
->field_type
;
This page took 0.036901 seconds and 4 git commands to generate.