1 // SPDX-License-Identifier: GPL-2.0-only 2 3 #define __printf(a, b) __attribute__((format(printf, a, b))) 4 5 #include <stdio.h> 6 #include <stdarg.h> 7 #include <unistd.h> 8 #include <linux/compiler.h> 9 #include <perf/core.h> 10 #include <internal/lib.h> 11 #include "internal.h" 12 13 static int __base_pr(enum libperf_print_level level __maybe_unused, const char *format, 14 va_list args) 15 { 16 return vfprintf(stderr, format, args); 17 } 18 19 static libperf_print_fn_t __libperf_pr = __base_pr; 20 21 __printf(2, 3) 22 void libperf_print(enum libperf_print_level level, const char *format, ...) 23 { 24 va_list args; 25 26 if (!__libperf_pr) 27 return; 28 29 va_start(args, format); 30 __libperf_pr(level, format, args); 31 va_end(args); 32 } 33 34 void libperf_init(libperf_print_fn_t fn) 35 { 36 page_size = sysconf(_SC_PAGE_SIZE); 37 __libperf_pr = fn; 38 } 39
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.