OSDN Git Service

perf expr: Remove unused headers and inline d_ratio
authorIan Rogers <irogers@google.com>
Thu, 23 Sep 2021 07:46:06 +0000 (00:46 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 29 Sep 2021 16:26:27 +0000 (13:26 -0300)
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>
tools/perf/util/expr.y

index 41c9cd4..e600545 100644 (file)
@@ -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;
+                                         }
+                                       }
        ;
 
 %%