2019-07-21 18:24:14 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
#define __printf(a, b) __attribute__((format(printf, a, b)))
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2019-08-06 20:25:25 +07:00
|
|
|
#include <unistd.h>
|
2019-10-11 19:21:55 +07:00
|
|
|
#include <linux/compiler.h>
|
2019-07-21 18:24:14 +07:00
|
|
|
#include <perf/core.h>
|
2019-08-06 20:25:25 +07:00
|
|
|
#include <internal/lib.h>
|
2019-07-21 18:24:14 +07:00
|
|
|
#include "internal.h"
|
|
|
|
|
2019-10-11 19:21:55 +07:00
|
|
|
static int __base_pr(enum libperf_print_level level __maybe_unused, const char *format,
|
2019-07-21 18:24:14 +07:00
|
|
|
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);
|
|
|
|
}
|
2019-08-06 20:25:25 +07:00
|
|
|
|
2019-09-01 01:44:13 +07:00
|
|
|
void libperf_init(libperf_print_fn_t fn)
|
2019-08-06 20:25:25 +07:00
|
|
|
{
|
|
|
|
page_size = sysconf(_SC_PAGE_SIZE);
|
2019-09-01 01:44:13 +07:00
|
|
|
__libperf_pr = fn;
|
2019-08-06 20:25:25 +07:00
|
|
|
}
|