LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) β the libtraceevent manual, bestie edition π
okay so welcome to the libtraceevent manual page, we're talking endianness today and honestly? it's giving foundational. stay with me. π¦
β¨ NAME β¨
tep_is_bigendian, tep_is_local_bigendian, tep_set_local_bigendian β get / set the endianness of the local machine. that's it, that's the whole job, and they do it flawlessly. π
πΈ SYNOPSIS πΈ
#include <event-parse.h>
enum tep_endian {
TEP_LITTLE_ENDIAN = 0,
TEP_BIG_ENDIAN
};
int tep_is_bigendian(void);
bool tep_is_local_bigendian(struct tep_handle *tep);
void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian);
look at that enum. TEP_LITTLE_ENDIAN = 0 and then TEP_BIG_ENDIAN just vibing right after it. so clean. π
π DESCRIPTION π
so tep_is_bigendian() gets the endianness of the machine that's executing the function. like, the actual machine, right now, no cache, no filter. it just checks. π
then tep_is_local_bigendian() gets the endianness of the local machine, but here's the tea: it's saved in the tep handler. the tep argument is the trace event parser context. and this API is a bit faster than tep_is_bigendian(), because it returns the cached endianness of the local machine instead of checking it every single time. obsessed with an efficient queen. β¨
and tep_set_local_bigendian() sets the endianness of the local machine in the tep handler. the tep argument is the trace event parser context. the endian argument is the endianness, and it has exactly two options, no in-between:
TEP_LITTLE_ENDIANβ the machine is little endian,TEP_BIG_ENDIANβ the machine is big endian.
periodt. π
π RETURN VALUE π
tep_is_bigendian() returns non zero if the endianness of the machine executing the code is big endian, and zero otherwise. non zero = big endian baddie, zero = nope. π
tep_is_local_bigendian() returns true if the endianness of the local machine, saved in the tep handler, is big endian, or false otherwise. so like, a whole bool. earn your true, bestie. π
β EXAMPLE β
here's the moment you've all been waiting for, actual code, no cap:
#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
if (tep_is_bigendian())
tep_set_local_bigendian(tep, TEP_BIG_ENDIAN);
else
tep_set_local_bigendian(tep, TEP_LITTLE_ENDIAN);
...
if (tep_is_local_bigendian(tep))
printf("This machine you are running on is bigendian\n");
else
printf("This machine you are running on is little endian\n");
the way this just *works*β¦ main character code fr fr. π«Ά
π§ FILES π§
event-parse.hβ header file to include in order to have access to the library APIs.-ltraceeventβ linker switch to add when building a program that uses the library.
don't forget the include OR the linker flag, i'm literally begging you. π
π₯ SEE ALSO π₯
go read those next, iykyk. π
π AUTHOR π
- Steven Rostedt
<rostedt@goodmis.org[1]>, author of libtraceevent. - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>, author of this man page.
legends, both of them. π
π REPORTING BUGS π
Report bugs to <linux-trace-devel@vger.kernel.org[3]>
found something sus? tell them, not me. π
πΈ LICENSE πΈ
libtraceevent is Free Software licensed under the GNU LGPL 2.1
π¦ RESOURCES π¦
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
π NOTES π
rostedt@goodmis.orgβmailto:rostedt@goodmis.orgtz.stoyanov@gmail.comβmailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgβmailto:linux-trace-devel@vger.kernel.org
that's a wrap on endianness, bestie. this was libtraceevent 1.9.0, dated 06/15/2026, and honestly? iconic. slay, stay little endian (or big, we don't judge), and go read your trace events. π
β¨π
π¦ where this page comes from
- ubuntu stonking: libtraceevent-doc 1:1.9.0-2 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms