Skip to content

Commit

Permalink
perf memswap: Split the byteswap memory range wrappers from util.[ch]
Browse files Browse the repository at this point in the history
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>
Arnaldo Carvalho de Melo committed Apr 25, 2017
1 parent 5ab8c68 commit 98521b3
Showing 8 changed files with 35 additions and 25 deletions.
1 change: 1 addition & 0 deletions tools/perf/util/Build
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions tools/perf/util/intel-pt.c
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 24 additions & 0 deletions tools/perf/util/memswap.c
Original file line number Diff line number Diff line change
@@ -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;
}
}
7 changes: 7 additions & 0 deletions tools/perf/util/memswap.h
Original file line number Diff line number Diff line change
@@ -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_ */
1 change: 1 addition & 0 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

#include "evlist.h"
#include "evsel.h"
#include "memswap.h"
#include "session.h"
#include "tool.h"
#include "sort.h"
22 changes: 0 additions & 22 deletions tools/perf/util/util.c
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 0 additions & 3 deletions tools/perf/util/util.h
Original file line number Diff line number Diff line change
@@ -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,

0 comments on commit 98521b3

Please sign in to comment.