xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent-host_endian.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyuntep_is_bigendian, tep_is_local_bigendian, tep_set_local_bigendian - Get / set
7*4882a593Smuzhiyunthe endianness of the local machine.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunSYNOPSIS
10*4882a593Smuzhiyun--------
11*4882a593Smuzhiyun[verse]
12*4882a593Smuzhiyun--
13*4882a593Smuzhiyun*#include <event-parse.h>*
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunenum *tep_endian* {
16*4882a593Smuzhiyun	TEP_LITTLE_ENDIAN = 0,
17*4882a593Smuzhiyun	TEP_BIG_ENDIAN
18*4882a593Smuzhiyun};
19*4882a593Smuzhiyun
20*4882a593Smuzhiyunint *tep_is_bigendian*(void);
21*4882a593Smuzhiyunbool *tep_is_local_bigendian*(struct tep_handle pass:[*]_tep_);
22*4882a593Smuzhiyunvoid *tep_set_local_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_);
23*4882a593Smuzhiyun--
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunDESCRIPTION
26*4882a593Smuzhiyun-----------
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunThe _tep_is_bigendian()_ gets the endianness of the machine, executing
29*4882a593Smuzhiyunthe function.
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunThe _tep_is_local_bigendian()_ function gets the endianness of the local
32*4882a593Smuzhiyunmachine, saved in the _tep_ handler. The _tep_ argument is the trace event
33*4882a593Smuzhiyunparser context. This API is a bit faster than _tep_is_bigendian()_, as it
34*4882a593Smuzhiyunreturns cached endianness of the local machine instead of checking it each time.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunThe _tep_set_local_bigendian()_ function sets the endianness of the local
37*4882a593Smuzhiyunmachine in the _tep_ handler. The _tep_ argument is trace event parser context.
38*4882a593SmuzhiyunThe _endian_ argument is the endianness:
39*4882a593Smuzhiyun[verse]
40*4882a593Smuzhiyun--
41*4882a593Smuzhiyun	_TEP_LITTLE_ENDIAN_ - the machine is little endian,
42*4882a593Smuzhiyun	_TEP_BIG_ENDIAN_ - the machine is big endian.
43*4882a593Smuzhiyun--
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunRETURN VALUE
46*4882a593Smuzhiyun------------
47*4882a593SmuzhiyunThe _tep_is_bigendian()_ function returns non zero if the endianness of the
48*4882a593Smuzhiyunmachine, executing the code, is big endian and zero otherwise.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunThe _tep_is_local_bigendian()_ function returns true, if the endianness of the
51*4882a593Smuzhiyunlocal machine, saved in the _tep_ handler, is big endian, or false otherwise.
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunEXAMPLE
54*4882a593Smuzhiyun-------
55*4882a593Smuzhiyun[source,c]
56*4882a593Smuzhiyun--
57*4882a593Smuzhiyun#include <event-parse.h>
58*4882a593Smuzhiyun...
59*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc();
60*4882a593Smuzhiyun...
61*4882a593Smuzhiyun	if (tep_is_bigendian())
62*4882a593Smuzhiyun		tep_set_local_bigendian(tep, TEP_BIG_ENDIAN);
63*4882a593Smuzhiyun	else
64*4882a593Smuzhiyun		tep_set_local_bigendian(tep, TEP_LITTLE_ENDIAN);
65*4882a593Smuzhiyun...
66*4882a593Smuzhiyun	if (tep_is_local_bigendian(tep))
67*4882a593Smuzhiyun		printf("This machine you are running on is bigendian\n");
68*4882a593Smuzhiyun	else
69*4882a593Smuzhiyun		printf("This machine you are running on is little endian\n");
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun--
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunFILES
74*4882a593Smuzhiyun-----
75*4882a593Smuzhiyun[verse]
76*4882a593Smuzhiyun--
77*4882a593Smuzhiyun*event-parse.h*
78*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
79*4882a593Smuzhiyun*-ltraceevent*
80*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
81*4882a593Smuzhiyun--
82*4882a593Smuzhiyun
83*4882a593SmuzhiyunSEE ALSO
84*4882a593Smuzhiyun--------
85*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_
86*4882a593Smuzhiyun
87*4882a593SmuzhiyunAUTHOR
88*4882a593Smuzhiyun------
89*4882a593Smuzhiyun[verse]
90*4882a593Smuzhiyun--
91*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
92*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
93*4882a593Smuzhiyun--
94*4882a593SmuzhiyunREPORTING BUGS
95*4882a593Smuzhiyun--------------
96*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
97*4882a593Smuzhiyun
98*4882a593SmuzhiyunLICENSE
99*4882a593Smuzhiyun-------
100*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
101*4882a593Smuzhiyun
102*4882a593SmuzhiyunRESOURCES
103*4882a593Smuzhiyun---------
104*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
105