From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752846AbcGLWma (ORCPT ); Tue, 12 Jul 2016 18:42:30 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42239 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752597AbcGLWlF (ORCPT ); Tue, 12 Jul 2016 18:41:05 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Josh Poimboeuf , Namhyung Kim , Wang Nan Subject: [PATCH 28/66] perf tools: Uninline scnprintf() and vscnprint() Date: Tue, 12 Jul 2016 19:40:03 -0300 Message-Id: <1468363241-14555-29-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468363241-14555-1-git-send-email-acme@kernel.org> References: <1468363241-14555-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo They were in tools/include/linux/kernel.h, requiring that it in turn included stdio.h, which is way too heavy. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Josh Poimboeuf Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-855h8olnkot9v0dajuee1lo3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/kernel.h | 28 +++------------------------- tools/lib/vsprintf.c | 24 ++++++++++++++++++++++++ tools/objtool/builtin-check.c | 1 + tools/perf/MANIFEST | 1 + tools/perf/util/Build | 5 +++++ tools/perf/util/color.c | 2 ++ tools/perf/util/dso.h | 1 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/python-ext-sources | 1 + 9 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 tools/lib/vsprintf.c 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 @@ #define __TOOLS_LINUX_KERNEL_H #include -#include -#include +#include #include #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 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 @@ +#include +#include +#include + +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; +} 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 @@ */ #include +#include #include #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 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 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 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) 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 @@ #include #include "cache.h" #include "config.h" +#include +#include #include "color.h" #include #include 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 @@ #include #include #include +#include #include #include #include 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 @@ #include "cache.h" #include "config.h" +#include #include #include "../builtin.h" #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 ../lib/find_bit.c ../lib/hweight.c ../lib/str_error_r.c +../lib/vsprintf.c util/thread_map.c util/util.c util/xyarray.c -- 2.7.4