perf tools: Move sane ctype stuff from util.h to sane_ctype.h
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 17 Apr 2017 19:10:49 +0000 (16:10 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 19 Apr 2017 16:01:48 +0000 (13:01 -0300)
More stuff that came from git, out of the hodge-podge that is util.h

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-e3lana4gctz3ub4hn4y29hkw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
37 files changed:
tools/lib/symbol/kallsyms.c
tools/perf/arch/common.c
tools/perf/builtin-kmem.c
tools/perf/builtin-sched.c
tools/perf/builtin-script.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/tests/code-reading.c
tools/perf/ui/browser.c
tools/perf/ui/browsers/hists.c
tools/perf/ui/browsers/map.c
tools/perf/ui/stdio/hist.c
tools/perf/util/annotate.c
tools/perf/util/auxtrace.c
tools/perf/util/build-id.c
tools/perf/util/config.c
tools/perf/util/cpumap.c
tools/perf/util/ctype.c
tools/perf/util/data-convert-bt.c
tools/perf/util/debug.c
tools/perf/util/demangle-java.c
tools/perf/util/event.c
tools/perf/util/evsel.c
tools/perf/util/header.c
tools/perf/util/jitdump.c
tools/perf/util/machine.c
tools/perf/util/probe-event.c
tools/perf/util/probe-finder.h
tools/perf/util/sane_ctype.h [new file with mode: 0644]
tools/perf/util/strfilter.c
tools/perf/util/string.c
tools/perf/util/symbol-elf.c
tools/perf/util/symbol.c
tools/perf/util/trace-event-parse.c
tools/perf/util/util.c
tools/perf/util/util.h

index 5e431077fcd6784ac9567a785bc6fb90a40bc7bb..d270ac00613d60612802e85cd71661a54c762f41 100644 (file)
@@ -1,3 +1,4 @@
+#include <ctype.h>
 #include "symbol/kallsyms.h"
 #include <stdio.h>
 #include <stdlib.h>
index 886dd2aaff0d81533468ad60db70abbd23465ec3..837067f48a4c54a88b883e8de6dc95df0dd5b3d0 100644 (file)
@@ -4,6 +4,8 @@
 #include "../util/util.h"
 #include "../util/debug.h"
 
+#include "sane_ctype.h"
+
 const char *const arm_triplets[] = {
        "arm-eabi-",
        "arm-linux-androideabi-",
index fa6bf1c39b65efe21e64b131ce5ef9850ee6a399..15754a492cadf1d7ce67040f7fa466fdbdec4b6e 100644 (file)
@@ -27,6 +27,8 @@
 #include <locale.h>
 #include <regex.h>
 
+#include "sane_ctype.h"
+
 static int     kmem_slab;
 static int     kmem_page;
 
index d4677fb7f7f5ba6a26eb75313b0e0116bb6c383e..aefab93d7d2fdb6c32a00e132541c227872c4e31 100644 (file)
@@ -34,6 +34,8 @@
 #include <api/fs/fs.h>
 #include <linux/time64.h>
 
+#include "sane_ctype.h"
+
 #define PR_SET_NAME            15               /* Set process name */
 #define MAX_CPUS               4096
 #define COMM_LEN               20
index c4e36b4743f4f267356349620d548e3c9a485da7..5afd9a62360a2c984266e2aa5d0dc972c0c7e0db 100644 (file)
@@ -32,6 +32,8 @@
 #include "util/dump-insn.h"
 #include <inttypes.h>
 
+#include "sane_ctype.h"
+
 static char const              *script_name;
 static char const              *generate_script_lang;
 static bool                    debug_mode;
index b7199f02907365f66a4296ded70a3c03856e3d9c..5abef25f998344d80ce3ddabfdebbf40b12bdc5c 100644 (file)
@@ -74,6 +74,8 @@
 #include <locale.h>
 #include <math.h>
 
+#include "sane_ctype.h"
+
 #define DEFAULT_SEPARATOR      " "
 #define CNTR_NOT_SUPPORTED     "<not supported>"
 #define CNTR_NOT_COUNTED       "<not counted>"
index a0c97c70ec81b569a8308ad92ddbe4b1080fff63..ec3247db482605963691aeafc4140f566460cfdf 100644 (file)
@@ -72,6 +72,8 @@
 #include <linux/time64.h>
 #include <linux/types.h>
 
+#include "sane_ctype.h"
+
 static volatile int done;
 
 #define HEADER_LINE_NR  5
index aba5fac4152923faf50e6be2e1723ad98964b3e9..0b00d8ac52266b89b8d80fb35c81e9679d9262c7 100644 (file)
@@ -51,6 +51,8 @@
 #include <linux/stringify.h>
 #include <linux/time64.h>
 
+#include "sane_ctype.h"
+
 #ifndef O_CLOEXEC
 # define O_CLOEXEC             02000000
 #endif
index 6effcfb7e0c13e06fc9e83819d7b47141ae44bd1..fe6aac82d54e9483567dc2b7984c21bee8b60930 100644 (file)
@@ -4,7 +4,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <ctype.h>
 #include <string.h>
 
 #include "parse-events.h"
@@ -18,6 +17,8 @@
 
 #include "tests.h"
 
+#include "sane_ctype.h"
+
 #define BUFSZ  1024
 #define READLEN        128
 
index 9e47ccbe07f16acfb23ea301b7a510bc09b66dcd..73bdd07321c4f40ac409405735960adef5a6f18e 100644 (file)
@@ -13,6 +13,7 @@
 #include "helpline.h"
 #include "keysyms.h"
 #include "../color.h"
+#include "sane_ctype.h"
 
 static int ui_browser__percent_color(struct ui_browser *browser,
                                     double percent, bool current)
index a2ea1fa15ae6a460bcd72dd8b18b609e9da60826..56f5c038689e8a163d2cfc31e5f565699b99bdc5 100644 (file)
@@ -20,6 +20,8 @@
 #include "map.h"
 #include "annotate.h"
 
+#include "sane_ctype.h"
+
 extern void hist_browser__init_hpp(void);
 
 static int perf_evsel_browser_title(struct hist_browser *browser,
index 9ce142de536d0dcbb4017d2d80a40a9a668775c4..ffa5addf631d95fab3b1abcb8fcd6389aef45aba 100644 (file)
@@ -11,6 +11,8 @@
 #include "../keysyms.h"
 #include "map.h"
 
+#include "sane_ctype.h"
+
 struct map_browser {
        struct ui_browser b;
        struct map        *map;
index d52d5f64ea89119064e3bc57479b6df82fde2a92..297a79c69b715cef9f357a7c2833c2a600cec4b4 100644 (file)
@@ -4,7 +4,7 @@
 #include "../../util/hist.h"
 #include "../../util/sort.h"
 #include "../../util/evsel.h"
-
+#include "../../util/sane_ctype.h"
 
 static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
 {
index 4d4faf99d52d91e7ce4f16f29dd47218b8b52688..d69fdafba27431b3a8dadd9956cfa5a6c666a378 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/kernel.h>
 #include <sys/utsname.h>
 
+#include "sane_ctype.h"
+
 const char     *disassembler_style;
 const char     *objdump_path;
 static regex_t  file_lineno;
index a81a402a74591ed67c595d23b7d91fd32e99e158..0daf63b9ee3e1482cdc5fc5e96a968c4117e3a0c 100644 (file)
@@ -17,7 +17,6 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <stdbool.h>
-#include <ctype.h>
 #include <string.h>
 #include <limits.h>
 #include <errno.h>
@@ -47,7 +46,6 @@
 #include "cpumap.h"
 #include "thread_map.h"
 #include "asm/bug.h"
-#include "symbol/kallsyms.h"
 #include "auxtrace.h"
 
 #include <linux/hash.h>
@@ -60,6 +58,9 @@
 #include "intel-pt.h"
 #include "intel-bts.h"
 
+#include "sane_ctype.h"
+#include "symbol/kallsyms.h"
+
 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
                        struct auxtrace_mmap_params *mp,
                        void *userpg, int fd)
index 33af67530d308bd46fb3c2098260b2bb22cc5aa9..3c075556396977abd2b6dbb82e8c6af7e2a0bb88 100644 (file)
@@ -19,6 +19,7 @@
 #include "vdso.h"
 #include "probe-file.h"
 
+#include "sane_ctype.h"
 
 static bool no_buildid_cache;
 
index 7b01d59076d3a68247e2115b3fe59c85547c0a92..88783aa3dfc9206b9b3fb5be08bbfc551a05700d 100644 (file)
@@ -15,6 +15,8 @@
 #include "util/llvm-utils.h"   /* perf_llvm_config */
 #include "config.h"
 
+#include "sane_ctype.h"
+
 #define MAXNAME (256)
 
 #define DEBUG_CACHE_DIR ".debug"
index 061018b4239341f7a74409fe64973c9a7f0bcd33..9d9ecb2430cccd14e09d9366f499f413e821f058 100644 (file)
@@ -8,6 +8,8 @@
 #include <linux/bitmap.h>
 #include "asm/bug.h"
 
+#include "sane_ctype.h"
+
 static int max_cpu_num;
 static int max_present_cpu_num;
 static int max_node_num;
index d4a5a21c2a7e2e47596444665b5f5828874da337..4b261c2ec0f10a8e85b68a8a16832ee54ea177b9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * No surprises, and works with signed and unsigned chars.
  */
-#include "util.h"
+#include "sane_ctype.h"
 
 enum {
        S = GIT_SPACE,
index ef80221e0d9cb24c7dc85d9b3ba4059cf50dd57f..c3277b32e9178b17a219642d36dad529789667b4 100644 (file)
@@ -29,6 +29,7 @@
 #include "evsel.h"
 #include "machine.h"
 #include "config.h"
+#include "sane_ctype.h"
 
 #define pr_N(n, fmt, ...) \
        eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__)
index 4d5df25f155a12a5e6708227c00f00a4de1bf7f2..41aa7c63e037287de283f920ad0a05baae635287 100644 (file)
@@ -16,6 +16,8 @@
 #include "util.h"
 #include "target.h"
 
+#include "sane_ctype.h"
+
 int verbose;
 bool dump_trace = false, quiet = false;
 int debug_ordered_events;
index 3e6062ab2cdda23e9b74b54ef4f021031905249b..cb66d334f5328690072193b5a902df50076786dc 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "demangle-java.h"
 
+#include "sane_ctype.h"
+
 enum {
        MODE_PREFIX = 0,
        MODE_CLASS  = 1,
index b761b0eb60aff29c0c02c4e6366711c774e4b9e7..f8a706ba72f244ffd390617be97fb7401b2b2611 100644 (file)
@@ -12,6 +12,7 @@
 #include "strlist.h"
 #include "thread.h"
 #include "thread_map.h"
+#include "sane_ctype.h"
 #include "symbol/kallsyms.h"
 #include "asm/bug.h"
 #include "stat.h"
index 99a13a63ff1f7504fd18e6cbb055e5f3bc4d405b..757f73c4fa95c596ced7391aab17ac443e4ea1fa 100644 (file)
@@ -31,6 +31,8 @@
 #include "stat.h"
 #include "util/parse-branch-options.h"
 
+#include "sane_ctype.h"
+
 static struct {
        bool sample_id_all;
        bool exclude_guest;
index 0371f3483ede146437e29c3d16fb9dd276570f09..faf046fc398fe5a22d206a96220b302360887358 100644 (file)
@@ -27,6 +27,8 @@
 #include <api/fs/fs.h>
 #include "asm/bug.h"
 
+#include "sane_ctype.h"
+
 /*
  * magic2 = "PERFILE2"
  * must be a numerical value to let the endianness
index da6262dbe9e34a520cc2e48f0a373113cc12bdb6..d6d25327bc924aaabf0f170f8e85d94197a7afad 100644 (file)
@@ -26,6 +26,8 @@
 #include "genelf.h"
 #include "../builtin.h"
 
+#include "sane_ctype.h"
+
 struct jit_buf_desc {
        struct perf_data_file *output;
        struct perf_session *session;
index 15b2a17cf76ec81c0177076ecca7c8ce92fc8582..f13f46a99b362204209541462154f7df27e854e4 100644 (file)
 #include "thread.h"
 #include "vdso.h"
 #include <stdbool.h>
-#include <symbol/kallsyms.h>
 #include "unwind.h"
 #include "linux/hash.h"
 #include "asm/bug.h"
 
+#include "sane_ctype.h"
+#include <symbol/kallsyms.h>
+
 static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
 
 static void dsos__init(struct dsos *dsos)
index e61b4b34a929fb0d49e2c283cac1a0fde33e07e6..7caba7003734bf4cd1de8e7e03c7b0e507a72c09 100644 (file)
@@ -48,6 +48,8 @@
 #include "probe-file.h"
 #include "session.h"
 
+#include "sane_ctype.h"
+
 #define PERFPROBE_GROUP "probe"
 
 bool probe_event_dry_run;      /* Dry run flag */
index 2956c51986529ee7481f922d488a449c0a7619a0..27f06155101298e1e5ab878d75b9944745c22bf4 100644 (file)
@@ -2,9 +2,9 @@
 #define _PROBE_FINDER_H
 
 #include <stdbool.h>
-#include "util.h"
 #include "intlist.h"
 #include "probe-event.h"
+#include "sane_ctype.h"
 
 #define MAX_PROBE_BUFFER       1024
 #define MAX_PROBES              128
diff --git a/tools/perf/util/sane_ctype.h b/tools/perf/util/sane_ctype.h
new file mode 100644 (file)
index 0000000..4308c22
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _PERF_SANE_CTYPE_H
+#define _PERF_SANE_CTYPE_H
+
+extern const char *graph_line;
+extern const char *graph_dotted_line;
+extern const char *spaces;
+extern const char *dots;
+
+/* 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 */
index efb53772e0ecc8e6a9c9ea4493d37c6dc55d38bf..c663c9153245feaa46827ef9c2a22e0b17e025cb 100644 (file)
@@ -2,6 +2,8 @@
 #include "string.h"
 #include "strfilter.h"
 
+#include "sane_ctype.h"
+
 /* Operators */
 static const char *OP_and      = "&";  /* Logical AND */
 static const char *OP_or       = "|";  /* Logical OR */
index e8feb142c9c9c660722cb154e32bae1d19ec3fed..e716a6e5bb19cf37aed1e421c30b08926735494e 100644 (file)
@@ -1,6 +1,8 @@
 #include "util.h"
 #include "linux/string.h"
 
+#include "sane_ctype.h"
+
 #define K 1024LL
 /*
  * perf_atoll()
index d1a40bb642ff6ca95467edb0ddb7309c48eedd72..e7ee47f7377ab17bbb414be4240cf01565ae863a 100644 (file)
@@ -10,8 +10,9 @@
 #include "demangle-rust.h"
 #include "machine.h"
 #include "vdso.h"
-#include <symbol/kallsyms.h>
 #include "debug.h"
+#include "sane_ctype.h"
+#include <symbol/kallsyms.h>
 
 #ifndef EM_AARCH64
 #define EM_AARCH64     183  /* ARM 64 bit */
index 619e3eb44c50a91657255016743ebce96976d21f..68f14d770083b724f137af1f43bc3af4d3ddccfb 100644 (file)
@@ -19,6 +19,7 @@
 #include "strlist.h"
 #include "intlist.h"
 #include "header.h"
+#include "sane_ctype.h"
 
 #include <elf.h>
 #include <limits.h>
index de0078e21408149fcf1105e357a3d829343233ff..746bbee645d98a69e3edabb73d92dd9a87da7422 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #include <errno.h>
 
 #include "../perf.h"
 #include "util.h"
 #include "trace-event.h"
 
+#include "sane_ctype.h"
+
 static int get_common_field(struct scripting_context *context,
                            int *offset, int *size, const char *type)
 {
index 524bd3b9d98d426f0aaedce737091630a7b649d9..717541e72999a7660d0371fe10bf7a3b8cb4f26d 100644 (file)
@@ -21,6 +21,8 @@
 #include "callchain.h"
 #include "strlist.h"
 
+#include "sane_ctype.h"
+
 #define CALLCHAIN_PARAM_DEFAULT                        \
        .mode           = CHAIN_GRAPH_ABS,      \
        .min_percent    = 0.5,                  \
index f26666d77677f9ef43110c60e9a61f7860d903bb..f7e1ead50f4726e59be629587bb085dff4bdfa7b 100644 (file)
 #include <termios.h>
 #include "strlist.h"
 
-extern const char *graph_line;
-extern const char *graph_dotted_line;
-extern const char *spaces;
-extern const char *dots;
 extern char buildid_dir[];
 
 #ifdef __GNUC__
@@ -94,48 +90,6 @@ static inline void *zalloc(size_t size)
 
 #define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
 
-/* 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;
-}
-
 int mkdir_p(char *path, mode_t mode);
 int rm_rf(const char *path);
 struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *));