diff options
author | Ian Rogers <irogers@google.com> | 2024-02-09 21:49:44 +0100 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2024-02-13 22:47:08 +0100 |
commit | 4ea7d94407b4cbc04cd0d610e38171c277cc601e (patch) | |
tree | 5a10d61e23b5f409604a86971011eb4bcd03f038 /tools/perf/util/expr.l | |
parent | perf maps: Locking tidy up of nr_maps (diff) | |
download | linux-4ea7d94407b4cbc04cd0d610e38171c277cc601e.tar.xz linux-4ea7d94407b4cbc04cd0d610e38171c277cc601e.zip |
perf expr: Allow NaN to be a valid number
Currently only floating point numbers can be parsed, add a special
case for NaN.
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kaige Ye <ye@kaige.org>
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240209204947.3873294-2-irogers@google.com
Diffstat (limited to 'tools/perf/util/expr.l')
-rw-r--r-- | tools/perf/util/expr.l | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l index 0feef0726c48..a2fc43159ee9 100644 --- a/tools/perf/util/expr.l +++ b/tools/perf/util/expr.l @@ -94,6 +94,14 @@ static int literal(yyscan_t scanner, const struct expr_scanner_ctx *sctx) } return LITERAL; } + +static int nan_value(yyscan_t scanner) +{ + YYSTYPE *yylval = expr_get_lval(scanner); + + yylval->num = NAN; + return NUMBER; +} %} number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)? @@ -115,6 +123,7 @@ else { return ELSE; } source_count { return SOURCE_COUNT; } has_event { return HAS_EVENT; } strcmp_cpuid_str { return STRCMP_CPUID_STR; } +NaN { return nan_value(yyscanner); } {literal} { return literal(yyscanner, sctx); } {number} { return value(yyscanner); } {symbol} { return str(yyscanner, ID, sctx->runtime); } |