5 #include "ltt-private.h"
8 static unsigned intSizes
[] = {
9 sizeof(int8_t), sizeof(int16_t), sizeof(int32_t), sizeof(int64_t),
12 static unsigned floatSizes
[] = {
13 0, 0, sizeof(float), sizeof(double), 0, sizeof(float), sizeof(double) };
16 /*****************************************************************************
18 * ltt_eventtype_name : get the name of the event type
22 * char * : the name of the event type
23 ****************************************************************************/
25 char *ltt_eventtype_name(LttEventType
*et
)
30 /*****************************************************************************
32 * ltt_eventtype_description : get the description of the event type
36 * char * : the description of the event type
37 ****************************************************************************/
39 char *ltt_eventtype_description(LttEventType
*et
)
41 return et
->description
;
44 /*****************************************************************************
46 * ltt_eventtype_facility : get the facility which contains the event type
50 * LttFacility * : the facility
51 ****************************************************************************/
53 LttFacility
*ltt_eventtype_facility(LttEventType
*et
)
58 /*****************************************************************************
60 * ltt_eventtype_relative_id : get the relative id of the event type
64 * unsigned : the relative id
65 ****************************************************************************/
67 unsigned ltt_eventtype_relative_id(LttEventType
*et
)
72 /*****************************************************************************
74 * ltt_eventtype_id : get the id of the event type
79 ****************************************************************************/
81 unsigned ltt_eventtype_id(LttEventType
*et
)
83 return et
->facility
->base_id
+ et
->index
;
86 /*****************************************************************************
88 * ltt_eventtype_type : get the type of the event type
92 * LttType * : the type of the event type
93 ****************************************************************************/
95 LttType
*ltt_eventtype_type(LttEventType
*et
)
97 if(!et
->root_field
) return NULL
;
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
;
167 if(size
== LTT_LP32
){
168 if(t
->size
== 5)return sizeof(int16_t);
169 else return sizeof(int32_t);
171 else if(size
== LTT_ILP32
|| size
== LTT_LP64
){
172 if(t
->size
== 5)return sizeof(int32_t);
174 if(size
== LTT_ILP32
) return sizeof(int32_t);
175 else return sizeof(int64_t);
178 else if(size
== LTT_ILP64
)return sizeof(int64_t);
183 /*****************************************************************************
185 * ltt_type_element_type : obtain the type of nested elements for arrays
190 * LttType : the type of nested element of array or sequence
191 ****************************************************************************/
193 LttType
*ltt_type_element_type(LttType
*t
)
195 if(t
->type_class
!= LTT_ARRAY
&& t
->type_class
!= LTT_SEQUENCE
)
197 return t
->element_type
[0];
200 /*****************************************************************************
202 * ltt_type_element_number : obtain the number of elements for arrays
206 * unsigned : the number of elements for arrays
207 ****************************************************************************/
209 unsigned ltt_type_element_number(LttType
*t
)
211 if(t
->type_class
!= LTT_ARRAY
)
213 return t
->element_number
;
216 /*****************************************************************************
218 * ltt_type_member_number : obtain the number of data members for structure
222 * unsigned : the number of members for structure
223 ****************************************************************************/
225 unsigned ltt_type_member_number(LttType
*t
)
227 if(t
->type_class
!= LTT_STRUCT
&& t
->type_class
!= LTT_UNION
)
229 return t
->element_number
;
232 /*****************************************************************************
234 * ltt_type_member_type : obtain the type of a data members in a structure
237 * i : index of the member
239 * LttType * : the type of structure member
240 ****************************************************************************/
242 LttType
*ltt_type_member_type(LttType
*t
, unsigned i
, char ** name
)
244 if(t
->type_class
!= LTT_STRUCT
){*name
== NULL
; return NULL
;}
245 if(i
>= t
->element_number
|| i
< 0 ){*name
= NULL
; return NULL
;}
246 *name
= t
->element_type
[i
]->element_name
;
247 return t
->element_type
[i
];
250 /*****************************************************************************
252 * ltt_enum_string_get : for enumerations, obtain the symbolic string
253 * associated with a value (0 to n - 1 for an
254 * enumeration of n elements)
257 * i : index of the member
259 * char * : symbolic string associated with a value
260 ****************************************************************************/
262 char *ltt_enum_string_get(LttType
*t
, unsigned i
)
264 if(t
->type_class
!= LTT_ENUM
) return NULL
;
265 if(i
>= t
->element_number
|| i
< 0 ) return NULL
;
266 return t
->enum_strings
[i
];
269 /*****************************************************************************
271 * ltt_field_element : obtain the field of nested elements for arrays and
276 * LttField * : the field of the nested element
277 ****************************************************************************/
279 LttField
*ltt_field_element(LttField
*f
)
281 if(f
->field_type
->type_class
!= LTT_ARRAY
&&
282 f
->field_type
->type_class
!= LTT_SEQUENCE
)
288 /*****************************************************************************
290 * ltt_field_member : obtain the filed of data members for structure
293 * i : index of member field
295 * LttField * : the field of the nested element
296 ****************************************************************************/
298 LttField
*ltt_field_member(LttField
*f
, unsigned i
)
300 if(f
->field_type
->type_class
!= LTT_STRUCT
) return NULL
;
301 if(i
< 0 || i
>= f
->field_type
->element_number
) return NULL
;
305 /*****************************************************************************
307 * ltt_field_type : obtain the type of the field
311 * ltt_tyoe * : the type of field
312 ****************************************************************************/
314 LttType
*ltt_field_type(LttField
*f
)
317 return f
->field_type
;
320 int ltt_field_size(LttField
* f
)
323 return f
->field_size
;
This page took 0.03696 seconds and 4 git commands to generate.