Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0761e37 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Uninline scnprintf() and vscnprint()

They were in tools/include/linux/kernel.h, requiring that it in turn
included stdio.h, which is way too heavy.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-855h8olnkot9v0dajuee1lo3@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5496bc0c
Loading
Loading
Loading
Loading
+3 −25
Original line number Diff line number Diff line
@@ -2,8 +2,7 @@
#define __TOOLS_LINUX_KERNEL_H

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>

#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
@@ -70,29 +69,8 @@
#define cpu_to_le64(x)	(x)
#define cpu_to_le32(x)	(x)

static inline int
vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
	int i;
	ssize_t ssize = size;

	i = vsnprintf(buf, size, fmt, args);

	return (i >= ssize) ? (ssize - 1) : i;
}

static inline int scnprintf(char * buf, size_t size, const char * fmt, ...)
{
	va_list args;
	ssize_t ssize = size;
	int i;

	va_start(args, fmt);
	i = vsnprintf(buf, size, fmt, args);
	va_end(args);

	return (i >= ssize) ? (ssize - 1) : i;
}
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
int scnprintf(char * buf, size_t size, const char * fmt, ...);

/*
 * This looks more complex than it should be. But we need to

tools/lib/vsprintf.c

0 → 100644
+24 −0
Original line number Diff line number Diff line
#include <sys/types.h>
#include <linux/kernel.h>
#include <stdio.h>

int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
       int i = vsnprintf(buf, size, fmt, args);
       ssize_t ssize = size;

       return (i >= ssize) ? (ssize - 1) : i;
}

int scnprintf(char * buf, size_t size, const char * fmt, ...)
{
       ssize_t ssize = size;
       va_list args;
       int i;

       va_start(args, fmt);
       i = vsnprintf(buf, size, fmt, args);
       va_end(args);

       return (i >= ssize) ? (ssize - 1) : i;
}
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
 */

#include <string.h>
#include <stdlib.h>
#include <subcmd/parse-options.h>

#include "builtin.h"
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ tools/lib/symbol/kallsyms.h
tools/lib/find_bit.c
tools/lib/bitmap.c
tools/lib/str_error_r.c
tools/lib/vsprintf.c
tools/include/asm/atomic.h
tools/include/asm/barrier.h
tools/include/asm/bug.h
+5 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ libperf-y += parse-regs-options.o
libperf-y += term.o
libperf-y += help-unknown-cmd.o
libperf-y += mem-events.o
libperf-y += vsprintf.o

libperf-$(CONFIG_LIBBPF) += bpf-loader.o
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
@@ -181,3 +182,7 @@ $(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE
$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
	$(call rule_mkdir)
	$(call if_changed_dep,cc_o_c)

$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
	$(call rule_mkdir)
	$(call if_changed_dep,cc_o_c)
Loading