diff options
-rw-r--r-- | tools/perf/builtin-trace.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/mmap-thread-lookup.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall-all-cpus.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall.c | 3 | ||||
-rw-r--r-- | tools/perf/ui/setup.c | 1 | ||||
-rw-r--r-- | tools/perf/util/build-id.c | 1 | ||||
-rw-r--r-- | tools/perf/util/counts.c | 1 | ||||
-rw-r--r-- | tools/perf/util/dso.c | 1 | ||||
-rw-r--r-- | tools/perf/util/path.c | 28 | ||||
-rw-r--r-- | tools/perf/util/path.h | 9 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 | ||||
-rw-r--r-- | tools/perf/util/unwind-libdw.c | 1 | ||||
-rw-r--r-- | tools/perf/util/util.c | 10 | ||||
-rw-r--r-- | tools/perf/util/util.h | 16 |
15 files changed, 52 insertions, 28 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e065c4a12f58..d1c8cdc6788b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "util/evlist.h" | 24 | #include "util/evlist.h" |
25 | #include <subcmd/exec-cmd.h> | 25 | #include <subcmd/exec-cmd.h> |
26 | #include "util/machine.h" | 26 | #include "util/machine.h" |
27 | #include "util/path.h" | ||
27 | #include "util/session.h" | 28 | #include "util/session.h" |
28 | #include "util/thread.h" | 29 | #include "util/thread.h" |
29 | #include <subcmd/parse-options.h> | 30 | #include <subcmd/parse-options.h> |
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c index a5ffb754f8c6..6ea4d8a5d26b 100644 --- a/tools/perf/tests/mmap-thread-lookup.c +++ b/tools/perf/tests/mmap-thread-lookup.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "thread_map.h" | 12 | #include "thread_map.h" |
13 | #include "symbol.h" | 13 | #include "symbol.h" |
14 | #include "thread.h" | 14 | #include "thread.h" |
15 | #include "util.h" | ||
15 | 16 | ||
16 | #define THREADS 4 | 17 | #define THREADS 4 |
17 | 18 | ||
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index b7dece0de42c..1a74dd9fd067 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c | |||
@@ -3,8 +3,12 @@ | |||
3 | /* For the CPU_* macros */ | 3 | /* For the CPU_* macros */ |
4 | #include <pthread.h> | 4 | #include <pthread.h> |
5 | 5 | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <fcntl.h> | ||
6 | #include <api/fs/fs.h> | 9 | #include <api/fs/fs.h> |
7 | #include <linux/err.h> | 10 | #include <linux/err.h> |
11 | #include <api/fs/tracing_path.h> | ||
8 | #include "evsel.h" | 12 | #include "evsel.h" |
9 | #include "tests.h" | 13 | #include "tests.h" |
10 | #include "thread_map.h" | 14 | #include "thread_map.h" |
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index 5f0c700b4693..e44506e21ee7 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c | |||
@@ -2,6 +2,9 @@ | |||
2 | #include <inttypes.h> | 2 | #include <inttypes.h> |
3 | #include <api/fs/tracing_path.h> | 3 | #include <api/fs/tracing_path.h> |
4 | #include <linux/err.h> | 4 | #include <linux/err.h> |
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
5 | #include "thread_map.h" | 8 | #include "thread_map.h" |
6 | #include "evsel.h" | 9 | #include "evsel.h" |
7 | #include "debug.h" | 10 | #include "debug.h" |
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 50d13e58210f..5ea0b40c4fc2 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "../util/cache.h" | 4 | #include "../util/cache.h" |
5 | #include "../util/debug.h" | 5 | #include "../util/debug.h" |
6 | #include "../util/hist.h" | 6 | #include "../util/hist.h" |
7 | #include "../util/util.h" | ||
7 | 8 | ||
8 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; | 9 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; |
9 | void *perf_gtk_handle; | 10 | void *perf_gtk_handle; |
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index f9ccd053cdf6..b5c4892c2e18 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "tool.h" | 18 | #include "tool.h" |
19 | #include "header.h" | 19 | #include "header.h" |
20 | #include "vdso.h" | 20 | #include "vdso.h" |
21 | #include "path.h" | ||
21 | #include "probe-file.h" | 22 | #include "probe-file.h" |
22 | #include "strlist.h" | 23 | #include "strlist.h" |
23 | 24 | ||
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c index 83fedd0d22a1..c4af82ab7808 100644 --- a/tools/perf/util/counts.c +++ b/tools/perf/util/counts.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "evsel.h" | 3 | #include "evsel.h" |
4 | #include "counts.h" | 4 | #include "counts.h" |
5 | #include "util.h" | ||
5 | 6 | ||
6 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) | 7 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) |
7 | { | 8 | { |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index cd061dc1de70..cbfe17f5168a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <sys/time.h> | 3 | #include <sys/time.h> |
4 | #include <sys/resource.h> | 4 | #include <sys/resource.h> |
5 | #include <errno.h> | 5 | #include <errno.h> |
6 | #include "path.h" | ||
6 | #include "symbol.h" | 7 | #include "symbol.h" |
7 | #include "dso.h" | 8 | #include "dso.h" |
8 | #include "machine.h" | 9 | #include "machine.h" |
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index 7c7630be5a89..50ec3bc87a60 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c | |||
@@ -11,8 +11,13 @@ | |||
11 | * which is what it's designed for. | 11 | * which is what it's designed for. |
12 | */ | 12 | */ |
13 | #include "cache.h" | 13 | #include "cache.h" |
14 | #include "util.h" | 14 | #include "path.h" |
15 | #include <linux/kernel.h> | ||
15 | #include <limits.h> | 16 | #include <limits.h> |
17 | #include <stdio.h> | ||
18 | #include <sys/types.h> | ||
19 | #include <sys/stat.h> | ||
20 | #include <unistd.h> | ||
16 | 21 | ||
17 | static char bad_path[] = "/bad-path/"; | 22 | static char bad_path[] = "/bad-path/"; |
18 | /* | 23 | /* |
@@ -50,3 +55,24 @@ char *mkpath(const char *fmt, ...) | |||
50 | return bad_path; | 55 | return bad_path; |
51 | return cleanup_path(pathname); | 56 | return cleanup_path(pathname); |
52 | } | 57 | } |
58 | |||
59 | int path__join(char *bf, size_t size, const char *path1, const char *path2) | ||
60 | { | ||
61 | return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); | ||
62 | } | ||
63 | |||
64 | int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3) | ||
65 | { | ||
66 | return scnprintf(bf, size, "%s%s%s%s%s", path1, path1[0] ? "/" : "", | ||
67 | path2, path2[0] ? "/" : "", path3); | ||
68 | } | ||
69 | |||
70 | bool is_regular_file(const char *file) | ||
71 | { | ||
72 | struct stat st; | ||
73 | |||
74 | if (stat(file, &st)) | ||
75 | return false; | ||
76 | |||
77 | return S_ISREG(st.st_mode); | ||
78 | } | ||
diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h new file mode 100644 index 000000000000..9a276a58e3c2 --- /dev/null +++ b/tools/perf/util/path.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _PERF_PATH_H | ||
2 | #define _PERF_PATH_H | ||
3 | |||
4 | int path__join(char *bf, size_t size, const char *path1, const char *path2); | ||
5 | int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3); | ||
6 | |||
7 | bool is_regular_file(const char *file); | ||
8 | |||
9 | #endif /* _PERF_PATH_H */ | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 68f14d770083..2cb7665e9973 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "strlist.h" | 19 | #include "strlist.h" |
20 | #include "intlist.h" | 20 | #include "intlist.h" |
21 | #include "header.h" | 21 | #include "header.h" |
22 | #include "path.h" | ||
22 | #include "sane_ctype.h" | 23 | #include "sane_ctype.h" |
23 | 24 | ||
24 | #include <elf.h> | 25 | #include <elf.h> |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 5245d2fb1a0a..7acd70fce68e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <libgen.h> | 13 | #include <libgen.h> |
14 | #include "build-id.h" | 14 | #include "build-id.h" |
15 | #include "event.h" | 15 | #include "event.h" |
16 | #include "util.h" | 16 | #include "path.h" |
17 | 17 | ||
18 | #ifdef HAVE_LIBELF_SUPPORT | 18 | #ifdef HAVE_LIBELF_SUPPORT |
19 | #include <libelf.h> | 19 | #include <libelf.h> |
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 783a53fb7a4e..f90e11a555b2 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "event.h" | 12 | #include "event.h" |
13 | #include "perf_regs.h" | 13 | #include "perf_regs.h" |
14 | #include "callchain.h" | 14 | #include "callchain.h" |
15 | #include "util.h" | ||
15 | 16 | ||
16 | static char *debuginfo_path; | 17 | static char *debuginfo_path; |
17 | 18 | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 4fb8ee552a31..64877c6d09b2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -713,16 +713,6 @@ out: | |||
713 | return tip; | 713 | return tip; |
714 | } | 714 | } |
715 | 715 | ||
716 | bool is_regular_file(const char *file) | ||
717 | { | ||
718 | struct stat st; | ||
719 | |||
720 | if (stat(file, &st)) | ||
721 | return false; | ||
722 | |||
723 | return S_ISREG(st.st_mode); | ||
724 | } | ||
725 | |||
726 | int fetch_current_timestamp(char *buf, size_t sz) | 716 | int fetch_current_timestamp(char *buf, size_t sz) |
727 | { | 717 | { |
728 | struct timeval tv; | 718 | struct timeval tv; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index fa8c2e59a0bc..617965644ff4 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -120,21 +120,6 @@ struct parse_tag { | |||
120 | 120 | ||
121 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); | 121 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); |
122 | 122 | ||
123 | static inline int path__join(char *bf, size_t size, | ||
124 | const char *path1, const char *path2) | ||
125 | { | ||
126 | return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); | ||
127 | } | ||
128 | |||
129 | static inline int path__join3(char *bf, size_t size, | ||
130 | const char *path1, const char *path2, | ||
131 | const char *path3) | ||
132 | { | ||
133 | return scnprintf(bf, size, "%s%s%s%s%s", | ||
134 | path1, path1[0] ? "/" : "", | ||
135 | path2, path2[0] ? "/" : "", path3); | ||
136 | } | ||
137 | |||
138 | int perf_event_paranoid(void); | 123 | int perf_event_paranoid(void); |
139 | 124 | ||
140 | void mem_bswap_64(void *src, int byte_size); | 125 | void mem_bswap_64(void *src, int byte_size); |
@@ -162,7 +147,6 @@ int fetch_kernel_version(unsigned int *puint, | |||
162 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) | 147 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) |
163 | 148 | ||
164 | const char *perf_tip(const char *dirpath); | 149 | const char *perf_tip(const char *dirpath); |
165 | bool is_regular_file(const char *file); | ||
166 | int fetch_current_timestamp(char *buf, size_t sz); | 150 | int fetch_current_timestamp(char *buf, size_t sz); |
167 | 151 | ||
168 | #ifndef HAVE_SCHED_GETCPU_SUPPORT | 152 | #ifndef HAVE_SCHED_GETCPU_SUPPORT |