Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+39 -25
+3 -25
tools/include/linux/kernel.h
··· 2 2 #define __TOOLS_LINUX_KERNEL_H 3 3 4 4 #include <stdarg.h> 5 - #include <stdio.h> 6 - #include <stdlib.h> 5 + #include <stddef.h> 7 6 #include <assert.h> 8 7 9 8 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) ··· 69 70 #define cpu_to_le64(x) (x) 70 71 #define cpu_to_le32(x) (x) 71 72 72 - static inline int 73 - vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 74 - { 75 - int i; 76 - ssize_t ssize = size; 77 - 78 - i = vsnprintf(buf, size, fmt, args); 79 - 80 - return (i >= ssize) ? (ssize - 1) : i; 81 - } 82 - 83 - static inline int scnprintf(char * buf, size_t size, const char * fmt, ...) 84 - { 85 - va_list args; 86 - ssize_t ssize = size; 87 - int i; 88 - 89 - va_start(args, fmt); 90 - i = vsnprintf(buf, size, fmt, args); 91 - va_end(args); 92 - 93 - return (i >= ssize) ? (ssize - 1) : i; 94 - } 73 + int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); 74 + int scnprintf(char * buf, size_t size, const char * fmt, ...); 95 75 96 76 /* 97 77 * This looks more complex than it should be. But we need to
+24
tools/lib/vsprintf.c
··· 1 + #include <sys/types.h> 2 + #include <linux/kernel.h> 3 + #include <stdio.h> 4 + 5 + int 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 + 13 + int 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 + }
+1
tools/objtool/builtin-check.c
··· 26 26 */ 27 27 28 28 #include <string.h> 29 + #include <stdlib.h> 29 30 #include <subcmd/parse-options.h> 30 31 31 32 #include "builtin.h"
+1
tools/perf/MANIFEST
··· 30 30 tools/lib/find_bit.c 31 31 tools/lib/bitmap.c 32 32 tools/lib/str_error_r.c 33 + tools/lib/vsprintf.c 33 34 tools/include/asm/atomic.h 34 35 tools/include/asm/barrier.h 35 36 tools/include/asm/bug.h
+5
tools/perf/util/Build
··· 85 85 libperf-y += term.o 86 86 libperf-y += help-unknown-cmd.o 87 87 libperf-y += mem-events.o 88 + libperf-y += vsprintf.o 88 89 89 90 libperf-$(CONFIG_LIBBPF) += bpf-loader.o 90 91 libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o ··· 180 179 $(call if_changed_dep,cc_o_c) 181 180 182 181 $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE 182 + $(call rule_mkdir) 183 + $(call if_changed_dep,cc_o_c) 184 + 185 + $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE 183 186 $(call rule_mkdir) 184 187 $(call if_changed_dep,cc_o_c)
+2
tools/perf/util/color.c
··· 1 1 #include <linux/kernel.h> 2 2 #include "cache.h" 3 3 #include "config.h" 4 + #include <stdlib.h> 5 + #include <stdio.h> 4 6 #include "color.h" 5 7 #include <math.h> 6 8 #include <unistd.h>
+1
tools/perf/util/dso.h
··· 4 4 #include <linux/atomic.h> 5 5 #include <linux/types.h> 6 6 #include <linux/rbtree.h> 7 + #include <sys/types.h> 7 8 #include <stdbool.h> 8 9 #include <pthread.h> 9 10 #include <linux/types.h>
+1
tools/perf/util/help-unknown-cmd.c
··· 1 1 #include "cache.h" 2 2 #include "config.h" 3 + #include <stdio.h> 3 4 #include <subcmd/help.h> 4 5 #include "../builtin.h" 5 6 #include "levenshtein.h"
+1
tools/perf/util/python-ext-sources
··· 14 14 ../lib/find_bit.c 15 15 ../lib/hweight.c 16 16 ../lib/str_error_r.c 17 + ../lib/vsprintf.c 17 18 util/thread_map.c 18 19 util/util.c 19 20 util/xyarray.c