Skip to content

Commit

Permalink
libperf: Merge libperf_set_print() into libperf_init()
Browse files Browse the repository at this point in the history
The libperf_set_print() function needs to be called in any case so let's
merge it with libperf_init(), so we have just one init function.

Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed Sep 25, 2019
1 parent fb4bf51 commit 428dab8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 2 additions & 6 deletions tools/perf/lib/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ static int __base_pr(enum libperf_print_level level, const char *format,

static libperf_print_fn_t __libperf_pr = __base_pr;

void libperf_set_print(libperf_print_fn_t fn)
{
__libperf_pr = fn;
}

__printf(2, 3)
void libperf_print(enum libperf_print_level level, const char *format, ...)
{
Expand All @@ -35,7 +30,8 @@ void libperf_print(enum libperf_print_level level, const char *format, ...)
va_end(args);
}

void libperf_init(void)
void libperf_init(libperf_print_fn_t fn)
{
page_size = sysconf(_SC_PAGE_SIZE);
__libperf_pr = fn;
}
3 changes: 1 addition & 2 deletions tools/perf/lib/include/perf/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ enum libperf_print_level {
typedef int (*libperf_print_fn_t)(enum libperf_print_level level,
const char *, va_list ap);

LIBPERF_API void libperf_set_print(libperf_print_fn_t fn);
LIBPERF_API void libperf_init(void);
LIBPERF_API void libperf_init(libperf_print_fn_t fn);

#endif /* __LIBPERF_CORE_H */
1 change: 0 additions & 1 deletion tools/perf/lib/libperf.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
LIBPERF_0.0.1 {
global:
libperf_init;
libperf_set_print;
perf_cpu_map__dummy_new;
perf_cpu_map__get;
perf_cpu_map__put;
Expand Down
8 changes: 7 additions & 1 deletion tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ void pthread__unblock_sigwinch(void)
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
}

static int libperf_print(enum libperf_print_level level,
const char *fmt, va_list ap)
{
return eprintf(level, verbose, fmt, ap);
}

int main(int argc, const char **argv)
{
int err;
Expand All @@ -440,7 +446,7 @@ int main(int argc, const char **argv)
exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
pager_init(PERF_PAGER_ENVIRONMENT);

libperf_init();
libperf_init(libperf_print);

cmd = extract_argv0_path(argv[0]);
if (!cmd)
Expand Down

0 comments on commit 428dab8

Please sign in to comment.