From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933508AbbFJTGI (ORCPT ); Wed, 10 Jun 2015 15:06:08 -0400 Received: from mail.kernel.org ([198.145.29.136]:45302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752251AbbFJTGF (ORCPT ); Wed, 10 Jun 2015 15:06:05 -0400 Date: Wed, 10 Jun 2015 16:06:00 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Adrian Hunter , Andi Kleen , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Stephane Eranian Subject: Re: [PATCH 02/25] perf tools: Introduce xyarray__zero function Message-ID: <20150610190600.GD3332@kernel.org> References: <1433959858-31858-1-git-send-email-jolsa@kernel.org> <1433959858-31858-3-git-send-email-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433959858-31858-3-git-send-email-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Jun 10, 2015 at 08:10:35PM +0200, Jiri Olsa escreveu: > To zero all the xyarray contents. It will be used > in following patches. I guess I would prefer xyarray__memset(), similar semantics as 'memset()', but I did a quick look and this is used in the kernel in things like bitmap_zero() and wrappers to it have that semantic... Interesting that we don't have anymore a bzero() like function, but then, looking at 'man bzero': ---------------------------- CONFORMING TO 4.3BSD. This function is deprecated (marked as LEGACY in POSIX.1-2001): use memset(3) in new programs. POSIX.1-2008 removes the specification of bzero(). ----------------------------- Guess we should use 'xyarray__memset()', ok? - Arnaldo > Link: http://lkml.kernel.org/n/tip-bp8bcl46cav05xn0uacg7ytn@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/util/xyarray.c | 8 ++++++++ > tools/perf/util/xyarray.h | 2 ++ > 2 files changed, 10 insertions(+) > > diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c > index 22afbf6c536a..d0ca9ed5e7f2 100644 > --- a/tools/perf/util/xyarray.c > +++ b/tools/perf/util/xyarray.c > @@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) > if (xy != NULL) { > xy->entry_size = entry_size; > xy->row_size = row_size; > + xy->entries = xlen * ylen; > } > > return xy; > } > > +void xyarray__zero(struct xyarray *xy) > +{ > + size_t n = xy->entries * xy->entry_size; > + > + memset(xy->contents, 0, n); > +} > + > void xyarray__delete(struct xyarray *xy) > { > free(xy); > diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h > index c488a07275dd..60cd80acdaa9 100644 > --- a/tools/perf/util/xyarray.h > +++ b/tools/perf/util/xyarray.h > @@ -6,11 +6,13 @@ > struct xyarray { > size_t row_size; > size_t entry_size; > + size_t entries; > char contents[]; > }; > > struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); > void xyarray__delete(struct xyarray *xy); > +void xyarray__zero(struct xyarray *xy); > > static inline void *xyarray__entry(struct xyarray *xy, int x, int y) > { > -- > 1.9.3