diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-07 14:42:33 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-12 14:20:24 -0400 |
commit | d0761e37fe3fed7810ed8d6e130b79359f0c3e13 (patch) | |
tree | dec9e6cc9008a1b80856cbc1ec1897dce975776c /tools/lib | |
parent | 5496bc0c0d255f2a8a3a4c36087eb3b72ff63ea0 (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>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/vsprintf.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 | |||
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 | } | ||