aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-04-25 14:45:35 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-04-25 14:45:35 -0400
commit98521b3869f8d6b4b9d2fdad8a56059e819ae002 (patch)
tree147c2ba21dcf8ca49cb87e106e8e1dbe9e4ef411
parent5ab8c689f7c0c97e98b8014b7f0ede386bef5aaf (diff)
perf memswap: Split the byteswap memory range wrappers from util.[ch]
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>
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/header.c1
-rw-r--r--tools/perf/util/intel-pt.c1
-rw-r--r--tools/perf/util/memswap.c24
-rw-r--r--tools/perf/util/memswap.h7
-rw-r--r--tools/perf/util/session.c1
-rw-r--r--tools/perf/util/util.c22
-rw-r--r--tools/perf/util/util.h3
8 files changed, 35 insertions, 25 deletions
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 069583bdc670..79dea95a7f68 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -13,6 +13,7 @@ libperf-y += find_bit.o
13libperf-y += kallsyms.o 13libperf-y += kallsyms.o
14libperf-y += levenshtein.o 14libperf-y += levenshtein.o
15libperf-y += llvm-utils.o 15libperf-y += llvm-utils.o
16libperf-y += memswap.o
16libperf-y += parse-events.o 17libperf-y += parse-events.o
17libperf-y += perf_regs.o 18libperf-y += perf_regs.o
18libperf-y += path.o 19libperf-y += path.o
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 948b2c5efb65..314a07151fb7 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -19,6 +19,7 @@
19#include "evlist.h" 19#include "evlist.h"
20#include "evsel.h" 20#include "evsel.h"
21#include "header.h" 21#include "header.h"
22#include "memswap.h"
22#include "../perf.h" 23#include "../perf.h"
23#include "trace-event.h" 24#include "trace-event.h"
24#include "session.h" 25#include "session.h"
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index bdd4a28c6cee..4c7718f87a08 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -23,6 +23,7 @@
23#include "../perf.h" 23#include "../perf.h"
24#include "session.h" 24#include "session.h"
25#include "machine.h" 25#include "machine.h"
26#include "memswap.h"
26#include "sort.h" 27#include "sort.h"
27#include "tool.h" 28#include "tool.h"
28#include "event.h" 29#include "event.h"
diff --git a/tools/perf/util/memswap.c b/tools/perf/util/memswap.c
new file mode 100644
index 000000000000..55f7faa8d9ec
--- /dev/null
+++ b/tools/perf/util/memswap.c
@@ -0,0 +1,24 @@
1#include <byteswap.h>
2#include "memswap.h"
3#include <linux/types.h>
4
5void mem_bswap_32(void *src, int byte_size)
6{
7 u32 *m = src;
8 while (byte_size > 0) {
9 *m = bswap_32(*m);
10 byte_size -= sizeof(u32);
11 ++m;
12 }
13}
14
15void mem_bswap_64(void *src, int byte_size)
16{
17 u64 *m = src;
18
19 while (byte_size > 0) {
20 *m = bswap_64(*m);
21 byte_size -= sizeof(u64);
22 ++m;
23 }
24}
diff --git a/tools/perf/util/memswap.h b/tools/perf/util/memswap.h
new file mode 100644
index 000000000000..7d1b1c34bb57
--- /dev/null
+++ b/tools/perf/util/memswap.h
@@ -0,0 +1,7 @@
1#ifndef PERF_MEMSWAP_H_
2#define PERF_MEMSWAP_H_
3
4void mem_bswap_64(void *src, int byte_size);
5void mem_bswap_32(void *src, int byte_size);
6
7#endif /* PERF_MEMSWAP_H_ */
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 3041c6b98191..7dc1096264c5 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -11,6 +11,7 @@
11 11
12#include "evlist.h" 12#include "evlist.h"
13#include "evsel.h" 13#include "evsel.h"
14#include "memswap.h"
14#include "session.h" 15#include "session.h"
15#include "tool.h" 16#include "tool.h"
16#include "sort.h" 17#include "sort.h"
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 6450c75a6f5b..b460f0db84d1 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -13,7 +13,6 @@
13#include <string.h> 13#include <string.h>
14#include <errno.h> 14#include <errno.h>
15#include <limits.h> 15#include <limits.h>
16#include <byteswap.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/log2.h> 17#include <linux/log2.h>
19#include <linux/time64.h> 18#include <linux/time64.h>
@@ -372,27 +371,6 @@ int perf_event_paranoid(void)
372 return value; 371 return value;
373} 372}
374 373
375void mem_bswap_32(void *src, int byte_size)
376{
377 u32 *m = src;
378 while (byte_size > 0) {
379 *m = bswap_32(*m);
380 byte_size -= sizeof(u32);
381 ++m;
382 }
383}
384
385void mem_bswap_64(void *src, int byte_size)
386{
387 u64 *m = src;
388
389 while (byte_size > 0) {
390 *m = bswap_64(*m);
391 byte_size -= sizeof(u64);
392 ++m;
393 }
394}
395
396bool find_process(const char *name) 374bool find_process(const char *name)
397{ 375{
398 size_t len = strlen(name); 376 size_t len = strlen(name);
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index f87b8948efdc..6855c454e5bc 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -69,9 +69,6 @@ struct parse_tag {
69 69
70unsigned long parse_tag_value(const char *str, struct parse_tag *tags); 70unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
71 71
72void mem_bswap_64(void *src, int byte_size);
73void mem_bswap_32(void *src, int byte_size);
74
75bool find_process(const char *name); 72bool find_process(const char *name);
76 73
77int fetch_kernel_version(unsigned int *puint, 74int fetch_kernel_version(unsigned int *puint,