This source file includes following definitions.
- tep_get_event
- tep_get_first_event
- tep_get_events_count
- tep_set_flag
- tep_clear_flag
- tep_test_flag
- tep_data2host2
- tep_data2host4
- tep_data2host8
- tep_get_header_page_size
- tep_get_header_timestamp_size
- tep_get_cpus
- tep_set_cpus
- tep_get_long_size
- tep_set_long_size
- tep_get_page_size
- tep_set_page_size
- tep_is_file_bigendian
- tep_set_file_bigendian
- tep_is_local_bigendian
- tep_set_local_bigendian
- tep_is_old_format
- tep_set_test_filters
1
2
3
4
5
6
7 #include "event-parse.h"
8 #include "event-parse-local.h"
9 #include "event-utils.h"
10
11
12
13
14
15
16
17
18
19 struct tep_event *tep_get_event(struct tep_handle *tep, int index)
20 {
21 if (tep && tep->events && index < tep->nr_events)
22 return tep->events[index];
23
24 return NULL;
25 }
26
27
28
29
30
31
32
33
34 struct tep_event *tep_get_first_event(struct tep_handle *tep)
35 {
36 return tep_get_event(tep, 0);
37 }
38
39
40
41
42
43
44
45
46 int tep_get_events_count(struct tep_handle *tep)
47 {
48 if (tep)
49 return tep->nr_events;
50 return 0;
51 }
52
53
54
55
56
57
58
59
60
61 void tep_set_flag(struct tep_handle *tep, int flag)
62 {
63 if (tep)
64 tep->flags |= flag;
65 }
66
67
68
69
70
71
72
73
74 void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag)
75 {
76 if (tep)
77 tep->flags &= ~flag;
78 }
79
80
81
82
83
84
85
86
87
88 bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)
89 {
90 if (tep)
91 return tep->flags & flag;
92 return false;
93 }
94
95 unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data)
96 {
97 unsigned short swap;
98
99 if (!tep || tep->host_bigendian == tep->file_bigendian)
100 return data;
101
102 swap = ((data & 0xffULL) << 8) |
103 ((data & (0xffULL << 8)) >> 8);
104
105 return swap;
106 }
107
108 unsigned int tep_data2host4(struct tep_handle *tep, unsigned int data)
109 {
110 unsigned int swap;
111
112 if (!tep || tep->host_bigendian == tep->file_bigendian)
113 return data;
114
115 swap = ((data & 0xffULL) << 24) |
116 ((data & (0xffULL << 8)) << 8) |
117 ((data & (0xffULL << 16)) >> 8) |
118 ((data & (0xffULL << 24)) >> 24);
119
120 return swap;
121 }
122
123 unsigned long long
124 tep_data2host8(struct tep_handle *tep, unsigned long long data)
125 {
126 unsigned long long swap;
127
128 if (!tep || tep->host_bigendian == tep->file_bigendian)
129 return data;
130
131 swap = ((data & 0xffULL) << 56) |
132 ((data & (0xffULL << 8)) << 40) |
133 ((data & (0xffULL << 16)) << 24) |
134 ((data & (0xffULL << 24)) << 8) |
135 ((data & (0xffULL << 32)) >> 8) |
136 ((data & (0xffULL << 40)) >> 24) |
137 ((data & (0xffULL << 48)) >> 40) |
138 ((data & (0xffULL << 56)) >> 56);
139
140 return swap;
141 }
142
143
144
145
146
147
148
149
150 int tep_get_header_page_size(struct tep_handle *tep)
151 {
152 if (tep)
153 return tep->header_page_size_size;
154 return 0;
155 }
156
157
158
159
160
161
162
163
164 int tep_get_header_timestamp_size(struct tep_handle *tep)
165 {
166 if (tep)
167 return tep->header_page_ts_size;
168 return 0;
169 }
170
171
172
173
174
175
176
177
178 int tep_get_cpus(struct tep_handle *tep)
179 {
180 if (tep)
181 return tep->cpus;
182 return 0;
183 }
184
185
186
187
188
189
190
191 void tep_set_cpus(struct tep_handle *tep, int cpus)
192 {
193 if (tep)
194 tep->cpus = cpus;
195 }
196
197
198
199
200
201
202
203
204 int tep_get_long_size(struct tep_handle *tep)
205 {
206 if (tep)
207 return tep->long_size;
208 return 0;
209 }
210
211
212
213
214
215
216
217
218 void tep_set_long_size(struct tep_handle *tep, int long_size)
219 {
220 if (tep)
221 tep->long_size = long_size;
222 }
223
224
225
226
227
228
229
230
231 int tep_get_page_size(struct tep_handle *tep)
232 {
233 if (tep)
234 return tep->page_size;
235 return 0;
236 }
237
238
239
240
241
242
243
244
245 void tep_set_page_size(struct tep_handle *tep, int _page_size)
246 {
247 if (tep)
248 tep->page_size = _page_size;
249 }
250
251
252
253
254
255
256
257
258 bool tep_is_file_bigendian(struct tep_handle *tep)
259 {
260 if (tep)
261 return (tep->file_bigendian == TEP_BIG_ENDIAN);
262 return false;
263 }
264
265
266
267
268
269
270
271
272 void tep_set_file_bigendian(struct tep_handle *tep, enum tep_endian endian)
273 {
274 if (tep)
275 tep->file_bigendian = endian;
276 }
277
278
279
280
281
282
283
284
285 bool tep_is_local_bigendian(struct tep_handle *tep)
286 {
287 if (tep)
288 return (tep->host_bigendian == TEP_BIG_ENDIAN);
289 return 0;
290 }
291
292
293
294
295
296
297
298
299 void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian)
300 {
301 if (tep)
302 tep->host_bigendian = endian;
303 }
304
305
306
307
308
309
310
311
312
313 bool tep_is_old_format(struct tep_handle *tep)
314 {
315 if (tep)
316 return tep->old_format;
317 return false;
318 }
319
320
321
322
323
324
325
326
327
328
329 void tep_set_test_filters(struct tep_handle *tep, int test_filters)
330 {
331 if (tep)
332 tep->test_filters = test_filters;
333 }