summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-options.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-17 12:16:48 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-17 12:16:48 -0300
commit6ba85cea872954a36d79e46bf6a9c6ea92794f01 (patch)
tree0831a7adc633ff0e493b53beb088cf91b827d5c6 /tools/perf/util/parse-options.c
parenta9a4ab747e2d45bf08fddbc1568f080091486af9 (diff)
perf options: Introduce OPT_U64
We have things like user_interval (-c/--count) in 'perf record' that needs this. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-options.c')
-rw-r--r--tools/perf/util/parse-options.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index ed887642460..b05d51df2ce 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -60,6 +60,7 @@ static int get_value(struct parse_opt_ctx_t *p,
case OPTION_STRING:
case OPTION_INTEGER:
case OPTION_LONG:
+ case OPTION_U64:
default:
break;
}
@@ -141,6 +142,22 @@ static int get_value(struct parse_opt_ctx_t *p,
return opterror(opt, "expects a numerical value", flags);
return 0;
+ case OPTION_U64:
+ if (unset) {
+ *(u64 *)opt->value = 0;
+ return 0;
+ }
+ if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
+ *(u64 *)opt->value = opt->defval;
+ return 0;
+ }
+ if (get_arg(p, opt, flags, &arg))
+ return -1;
+ *(u64 *)opt->value = strtoull(arg, (char **)&s, 10);
+ if (*s)
+ return opterror(opt, "expects a numerical value", flags);
+ return 0;
+
case OPTION_END:
case OPTION_ARGUMENT:
case OPTION_GROUP:
@@ -487,6 +504,7 @@ int usage_with_options_internal(const char * const *usagestr,
case OPTION_SET_INT:
case OPTION_SET_PTR:
case OPTION_LONG:
+ case OPTION_U64:
break;
}