1 // SPDX-License-Identifier: LGPL-2.1
7 #include "event-parse.h"
8 #include "event-parse-local.h"
9 #include "event-utils.h"
12 * tep_get_first_event - returns the first event in the events array
13 * @tep: a handle to the tep_handle
15 * This returns pointer to the first element of the events array
16 * If @tep is NULL, NULL is returned.
18 struct tep_event *tep_get_first_event(struct tep_handle *tep)
20 if (tep && tep->events)
21 return tep->events[0];
27 * tep_get_events_count - get the number of defined events
28 * @tep: a handle to the tep_handle
30 * This returns number of elements in event array
31 * If @tep is NULL, 0 is returned.
33 int tep_get_events_count(struct tep_handle *tep)
36 return tep->nr_events;
41 * tep_set_flag - set event parser flag
42 * @tep: a handle to the tep_handle
43 * @flag: flag, or combination of flags to be set
44 * can be any combination from enum tep_flag
46 * This sets a flag or mbination of flags from enum tep_flag
48 void tep_set_flag(struct tep_handle *tep, int flag)
54 unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data)
58 if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
61 swap = ((data & 0xffULL) << 8) |
62 ((data & (0xffULL << 8)) >> 8);
67 unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data)
71 if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
74 swap = ((data & 0xffULL) << 24) |
75 ((data & (0xffULL << 8)) << 8) |
76 ((data & (0xffULL << 16)) >> 8) |
77 ((data & (0xffULL << 24)) >> 24);
83 tep_data2host8(struct tep_handle *pevent, unsigned long long data)
85 unsigned long long swap;
87 if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
90 swap = ((data & 0xffULL) << 56) |
91 ((data & (0xffULL << 8)) << 40) |
92 ((data & (0xffULL << 16)) << 24) |
93 ((data & (0xffULL << 24)) << 8) |
94 ((data & (0xffULL << 32)) >> 8) |
95 ((data & (0xffULL << 40)) >> 24) |
96 ((data & (0xffULL << 48)) >> 40) |
97 ((data & (0xffULL << 56)) >> 56);
103 * tep_get_header_page_size - get size of the header page
104 * @pevent: a handle to the tep_handle
106 * This returns size of the header page
107 * If @pevent is NULL, 0 is returned.
109 int tep_get_header_page_size(struct tep_handle *pevent)
112 return pevent->header_page_size_size;
117 * tep_get_cpus - get the number of CPUs
118 * @pevent: a handle to the tep_handle
120 * This returns the number of CPUs
121 * If @pevent is NULL, 0 is returned.
123 int tep_get_cpus(struct tep_handle *pevent)
131 * tep_set_cpus - set the number of CPUs
132 * @pevent: a handle to the tep_handle
134 * This sets the number of CPUs
136 void tep_set_cpus(struct tep_handle *pevent, int cpus)
143 * tep_get_long_size - get the size of a long integer on the current machine
144 * @pevent: a handle to the tep_handle
146 * This returns the size of a long integer on the current machine
147 * If @pevent is NULL, 0 is returned.
149 int tep_get_long_size(struct tep_handle *pevent)
152 return pevent->long_size;
157 * tep_set_long_size - set the size of a long integer on the current machine
158 * @pevent: a handle to the tep_handle
159 * @size: size, in bytes, of a long integer
161 * This sets the size of a long integer on the current machine
163 void tep_set_long_size(struct tep_handle *pevent, int long_size)
166 pevent->long_size = long_size;
170 * tep_get_page_size - get the size of a memory page on the current machine
171 * @pevent: a handle to the tep_handle
173 * This returns the size of a memory page on the current machine
174 * If @pevent is NULL, 0 is returned.
176 int tep_get_page_size(struct tep_handle *pevent)
179 return pevent->page_size;
184 * tep_set_page_size - set the size of a memory page on the current machine
185 * @pevent: a handle to the tep_handle
186 * @_page_size: size of a memory page, in bytes
188 * This sets the size of a memory page on the current machine
190 void tep_set_page_size(struct tep_handle *pevent, int _page_size)
193 pevent->page_size = _page_size;
197 * tep_is_file_bigendian - get if the file is in big endian order
198 * @pevent: a handle to the tep_handle
200 * This returns if the file is in big endian order
201 * If @pevent is NULL, 0 is returned.
203 int tep_is_file_bigendian(struct tep_handle *pevent)
206 return pevent->file_bigendian;
211 * tep_set_file_bigendian - set if the file is in big endian order
212 * @pevent: a handle to the tep_handle
213 * @endian: non zero, if the file is in big endian order
215 * This sets if the file is in big endian order
217 void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian)
220 pevent->file_bigendian = endian;
224 * tep_is_host_bigendian - get if the order of the current host is big endian
225 * @pevent: a handle to the tep_handle
227 * This gets if the order of the current host is big endian
228 * If @pevent is NULL, 0 is returned.
230 int tep_is_host_bigendian(struct tep_handle *pevent)
233 return pevent->host_bigendian;
238 * tep_set_host_bigendian - set the order of the local host
239 * @pevent: a handle to the tep_handle
240 * @endian: non zero, if the local host has big endian order
242 * This sets the order of the local host
244 void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian)
247 pevent->host_bigendian = endian;
251 * tep_is_latency_format - get if the latency output format is configured
252 * @pevent: a handle to the tep_handle
254 * This gets if the latency output format is configured
255 * If @pevent is NULL, 0 is returned.
257 int tep_is_latency_format(struct tep_handle *pevent)
260 return pevent->latency_format;
265 * tep_set_latency_format - set the latency output format
266 * @pevent: a handle to the tep_handle
267 * @lat: non zero for latency output format
269 * This sets the latency output format
271 void tep_set_latency_format(struct tep_handle *pevent, int lat)
274 pevent->latency_format = lat;