xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-host_endian.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_is_bigendian, tep_is_local_bigendian, tep_set_local_bigendian - Get / set
7*436bf2bcSAndroid Build Coastguard Workerthe endianness of the local machine.
8*436bf2bcSAndroid Build Coastguard Worker
9*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS
10*436bf2bcSAndroid Build Coastguard Worker--------
11*436bf2bcSAndroid Build Coastguard Worker[verse]
12*436bf2bcSAndroid Build Coastguard Worker--
13*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>*
14*436bf2bcSAndroid Build Coastguard Worker
15*436bf2bcSAndroid Build Coastguard Workerenum *tep_endian* {
16*436bf2bcSAndroid Build Coastguard Worker	TEP_LITTLE_ENDIAN = 0,
17*436bf2bcSAndroid Build Coastguard Worker	TEP_BIG_ENDIAN
18*436bf2bcSAndroid Build Coastguard Worker};
19*436bf2bcSAndroid Build Coastguard Worker
20*436bf2bcSAndroid Build Coastguard Workerint *tep_is_bigendian*(void);
21*436bf2bcSAndroid Build Coastguard Workerbool *tep_is_local_bigendian*(struct tep_handle pass:[*]_tep_);
22*436bf2bcSAndroid Build Coastguard Workervoid *tep_set_local_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_);
23*436bf2bcSAndroid Build Coastguard Worker--
24*436bf2bcSAndroid Build Coastguard Worker
25*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION
26*436bf2bcSAndroid Build Coastguard Worker-----------
27*436bf2bcSAndroid Build Coastguard Worker
28*436bf2bcSAndroid Build Coastguard WorkerThe *tep_is_bigendian()* gets the endianness of the machine, executing
29*436bf2bcSAndroid Build Coastguard Workerthe function.
30*436bf2bcSAndroid Build Coastguard Worker
31*436bf2bcSAndroid Build Coastguard WorkerThe *tep_is_local_bigendian()* function gets the endianness of the local
32*436bf2bcSAndroid Build Coastguard Workermachine, saved in the _tep_ handler. The _tep_ argument is the trace event
33*436bf2bcSAndroid Build Coastguard Workerparser context. This API is a bit faster than *tep_is_bigendian()*, as it
34*436bf2bcSAndroid Build Coastguard Workerreturns cached endianness of the local machine instead of checking it each time.
35*436bf2bcSAndroid Build Coastguard Worker
36*436bf2bcSAndroid Build Coastguard WorkerThe *tep_set_local_bigendian()* function sets the endianness of the local
37*436bf2bcSAndroid Build Coastguard Workermachine in the _tep_ handler. The _tep_ argument is trace event parser context.
38*436bf2bcSAndroid Build Coastguard WorkerThe _endian_ argument is the endianness:
39*436bf2bcSAndroid Build Coastguard Worker[verse]
40*436bf2bcSAndroid Build Coastguard Worker--
41*436bf2bcSAndroid Build Coastguard Worker	_TEP_LITTLE_ENDIAN_ - the machine is little endian,
42*436bf2bcSAndroid Build Coastguard Worker	_TEP_BIG_ENDIAN_ - the machine is big endian.
43*436bf2bcSAndroid Build Coastguard Worker--
44*436bf2bcSAndroid Build Coastguard Worker
45*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE
46*436bf2bcSAndroid Build Coastguard Worker------------
47*436bf2bcSAndroid Build Coastguard WorkerThe *tep_is_bigendian()* function returns non zero if the endianness of the
48*436bf2bcSAndroid Build Coastguard Workermachine, executing the code, is big endian and zero otherwise.
49*436bf2bcSAndroid Build Coastguard Worker
50*436bf2bcSAndroid Build Coastguard WorkerThe *tep_is_local_bigendian()* function returns true, if the endianness of the
51*436bf2bcSAndroid Build Coastguard Workerlocal machine, saved in the _tep_ handler, is big endian, or false otherwise.
52*436bf2bcSAndroid Build Coastguard Worker
53*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE
54*436bf2bcSAndroid Build Coastguard Worker-------
55*436bf2bcSAndroid Build Coastguard Worker[source,c]
56*436bf2bcSAndroid Build Coastguard Worker--
57*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h>
58*436bf2bcSAndroid Build Coastguard Worker...
59*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc();
60*436bf2bcSAndroid Build Coastguard Worker...
61*436bf2bcSAndroid Build Coastguard Worker	if (tep_is_bigendian())
62*436bf2bcSAndroid Build Coastguard Worker		tep_set_local_bigendian(tep, TEP_BIG_ENDIAN);
63*436bf2bcSAndroid Build Coastguard Worker	else
64*436bf2bcSAndroid Build Coastguard Worker		tep_set_local_bigendian(tep, TEP_LITTLE_ENDIAN);
65*436bf2bcSAndroid Build Coastguard Worker...
66*436bf2bcSAndroid Build Coastguard Worker	if (tep_is_local_bigendian(tep))
67*436bf2bcSAndroid Build Coastguard Worker		printf("This machine you are running on is bigendian\n");
68*436bf2bcSAndroid Build Coastguard Worker	else
69*436bf2bcSAndroid Build Coastguard Worker		printf("This machine you are running on is little endian\n");
70*436bf2bcSAndroid Build Coastguard Worker
71*436bf2bcSAndroid Build Coastguard Worker--
72*436bf2bcSAndroid Build Coastguard Worker
73*436bf2bcSAndroid Build Coastguard WorkerFILES
74*436bf2bcSAndroid Build Coastguard Worker-----
75*436bf2bcSAndroid Build Coastguard Worker[verse]
76*436bf2bcSAndroid Build Coastguard Worker--
77*436bf2bcSAndroid Build Coastguard Worker*event-parse.h*
78*436bf2bcSAndroid Build Coastguard Worker	Header file to include in order to have access to the library APIs.
79*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent*
80*436bf2bcSAndroid Build Coastguard Worker	Linker switch to add when building a program that uses the library.
81*436bf2bcSAndroid Build Coastguard Worker--
82*436bf2bcSAndroid Build Coastguard Worker
83*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO
84*436bf2bcSAndroid Build Coastguard Worker--------
85*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1)
86*436bf2bcSAndroid Build Coastguard Worker
87*436bf2bcSAndroid Build Coastguard WorkerAUTHOR
88*436bf2bcSAndroid Build Coastguard Worker------
89*436bf2bcSAndroid Build Coastguard Worker[verse]
90*436bf2bcSAndroid Build Coastguard Worker--
91*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
92*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
93*436bf2bcSAndroid Build Coastguard Worker--
94*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS
95*436bf2bcSAndroid Build Coastguard Worker--------------
96*436bf2bcSAndroid Build Coastguard WorkerReport bugs to  <[email protected]>
97*436bf2bcSAndroid Build Coastguard Worker
98*436bf2bcSAndroid Build Coastguard WorkerLICENSE
99*436bf2bcSAndroid Build Coastguard Worker-------
100*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1
101*436bf2bcSAndroid Build Coastguard Worker
102*436bf2bcSAndroid Build Coastguard WorkerRESOURCES
103*436bf2bcSAndroid Build Coastguard Worker---------
104*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
105