diff options
author | Jiri Olsa <jolsa@redhat.com> | 2016-08-02 13:33:02 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-08-02 16:33:26 -0300 |
commit | 98c032967a299ee4bf14ef19eded02b65df32e6f (patch) | |
tree | a65d6bc10246f369c7cb62e3f3942a3e5593e4ef /tools/include | |
parent | 979a70a237efb68e15b1cee36f9f92037e71d1fd (diff) |
tools lib: Add bitmap_alloc function
Adding bitmap_alloc function to dynamically allocate bitmap.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20160802113302.GA7479@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/linux/bitmap.h | 10 |
1 files changed, 10 insertions, 0 deletions
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 */ |