tools lib traceevent: Add traceevent_host_bigendian function
authorJiri Olsa <[email protected]>
Tue, 3 Dec 2013 13:09:18 +0000 (14:09 +0100)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 4 Dec 2013 18:17:58 +0000 (15:17 -0300)
Adding traceevent_host_bigendian function to get host endianity. It's
used in following patches.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/lib/traceevent/event-parse.h

index a28886066bcc793f3dacb7706e44df696c3e5baa..54273c0ec5448e62d2571eeaa06510a9129cfc08 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdbool.h>
 #include <stdarg.h>
 #include <regex.h>
+#include <string.h>
 
 #ifndef __maybe_unused
 #define __maybe_unused __attribute__((unused))
@@ -527,6 +528,15 @@ __data2host8(struct pevent *pevent, unsigned long long data)
        __data2host8(pevent, __val);                            \
 })
 
+static inline int traceevent_host_bigendian(void)
+{
+       unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
+       unsigned int val;
+
+       memcpy(&val, str, 4);
+       return val == 0x01020304;
+}
+
 /* taken from kernel/trace/trace.h */
 enum trace_flag_type {
        TRACE_FLAG_IRQS_OFF             = 0x01,