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
)
71 /*****************************************************************************
73 * ltt_eventtype_id : get the id of the event type
78 ****************************************************************************/
80 unsigned ltt_eventtype_id(LttEventType
*et
)
82 return et
->facility
->base_id
+ et
->index
;
85 /*****************************************************************************
87 * ltt_eventtype_type : get the type of the event type
91 * LttType * : the type of the event type
92 ****************************************************************************/
94 LttType
*ltt_eventtype_type(LttEventType
*et
)
96 if(!et
->root_field
) return NULL
;
97 return et
->root_field
->field_type
;
100 /*****************************************************************************
102 * ltt_eventtype_field : get the root filed of the event type
106 * LttField * : the root filed of the event type
107 ****************************************************************************/
109 LttField
*ltt_eventtype_field(LttEventType
*et
)
111 return et
->root_field
;
114 /*****************************************************************************
116 * ltt_type_name : get the name of the type
120 * char * : the name of the type
121 ****************************************************************************/
123 char *ltt_type_name(LttType
*t
)
125 return t
->element_name
;
128 /*****************************************************************************
130 * ltt_type_class : get the type class of the type
134 * LttTypeEnum : the type class of the type
135 ****************************************************************************/
137 LttTypeEnum
ltt_type_class(LttType
*t
)
139 return t
->type_class
;
142 /*****************************************************************************
144 * ltt_type_size : obtain the type size. The size is the number of bytes
145 * for primitive types (INT, UINT, FLOAT, ENUM), or the
146 * size for the unsigned integer length count for sequences
151 * unsigned : the type size
152 ****************************************************************************/
154 unsigned ltt_type_size(LttTrace
* trace
, LttType
*t
)
156 if(t
->type_class
==LTT_STRUCT
|| t
->type_class
==LTT_ARRAY
||
157 t
->type_class
==LTT_STRING
) return 0;
159 if(t
->type_class
== LTT_FLOAT
){
160 return floatSizes
[t
->size
];
162 if(t
->size
< sizeof(intSizes
)/sizeof(unsigned))
163 return intSizes
[t
->size
];
165 LttArchSize size
= trace
->system_description
->size
;
166 if(size
== LTT_LP32
){
167 if(t
->size
== 5)return sizeof(int16_t);
168 else return sizeof(int32_t);
170 else if(size
== LTT_ILP32
|| size
== LTT_LP64
){
171 if(t
->size
== 5)return sizeof(int32_t);
173 if(size
== LTT_ILP32
) return sizeof(int32_t);
174 else return sizeof(int64_t);
177 else if(size
== LTT_ILP64
)return sizeof(int64_t);
182 /*****************************************************************************
184 * ltt_type_element_type : obtain the type of nested elements for arrays
189 * LttType : the type of nested element of array or sequence
190 ****************************************************************************/
192 LttType
*ltt_type_element_type(LttType
*t
)
194 if(t
->type_class
!= LTT_ARRAY
&& t
->type_class
!= LTT_SEQUENCE
)
196 return t
->element_type
[0];
199 /*****************************************************************************
201 * ltt_type_element_number : obtain the number of elements for arrays
205 * unsigned : the number of elements for arrays
206 ****************************************************************************/
208 unsigned ltt_type_element_number(LttType
*t
)
210 if(t
->type_class
!= LTT_ARRAY
)
212 return t
->element_number
;
215 /*****************************************************************************
217 * ltt_type_member_number : obtain the number of data members for structure
221 * unsigned : the number of members for structure
222 ****************************************************************************/
224 unsigned ltt_type_member_number(LttType
*t
)
226 if(t
->type_class
!= LTT_STRUCT
&& t
->type_class
!= LTT_UNION
)
228 return t
->element_number
;
231 /*****************************************************************************
233 * ltt_type_member_type : obtain the type of a data members in a structure
236 * i : index of the member
238 * LttType * : the type of structure member
239 ****************************************************************************/
241 LttType
*ltt_type_member_type(LttType
*t
, unsigned i
, char ** name
)
243 if(t
->type_class
!= LTT_STRUCT
){*name
== NULL
; return NULL
;}
244 if(i
>= t
->element_number
|| i
< 0 ){*name
= NULL
; return NULL
;}
245 *name
= t
->element_type
[i
]->element_name
;
246 return t
->element_type
[i
];
249 /*****************************************************************************
251 * ltt_enum_string_get : for enumerations, obtain the symbolic string
252 * associated with a value (0 to n - 1 for an
253 * enumeration of n elements)
256 * i : index of the member
258 * char * : symbolic string associated with a value
259 ****************************************************************************/
261 char *ltt_enum_string_get(LttType
*t
, unsigned i
)
263 if(t
->type_class
!= LTT_ENUM
) return NULL
;
264 if(i
>= t
->element_number
|| i
< 0 ) return NULL
;
265 return t
->enum_strings
[i
];
268 /*****************************************************************************
270 * ltt_field_element : obtain the field of nested elements for arrays and
275 * LttField * : the field of the nested element
276 ****************************************************************************/
278 LttField
*ltt_field_element(LttField
*f
)
280 if(f
->field_type
->type_class
!= LTT_ARRAY
&&
281 f
->field_type
->type_class
!= LTT_SEQUENCE
)
287 /*****************************************************************************
289 * ltt_field_member : obtain the filed of data members for structure
292 * i : index of member field
294 * LttField * : the field of the nested element
295 ****************************************************************************/
297 LttField
*ltt_field_member(LttField
*f
, unsigned i
)
299 if(f
->field_type
->type_class
!= LTT_STRUCT
) return NULL
;
300 if(i
< 0 || i
>= f
->field_type
->element_number
) return NULL
;
304 /*****************************************************************************
306 * ltt_field_type : obtain the type of the field
310 * ltt_tyoe * : the type of field
311 ****************************************************************************/
313 LttType
*ltt_field_type(LttField
*f
)
316 return f
->field_type
;
This page took 0.037652 seconds and 4 git commands to generate.