Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191371
b: refs/heads/master
c: 6ba85ce
h: refs/heads/master
i:
  191369: 502a6a9
  191367: be1a30b
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed May 17, 2010
1 parent da98d98 commit 5045841
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9a4ab747e2d45bf08fddbc1568f080091486af9
refs/heads/master: 6ba85cea872954a36d79e46bf6a9c6ea92794f01
18 changes: 18 additions & 0 deletions trunk/tools/perf/util/parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/parse-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum parse_opt_type {
OPTION_INTEGER,
OPTION_LONG,
OPTION_CALLBACK,
OPTION_U64,
};

enum parse_opt_flags {
Expand Down Expand Up @@ -101,6 +102,7 @@ struct option {
#define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) }
#define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
#define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
#define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
#define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) }
#define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
Expand Down

0 comments on commit 5045841

Please sign in to comment.