perf tools: Move mem_bswap32/64 to util.c
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 11 Dec 2013 12:36:32 +0000 (14:36 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 13 Dec 2013 13:30:21 +0000 (10:30 -0300)
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>
tools/perf/util/session.c
tools/perf/util/session.h
tools/perf/util/util.c
tools/perf/util/util.h

index e748f29c53cf0ca34093ee87e6938a4357ce89a8..989b2e37762614bd1c487d198742b8fd9a4386f0 100644 (file)
@@ -247,27 +247,6 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
        }
 }
  
-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;
-       }
-}
-
 static void swap_sample_id_all(union perf_event *event, void *data)
 {
        void *end = (void *) event + event->header.size;
index 2a3955ea4fd88257d762738d3ac897c2ce2cab26..9c25d49900af8345088afbb0ac8e2c3b80a17c07 100644 (file)
@@ -74,8 +74,6 @@ int perf_session__resolve_callchain(struct perf_session *session,
 
 bool perf_session__has_traces(struct perf_session *session, const char *msg);
 
-void mem_bswap_64(void *src, int byte_size);
-void mem_bswap_32(void *src, int byte_size);
 void perf_event__attr_swap(struct perf_event_attr *attr);
 
 int perf_session__create_kernel_maps(struct perf_session *session);
index 8f63dba212d7f850350d8b2fad95034bad53827b..42ad667bb317570e6f22216598181d1e2a8c9798 100644 (file)
@@ -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;
+       }
+}
index 1e7d4136cc82aaeb0881907610d71b3cff1b3f61..a1eea3e809a3e5a6fd8a4da08c1cb9b3eaaf9bee 100644 (file)
@@ -323,5 +323,8 @@ int filename__read_int(const char *filename, int *value);
 int filename__read_str(const char *filename, char **buf, size_t *sizep);
 int perf_event_paranoid(void);
 
+void mem_bswap_64(void *src, int byte_size);
+void mem_bswap_32(void *src, int byte_size);
+
 const char *get_filename_for_perf_kvm(void);
 #endif /* GIT_COMPAT_UTIL_H */