aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-12-11 14:36:32 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-12-13 10:30:21 -0300
commit71db07b12eace6a3619335d03eaf3cbe2de131ed (patch)
tree3f27c4d4a906e864aac2342c3b535cb675a7807e /tools/perf/util/util.c
parentperf evlist: Add can_select_event() method (diff)
downloadlinux-dev-71db07b12eace6a3619335d03eaf3cbe2de131ed.tar.xz
linux-dev-71db07b12eace6a3619335d03eaf3cbe2de131ed.zip
perf tools: Move mem_bswap32/64 to util.c
Move functions mem_bswap_32() and mem_bswap_64() so they can be reused. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1386765443-26966-21-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8f63dba212d7..42ad667bb317 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <errno.h>
#include <limits.h>
+#include <byteswap.h>
#include <linux/kernel.h>
/*
@@ -515,3 +516,24 @@ int perf_event_paranoid(void)
return value;
}
+
+void mem_bswap_32(void *src, int byte_size)
+{
+ u32 *m = src;
+ while (byte_size > 0) {
+ *m = bswap_32(*m);
+ byte_size -= sizeof(u32);
+ ++m;
+ }
+}
+
+void mem_bswap_64(void *src, int byte_size)
+{
+ u64 *m = src;
+
+ while (byte_size > 0) {
+ *m = bswap_64(*m);
+ byte_size -= sizeof(u64);
+ ++m;
+ }
+}