[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160802125616.GC26514@kernel.org>
Date: Tue, 2 Aug 2016 09:56:16 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Jiri Olsa <jolsa@...hat.com>
Cc: David Ahern <dsahern@...il.com>, Jiri Olsa <jolsa@...nel.org>,
lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCHv2 1/7] tools lib: Add bitmap_alloc function
Em Tue, Aug 02, 2016 at 01:33:02PM +0200, Jiri Olsa escreveu:
> ---
> Adding bitmap_alloc function to dynamically allocate bitmap.
Why should we deviate from the kernel way of doing things, where, AFAIK,
there is no such bitmap_alloc() function?
[acme@...et linux]$ find . -type f | xargs grep -w bitmap_alloc
[acme@...et linux]$
- Arnaldo
> Link: http://lkml.kernel.org/n/tip-ictn3ke5ewrzwyn8webfeai9@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> tools/include/linux/bitmap.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
> index 28f5493da491..60c44b615902 100644
> --- a/tools/include/linux/bitmap.h
> +++ b/tools/include/linux/bitmap.h
> @@ -3,6 +3,7 @@
>
> #include <string.h>
> #include <linux/bitops.h>
> +#include <stdlib.h>
>
> #define DECLARE_BITMAP(name,bits) \
> unsigned long name[BITS_TO_LONGS(bits)]
> @@ -65,4 +66,13 @@ static inline int test_and_set_bit(int nr, unsigned long *addr)
> return (old & mask) != 0;
> }
>
> +/**
> + * bitmap_alloc - Allocate bitmap
> + * @nr: Bit to set
> + */
> +static inline unsigned long *bitmap_alloc(int nbits)
> +{
> + return calloc(1, BITS_TO_LONGS(nbits) * sizeof(unsigned long));
> +}
> +
> #endif /* _PERF_BITOPS_H */
> --
> 2.4.11
Powered by blists - more mailing lists