Re: [PATCH 14/18] perf tools: Add perf_config_u64 function
On Fri, Jun 27, 2014 at 05:08:03PM -0600, David Ahern wrote: > On 6/18/14, 8:58 AM, Jiri Olsa wrote: > > >@@ -307,6 +322,15 @@ static void die_bad_config(const char *name) > > die("bad config value for '%s'", name); > > } > > > >+u64 perf_config_u64(const char *name, const char *value) > >+{ > >+long long ret = 0; > >+ > >+if (!perf_parse_llong(value, )) > >+die_bad_config(name); > >+return (u64) ret; > > > Thought we were not using the die functions any longer? seem like patchset removing that for config object will prepare separate change jirka -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 14/18] perf tools: Add perf_config_u64 function
On Fri, Jun 27, 2014 at 05:08:03PM -0600, David Ahern wrote: On 6/18/14, 8:58 AM, Jiri Olsa wrote: @@ -307,6 +322,15 @@ static void die_bad_config(const char *name) die(bad config value for '%s', name); } +u64 perf_config_u64(const char *name, const char *value) +{ +long long ret = 0; + +if (!perf_parse_llong(value, ret)) +die_bad_config(name); +return (u64) ret; Thought we were not using the die functions any longer? seem like patchset removing that for config object will prepare separate change jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 14/18] perf tools: Add perf_config_u64 function
On 6/18/14, 8:58 AM, Jiri Olsa wrote: @@ -307,6 +322,15 @@ static void die_bad_config(const char *name) die("bad config value for '%s'", name); } +u64 perf_config_u64(const char *name, const char *value) +{ + long long ret = 0; + + if (!perf_parse_llong(value, )) + die_bad_config(name); + return (u64) ret; Thought we were not using the die functions any longer? David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 14/18] perf tools: Add perf_config_u64 function
On 6/18/14, 8:58 AM, Jiri Olsa wrote: @@ -307,6 +322,15 @@ static void die_bad_config(const char *name) die(bad config value for '%s', name); } +u64 perf_config_u64(const char *name, const char *value) +{ + long long ret = 0; + + if (!perf_parse_llong(value, ret)) + die_bad_config(name); + return (u64) ret; Thought we were not using the die functions any longer? David -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/18] perf tools: Add perf_config_u64 function
From: Jiri Olsa Adding perf_config_u64 function to be able to parse 'llong' values out of config file. Cc: Arnaldo Carvalho de Melo Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jean Pihet Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Signed-off-by: Jiri Olsa --- tools/perf/util/cache.h | 1 + tools/perf/util/config.c | 24 2 files changed, 25 insertions(+) diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 7b176dd..5cf9e1b 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h @@ -22,6 +22,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *); extern int perf_default_config(const char *, const char *, void *); extern int perf_config(config_fn_t fn, void *); extern int perf_config_int(const char *, const char *); +extern u64 perf_config_u64(const char *, const char *); extern int perf_config_bool(const char *, const char *); extern int config_error_nonbool(const char *); extern const char *perf_config_dirname(const char *, const char *); diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 24519e1..27ad81c 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -286,6 +286,21 @@ static int parse_unit_factor(const char *end, unsigned long *val) return 0; } +static int perf_parse_llong(const char *value, long long *ret) +{ + if (value && *value) { + char *end; + long long val = strtoll(value, , 0); + unsigned long factor = 1; + + if (!parse_unit_factor(end, )) + return 0; + *ret = val * factor; + return 1; + } + return 0; +} + static int perf_parse_long(const char *value, long *ret) { if (value && *value) { @@ -307,6 +322,15 @@ static void die_bad_config(const char *name) die("bad config value for '%s'", name); } +u64 perf_config_u64(const char *name, const char *value) +{ + long long ret = 0; + + if (!perf_parse_llong(value, )) + die_bad_config(name); + return (u64) ret; +} + int perf_config_int(const char *name, const char *value) { long ret = 0; -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/18] perf tools: Add perf_config_u64 function
From: Jiri Olsa jo...@redhat.com Adding perf_config_u64 function to be able to parse 'llong' values out of config file. Cc: Arnaldo Carvalho de Melo a...@kernel.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: David Ahern dsah...@gmail.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@kernel.org Cc: Jean Pihet jean.pi...@linaro.org Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@kernel.org --- tools/perf/util/cache.h | 1 + tools/perf/util/config.c | 24 2 files changed, 25 insertions(+) diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 7b176dd..5cf9e1b 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h @@ -22,6 +22,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *); extern int perf_default_config(const char *, const char *, void *); extern int perf_config(config_fn_t fn, void *); extern int perf_config_int(const char *, const char *); +extern u64 perf_config_u64(const char *, const char *); extern int perf_config_bool(const char *, const char *); extern int config_error_nonbool(const char *); extern const char *perf_config_dirname(const char *, const char *); diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 24519e1..27ad81c 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -286,6 +286,21 @@ static int parse_unit_factor(const char *end, unsigned long *val) return 0; } +static int perf_parse_llong(const char *value, long long *ret) +{ + if (value *value) { + char *end; + long long val = strtoll(value, end, 0); + unsigned long factor = 1; + + if (!parse_unit_factor(end, factor)) + return 0; + *ret = val * factor; + return 1; + } + return 0; +} + static int perf_parse_long(const char *value, long *ret) { if (value *value) { @@ -307,6 +322,15 @@ static void die_bad_config(const char *name) die(bad config value for '%s', name); } +u64 perf_config_u64(const char *name, const char *value) +{ + long long ret = 0; + + if (!perf_parse_llong(value, ret)) + die_bad_config(name); + return (u64) ret; +} + int perf_config_int(const char *name, const char *value) { long ret = 0; -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/