mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
perf tools: Move extra string util functions to util/string2.h
Moving them from util.h, where they don't belong. Since libc already have string.h, name it slightly differently, as string2.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-eh3vz5sqxsrdd8lodoro4jrw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
632a5cabea
commit
a067558e2f
@ -12,6 +12,7 @@
|
||||
#include <subcmd/parse-options.h>
|
||||
#include "../util/header.h"
|
||||
#include "../util/cloexec.h"
|
||||
#include "../util/string2.h"
|
||||
#include "bench.h"
|
||||
#include "mem-memcpy-arch.h"
|
||||
#include "mem-memset-arch.h"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "util/cpumap.h"
|
||||
#include "util/thread_map.h"
|
||||
#include "util/stat.h"
|
||||
#include "util/string2.h"
|
||||
#include "util/thread-stack.h"
|
||||
#include "util/time-utils.h"
|
||||
#include "print_binary.h"
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "util/session.h"
|
||||
#include "util/tool.h"
|
||||
#include "util/group.h"
|
||||
#include "util/string2.h"
|
||||
#include "asm/bug.h"
|
||||
|
||||
#include <linux/time64.h>
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "util/bpf-loader.h"
|
||||
#include "callchain.h"
|
||||
#include "print_binary.h"
|
||||
#include "string2.h"
|
||||
#include "syscalltbl.h"
|
||||
#include "rb_resort.h"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "../util.h"
|
||||
#include "../string2.h"
|
||||
#include "../config.h"
|
||||
#include "../../perf.h"
|
||||
#include "libslang.h"
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "map.h"
|
||||
#include "annotate.h"
|
||||
#include "srcline.h"
|
||||
#include "string2.h"
|
||||
|
||||
#include "sane_ctype.h"
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "../sort.h"
|
||||
#include "../hist.h"
|
||||
#include "../helpline.h"
|
||||
#include "../string2.h"
|
||||
#include "gtk.h"
|
||||
|
||||
#define MAX_COLUMNS 32
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "../../util/sort.h"
|
||||
#include "../../util/evsel.h"
|
||||
#include "../../util/srcline.h"
|
||||
#include "../../util/string2.h"
|
||||
#include "../../util/sane_ctype.h"
|
||||
|
||||
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "annotate.h"
|
||||
#include "evsel.h"
|
||||
#include "block-range.h"
|
||||
#include "string2.h"
|
||||
#include "arch/common.h"
|
||||
#include <regex.h>
|
||||
#include <pthread.h>
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "auxtrace.h"
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
#include "string2.h"
|
||||
#include "vdso.h"
|
||||
|
||||
static const char * const debuglink_paths[] = {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
#include "dwarf-aux.h"
|
||||
#include "string2.h"
|
||||
|
||||
/**
|
||||
* cu_find_realpath - Find the realpath of the target file
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "hist.h"
|
||||
#include "machine.h"
|
||||
#include "sort.h"
|
||||
#include "string.h"
|
||||
#include "string2.h"
|
||||
#include "strlist.h"
|
||||
#include "thread.h"
|
||||
#include "thread_map.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <inttypes.h>
|
||||
#include "util.h"
|
||||
#include "string2.h"
|
||||
#include <sys/types.h>
|
||||
#include <byteswap.h>
|
||||
#include <unistd.h>
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <subcmd/parse-options.h>
|
||||
#include "parse-events.h"
|
||||
#include <subcmd/exec-cmd.h>
|
||||
#include "string.h"
|
||||
#include "string2.h"
|
||||
#include "symbol.h"
|
||||
#include "cache.h"
|
||||
#include "header.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "header.h"
|
||||
#include "pmu-events/pmu-events.h"
|
||||
#include "cache.h"
|
||||
#include "string2.h"
|
||||
|
||||
struct perf_pmu_format {
|
||||
char *name;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "probe-finder.h"
|
||||
#include "probe-file.h"
|
||||
#include "session.h"
|
||||
#include "string2.h"
|
||||
|
||||
#include "sane_ctype.h"
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "probe-file.h"
|
||||
#include "session.h"
|
||||
#include "perf_regs.h"
|
||||
#include "string2.h"
|
||||
|
||||
/* 4096 - 2 ('\n' + '\0') */
|
||||
#define MAX_CMDLEN 4094
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "symbol.h"
|
||||
#include "probe-finder.h"
|
||||
#include "probe-file.h"
|
||||
#include "string2.h"
|
||||
|
||||
/* Kprobe tracer basic type is up to u64 */
|
||||
#define MAX_BASIC_TYPE_BITS 64
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "string2.h"
|
||||
#include "strfilter.h"
|
||||
|
||||
#include "sane_ctype.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "util.h"
|
||||
#include "linux/string.h"
|
||||
#include "string2.h"
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sane_ctype.h"
|
||||
|
||||
@ -101,8 +103,10 @@ static int count_argc(const char *str)
|
||||
void argv_free(char **argv)
|
||||
{
|
||||
char **p;
|
||||
for (p = argv; *p; p++)
|
||||
zfree(p);
|
||||
for (p = argv; *p; p++) {
|
||||
free(*p);
|
||||
*p = NULL;
|
||||
}
|
||||
|
||||
free(argv);
|
||||
}
|
||||
@ -122,7 +126,7 @@ void argv_free(char **argv)
|
||||
char **argv_split(const char *str, int *argcp)
|
||||
{
|
||||
int argc = count_argc(str);
|
||||
char **argv = zalloc(sizeof(*argv) * (argc+1));
|
||||
char **argv = calloc(argc + 1, sizeof(*argv));
|
||||
char **argvp;
|
||||
|
||||
if (argv == NULL)
|
||||
@ -379,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints
|
||||
goto out_err_overflow;
|
||||
|
||||
if (i > 0)
|
||||
printed += snprintf(e + printed, size - printed, " %s ", or_and);
|
||||
printed += scnprintf(e + printed, size - printed, " %s ", or_and);
|
||||
printed += scnprintf(e + printed, size - printed,
|
||||
"%s %s %d", var, eq_neq, ints[i]);
|
||||
}
|
||||
|
42
tools/perf/util/string2.h
Normal file
42
tools/perf/util/string2.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef PERF_STRING_H
|
||||
#define PERF_STRING_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
s64 perf_atoll(const char *str);
|
||||
char **argv_split(const char *str, int *argcp);
|
||||
void argv_free(char **argv);
|
||||
bool strglobmatch(const char *str, const char *pat);
|
||||
bool strglobmatch_nocase(const char *str, const char *pat);
|
||||
bool strlazymatch(const char *str, const char *pat);
|
||||
static inline bool strisglob(const char *str)
|
||||
{
|
||||
return strpbrk(str, "*?[") != NULL;
|
||||
}
|
||||
int strtailcmp(const char *s1, const char *s2);
|
||||
char *strxfrchar(char *s, char from, char to);
|
||||
|
||||
char *ltrim(char *s);
|
||||
char *rtrim(char *s);
|
||||
|
||||
static inline char *trim(char *s)
|
||||
{
|
||||
return ltrim(rtrim(s));
|
||||
}
|
||||
|
||||
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
|
||||
|
||||
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
|
||||
{
|
||||
return asprintf_expr_inout_ints(var, true, nints, ints);
|
||||
}
|
||||
|
||||
static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
|
||||
{
|
||||
return asprintf_expr_inout_ints(var, false, nints, ints);
|
||||
}
|
||||
|
||||
|
||||
#endif /* PERF_STRING_H */
|
@ -6,6 +6,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "string2.h"
|
||||
#include "strlist.h"
|
||||
#include <string.h>
|
||||
#include <api/fs/fs.h>
|
||||
|
@ -98,18 +98,6 @@ int copyfile(const char *from, const char *to);
|
||||
int copyfile_mode(const char *from, const char *to, mode_t mode);
|
||||
int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
|
||||
|
||||
s64 perf_atoll(const char *str);
|
||||
char **argv_split(const char *str, int *argcp);
|
||||
void argv_free(char **argv);
|
||||
bool strglobmatch(const char *str, const char *pat);
|
||||
bool strglobmatch_nocase(const char *str, const char *pat);
|
||||
bool strlazymatch(const char *str, const char *pat);
|
||||
static inline bool strisglob(const char *str)
|
||||
{
|
||||
return strpbrk(str, "*?[") != NULL;
|
||||
}
|
||||
int strtailcmp(const char *s1, const char *s2);
|
||||
char *strxfrchar(char *s, char from, char to);
|
||||
unsigned long convert_unit(unsigned long value, char *unit);
|
||||
ssize_t readn(int fd, void *buf, size_t n);
|
||||
ssize_t writen(int fd, void *buf, size_t n);
|
||||
@ -121,14 +109,6 @@ void event_attr_init(struct perf_event_attr *attr);
|
||||
size_t hex_width(u64 v);
|
||||
int hex2u64(const char *ptr, u64 *val);
|
||||
|
||||
char *ltrim(char *s);
|
||||
char *rtrim(char *s);
|
||||
|
||||
static inline char *trim(char *s)
|
||||
{
|
||||
return ltrim(rtrim(s));
|
||||
}
|
||||
|
||||
void dump_stack(void);
|
||||
void sighandler_dump_stack(int sig);
|
||||
|
||||
@ -175,18 +155,6 @@ int gzip_decompress_to_file(const char *input, int output_fd);
|
||||
int lzma_decompress_to_file(const char *input, int output_fd);
|
||||
#endif
|
||||
|
||||
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
|
||||
|
||||
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
|
||||
{
|
||||
return asprintf_expr_inout_ints(var, true, nints, ints);
|
||||
}
|
||||
|
||||
static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
|
||||
{
|
||||
return asprintf_expr_inout_ints(var, false, nints, ints);
|
||||
}
|
||||
|
||||
int get_stack_size(const char *str, unsigned long *_size);
|
||||
|
||||
int fetch_kernel_version(unsigned int *puint,
|
||||
|
Loading…
Reference in New Issue
Block a user