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 return et
->root_field
->field_type
;
99 /*****************************************************************************
101 * ltt_eventtype_field : get the root filed of the event type
105 * LttField * : the root filed of the event type
106 ****************************************************************************/
108 LttField
*ltt_eventtype_field(LttEventType
*et
)
110 return et
->root_field
;
113 /*****************************************************************************
115 * ltt_type_name : get the name of the type
119 * char * : the name of the type
120 ****************************************************************************/
122 char *ltt_type_name(LttType
*t
)
124 return t
->element_name
;
127 /*****************************************************************************
129 * ltt_type_class : get the type class of the type
133 * LttTypeEnum : the type class of the type
134 ****************************************************************************/
136 LttTypeEnum
ltt_type_class(LttType
*t
)
138 return t
->type_class
;
141 /*****************************************************************************
143 * ltt_type_size : obtain the type size. The size is the number of bytes
144 * for primitive types (INT, UINT, FLOAT, ENUM), or the
145 * size for the unsigned integer length count for sequences
150 * unsigned : the type size
151 ****************************************************************************/
153 unsigned ltt_type_size(LttTrace
* trace
, LttType
*t
)
155 if(t
->type_class
==LTT_STRUCT
|| t
->type_class
==LTT_ARRAY
||
156 t
->type_class
==LTT_STRING
) return 0;
158 if(t
->type_class
== LTT_FLOAT
){
159 return floatSizes
[t
->size
];
161 if(t
->size
< sizeof(intSizes
)/sizeof(unsigned))
162 return intSizes
[t
->size
];
164 LttArchSize size
= trace
->system_description
->size
;
165 if(size
== LTT_LP32
){
166 if(t
->size
== 5)return sizeof(int16_t);
167 else return sizeof(int32_t);
169 else if(size
== LTT_ILP32
|| size
== LTT_LP64
){
170 if(t
->size
== 5)return sizeof(int32_t);
172 if(size
== LTT_ILP32
) return sizeof(int32_t);
173 else return sizeof(int64_t);
176 else if(size
== LTT_ILP64
)return sizeof(int64_t);
181 /*****************************************************************************
183 * ltt_type_element_type : obtain the type of nested elements for arrays
188 * LttType : the type of nested element of array or sequence
189 ****************************************************************************/
191 LttType
*ltt_type_element_type(LttType
*t
)
193 if(t
->type_class
!= LTT_ARRAY
&& t
->type_class
!= LTT_SEQUENCE
)
195 return t
->element_type
[0];
198 /*****************************************************************************
200 * ltt_type_element_number : obtain the number of elements for arrays
204 * unsigned : the number of elements for arrays
205 ****************************************************************************/
207 unsigned ltt_type_element_number(LttType
*t
)
209 if(t
->type_class
!= LTT_ARRAY
)
211 return t
->element_number
;
214 /*****************************************************************************
216 * ltt_type_member_number : obtain the number of data members for structure
220 * unsigned : the number of members for structure
221 ****************************************************************************/
223 unsigned ltt_type_member_number(LttType
*t
)
225 if(t
->type_class
!= LTT_STRUCT
&& t
->type_class
!= LTT_UNION
)
227 return t
->element_number
;
230 /*****************************************************************************
232 * ltt_type_member_type : obtain the type of a data members in a structure
235 * i : index of the member
237 * LttType * : the type of structure member
238 ****************************************************************************/
240 LttType
*ltt_type_member_type(LttType
*t
, unsigned i
, char ** name
)
242 if(t
->type_class
!= LTT_STRUCT
){*name
== NULL
; return NULL
;}
243 if(i
>= t
->element_number
|| i
< 0 ){*name
= NULL
; return NULL
;}
244 *name
= t
->element_type
[i
]->element_name
;
245 return t
->element_type
[i
];
248 /*****************************************************************************
250 * ltt_enum_string_get : for enumerations, obtain the symbolic string
251 * associated with a value (0 to n - 1 for an
252 * enumeration of n elements)
255 * i : index of the member
257 * char * : symbolic string associated with a value
258 ****************************************************************************/
260 char *ltt_enum_string_get(LttType
*t
, unsigned i
)
262 if(t
->type_class
!= LTT_ENUM
) return NULL
;
263 if(i
>= t
->element_number
|| i
< 0 ) return NULL
;
264 return t
->enum_strings
[i
];
267 /*****************************************************************************
269 * ltt_field_element : obtain the field of nested elements for arrays and
274 * LttField * : the field of the nested element
275 ****************************************************************************/
277 LttField
*ltt_field_element(LttField
*f
)
279 if(f
->field_type
->type_class
!= LTT_ARRAY
&&
280 f
->field_type
->type_class
!= LTT_SEQUENCE
)
286 /*****************************************************************************
288 * ltt_field_member : obtain the filed of data members for structure
291 * i : index of member field
293 * LttField * : the field of the nested element
294 ****************************************************************************/
296 LttField
*ltt_field_member(LttField
*f
, unsigned i
)
298 if(f
->field_type
->type_class
!= LTT_STRUCT
) return NULL
;
299 if(i
< 0 || i
>= f
->field_type
->element_number
) return NULL
;
303 /*****************************************************************************
305 * ltt_field_type : obtain the type of the field
309 * ltt_tyoe * : the type of field
310 ****************************************************************************/
312 LttType
*ltt_field_type(LttField
*f
)
314 return f
->field_type
;
This page took 0.037014 seconds and 4 git commands to generate.