mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-02 02:34:05 +08:00
428dab813a
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 <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lore.kernel.org/lkml/20190913132355.21634-34-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
38 lines
749 B
C
38 lines
749 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#define __printf(a, b) __attribute__((format(printf, a, b)))
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <unistd.h>
|
|
#include <perf/core.h>
|
|
#include <internal/lib.h>
|
|
#include "internal.h"
|
|
|
|
static int __base_pr(enum libperf_print_level level, const char *format,
|
|
va_list args)
|
|
{
|
|
return vfprintf(stderr, format, args);
|
|
}
|
|
|
|
static libperf_print_fn_t __libperf_pr = __base_pr;
|
|
|
|
__printf(2, 3)
|
|
void libperf_print(enum libperf_print_level level, const char *format, ...)
|
|
{
|
|
va_list args;
|
|
|
|
if (!__libperf_pr)
|
|
return;
|
|
|
|
va_start(args, format);
|
|
__libperf_pr(level, format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
void libperf_init(libperf_print_fn_t fn)
|
|
{
|
|
page_size = sysconf(_SC_PAGE_SIZE);
|
|
__libperf_pr = fn;
|
|
}
|