perf trace: Generalize the syscall_fmt find routines
To allow them to be used with other stuff, such as tracepoints. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-od3gzg77ppqgnnrxqv40fvgx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
9b2036cd32
commit
bcddbfc5c8
|
@ -966,22 +966,33 @@ static int syscall_fmt__cmp(const void *name, const void *fmtp)
|
|||
return strcmp(name, fmt->name);
|
||||
}
|
||||
|
||||
static struct syscall_fmt *__syscall_fmt__find(struct syscall_fmt *fmts, const int nmemb, const char *name)
|
||||
{
|
||||
return bsearch(name, fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp);
|
||||
}
|
||||
|
||||
static struct syscall_fmt *syscall_fmt__find(const char *name)
|
||||
{
|
||||
const int nmemb = ARRAY_SIZE(syscall_fmts);
|
||||
return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp);
|
||||
return __syscall_fmt__find(syscall_fmts, nmemb, name);
|
||||
}
|
||||
|
||||
static struct syscall_fmt *__syscall_fmt__find_by_alias(struct syscall_fmt *fmts, const int nmemb, const char *alias)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nmemb; ++i) {
|
||||
if (fmts[i].alias && strcmp(fmts[i].alias, alias) == 0)
|
||||
return &fmts[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias)
|
||||
{
|
||||
int i, nmemb = ARRAY_SIZE(syscall_fmts);
|
||||
|
||||
for (i = 0; i < nmemb; ++i) {
|
||||
if (syscall_fmts[i].alias && strcmp(syscall_fmts[i].alias, alias) == 0)
|
||||
return &syscall_fmts[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
const int nmemb = ARRAY_SIZE(syscall_fmts);
|
||||
return __syscall_fmt__find_by_alias(syscall_fmts, nmemb, alias);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue