Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp477724ybf; Fri, 28 Feb 2020 01:36:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwlZt37Nw1T4RZUSxIcRSBU7es2DDQ1d+jKjcHJjJ+QGrOHIEm/cg2vfT96CIjYUIQgkvhL X-Received: by 2002:aca:1a10:: with SMTP id a16mr2477767oia.9.1582882618322; Fri, 28 Feb 2020 01:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582882618; cv=none; d=google.com; s=arc-20160816; b=M7wDQYlV04NVEwasp5qBNTWXTvydqI93lvQYrRXi3y1ipjvRuo2HrgtW6ONq/zgKuY pyP4aotNyO0q5GxInRv/DqruLz3xy+qFDJp8NsP+nSrmdSXPFp9OfkJ0XZxORCGSsHtR By1lXZ1EiSDcC2kDc9SFPnlWGr8lIzIEgBgyu1Wks18d4v+OIkrgygPh3dPkk0y0bxQ6 sRVan0JC5oyrc0rCnVXHCSPSLEAACJy/82+VCGzJ9kiAwEyKWrtMX2p6BW+yKVWLj2Dg 5M97EIq2YNQ+X4SDVr7TjGHhqOzW1Eyq0meUd9dIuycsVi4OqyhHCifUL87Prj85wTt1 rXTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ubcnvtSNHw+yF/6crBaWm2sxFIrd0drFmbot1Sijh6I=; b=XbkrJleky5m5tt9nrT0HjHFRpLC6OjxlYX+0SeF44okCyT7yFESKbtBf2MTIkttnl4 oAtCHSU/cthCUuuoc4Grxv1AHKXlhoLAzwnH8xvAhtxVsn04hMZRMFGlQzX/1UcbqrTm OtqmLxiW4zs38FnVysmzZcF5mjTQ6hp9pSybliz0kESAs2YxEOlSAvCRsWs8ifoI+BZl DcqZFXCHTauuicCFnz3e5jQJqY3m/fsFQ053vUhfDfMXgwVPhWs3eawzfb2u2DslwO8s QMS+DXCVOG/+6UxR7U+RkpZAb31tlDjLtXlnTsHC4Ci++uHuAD0Jhd9SHixVnrd+LFsH N/1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c189si1396826oig.74.2020.02.28.01.36.46; Fri, 28 Feb 2020 01:36:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbgB1Jgb convert rfc822-to-8bit (ORCPT + 99 others); Fri, 28 Feb 2020 04:36:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53255 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726951AbgB1Jga (ORCPT ); Fri, 28 Feb 2020 04:36:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-WYJF47erOpqR2qUwo2k2hg-1; Fri, 28 Feb 2020 04:36:26 -0500 X-MC-Unique: WYJF47erOpqR2qUwo2k2hg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E142C8017CC; Fri, 28 Feb 2020 09:36:23 +0000 (UTC) Received: from krava.redhat.com (unknown [10.36.118.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D4D8AC3F; Fri, 28 Feb 2020 09:36:21 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ravi Bangoria , Andi Kleen , Kajol Jain , John Garry Subject: [PATCH 1/5] perf expr: Add expr.c object Date: Fri, 28 Feb 2020 10:36:12 +0100 Message-Id: <20200228093616.67125-2-jolsa@kernel.org> In-Reply-To: <20200228093616.67125-1-jolsa@kernel.org> References: <20200228093616.67125-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add generic expr code into new expr.c object. The expr.c object will be mainly used in following change that will get rid of the manual flex code, Signed-off-by: Jiri Olsa --- tools/perf/util/Build | 1 + tools/perf/util/expr.c | 19 +++++++++++++++++++ tools/perf/util/expr.y | 16 ---------------- 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 tools/perf/util/expr.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 07da6c790b63..6fdf073093a6 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -122,6 +122,7 @@ perf-y += vsprintf.o perf-y += units.o perf-y += time-utils.o perf-y += expr-bison.o +perf-y += expr.o perf-y += branch.o perf-y += mem2node.o diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c new file mode 100644 index 000000000000..816b23b2068a --- /dev/null +++ b/tools/perf/util/expr.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include "expr.h" + +/* Caller must make sure id is allocated */ +void expr__add_id(struct parse_ctx *ctx, const char *name, double val) +{ + int idx; + + assert(ctx->num_ids < MAX_PARSE_ID); + idx = ctx->num_ids++; + ctx->ids[idx].name = name; + ctx->ids[idx].val = val; +} + +void expr__ctx_init(struct parse_ctx *ctx) +{ + ctx->num_ids = 0; +} diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index 7d226241f1d7..7cea8b7c3a5c 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -6,7 +6,6 @@ #define IN_EXPR_Y 1 #include "expr.h" #include "smt.h" -#include #include #define MAXIDLEN 256 @@ -169,21 +168,6 @@ static int expr__lex(YYSTYPE *res, const char **pp) return tok; } -/* Caller must make sure id is allocated */ -void expr__add_id(struct parse_ctx *ctx, const char *name, double val) -{ - int idx; - assert(ctx->num_ids < MAX_PARSE_ID); - idx = ctx->num_ids++; - ctx->ids[idx].name = name; - ctx->ids[idx].val = val; -} - -void expr__ctx_init(struct parse_ctx *ctx) -{ - ctx->num_ids = 0; -} - static bool already_seen(const char *val, const char *one, const char **other, int num_other) { -- 2.24.1