* [RFC/PATCH 1/2] tools lib subcmd: Suppport cascading options @ 2016-10-24 3:00 Namhyung Kim 2016-10-24 3:00 ` [RFC/PATCH 2/2] perf sched: Make common options cascading Namhyung Kim 2016-10-28 17:44 ` [tip:perf/core] tools lib subcmd: Suppport cascading options tip-bot for Namhyung Kim 0 siblings, 2 replies; 7+ messages in thread From: Namhyung Kim @ 2016-10-24 3:00 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Andi Kleen, Wang Nan, Josh Poimboeuf Sometimes subcommand have common options and it can only handled in the upper level command unless it duplicates the options. This patch adds a parent field and fallback to the parent if the given argument was not found in the current options. Cc: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/lib/subcmd/parse-options.c | 14 ++++++++++++++ tools/lib/subcmd/parse-options.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 981bb4481fd5..3284bb14ae78 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -314,12 +314,19 @@ static int get_value(struct parse_opt_ctx_t *p, static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options) { +retry: for (; options->type != OPTION_END; options++) { if (options->short_name == *p->opt) { p->opt = p->opt[1] ? p->opt + 1 : NULL; return get_value(p, options, OPT_SHORT); } } + + if (options->parent) { + options = options->parent; + goto retry; + } + return -2; } @@ -333,6 +340,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, if (!arg_end) arg_end = arg + strlen(arg); +retry: for (; options->type != OPTION_END; options++) { const char *rest; int flags = 0; @@ -426,6 +434,12 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, } if (abbrev_option) return get_value(p, abbrev_option, abbrev_flags); + + if (options->parent) { + options = options->parent; + goto retry; + } + return -2; } diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h index d60cab2726da..8866ac438b34 100644 --- a/tools/lib/subcmd/parse-options.h +++ b/tools/lib/subcmd/parse-options.h @@ -109,11 +109,13 @@ struct option { intptr_t defval; bool *set; void *data; + const struct option *parent; }; #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) #define OPT_END() { .type = OPTION_END } +#define OPT_PARENT(p) { .type = OPTION_END, .parent = (p) } #define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) } #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h), .defval = (b) } -- 2.10.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC/PATCH 2/2] perf sched: Make common options cascading 2016-10-24 3:00 [RFC/PATCH 1/2] tools lib subcmd: Suppport cascading options Namhyung Kim @ 2016-10-24 3:00 ` Namhyung Kim 2016-10-24 17:03 ` Jiri Olsa 2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim 2016-10-28 17:44 ` [tip:perf/core] tools lib subcmd: Suppport cascading options tip-bot for Namhyung Kim 1 sibling, 2 replies; 7+ messages in thread From: Namhyung Kim @ 2016-10-24 3:00 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Andi Kleen, Wang Nan, Josh Poimboeuf The -i and -v options can be used in subcommands so enable cascading the sched_options. This fixes the following inconvenience in 'perf sched': $ perf sched -i perf.data.sched map ... (it works well) ... $ perf sched map -i perf.data.sched Error: unknown switch `i' Usage: perf sched map [<options>] --color-cpus <cpus> highlight given CPUs in map --color-pids <pids> highlight given pids in map --compact map output in compact mode --cpus <cpus> display given CPUs in map With this patch, the second command line works with the perf.data.sched data file. Cc: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/builtin-sched.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index f5503ca22e1c..8ca1b5409289 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1954,6 +1954,15 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) .next_shortname2 = '0', .skip_merge = 0, }; + const struct option sched_options[] = { + OPT_STRING('i', "input", &input_name, "file", + "input file name"), + OPT_INCR('v', "verbose", &verbose, + "be more verbose (show symbol address, etc)"), + OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, + "dump raw trace in ASCII"), + OPT_END() + }; const struct option latency_options[] = { OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]", "sort by key(s): runtime, switch, avg, max"), @@ -1965,7 +1974,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) "dump raw trace in ASCII"), OPT_BOOLEAN('p', "pids", &sched.skip_merge, "latency stats per pid instead of per comm"), - OPT_END() + OPT_PARENT(sched_options) }; const struct option replay_options[] = { OPT_UINTEGER('r', "repeat", &sched.replay_repeat, @@ -1975,16 +1984,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_BOOLEAN('f', "force", &sched.force, "don't complain, do it"), - OPT_END() - }; - const struct option sched_options[] = { - OPT_STRING('i', "input", &input_name, "file", - "input file name"), - OPT_INCR('v', "verbose", &verbose, - "be more verbose (show symbol address, etc)"), - OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, - "dump raw trace in ASCII"), - OPT_END() + OPT_PARENT(sched_options) }; const struct option map_options[] = { OPT_BOOLEAN(0, "compact", &sched.map.comp, @@ -1995,7 +1995,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) "highlight given CPUs in map"), OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", "display given CPUs in map"), - OPT_END() + OPT_PARENT(sched_options) }; const char * const latency_usage[] = { "perf sched latency [<options>]", -- 2.10.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] perf sched: Make common options cascading 2016-10-24 3:00 ` [RFC/PATCH 2/2] perf sched: Make common options cascading Namhyung Kim @ 2016-10-24 17:03 ` Jiri Olsa 2016-10-25 17:21 ` Arnaldo Carvalho de Melo 2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim 1 sibling, 1 reply; 7+ messages in thread From: Jiri Olsa @ 2016-10-24 17:03 UTC (permalink / raw) To: Namhyung Kim Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Andi Kleen, Wang Nan, Josh Poimboeuf On Mon, Oct 24, 2016 at 12:00:03PM +0900, Namhyung Kim wrote: > The -i and -v options can be used in subcommands so enable cascading the > sched_options. This fixes the following inconvenience in 'perf sched': > > $ perf sched -i perf.data.sched map > ... (it works well) ... > > $ perf sched map -i perf.data.sched > Error: unknown switch `i' > > Usage: perf sched map [<options>] > > --color-cpus <cpus> > highlight given CPUs in map > --color-pids <pids> > highlight given pids in map > --compact map output in compact mode > --cpus <cpus> display given CPUs in map > > With this patch, the second command line works with the perf.data.sched > data file. > > Cc: Josh Poimboeuf <jpoimboe@redhat.com> > Signed-off-by: Namhyung Kim <namhyung@kernel.org> good idea, I'll use it in c2c ;-) for both: Acked-by: Jiri Olsa <jolsa@kernel.org> thanks, jirka > --- > tools/perf/builtin-sched.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c > index f5503ca22e1c..8ca1b5409289 100644 > --- a/tools/perf/builtin-sched.c > +++ b/tools/perf/builtin-sched.c > @@ -1954,6 +1954,15 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) > .next_shortname2 = '0', > .skip_merge = 0, > }; > + const struct option sched_options[] = { > + OPT_STRING('i', "input", &input_name, "file", > + "input file name"), > + OPT_INCR('v', "verbose", &verbose, > + "be more verbose (show symbol address, etc)"), > + OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, > + "dump raw trace in ASCII"), > + OPT_END() > + }; > const struct option latency_options[] = { > OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]", > "sort by key(s): runtime, switch, avg, max"), > @@ -1965,7 +1974,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) > "dump raw trace in ASCII"), > OPT_BOOLEAN('p', "pids", &sched.skip_merge, > "latency stats per pid instead of per comm"), > - OPT_END() > + OPT_PARENT(sched_options) > }; > const struct option replay_options[] = { > OPT_UINTEGER('r', "repeat", &sched.replay_repeat, > @@ -1975,16 +1984,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) > OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, > "dump raw trace in ASCII"), > OPT_BOOLEAN('f', "force", &sched.force, "don't complain, do it"), > - OPT_END() > - }; > - const struct option sched_options[] = { > - OPT_STRING('i', "input", &input_name, "file", > - "input file name"), > - OPT_INCR('v', "verbose", &verbose, > - "be more verbose (show symbol address, etc)"), > - OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, > - "dump raw trace in ASCII"), > - OPT_END() > + OPT_PARENT(sched_options) > }; > const struct option map_options[] = { > OPT_BOOLEAN(0, "compact", &sched.map.comp, > @@ -1995,7 +1995,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) > "highlight given CPUs in map"), > OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", > "display given CPUs in map"), > - OPT_END() > + OPT_PARENT(sched_options) > }; > const char * const latency_usage[] = { > "perf sched latency [<options>]", > -- > 2.10.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] perf sched: Make common options cascading 2016-10-24 17:03 ` Jiri Olsa @ 2016-10-25 17:21 ` Arnaldo Carvalho de Melo 2016-10-25 21:27 ` Namhyung Kim 0 siblings, 1 reply; 7+ messages in thread From: Arnaldo Carvalho de Melo @ 2016-10-25 17:21 UTC (permalink / raw) To: Jiri Olsa Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Andi Kleen, Wang Nan, Josh Poimboeuf Em Mon, Oct 24, 2016 at 07:03:32PM +0200, Jiri Olsa escreveu: > On Mon, Oct 24, 2016 at 12:00:03PM +0900, Namhyung Kim wrote: > > The -i and -v options can be used in subcommands so enable cascading the > > sched_options. This fixes the following inconvenience in 'perf sched': > > > > $ perf sched -i perf.data.sched map > > ... (it works well) ... > > > > $ perf sched map -i perf.data.sched > > Error: unknown switch `i' > > > > Usage: perf sched map [<options>] > > > > --color-cpus <cpus> > > highlight given CPUs in map > > --color-pids <pids> > > highlight given pids in map > > --compact map output in compact mode > > --cpus <cpus> display given CPUs in map > > > > With this patch, the second command line works with the perf.data.sched > > data file. > > > > Cc: Josh Poimboeuf <jpoimboe@redhat.com> > > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > > good idea, I'll use it in c2c ;-) > > for both: > > Acked-by: Jiri Olsa <jolsa@kernel.org> Applied, I guess 'perf kvm' would be another user, to make it sane wrt file_name, -i and -o being available for 'perf kvm record', etc. - Arnaldo ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] perf sched: Make common options cascading 2016-10-25 17:21 ` Arnaldo Carvalho de Melo @ 2016-10-25 21:27 ` Namhyung Kim 0 siblings, 0 replies; 7+ messages in thread From: Namhyung Kim @ 2016-10-25 21:27 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Jiri Olsa, Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, David Ahern, Andi Kleen, Wang Nan, Josh Poimboeuf On Tue, Oct 25, 2016 at 02:21:32PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Oct 24, 2016 at 07:03:32PM +0200, Jiri Olsa escreveu: > > On Mon, Oct 24, 2016 at 12:00:03PM +0900, Namhyung Kim wrote: > > > The -i and -v options can be used in subcommands so enable cascading the > > > sched_options. This fixes the following inconvenience in 'perf sched': > > > > > > $ perf sched -i perf.data.sched map > > > ... (it works well) ... > > > > > > $ perf sched map -i perf.data.sched > > > Error: unknown switch `i' > > > > > > Usage: perf sched map [<options>] > > > > > > --color-cpus <cpus> > > > highlight given CPUs in map > > > --color-pids <pids> > > > highlight given pids in map > > > --compact map output in compact mode > > > --cpus <cpus> display given CPUs in map > > > > > > With this patch, the second command line works with the perf.data.sched > > > data file. > > > > > > Cc: Josh Poimboeuf <jpoimboe@redhat.com> > > > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > > > > good idea, I'll use it in c2c ;-) > > > > for both: > > > > Acked-by: Jiri Olsa <jolsa@kernel.org> > > Applied, I guess 'perf kvm' would be another user, to make it sane wrt > file_name, -i and -o being available for 'perf kvm record', etc. Yep, I think we have few more. I'll send the patch when I can find a time (FYI I'm travelling now). Thanks, Namhyung ^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/core] perf sched: Make common options cascading 2016-10-24 3:00 ` [RFC/PATCH 2/2] perf sched: Make common options cascading Namhyung Kim 2016-10-24 17:03 ` Jiri Olsa @ 2016-10-28 17:45 ` tip-bot for Namhyung Kim 1 sibling, 0 replies; 7+ messages in thread From: tip-bot for Namhyung Kim @ 2016-10-28 17:45 UTC (permalink / raw) To: linux-tip-commits Cc: jpoimboe, a.p.zijlstra, namhyung, hpa, dsahern, jolsa, mingo, andi, tglx, acme, wangnan0, linux-kernel Commit-ID: 77f02f44460ab1480af2ae6145a1a85b9fe0b8ac Gitweb: http://git.kernel.org/tip/77f02f44460ab1480af2ae6145a1a85b9fe0b8ac Author: Namhyung Kim <namhyung@kernel.org> AuthorDate: Mon, 24 Oct 2016 12:00:03 +0900 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Tue, 25 Oct 2016 10:24:48 -0300 perf sched: Make common options cascading The -i and -v options can be used in subcommands so enable cascading the sched_options. This fixes the following inconvenience in 'perf sched': $ perf sched -i perf.data.sched map ... (it works well) ... $ perf sched map -i perf.data.sched Error: unknown switch `i' Usage: perf sched map [<options>] --color-cpus <cpus> highlight given CPUs in map --color-pids <pids> highlight given pids in map --compact map output in compact mode --cpus <cpus> display given CPUs in map With this patch, the second command line works with the perf.data.sched data file. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20161024030003.28534-2-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/builtin-sched.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index f5503ca..8ca1b540 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1954,6 +1954,15 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) .next_shortname2 = '0', .skip_merge = 0, }; + const struct option sched_options[] = { + OPT_STRING('i', "input", &input_name, "file", + "input file name"), + OPT_INCR('v', "verbose", &verbose, + "be more verbose (show symbol address, etc)"), + OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, + "dump raw trace in ASCII"), + OPT_END() + }; const struct option latency_options[] = { OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]", "sort by key(s): runtime, switch, avg, max"), @@ -1965,7 +1974,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) "dump raw trace in ASCII"), OPT_BOOLEAN('p', "pids", &sched.skip_merge, "latency stats per pid instead of per comm"), - OPT_END() + OPT_PARENT(sched_options) }; const struct option replay_options[] = { OPT_UINTEGER('r', "repeat", &sched.replay_repeat, @@ -1975,16 +1984,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_BOOLEAN('f', "force", &sched.force, "don't complain, do it"), - OPT_END() - }; - const struct option sched_options[] = { - OPT_STRING('i', "input", &input_name, "file", - "input file name"), - OPT_INCR('v', "verbose", &verbose, - "be more verbose (show symbol address, etc)"), - OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, - "dump raw trace in ASCII"), - OPT_END() + OPT_PARENT(sched_options) }; const struct option map_options[] = { OPT_BOOLEAN(0, "compact", &sched.map.comp, @@ -1995,7 +1995,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) "highlight given CPUs in map"), OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", "display given CPUs in map"), - OPT_END() + OPT_PARENT(sched_options) }; const char * const latency_usage[] = { "perf sched latency [<options>]", ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [tip:perf/core] tools lib subcmd: Suppport cascading options 2016-10-24 3:00 [RFC/PATCH 1/2] tools lib subcmd: Suppport cascading options Namhyung Kim 2016-10-24 3:00 ` [RFC/PATCH 2/2] perf sched: Make common options cascading Namhyung Kim @ 2016-10-28 17:44 ` tip-bot for Namhyung Kim 1 sibling, 0 replies; 7+ messages in thread From: tip-bot for Namhyung Kim @ 2016-10-28 17:44 UTC (permalink / raw) To: linux-tip-commits Cc: wangnan0, a.p.zijlstra, tglx, mingo, namhyung, jpoimboe, andi, jolsa, dsahern, acme, hpa, linux-kernel Commit-ID: 369a2478973a416a2c42a37a8cf7031872a6d926 Gitweb: http://git.kernel.org/tip/369a2478973a416a2c42a37a8cf7031872a6d926 Author: Namhyung Kim <namhyung@kernel.org> AuthorDate: Mon, 24 Oct 2016 12:00:02 +0900 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Tue, 25 Oct 2016 10:12:16 -0300 tools lib subcmd: Suppport cascading options Sometimes subcommand have common options and it can only handled in the upper level command unless it duplicates the options. This patch adds a parent field and fallback to the parent if the given argument was not found in the current options. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20161024030003.28534-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/lib/subcmd/parse-options.c | 14 ++++++++++++++ tools/lib/subcmd/parse-options.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 981bb44..3284bb1 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -314,12 +314,19 @@ static int get_value(struct parse_opt_ctx_t *p, static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options) { +retry: for (; options->type != OPTION_END; options++) { if (options->short_name == *p->opt) { p->opt = p->opt[1] ? p->opt + 1 : NULL; return get_value(p, options, OPT_SHORT); } } + + if (options->parent) { + options = options->parent; + goto retry; + } + return -2; } @@ -333,6 +340,7 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, if (!arg_end) arg_end = arg + strlen(arg); +retry: for (; options->type != OPTION_END; options++) { const char *rest; int flags = 0; @@ -426,6 +434,12 @@ match: } if (abbrev_option) return get_value(p, abbrev_option, abbrev_flags); + + if (options->parent) { + options = options->parent; + goto retry; + } + return -2; } diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h index d60cab2..8866ac4 100644 --- a/tools/lib/subcmd/parse-options.h +++ b/tools/lib/subcmd/parse-options.h @@ -109,11 +109,13 @@ struct option { intptr_t defval; bool *set; void *data; + const struct option *parent; }; #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) #define OPT_END() { .type = OPTION_END } +#define OPT_PARENT(p) { .type = OPTION_END, .parent = (p) } #define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) } #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h), .defval = (b) } ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-28 17:45 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-10-24 3:00 [RFC/PATCH 1/2] tools lib subcmd: Suppport cascading options Namhyung Kim 2016-10-24 3:00 ` [RFC/PATCH 2/2] perf sched: Make common options cascading Namhyung Kim 2016-10-24 17:03 ` Jiri Olsa 2016-10-25 17:21 ` Arnaldo Carvalho de Melo 2016-10-25 21:27 ` Namhyung Kim 2016-10-28 17:45 ` [tip:perf/core] " tip-bot for Namhyung Kim 2016-10-28 17:44 ` [tip:perf/core] tools lib subcmd: Suppport cascading options tip-bot for Namhyung Kim
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.