diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-07-14 06:02:54 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-16 16:57:36 -0400 |
commit | ea8e08a16a1e6566be3f775c0bd351fa52ab6b9d (patch) | |
tree | f4698f3f65652a09c31fe20b622729dc50cbdc8d | |
parent | f6d313699a9612a30fabe05bf2c9302c1408b5cf (diff) |
perf tools: Add option macro OPT_CALLBACK_OPTARG
Add an option macro that is the same as OPT_CALLBACK except that the
argument is optional and it is possible to associate additional data
with it.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1405332185-4050-31-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/parse-options.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index d8dac8ac5f37..b59ba858e73d 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h | |||
@@ -98,6 +98,7 @@ struct option { | |||
98 | parse_opt_cb *callback; | 98 | parse_opt_cb *callback; |
99 | intptr_t defval; | 99 | intptr_t defval; |
100 | bool *set; | 100 | bool *set; |
101 | void *data; | ||
101 | }; | 102 | }; |
102 | 103 | ||
103 | #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) | 104 | #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) |
@@ -131,6 +132,10 @@ struct option { | |||
131 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\ | 132 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\ |
132 | .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\ | 133 | .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\ |
133 | .flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG} | 134 | .flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG} |
135 | #define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \ | ||
136 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \ | ||
137 | .value = (v), (a), .help = (h), .callback = (f), \ | ||
138 | .flags = PARSE_OPT_OPTARG, .data = (d) } | ||
134 | 139 | ||
135 | /* parse_options() will filter out the processed options and leave the | 140 | /* parse_options() will filter out the processed options and leave the |
136 | * non-option argments in argv[]. | 141 | * non-option argments in argv[]. |