Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2412315ybv; Fri, 21 Feb 2020 15:20:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzDLlyjDN3r2E4UOUEBmWdZ0HB93INkUNxlHdw8sh/b9cvWtwndaYvmfSd6G7fLZesrAy9f X-Received: by 2002:a9d:7410:: with SMTP id n16mr31260678otk.23.1582327209882; Fri, 21 Feb 2020 15:20:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582327209; cv=none; d=google.com; s=arc-20160816; b=MWKiea86Vvgkxa9pu9vm0DtZceu4zpH50taMwr+aS5CNAQf8lhj+Lhaa9+EKKCe5R1 3ibJhk3BLrf3NfB1ZtyghxcaRzBvet36+XZLYCYBOOqK95b8i5+OUY4z5HzGiNewXDE3 /jXQ277IfAIOAy8ieY2IDuYTyU+FzDFZASaPpAq6mtnU7VsWc7pODGPxv9zlVuIPUs6w x/kRk6SwcsoakHN6jS/DJXT0aadLoqMgrgG1dt6pnnn5Jy1LP4BN0r+nY7+nqofiZT7W GzF6SMeN1DjgPeBP7tuGs27wIPR4zpX7fpu2rWh70xsneoRBslfdTeMpA7gcXiTziLBV MABg== 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=E9vBve7B8NUS8MfDq9VIGX0mRvc4ZwzNF/80Ac7HOXM=; b=0kULQtwkOdYzZxrzFNawcxlmy37Pu6Nz7jHyhsqHOLArD6dxAppgOxwo0UKp2v8SVg smXkx8Sp7/7+DncGIlGEvDOgo7s/fvnDEd6QK2+N5VUWuns3GlALE5XDrRtpj4BUS1gy VbdQYHMAfivM6c4MKA/xGP+e4J0M3cA8dMFny31Q4Wzt7QPdhgtQqka87CtGcER+B0M8 yZhs2pGpj6HysszxnPKiBNM5JrouH21I430g8JO5XNs3GvBHN+P8Y2Cwy8VpPO86XcP4 olTpwC/RQjiPMbKBEAE8uRx+NSzVLb9AWmyTTamAbH4LjS7g2mTZ4QvhpKeEXMGdtJgM T1ig== 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 z1si2273339otp.70.2020.02.21.15.19.57; Fri, 21 Feb 2020 15:20:09 -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 S1729541AbgBUXTt convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 Feb 2020 18:19:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27055 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726290AbgBUXTs (ORCPT ); Fri, 21 Feb 2020 18:19:48 -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-13-1jQvQluMPwOkZT2ctSE-7A-1; Fri, 21 Feb 2020 18:19:45 -0500 X-MC-Unique: 1jQvQluMPwOkZT2ctSE-7A-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 1C6E41084430; Fri, 21 Feb 2020 23:19:43 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-57.brq.redhat.com [10.40.204.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3646160499; Fri, 21 Feb 2020 23:19:39 +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/4] perf expr: Add expr.c object Date: Sat, 22 Feb 2020 00:19:32 +0100 Message-Id: <20200221231935.735145-2-jolsa@kernel.org> In-Reply-To: <20200221231935.735145-1-jolsa@kernel.org> References: <20200221231935.735145-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 | 20 ++++++++++++++++++++ tools/perf/util/expr.y | 16 ---------------- 3 files changed, 21 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..4a82ff3bdbcc --- /dev/null +++ b/tools/perf/util/expr.c @@ -0,0 +1,20 @@ +// 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