diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-18 11:19:03 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-18 11:19:03 -0400 |
| commit | 4d7b4ac22fbec1a03206c6cde353f2fd6942f828 (patch) | |
| tree | 2d96a9e9c28cf6fa628a278decc00ad55a8b043b /tools/perf/util/parse-options.h | |
| parent | 3aaf51ace5975050ab43c7d4d7e439e0ae7d13d7 (diff) | |
| parent | 94f3ca95787ada3d64339a4ecb2754236ab563f6 (diff) | |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (311 commits)
perf tools: Add mode to build without newt support
perf symbols: symbol inconsistency message should be done only at verbose=1
perf tui: Add explicit -lslang option
perf options: Type check all the remaining OPT_ variants
perf options: Type check OPT_BOOLEAN and fix the offenders
perf options: Check v type in OPT_U?INTEGER
perf options: Introduce OPT_UINTEGER
perf tui: Add workaround for slang < 2.1.4
perf record: Fix bug mismatch with -c option definition
perf options: Introduce OPT_U64
perf tui: Add help window to show key associations
perf tui: Make <- exit menus too
perf newt: Add single key shortcuts for zoom into DSO and threads
perf newt: Exit browser unconditionally when CTRL+C, q or Q is pressed
perf newt: Fix the 'A'/'a' shortcut for annotate
perf newt: Make <- exit the ui_browser
x86, perf: P4 PMU - fix counters management logic
perf newt: Make <- zoom out filters
perf report: Report number of events, not samples
perf hist: Clarify events_stats fields usage
...
Fix up trivial conflicts in kernel/fork.c and tools/perf/builtin-record.c
Diffstat (limited to 'tools/perf/util/parse-options.h')
| -rw-r--r-- | tools/perf/util/parse-options.h | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index 948805af43c2..c7d72dce54b2 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #ifndef __PERF_PARSE_OPTIONS_H | 1 | #ifndef __PERF_PARSE_OPTIONS_H |
| 2 | #define __PERF_PARSE_OPTIONS_H | 2 | #define __PERF_PARSE_OPTIONS_H |
| 3 | 3 | ||
| 4 | #include <linux/kernel.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | |||
| 4 | enum parse_opt_type { | 7 | enum parse_opt_type { |
| 5 | /* special types */ | 8 | /* special types */ |
| 6 | OPTION_END, | 9 | OPTION_END, |
| @@ -8,14 +11,17 @@ enum parse_opt_type { | |||
| 8 | OPTION_GROUP, | 11 | OPTION_GROUP, |
| 9 | /* options with no arguments */ | 12 | /* options with no arguments */ |
| 10 | OPTION_BIT, | 13 | OPTION_BIT, |
| 11 | OPTION_BOOLEAN, /* _INCR would have been a better name */ | 14 | OPTION_BOOLEAN, |
| 12 | OPTION_SET_INT, | 15 | OPTION_INCR, |
| 16 | OPTION_SET_UINT, | ||
| 13 | OPTION_SET_PTR, | 17 | OPTION_SET_PTR, |
| 14 | /* options with arguments (usually) */ | 18 | /* options with arguments (usually) */ |
| 15 | OPTION_STRING, | 19 | OPTION_STRING, |
| 16 | OPTION_INTEGER, | 20 | OPTION_INTEGER, |
| 17 | OPTION_LONG, | 21 | OPTION_LONG, |
| 18 | OPTION_CALLBACK, | 22 | OPTION_CALLBACK, |
| 23 | OPTION_U64, | ||
| 24 | OPTION_UINTEGER, | ||
| 19 | }; | 25 | }; |
| 20 | 26 | ||
| 21 | enum parse_opt_flags { | 27 | enum parse_opt_flags { |
| @@ -73,7 +79,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset); | |||
| 73 | * | 79 | * |
| 74 | * `defval`:: | 80 | * `defval`:: |
| 75 | * default value to fill (*->value) with for PARSE_OPT_OPTARG. | 81 | * default value to fill (*->value) with for PARSE_OPT_OPTARG. |
| 76 | * OPTION_{BIT,SET_INT,SET_PTR} store the {mask,integer,pointer} to put in | 82 | * OPTION_{BIT,SET_UINT,SET_PTR} store the {mask,integer,pointer} to put in |
| 77 | * the value when met. | 83 | * the value when met. |
| 78 | * CALLBACKS can use it like they want. | 84 | * CALLBACKS can use it like they want. |
| 79 | */ | 85 | */ |
| @@ -90,16 +96,21 @@ struct option { | |||
| 90 | intptr_t defval; | 96 | intptr_t defval; |
| 91 | }; | 97 | }; |
| 92 | 98 | ||
| 99 | #define check_vtype(v, type) ( BUILD_BUG_ON_ZERO(!__builtin_types_compatible_p(typeof(v), type)) + v ) | ||
| 100 | |||
| 93 | #define OPT_END() { .type = OPTION_END } | 101 | #define OPT_END() { .type = OPTION_END } |
| 94 | #define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) } | 102 | #define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) } |
| 95 | #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } | 103 | #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } |
| 96 | #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) } | 104 | #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) } |
| 97 | #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 105 | #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h) } |
| 98 | #define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) } | 106 | #define OPT_INCR(s, l, v, h) { .type = OPTION_INCR, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) } |
| 107 | #define OPT_SET_UINT(s, l, v, h, i) { .type = OPTION_SET_UINT, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h), .defval = (i) } | ||
| 99 | #define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) } | 108 | #define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) } |
| 100 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 109 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h) } |
| 101 | #define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 110 | #define OPT_UINTEGER(s, l, v, h) { .type = OPTION_UINTEGER, .short_name = (s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) } |
| 102 | #define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) } | 111 | #define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = check_vtype(v, long *), .help = (h) } |
| 112 | #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), .long_name = (l), .value = check_vtype(v, u64 *), .help = (h) } | ||
| 113 | #define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) } | ||
| 103 | #define OPT_DATE(s, l, v, h) \ | 114 | #define OPT_DATE(s, l, v, h) \ |
| 104 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } | 115 | { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb } |
| 105 | #define OPT_CALLBACK(s, l, v, a, h, f) \ | 116 | #define OPT_CALLBACK(s, l, v, a, h, f) \ |
