From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbdHXIUr (ORCPT ); Thu, 24 Aug 2017 04:20:47 -0400 Received: from terminus.zytor.com ([65.50.211.136]:38811 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbdHXIUo (ORCPT ); Thu, 24 Aug 2017 04:20:44 -0400 Date: Thu, 24 Aug 2017 01:19:31 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, mingo@kernel.org, ak@linux.intel.com, jolsa@kernel.org, hpa@zytor.com Reply-To: jolsa@kernel.org, ak@linux.intel.com, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de In-Reply-To: <20170811232634.30465-1-andi@firstfloor.org> References: <20170811232634.30465-1-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf xyarray: Save max_x, max_y Git-Commit-ID: d74be47673676eded2f0bb8274e752bed32c42d8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d74be47673676eded2f0bb8274e752bed32c42d8 Gitweb: http://git.kernel.org/tip/d74be47673676eded2f0bb8274e752bed32c42d8 Author: Andi Kleen AuthorDate: Fri, 11 Aug 2017 16:26:16 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 22 Aug 2017 11:51:28 -0300 perf xyarray: Save max_x, max_y Save the original array dimensions in xyarrays, so that users can retrieve them later. Add some inline functions to access these fields. Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20170811232634.30465-1-andi@firstfloor.org [ As noticed by Jiri, fix up namespacing: xy__method() -> xyarray__method() ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/xyarray.c | 2 ++ tools/perf/util/xyarray.h | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c index 7251fdb..c8f415d 100644 --- a/tools/perf/util/xyarray.c +++ b/tools/perf/util/xyarray.c @@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) xy->entry_size = entry_size; xy->row_size = row_size; xy->entries = xlen * ylen; + xy->max_x = xlen; + xy->max_y = ylen; } return xy; diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h index 7f30af3..4ba726c 100644 --- a/tools/perf/util/xyarray.h +++ b/tools/perf/util/xyarray.h @@ -7,6 +7,8 @@ struct xyarray { size_t row_size; size_t entry_size; size_t entries; + size_t max_x; + size_t max_y; char contents[]; }; @@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y) return &xy->contents[x * xy->row_size + y * xy->entry_size]; } +static inline int xyarray__max_y(struct xyarray *xy) +{ + return xy->max_x; +} + +static inline int xyarray__max_x(struct xyarray *xy) +{ + return xy->max_y; +} + #endif /* _PERF_XYARRAY_H_ */