Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2180925ybv; Mon, 24 Feb 2020 00:30:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzEwIuCLaxzPVYnWfVS3ydbus4oEUoSD8QoAeCHRnprwN0AmFa5qNAMdcq1nYUbIzhcwATH X-Received: by 2002:aca:4ad8:: with SMTP id x207mr11161617oia.55.1582533005040; Mon, 24 Feb 2020 00:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582533005; cv=none; d=google.com; s=arc-20160816; b=n/uZtRs8/OrGb9+Af1+FGZ/pZqCe5x7ZI3eS0QesmXlr2a3zo7IJ9/en3aPsgtEncX yOnNrLKM6wxXK8WtlF+T1cckfi9ePcjQF+hWaGyJOKL466am4jn3xyvpMIdqN2h6H6Ih VBDYRyYq7o6xlfnGnVtzJh1Ldb7kHh979DiDcVY4o+F47JcdHDDSvNbDBfPtM4QRY2x9 3aOxpEEUYI3zP7dS+SH654fkjZwre/Y3RGL3FDHUa55NCQaxDVB4OU/h5KzLqD8aPkZj 0uYeogC7Tlov73OfgxXyx4rOH9CXR+AJSB/Qw6jXYf20w+x5AE1vXgxQR9es0sM1aE9t r06Q== 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=qFKtAnT0Qyjxi9/tPZN4uUueopv7mgjaw8stAMB0JF5q1//MGxuebVDSaif6bqaa1i w+IyiHeEpsLmiE7wNH1qigUwuU5NjCFhLX8HzS43rnrhCI43XPWsHj80i2E7S9V6lSM+ +ncOnbXwPZT7zkijtawioI9VG72vHpE2LszufY7XWfNjtfdGzyk0OB/2OLid5pRCp5UO H8ephTmamdJ6p96m/NAjCjcikysiXGSCRYO51mblAIxzAEBhGAdNtwheIgIbx4ohNzO6 de+cdZUQBv0y7VFcr6TeAi4vDkmLR9hIxwSGyBI8oz/1abljGhp8/AQo2dPGua45+px/ T08A== 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 w142si4492537oia.132.2020.02.24.00.29.45; Mon, 24 Feb 2020 00:30:05 -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 S1727395AbgBXI3e convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Feb 2020 03:29:34 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56060 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726216AbgBXI3e (ORCPT ); Mon, 24 Feb 2020 03:29:34 -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-384-AM3G2bOIMy6bGP49SxUsNQ-1; Mon, 24 Feb 2020 03:29:28 -0500 X-MC-Unique: AM3G2bOIMy6bGP49SxUsNQ-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 7618D800D53; Mon, 24 Feb 2020 08:29:26 +0000 (UTC) Received: from krava.redhat.com (ovpn-205-68.brq.redhat.com [10.40.205.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93B8985781; Mon, 24 Feb 2020 08:29:23 +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: Mon, 24 Feb 2020 09:29:14 +0100 Message-Id: <20200224082918.58489-2-jolsa@kernel.org> In-Reply-To: <20200224082918.58489-1-jolsa@kernel.org> References: <20200224082918.58489-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