diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-17 15:30:00 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-17 15:30:00 -0300 |
commit | c100edbee8dbf033ec4095a976a74c1c75c9fc1d (patch) | |
tree | ff4d16bfe5fb31c78e78fb6f99a297000ee07353 /tools/perf/util/parse-options.c | |
parent | dc4ff19341126155c5714119396efbae62ab40bf (diff) | |
download | talos-obmc-linux-c100edbee8dbf033ec4095a976a74c1c75c9fc1d.tar.gz talos-obmc-linux-c100edbee8dbf033ec4095a976a74c1c75c9fc1d.zip |
perf options: Introduce OPT_UINTEGER
For unsigned int options to be parsed, next patches will make use of it.
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.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c index b05d51df2ce7..36d955e49422 100644 --- a/tools/perf/util/parse-options.c +++ b/tools/perf/util/parse-options.c @@ -59,6 +59,7 @@ static int get_value(struct parse_opt_ctx_t *p, case OPTION_GROUP: case OPTION_STRING: case OPTION_INTEGER: + case OPTION_UINTEGER: case OPTION_LONG: case OPTION_U64: default: @@ -126,6 +127,22 @@ static int get_value(struct parse_opt_ctx_t *p, return opterror(opt, "expects a numerical value", flags); return 0; + case OPTION_UINTEGER: + if (unset) { + *(unsigned int *)opt->value = 0; + return 0; + } + if (opt->flags & PARSE_OPT_OPTARG && !p->opt) { + *(unsigned int *)opt->value = opt->defval; + return 0; + } + if (get_arg(p, opt, flags, &arg)) + return -1; + *(unsigned int *)opt->value = strtol(arg, (char **)&s, 10); + if (*s) + return opterror(opt, "expects a numerical value", flags); + return 0; + case OPTION_LONG: if (unset) { *(long *)opt->value = 0; @@ -463,7 +480,10 @@ int usage_with_options_internal(const char * const *usagestr, switch (opts->type) { case OPTION_ARGUMENT: break; + case OPTION_LONG: + case OPTION_U64: case OPTION_INTEGER: + case OPTION_UINTEGER: if (opts->flags & PARSE_OPT_OPTARG) if (opts->long_name) pos += fprintf(stderr, "[=<n>]"); @@ -503,8 +523,6 @@ int usage_with_options_internal(const char * const *usagestr, case OPTION_INCR: case OPTION_SET_INT: case OPTION_SET_PTR: - case OPTION_LONG: - case OPTION_U64: break; } |