From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: namhyung@kernel.org, yarygin@linux.vnet.ibm.com,
hemant@linux.vnet.ibm.com, mingo@kernel.org, acme@redhat.com,
tglx@linutronix.de, linux-kernel@vger.kernel.org,
dsahern@gmail.com, masami.hiramatsu.pt@hitachi.com,
peterz@infradead.org, jolsa@redhat.com, hpa@zytor.com
Subject: [tip:perf/core] perf tools: Add PARSE_OPT_DISABLED flag
Date: Wed, 29 Oct 2014 23:43:55 -0700 [thread overview]
Message-ID: <tip-d152d1be5962ace0706066db71b4f05dff8764eb@git.kernel.org> (raw)
In-Reply-To: <1413990949-13953-2-git-send-email-namhyung@kernel.org>
Commit-ID: d152d1be5962ace0706066db71b4f05dff8764eb
Gitweb: http://git.kernel.org/tip/d152d1be5962ace0706066db71b4f05dff8764eb
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 23 Oct 2014 00:15:45 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 29 Oct 2014 10:32:47 -0200
perf tools: Add PARSE_OPT_DISABLED flag
In some cases, we need to reuse exising options with some of them
disabled. To do that, add PARSE_OPT_DISABLED flag and
set_option_flag() function.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1413990949-13953-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-options.c | 17 +++++++++++++++++
tools/perf/util/parse-options.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index bf48092..b601610 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -42,6 +42,8 @@ static int get_value(struct parse_opt_ctx_t *p,
return opterror(opt, "takes no value", flags);
if (unset && (opt->flags & PARSE_OPT_NONEG))
return opterror(opt, "isn't available", flags);
+ if (opt->flags & PARSE_OPT_DISABLED)
+ return opterror(opt, "is not usable", flags);
if (!(flags & OPT_SHORT) && p->opt) {
switch (opt->type) {
@@ -509,6 +511,8 @@ static void print_option_help(const struct option *opts, int full)
}
if (!full && (opts->flags & PARSE_OPT_HIDDEN))
return;
+ if (opts->flags & PARSE_OPT_DISABLED)
+ return;
pos = fprintf(stderr, " ");
if (opts->short_name)
@@ -679,3 +683,16 @@ int parse_opt_verbosity_cb(const struct option *opt,
}
return 0;
}
+
+void set_option_flag(struct option *opts, int shortopt, const char *longopt,
+ int flag)
+{
+ for (; opts->type != OPTION_END; opts++) {
+ if ((shortopt && opts->short_name == shortopt) ||
+ (opts->long_name && longopt &&
+ !strcmp(opts->long_name, longopt))) {
+ opts->flags |= flag;
+ break;
+ }
+ }
+}
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
index b59ba85..b7c80db 100644
--- a/tools/perf/util/parse-options.h
+++ b/tools/perf/util/parse-options.h
@@ -38,6 +38,7 @@ enum parse_opt_option_flags {
PARSE_OPT_NONEG = 4,
PARSE_OPT_HIDDEN = 8,
PARSE_OPT_LASTARG_DEFAULT = 16,
+ PARSE_OPT_DISABLED = 32,
};
struct option;
@@ -211,4 +212,5 @@ extern int parse_opt_verbosity_cb(const struct option *, const char *, int);
extern const char *parse_options_fix_filename(const char *prefix, const char *file);
+void set_option_flag(struct option *opts, int sopt, const char *lopt, int flag);
#endif /* __PERF_PARSE_OPTIONS_H */
next prev parent reply other threads:[~2014-10-30 6:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 15:15 [PATCHSET 0/5] perf tools: option parsing improvement Namhyung Kim
2014-10-22 15:15 ` [PATCH 1/5] perf tools: Add PARSE_OPT_DISABLED flag Namhyung Kim
2014-10-30 6:43 ` tip-bot for Namhyung Kim [this message]
2014-10-22 15:15 ` [PATCH 2/5] perf tools: Export usage string and option table of perf record Namhyung Kim
2014-10-30 6:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-10-22 15:15 ` [PATCH 3/5] perf kvm: Print kvm specific --help output Namhyung Kim
2014-10-30 6:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-10-22 15:15 ` [PATCH 4/5] perf tools: Add support for exclusive option Namhyung Kim
2014-10-23 5:05 ` Masami Hiramatsu
2014-10-23 20:29 ` Arnaldo Carvalho de Melo
2014-10-24 0:40 ` Namhyung Kim
2014-10-30 6:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-10-22 15:15 ` [PATCH 5/5] perf probe: Use PARSE_OPT_EXCLUSIVE flag Namhyung Kim
2014-10-23 5:00 ` Masami Hiramatsu
2014-10-30 6:44 ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-10-23 3:06 ` [PATCHSET 0/5] perf tools: option parsing improvement Hemant Kumar
2014-10-23 20:33 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-d152d1be5962ace0706066db71b4f05dff8764eb@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=yarygin@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome