Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea8e08a1 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarAdrian 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f6d31369
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ struct option {
	parse_opt_cb *callback;
	parse_opt_cb *callback;
	intptr_t defval;
	intptr_t defval;
	bool *set;
	bool *set;
	void *data;
};
};


#define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v )
#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),\
	{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
	.value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
	.value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
	.flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
	.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
/* parse_options() will filter out the processed options and leave the
 * non-option argments in argv[].
 * non-option argments in argv[].