diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/parse-options.c | 18 | ||||
-rw-r--r-- | tools/perf/util/parse-options.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c index ed887642460c..b05d51df2ce7 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, | |||
60 | case OPTION_STRING: | 60 | case OPTION_STRING: |
61 | case OPTION_INTEGER: | 61 | case OPTION_INTEGER: |
62 | case OPTION_LONG: | 62 | case OPTION_LONG: |
63 | case OPTION_U64: | ||
63 | default: | 64 | default: |
64 | break; | 65 | break; |
65 | } | 66 | } |
@@ -141,6 +142,22 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
141 | return opterror(opt, "expects a numerical value", flags); | 142 | return opterror(opt, "expects a numerical value", flags); |
142 | return 0; | 143 | return 0; |
143 | 144 | ||
145 | case OPTION_U64: | ||
146 | if (unset) { | ||
147 | *(u64 *)opt->value = 0; | ||
148 | return 0; | ||
149 | } | ||
150 | if (opt->flags & PARSE_OPT_OPTARG && !p->opt) { | ||
151 | *(u64 *)opt->value = opt->defval; | ||
152 | return 0; | ||
153 | } | ||
154 | if (get_arg(p, opt, flags, &arg)) | ||
155 | return -1; | ||
156 | *(u64 *)opt->value = strtoull(arg, (char **)&s, 10); | ||
157 | if (*s) | ||
158 | return opterror(opt, "expects a numerical value", flags); | ||
159 | return 0; | ||
160 | |||
144 | case OPTION_END: | 161 | case OPTION_END: |
145 | case OPTION_ARGUMENT: | 162 | case OPTION_ARGUMENT: |
146 | case OPTION_GROUP: | 163 | case OPTION_GROUP: |
@@ -487,6 +504,7 @@ int usage_with_options_internal(const char * const *usagestr, | |||
487 | case OPTION_SET_INT: | 504 | case OPTION_SET_INT: |
488 | case OPTION_SET_PTR: | 505 | case OPTION_SET_PTR: |
489 | case OPTION_LONG: | 506 | case OPTION_LONG: |
507 | case OPTION_U64: | ||
490 | break; | 508 | break; |
491 | } | 509 | } |
492 | 510 | ||
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index b2da725f102a..e301e96b9d17 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h | |||
@@ -17,6 +17,7 @@ enum parse_opt_type { | |||
17 | OPTION_INTEGER, | 17 | OPTION_INTEGER, |
18 | OPTION_LONG, | 18 | OPTION_LONG, |
19 | OPTION_CALLBACK, | 19 | OPTION_CALLBACK, |
20 | OPTION_U64, | ||
20 | }; | 21 | }; |
21 | 22 | ||
22 | enum parse_opt_flags { | 23 | enum parse_opt_flags { |
@@ -101,6 +102,7 @@ struct option { | |||
101 | #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) } | 102 | #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) } |
102 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 103 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
103 | #define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 104 | #define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
105 | #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | ||
104 | #define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) } | 106 | #define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) } |
105 | #define OPT_DATE(s, l, v, h) \ | 107 | #define OPT_DATE(s, l, v, h) \ |
106 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } | 108 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } |