lkml.org 
[lkml]   [2014]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[tip:perf/core] perf tools: Add option macro OPT_CALLBACK_OPTARG
    Commit-ID:  ea8e08a16a1e6566be3f775c0bd351fa52ab6b9d
    Gitweb: http://git.kernel.org/tip/ea8e08a16a1e6566be3f775c0bd351fa52ab6b9d
    Author: Adrian Hunter <adrian.hunter@intel.com>
    AuthorDate: Mon, 14 Jul 2014 13:02:54 +0300
    Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
    CommitDate: Wed, 16 Jul 2014 17:57:36 -0300

    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>
    ---
    tools/perf/util/parse-options.h | 5 +++++
    1 file changed, 5 insertions(+)

    diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
    index d8dac8a..b59ba85 100644
    --- a/tools/perf/util/parse-options.h
    +++ b/tools/perf/util/parse-options.h
    @@ -98,6 +98,7 @@ struct option {
    parse_opt_cb *callback;
    intptr_t defval;
    bool *set;
    + void *data;
    };

    #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v )
    @@ -131,6 +132,10 @@ struct option {
    { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
    .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
    .flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
    +#define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \
    + { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \
    + .value = (v), (a), .help = (h), .callback = (f), \
    + .flags = PARSE_OPT_OPTARG, .data = (d) }

    /* parse_options() will filter out the processed options and leave the
    * non-option argments in argv[].

    \
     
     \ /
      Last update: 2014-07-19 14:41    [W:2.667 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site