xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-endian_read.txt (revision 436bf2bcd5202612ffffe471bbcc1f277cc8d28e)
1*436bf2bcSAndroid Build Coastguard Workerlibtraceevent(3)
2*436bf2bcSAndroid Build Coastguard Worker================
3*436bf2bcSAndroid Build Coastguard Worker
4*436bf2bcSAndroid Build Coastguard WorkerNAME
5*436bf2bcSAndroid Build Coastguard Worker----
6*436bf2bcSAndroid Build Coastguard Workertep_read_number - Reads a number from raw data.
7*436bf2bcSAndroid Build Coastguard Worker
8*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS
9*436bf2bcSAndroid Build Coastguard Worker--------
10*436bf2bcSAndroid Build Coastguard Worker[verse]
11*436bf2bcSAndroid Build Coastguard Worker--
12*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>*
13*436bf2bcSAndroid Build Coastguard Worker
14*436bf2bcSAndroid Build Coastguard Workerunsigned long long *tep_read_number*(struct tep_handle pass:[*]_tep_, const void pass:[*]_ptr_, int _size_);
15*436bf2bcSAndroid Build Coastguard Worker--
16*436bf2bcSAndroid Build Coastguard Worker
17*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION
18*436bf2bcSAndroid Build Coastguard Worker-----------
19*436bf2bcSAndroid Build Coastguard WorkerThe *tep_read_number()* function reads an integer from raw data, taking into
20*436bf2bcSAndroid Build Coastguard Workeraccount the endianness of the raw data and the current host. The _tep_ argument
21*436bf2bcSAndroid Build Coastguard Workeris the trace event parser context. The _ptr_ is a pointer to the raw data, where
22*436bf2bcSAndroid Build Coastguard Workerthe integer is, and the _size_ is the size of the integer.
23*436bf2bcSAndroid Build Coastguard Worker
24*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE
25*436bf2bcSAndroid Build Coastguard Worker------------
26*436bf2bcSAndroid Build Coastguard WorkerThe *tep_read_number()* function returns the integer in the byte order of
27*436bf2bcSAndroid Build Coastguard Workerthe current host. In case of an error, 0 is returned.
28*436bf2bcSAndroid Build Coastguard Worker
29*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE
30*436bf2bcSAndroid Build Coastguard Worker-------
31*436bf2bcSAndroid Build Coastguard Worker[source,c]
32*436bf2bcSAndroid Build Coastguard Worker--
33*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h>
34*436bf2bcSAndroid Build Coastguard Worker...
35*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc();
36*436bf2bcSAndroid Build Coastguard Worker...
37*436bf2bcSAndroid Build Coastguard Workervoid process_record(struct tep_record *record)
38*436bf2bcSAndroid Build Coastguard Worker{
39*436bf2bcSAndroid Build Coastguard Worker	int offset = 24;
40*436bf2bcSAndroid Build Coastguard Worker	int data = tep_read_number(tep, record->data + offset, 4);
41*436bf2bcSAndroid Build Coastguard Worker
42*436bf2bcSAndroid Build Coastguard Worker	/* Read the 4 bytes at the offset 24 of data as an integer */
43*436bf2bcSAndroid Build Coastguard Worker}
44*436bf2bcSAndroid Build Coastguard Worker...
45*436bf2bcSAndroid Build Coastguard Worker--
46*436bf2bcSAndroid Build Coastguard Worker
47*436bf2bcSAndroid Build Coastguard WorkerFILES
48*436bf2bcSAndroid Build Coastguard Worker-----
49*436bf2bcSAndroid Build Coastguard Worker[verse]
50*436bf2bcSAndroid Build Coastguard Worker--
51*436bf2bcSAndroid Build Coastguard Worker*event-parse.h*
52*436bf2bcSAndroid Build Coastguard Worker	Header file to include in order to have access to the library APIs.
53*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent*
54*436bf2bcSAndroid Build Coastguard Worker	Linker switch to add when building a program that uses the library.
55*436bf2bcSAndroid Build Coastguard Worker--
56*436bf2bcSAndroid Build Coastguard Worker
57*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO
58*436bf2bcSAndroid Build Coastguard Worker--------
59*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1)
60*436bf2bcSAndroid Build Coastguard Worker
61*436bf2bcSAndroid Build Coastguard WorkerAUTHOR
62*436bf2bcSAndroid Build Coastguard Worker------
63*436bf2bcSAndroid Build Coastguard Worker[verse]
64*436bf2bcSAndroid Build Coastguard Worker--
65*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
66*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
67*436bf2bcSAndroid Build Coastguard Worker--
68*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS
69*436bf2bcSAndroid Build Coastguard Worker--------------
70*436bf2bcSAndroid Build Coastguard WorkerReport bugs to  <[email protected]>
71*436bf2bcSAndroid Build Coastguard Worker
72*436bf2bcSAndroid Build Coastguard WorkerLICENSE
73*436bf2bcSAndroid Build Coastguard Worker-------
74*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1
75*436bf2bcSAndroid Build Coastguard Worker
76*436bf2bcSAndroid Build Coastguard WorkerRESOURCES
77*436bf2bcSAndroid Build Coastguard Worker---------
78*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
79