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 πŸ“

  1. rostedt@goodmis.org β€” mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com β€” mailto:tz.stoyanov@gmail.com
  3. linux-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