lkml.org 
[lkml]   [2013]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[tip:perf/core] tools lib traceevent: Add traceevent_host_bigendian function
    Commit-ID:  91a058ad3856b0a37cb21250eb4c478d0297a1a3
    Gitweb: http://git.kernel.org/tip/91a058ad3856b0a37cb21250eb4c478d0297a1a3
    Author: Jiri Olsa <jolsa@redhat.com>
    AuthorDate: Tue, 3 Dec 2013 14:09:18 +0100
    Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
    CommitDate: Wed, 4 Dec 2013 15:17:58 -0300

    tools lib traceevent: Add traceevent_host_bigendian function

    Adding traceevent_host_bigendian function to get host endianity. It's
    used in following patches.

    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Link: http://lkml.kernel.org/r/1386076182-14484-5-git-send-email-jolsa@redhat.com
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    ---
    tools/lib/traceevent/event-parse.h | 10 ++++++++++
    1 file changed, 10 insertions(+)

    diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
    index a288860..54273c0 100644
    --- a/tools/lib/traceevent/event-parse.h
    +++ b/tools/lib/traceevent/event-parse.h
    @@ -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,

    \
     
     \ /
      Last update: 2013-12-10 13:21    [W:4.140 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site