diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-25 17:27:31 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-06-25 21:02:47 -0300 |
commit | 3052ba56bcb589046eca6a931bd897742653d2cb (patch) | |
tree | e0a21f954cedf103bc42423d24cc15239fae73b2 /tools/perf/util | |
parent | 1b2fc358ddfb1b0915922e441182cda7043f5116 (diff) | |
download | lwn-3052ba56bcb589046eca6a931bd897742653d2cb.tar.gz lwn-3052ba56bcb589046eca6a931bd897742653d2cb.zip |
tools perf: Move from sane_ctype.h obtained from git to the Linux's original
We got the sane_ctype.h headers from git and kept using it so far, but
since that code originally came from the kernel sources to the git
sources, perhaps its better to just use the one in the kernel, so that
we can leverage tools/perf/check_headers.sh to be notified when our copy
gets out of sync, i.e. when fixes or goodies are added to the code we've
copied.
This will help with things like tools/lib/string.c where we want to have
more things in common with the kernel, such as strim(), skip_spaces(),
etc so as to go on removing the things that we have in tools/perf/util/
and instead using the code in the kernel, indirectly and removing things
like EXPORT_SYMBOL(), etc, getting notified when fixes and improvements
are made to the original code.
Hopefully this also should help with reducing the difference of code
hosted in tools/ to the one in the kernel proper.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-7k9868l713wqtgo01xxygn12@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
27 files changed, 28 insertions, 103 deletions
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 6d5bbc8b589b..b4dc6112138f 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -213,6 +213,10 @@ $(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)util/ctype.o: ../lib/ctype.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + $(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index c8ce13419d9b..65005ccea232 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -49,7 +49,7 @@ #define DARROW_CHAR ((unsigned char)'.') #define UARROW_CHAR ((unsigned char)'-') -#include "sane_ctype.h" +#include <linux/ctype.h> struct annotation_options annotation__default_options = { .use_offset = true, diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index cfdbf65f1e02..bc215fe0b4b4 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -51,7 +51,7 @@ #include "arm-spe.h" #include "s390-cpumsf.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include "symbol/kallsyms.h" static bool auxtrace__dont_decode(struct perf_session *session) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 0c5517a8d0b7..89c6913dfc25 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -29,7 +29,7 @@ #include "probe-file.h" #include "strlist.h" -#include "sane_ctype.h" +#include <linux/ctype.h> static bool no_buildid_cache; diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index e7d2c08d263a..752cce853e51 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -24,7 +24,7 @@ #include <unistd.h> #include <linux/string.h> -#include "sane_ctype.h" +#include <linux/ctype.h> #define MAXNAME (256) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index c11a459ca582..0d8fbedf7bd5 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -10,7 +10,7 @@ #include <linux/bitmap.h> #include "asm/bug.h" -#include "sane_ctype.h" +#include <linux/ctype.h> static int max_cpu_num; static int max_present_cpu_num; diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c deleted file mode 100644 index f84ecd9e5329..000000000000 --- a/tools/perf/util/ctype.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Sane locale-independent, ASCII ctype. - * - * No surprises, and works with signed and unsigned chars. - */ -#include "sane_ctype.h" - -enum { - S = GIT_SPACE, - A = GIT_ALPHA, - D = GIT_DIGIT, - G = GIT_GLOB_SPECIAL, /* *, ?, [, \\ */ - R = GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | * */ - P = GIT_PRINT_EXTRA, /* printable - alpha - digit - glob - regex */ - - PS = GIT_SPACE | GIT_PRINT_EXTRA, -}; - -unsigned char sane_ctype[256] = { -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ - - 0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0, /* 0.. 15 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16.. 31 */ - PS,P, P, P, R, P, P, P, R, R, G, R, P, P, R, P, /* 32.. 47 */ - D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G, /* 48.. 63 */ - P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */ - A, A, A, A, A, A, A, A, A, A, A, G, G, P, R, P, /* 80.. 95 */ - P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */ - A, A, A, A, A, A, A, A, A, A, A, R, R, P, P, 0, /* 112..127 */ - /* Nothing in the 128.. range */ -}; diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index b79e1d6839ed..7b06e7373b9e 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -29,7 +29,7 @@ #include "evsel.h" #include "machine.h" #include "config.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #define pr_N(n, fmt, ...) \ eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 3d6459626c2a..3cc578343f48 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -21,7 +21,7 @@ #include "util.h" #include "target.h" -#include "sane_ctype.h" +#include <linux/ctype.h> int verbose; bool dump_trace = false, quiet = false; diff --git a/tools/perf/util/demangle-java.c b/tools/perf/util/demangle-java.c index e4c486756053..5b4900d67c80 100644 --- a/tools/perf/util/demangle-java.c +++ b/tools/perf/util/demangle-java.c @@ -8,7 +8,7 @@ #include "demangle-java.h" -#include "sane_ctype.h" +#include <linux/ctype.h> enum { MODE_PREFIX = 0, diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 1cc7a1837822..22eee8942527 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "cpumap.h" #include "env.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include "util.h" #include "bpf-event.h" #include <errno.h> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c9c6857360e4..d8f8a20543c5 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -20,7 +20,7 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include "map.h" #include "symbol.h" #include "symbol/kallsyms.h" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 4b175166d264..5ab31a4a658d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -39,7 +39,7 @@ #include "memswap.h" #include "util/parse-branch-options.h" -#include "sane_ctype.h" +#include <linux/ctype.h> struct perf_missing_features perf_missing_features; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index abc9c2145efe..fca9dbaf61ae 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -43,7 +43,7 @@ #include "cputopo.h" #include "bpf-event.h" -#include "sane_ctype.h" +#include <linux/ctype.h> /* * magic2 = "PERFILE2" diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index eda28d3570bc..28908afedec4 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -28,7 +28,7 @@ #include "genelf.h" #include "../builtin.h" -#include "sane_ctype.h" +#include <linux/ctype.h> struct jit_buf_desc { struct perf_data *output; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index a0bb05dd008f..1b3d7265bca9 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -25,7 +25,7 @@ #include "asm/bug.h" #include "bpf-event.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include <symbol/kallsyms.h> #include <linux/mman.h> diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c index 23e367063446..599a1543871d 100644 --- a/tools/perf/util/print_binary.c +++ b/tools/perf/util/print_binary.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "print_binary.h" #include <linux/log2.h> -#include "sane_ctype.h" +#include <linux/ctype.h> int binary__fprintf(unsigned char *data, size_t len, size_t bytes_per_line, binary__fprintf_t printer, diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2ebf8673f8e9..6f24eaf6e504 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -39,7 +39,7 @@ #include "session.h" #include "string2.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #define PERFPROBE_GROUP "probe" diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 16252980ff00..670c477bf8cf 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h @@ -5,7 +5,7 @@ #include <stdbool.h> #include "intlist.h" #include "probe-event.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #define MAX_PROBE_BUFFER 1024 #define MAX_PROBES 128 diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 7aa0ea64544e..648bcd80b475 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources @@ -6,7 +6,7 @@ # util/python.c -util/ctype.c +../lib/ctype.c util/evlist.c util/evsel.c util/cpumap.c diff --git a/tools/perf/util/sane_ctype.h b/tools/perf/util/sane_ctype.h deleted file mode 100644 index c4dce9e3001b..000000000000 --- a/tools/perf/util/sane_ctype.h +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _PERF_SANE_CTYPE_H -#define _PERF_SANE_CTYPE_H - -/* Sane ctype - no locale, and works with signed chars */ -#undef isascii -#undef isspace -#undef isdigit -#undef isxdigit -#undef isalpha -#undef isprint -#undef isalnum -#undef islower -#undef isupper -#undef tolower -#undef toupper - -extern unsigned char sane_ctype[256]; -#define GIT_SPACE 0x01 -#define GIT_DIGIT 0x02 -#define GIT_ALPHA 0x04 -#define GIT_GLOB_SPECIAL 0x08 -#define GIT_REGEX_SPECIAL 0x10 -#define GIT_PRINT_EXTRA 0x20 -#define GIT_PRINT 0x3E -#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) -#define isascii(x) (((x) & ~0x7f) == 0) -#define isspace(x) sane_istest(x,GIT_SPACE) -#define isdigit(x) sane_istest(x,GIT_DIGIT) -#define isxdigit(x) \ - (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G') -#define isalpha(x) sane_istest(x,GIT_ALPHA) -#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) -#define isprint(x) sane_istest(x,GIT_PRINT) -#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20)) -#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20)) -#define tolower(x) sane_case((unsigned char)(x), 0x20) -#define toupper(x) sane_case((unsigned char)(x), 0) - -static inline int sane_case(int x, int high) -{ - if (sane_istest(x, GIT_ALPHA)) - x = (x & ~0x20) | high; - return x; -} - -#endif /* _PERF_SANE_CTYPE_H */ diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index a6b9de3e83fc..992e327bce85 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -10,7 +10,7 @@ #include "thread_map.h" #include "cpumap.h" #include "string2.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include "cgroup.h" #include <math.h> #include <api/fs/fs.h> diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index 7f3253d44afd..2c3a2904ebcd 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c @@ -4,7 +4,7 @@ #include "strfilter.h" #include <errno.h> -#include "sane_ctype.h" +#include <linux/ctype.h> /* Operators */ static const char *OP_and = "&"; /* Logical AND */ diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index b18884bd673b..084c3e4e9400 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -4,7 +4,7 @@ #include <linux/string.h> #include <stdlib.h> -#include "sane_ctype.h" +#include <linux/ctype.h> const char *graph_dotted_line = "---------------------------------------------------------------------" diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index f04ef851ae86..62008756d8cc 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -15,7 +15,7 @@ #include "vdso.h" #include "debug.h" #include "util.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include <symbol/kallsyms.h> #ifndef EM_AARCH64 diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index f4540f8bbed1..46d2c03814a1 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -25,7 +25,7 @@ #include "namespaces.h" #include "header.h" #include "path.h" -#include "sane_ctype.h" +#include <linux/ctype.h> #include <elf.h> #include <limits.h> diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 62bc61155dd1..b3982e1bb4c5 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -11,7 +11,7 @@ #include "debug.h" #include "trace-event.h" -#include "sane_ctype.h" +#include <linux/ctype.h> static int get_common_field(struct scripting_context *context, int *offset, int *size, const char *type) |