Skip to contentSkip to conversation

perf memswap: Split the byteswap memory range wrappers from util.[ch]

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message May 3, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  98521b3869f8d6b4b9d2fdad8a56059e819ae002
Gitweb:     http://git.kernel.org/tip/98521b3869f8d6b4b9d2fdad8a56059e819ae002
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Tue, 25 Apr 2017 15:45:35 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 25 Apr 2017 15:45:35 -0300

perf memswap: Split the byteswap memory range wrappers from util.[ch]

Just one more step into splitting util.[ch] to reduce the includes hell.

---
 tools/perf/util/Build      |  1 +
 tools/perf/util/header.c   |  1 +
 tools/perf/util/intel-pt.c |  1 +
 tools/perf/util/memswap.c  | 24 ++++++++++++++++++++++++
 tools/perf/util/memswap.h  |  7 +++++++
 tools/perf/util/session.c  |  1 +
 tools/perf/util/util.c     | 22 ----------------------
 tools/perf/util/util.h     |  3 ---
 8 files changed, 35 insertions(+), 25 deletions(-)
tools/perf/util/Build +1 -0
index 069583b..79dea95 100644
@@ -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
tools/perf/util/header.c +1 -0
index 948b2c5..314a071 100644
@@ -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"
tools/perf/util/intel-pt.c +1 -0
index bdd4a28..4c7718f 100644
@@ -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"
tools/perf/util/memswap.c new file +24 -0
new file mode 100644
index 0000000..55f7faa
@@ -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;
+	}
+}
tools/perf/util/memswap.h new file +7 -0
new file mode 100644
index 0000000..7d1b1c3
@@ -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_ */
tools/perf/util/session.c +1 -0
index 3041c6b..7dc1096 100644
@@ -11,6 +11,7 @@
 
 #include "evlist.h"
 #include "evsel.h"
+#include "memswap.h"
 #include "session.h"
 #include "tool.h"
 #include "sort.h"
tools/perf/util/util.c +0 -22
index 6450c75..b460f0d 100644
@@ -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);
tools/perf/util/util.h +0 -3
index f87b894..6855c45 100644
@@ -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,