summaryrefslogtreecommitdiff
path: root/tools/perf/util/expr.y
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2021-09-23 10:46:06 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-09-29 19:26:27 +0300
commit7f8fdcbbbefb2d95259aa76a362689affafa4e4b (patch)
tree317c9818cac5a6b3fca9c37d5e1a77d4136469f3 /tools/perf/util/expr.y
parentedfe7f554ab8f083556c718ecbcefda509c46851 (diff)
downloadlinux-7f8fdcbbbefb2d95259aa76a362689affafa4e4b.tar.xz
perf expr: Remove unused headers and inline d_ratio
No functional change. Inlining d_ratio makes it easier to special case for constants in a later patch. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: John Garry <john.garry@huawei.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sandeep Dasgupta <sdasgup@google.com> Cc: Stephane Eranian <eranian@google.com> Link: https://lore.kernel.org/r/20210923074616.674826-4-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/expr.y')
-rw-r--r--tools/perf/util/expr.y22
1 files changed, 7 insertions, 15 deletions
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
index 41c9cd4efadd..e6005450feae 100644
--- a/tools/perf/util/expr.y
+++ b/tools/perf/util/expr.y
@@ -2,23 +2,10 @@
%{
#define YYDEBUG 1
#include <math.h>
-#include <stdio.h>
-#include "util.h"
#include "util/debug.h"
-#include <stdlib.h> // strtod()
+#include "smt.h"
#define IN_EXPR_Y 1
#include "expr.h"
-#include "smt.h"
-#include <string.h>
-
-static double d_ratio(double val0, double val1)
-{
- if (val1 == 0) {
- return 0;
- }
- return val0 / val1;
-}
-
%}
%define api.pure full
@@ -120,7 +107,12 @@ expr: NUMBER
| MIN '(' expr ',' expr ')' { $$ = $3 < $5 ? $3 : $5; }
| MAX '(' expr ',' expr ')' { $$ = $3 > $5 ? $3 : $5; }
| SMT_ON { $$ = smt_on() > 0; }
- | D_RATIO '(' expr ',' expr ')' { $$ = d_ratio($3,$5); }
+ | D_RATIO '(' expr ',' expr ')' { if ($5 == 0) {
+ $$ = 0;
+ } else {
+ $$ = $3 / $5;
+ }
+ }
;
%%