aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-07-07 14:42:33 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 14:20:24 -0400
commitd0761e37fe3fed7810ed8d6e130b79359f0c3e13 (patch)
treedec9e6cc9008a1b80856cbc1ec1897dce975776c
parent5496bc0c0d255f2a8a3a4c36087eb3b72ff63ea0 (diff)
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: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/include/linux/kernel.h28
-rw-r--r--tools/lib/vsprintf.c24
-rw-r--r--tools/objtool/builtin-check.c1
-rw-r--r--tools/perf/MANIFEST1
-rw-r--r--tools/perf/util/Build5
-rw-r--r--tools/perf/util/color.c2
-rw-r--r--tools/perf/util/dso.h1
-rw-r--r--tools/perf/util/help-unknown-cmd.c1
-rw-r--r--tools/perf/util/python-ext-sources1
9 files changed, 39 insertions, 25 deletions
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 76df53539c2a..28607db02bd3 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -2,8 +2,7 @@
2#define __TOOLS_LINUX_KERNEL_H 2#define __TOOLS_LINUX_KERNEL_H
3 3
4#include <stdarg.h> 4#include <stdarg.h>
5#include <stdio.h> 5#include <stddef.h>
6#include <stdlib.h>
7#include <assert.h> 6#include <assert.h>
8 7
9#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 8#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
@@ -70,29 +69,8 @@
70#define cpu_to_le64(x) (x) 69#define cpu_to_le64(x) (x)
71#define cpu_to_le32(x) (x) 70#define cpu_to_le32(x) (x)
72 71
73static inline int 72int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
74vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 73int scnprintf(char * buf, size_t size, const char * fmt, ...);
75{
76 int i;
77 ssize_t ssize = size;
78
79 i = vsnprintf(buf, size, fmt, args);
80
81 return (i >= ssize) ? (ssize - 1) : i;
82}
83
84static inline int scnprintf(char * buf, size_t size, const char * fmt, ...)
85{
86 va_list args;
87 ssize_t ssize = size;
88 int i;
89
90 va_start(args, fmt);
91 i = vsnprintf(buf, size, fmt, args);
92 va_end(args);
93
94 return (i >= ssize) ? (ssize - 1) : i;
95}
96 74
97/* 75/*
98 * This looks more complex than it should be. But we need to 76 * This looks more complex than it should be. But we need to
diff --git a/tools/lib/vsprintf.c b/tools/lib/vsprintf.c
new file mode 100644
index 000000000000..45f9a06daa56
--- /dev/null
+++ b/tools/lib/vsprintf.c
@@ -0,0 +1,24 @@
1#include <sys/types.h>
2#include <linux/kernel.h>
3#include <stdio.h>
4
5int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
6{
7 int i = vsnprintf(buf, size, fmt, args);
8 ssize_t ssize = size;
9
10 return (i >= ssize) ? (ssize - 1) : i;
11}
12
13int scnprintf(char * buf, size_t size, const char * fmt, ...)
14{
15 ssize_t ssize = size;
16 va_list args;
17 int i;
18
19 va_start(args, fmt);
20 i = vsnprintf(buf, size, fmt, args);
21 va_end(args);
22
23 return (i >= ssize) ? (ssize - 1) : i;
24}
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index e8a1e69eb92c..92d84b277032 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <string.h> 28#include <string.h>
29#include <stdlib.h>
29#include <subcmd/parse-options.h> 30#include <subcmd/parse-options.h>
30 31
31#include "builtin.h" 32#include "builtin.h"
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index f18e781447bc..2bd8c310606c 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -30,6 +30,7 @@ tools/lib/symbol/kallsyms.h
30tools/lib/find_bit.c 30tools/lib/find_bit.c
31tools/lib/bitmap.c 31tools/lib/bitmap.c
32tools/lib/str_error_r.c 32tools/lib/str_error_r.c
33tools/lib/vsprintf.c
33tools/include/asm/atomic.h 34tools/include/asm/atomic.h
34tools/include/asm/barrier.h 35tools/include/asm/barrier.h
35tools/include/asm/bug.h 36tools/include/asm/bug.h
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index a6a805302312..eda68f582884 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -85,6 +85,7 @@ libperf-y += parse-regs-options.o
85libperf-y += term.o 85libperf-y += term.o
86libperf-y += help-unknown-cmd.o 86libperf-y += help-unknown-cmd.o
87libperf-y += mem-events.o 87libperf-y += mem-events.o
88libperf-y += vsprintf.o
88 89
89libperf-$(CONFIG_LIBBPF) += bpf-loader.o 90libperf-$(CONFIG_LIBBPF) += bpf-loader.o
90libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o 91libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
@@ -181,3 +182,7 @@ $(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE
181$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE 182$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
182 $(call rule_mkdir) 183 $(call rule_mkdir)
183 $(call if_changed_dep,cc_o_c) 184 $(call if_changed_dep,cc_o_c)
185
186$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
187 $(call rule_mkdir)
188 $(call if_changed_dep,cc_o_c)
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 47a34b561f5d..dbbf89b050a5 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -1,6 +1,8 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include "cache.h" 2#include "cache.h"
3#include "config.h" 3#include "config.h"
4#include <stdlib.h>
5#include <stdio.h>
4#include "color.h" 6#include "color.h"
5#include <math.h> 7#include <math.h>
6#include <unistd.h> 8#include <unistd.h>
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a571f24895ca..ecc4bbd3f82e 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -4,6 +4,7 @@
4#include <linux/atomic.h> 4#include <linux/atomic.h>
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/rbtree.h> 6#include <linux/rbtree.h>
7#include <sys/types.h>
7#include <stdbool.h> 8#include <stdbool.h>
8#include <pthread.h> 9#include <pthread.h>
9#include <linux/types.h> 10#include <linux/types.h>
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index 776e28562345..2821f8d77e52 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -1,5 +1,6 @@
1#include "cache.h" 1#include "cache.h"
2#include "config.h" 2#include "config.h"
3#include <stdio.h>
3#include <subcmd/help.h> 4#include <subcmd/help.h>
4#include "../builtin.h" 5#include "../builtin.h"
5#include "levenshtein.h" 6#include "levenshtein.h"
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 49210b7a7925..5065ec98049c 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -14,6 +14,7 @@ util/cpumap.c
14../lib/find_bit.c 14../lib/find_bit.c
15../lib/hweight.c 15../lib/hweight.c
16../lib/str_error_r.c 16../lib/str_error_r.c
17../lib/vsprintf.c
17util/thread_map.c 18util/thread_map.c
18util/util.c 19util/util.c
19util/xyarray.c 20util/xyarray.c