perf memswap: Split the byteswap memory range wrappers from util.[ch]
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 25 Apr 2017 18:45:35 +0000 (15:45 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 25 Apr 2017 18:45:35 +0000 (15:45 -0300)
Just one more step into splitting util.[ch] to reduce the includes hell.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-navarr9mijkgwgbzu464dwam@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/Build
tools/perf/util/header.c
tools/perf/util/intel-pt.c
tools/perf/util/memswap.c [new file with mode: 0644]
tools/perf/util/memswap.h [new file with mode: 0644]
tools/perf/util/session.c
tools/perf/util/util.c
tools/perf/util/util.h

index 069583bdc670f0bf05c3f48762a53dc412a67fae..79dea95a7f688ca9fa9b16346b3fae25af797f5c 100644 (file)
@@ -13,6 +13,7 @@ libperf-y += find_bit.o
 libperf-y += kallsyms.o
 libperf-y += levenshtein.o
 libperf-y += llvm-utils.o
+libperf-y += memswap.o
 libperf-y += parse-events.o
 libperf-y += perf_regs.o
 libperf-y += path.o
index 948b2c5efb658e419114680ff07f4bf32cd70871..314a07151fb772377752dae62658b79ffdc87cd6 100644 (file)
@@ -19,6 +19,7 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "header.h"
+#include "memswap.h"
 #include "../perf.h"
 #include "trace-event.h"
 #include "session.h"
index bdd4a28c6cee13e296b425d40343fb3b6e11a861..4c7718f87a0890ee64e2f78e0b97291b67ecf33e 100644 (file)
@@ -23,6 +23,7 @@
 #include "../perf.h"
 #include "session.h"
 #include "machine.h"
+#include "memswap.h"
 #include "sort.h"
 #include "tool.h"
 #include "event.h"
diff --git a/tools/perf/util/memswap.c b/tools/perf/util/memswap.c
new file mode 100644 (file)
index 0000000..55f7faa
--- /dev/null
@@ -0,0 +1,24 @@
+#include <byteswap.h>
+#include "memswap.h"
+#include <linux/types.h>
+
+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;
+       }
+}
diff --git a/tools/perf/util/memswap.h b/tools/perf/util/memswap.h
new file mode 100644 (file)
index 0000000..7d1b1c3
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef PERF_MEMSWAP_H_
+#define PERF_MEMSWAP_H_
+
+void mem_bswap_64(void *src, int byte_size);
+void mem_bswap_32(void *src, int byte_size);
+
+#endif /* PERF_MEMSWAP_H_ */
index 3041c6b9819152cdd8ad5e856c735d2c7073d903..7dc1096264c575cbbd1cd41d07f041585a997453 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "evlist.h"
 #include "evsel.h"
+#include "memswap.h"
 #include "session.h"
 #include "tool.h"
 #include "sort.h"
index 6450c75a6f5b40bc28e9fe5f98cb98960cec1d10..b460f0db84d103b008a716bd99940c36f6aa1ded 100644 (file)
@@ -13,7 +13,6 @@
 #include <string.h>
 #include <errno.h>
 #include <limits.h>
-#include <byteswap.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
 #include <linux/time64.h>
@@ -372,27 +371,6 @@ 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;
-       }
-}
-
 bool find_process(const char *name)
 {
        size_t len = strlen(name);
index f87b8948efdc9bdad0c7d8601b9f3d26bac743d0..6855c454e5bcb27af4411c353eef2db43686d2d8 100644 (file)
@@ -69,9 +69,6 @@ struct parse_tag {
 
 unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
 
-void mem_bswap_64(void *src, int byte_size);
-void mem_bswap_32(void *src, int byte_size);
-
 bool find_process(const char *name);
 
 int fetch_kernel_version(unsigned int *puint,