diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-04-20 10:07:18 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-04-20 10:07:18 +0200 |
commit | 07590a7d4030c159b9a0d7171f81049a9ce23245 (patch) | |
tree | 1aa05455a4eacca2ca9dc3b228f19addf7bfd395 /tools/perf/util/util.c | |
parent | afa7a17f3aafb64647ba4cd38e20f3d678c7949b (diff) | |
parent | 1b5ad16c7aa7177512ce141e345ff36b9f1a6136 (diff) |
Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core cleanups from Arnaldo Carvalho de Melo:
- Introduce new header files out of the hodge-podge that util/util.h
became, trying to disentangle the includes hell that all C projects
end up growing. This should help in build times, as changes to
seemingly unrelated files (util.h included tons of headers) won't
trigger a rebuild of most object files.
- Use equivalent facilities found in the kernel source code base
originated tools/include/ header files, such as __stringify(),
ARRAY_SIZE, that has extra checks (__must_be_array()), etc.
- For that get some more files from the kernel sources, like
include/linux/bug.h, some just with the bits needed at this time.
- Use the headers where facilities declared in them are used, such
as PRIxu(32,64) macros (inttypes.h), errno defines (errno.h), etc.
- Remove various leftovers from the initial code base we copied from
git.git: FLEX_ARRAY, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6097d87429e2..b9716bc6e8fd 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -7,6 +7,8 @@ #ifdef HAVE_BACKTRACE_SUPPORT #include <execinfo.h> #endif +#include <dirent.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -712,16 +714,6 @@ out: return tip; } -bool is_regular_file(const char *file) -{ - struct stat st; - - if (stat(file, &st)) - return false; - - return S_ISREG(st.st_mode); -} - int fetch_current_timestamp(char *buf, size_t sz) { struct timeval tv; @@ -739,58 +731,6 @@ int fetch_current_timestamp(char *buf, size_t sz) return 0; } -void print_binary(unsigned char *data, size_t len, - size_t bytes_per_line, print_binary_t printer, - void *extra) -{ - size_t i, j, mask; - - if (!printer) - return; - - bytes_per_line = roundup_pow_of_two(bytes_per_line); - mask = bytes_per_line - 1; - - printer(BINARY_PRINT_DATA_BEGIN, 0, extra); - for (i = 0; i < len; i++) { - if ((i & mask) == 0) { - printer(BINARY_PRINT_LINE_BEGIN, -1, extra); - printer(BINARY_PRINT_ADDR, i, extra); - } - - printer(BINARY_PRINT_NUM_DATA, data[i], extra); - - if (((i & mask) == mask) || i == len - 1) { - for (j = 0; j < mask-(i & mask); j++) - printer(BINARY_PRINT_NUM_PAD, -1, extra); - - printer(BINARY_PRINT_SEP, i, extra); - for (j = i & ~mask; j <= i; j++) - printer(BINARY_PRINT_CHAR_DATA, data[j], extra); - for (j = 0; j < mask-(i & mask); j++) - printer(BINARY_PRINT_CHAR_PAD, i, extra); - printer(BINARY_PRINT_LINE_END, -1, extra); - } - } - printer(BINARY_PRINT_DATA_END, -1, extra); -} - -int is_printable_array(char *p, unsigned int len) -{ - unsigned int i; - - if (!p || !len || p[len - 1] != 0) - return 0; - - len--; - - for (i = 0; i < len; i++) { - if (!isprint(p[i]) && !isspace(p[i])) - return 0; - } - return 1; -} - int unit_number__scnprintf(char *buf, size_t size, u64 n) { char unit[4] = "BKMG"; |