diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2013-12-11 07:36:32 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-13 08:30:21 -0500 |
commit | 71db07b12eace6a3619335d03eaf3cbe2de131ed (patch) | |
tree | 3f27c4d4a906e864aac2342c3b535cb675a7807e /tools/perf | |
parent | c09ec622629eeb4b7877646a42852e7156363425 (diff) |
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')
-rw-r--r-- | tools/perf/util/session.c | 21 | ||||
-rw-r--r-- | tools/perf/util/session.h | 2 | ||||
-rw-r--r-- | tools/perf/util/util.c | 22 | ||||
-rw-r--r-- | tools/perf/util/util.h | 3 |
4 files changed, 25 insertions, 23 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index e748f29c53cf..989b2e377626 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -247,27 +247,6 @@ void perf_tool__fill_defaults(struct perf_tool *tool) | |||
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void mem_bswap_32(void *src, int byte_size) | ||
251 | { | ||
252 | u32 *m = src; | ||
253 | while (byte_size > 0) { | ||
254 | *m = bswap_32(*m); | ||
255 | byte_size -= sizeof(u32); | ||
256 | ++m; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | void mem_bswap_64(void *src, int byte_size) | ||
261 | { | ||
262 | u64 *m = src; | ||
263 | |||
264 | while (byte_size > 0) { | ||
265 | *m = bswap_64(*m); | ||
266 | byte_size -= sizeof(u64); | ||
267 | ++m; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | static void swap_sample_id_all(union perf_event *event, void *data) | 250 | static void swap_sample_id_all(union perf_event *event, void *data) |
272 | { | 251 | { |
273 | void *end = (void *) event + event->header.size; | 252 | void *end = (void *) event + event->header.size; |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 2a3955ea4fd8..9c25d49900af 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -74,8 +74,6 @@ int perf_session__resolve_callchain(struct perf_session *session, | |||
74 | 74 | ||
75 | bool perf_session__has_traces(struct perf_session *session, const char *msg); | 75 | bool perf_session__has_traces(struct perf_session *session, const char *msg); |
76 | 76 | ||
77 | void mem_bswap_64(void *src, int byte_size); | ||
78 | void mem_bswap_32(void *src, int byte_size); | ||
79 | void perf_event__attr_swap(struct perf_event_attr *attr); | 77 | void perf_event__attr_swap(struct perf_event_attr *attr); |
80 | 78 | ||
81 | int perf_session__create_kernel_maps(struct perf_session *session); | 79 | int perf_session__create_kernel_maps(struct perf_session *session); |
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 @@ | |||
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <errno.h> | 11 | #include <errno.h> |
12 | #include <limits.h> | 12 | #include <limits.h> |
13 | #include <byteswap.h> | ||
13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
14 | 15 | ||
15 | /* | 16 | /* |
@@ -515,3 +516,24 @@ int perf_event_paranoid(void) | |||
515 | 516 | ||
516 | return value; | 517 | return value; |
517 | } | 518 | } |
519 | |||
520 | void mem_bswap_32(void *src, int byte_size) | ||
521 | { | ||
522 | u32 *m = src; | ||
523 | while (byte_size > 0) { | ||
524 | *m = bswap_32(*m); | ||
525 | byte_size -= sizeof(u32); | ||
526 | ++m; | ||
527 | } | ||
528 | } | ||
529 | |||
530 | void mem_bswap_64(void *src, int byte_size) | ||
531 | { | ||
532 | u64 *m = src; | ||
533 | |||
534 | while (byte_size > 0) { | ||
535 | *m = bswap_64(*m); | ||
536 | byte_size -= sizeof(u64); | ||
537 | ++m; | ||
538 | } | ||
539 | } | ||
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 1e7d4136cc82..a1eea3e809a3 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -323,5 +323,8 @@ int filename__read_int(const char *filename, int *value); | |||
323 | int filename__read_str(const char *filename, char **buf, size_t *sizep); | 323 | int filename__read_str(const char *filename, char **buf, size_t *sizep); |
324 | int perf_event_paranoid(void); | 324 | int perf_event_paranoid(void); |
325 | 325 | ||
326 | void mem_bswap_64(void *src, int byte_size); | ||
327 | void mem_bswap_32(void *src, int byte_size); | ||
328 | |||
326 | const char *get_filename_for_perf_kvm(void); | 329 | const char *get_filename_for_perf_kvm(void); |
327 | #endif /* GIT_COMPAT_UTIL_H */ | 330 | #endif /* GIT_COMPAT_UTIL_H */ |