From: Jiri Olsa Date: Tue, 2 Aug 2016 11:33:02 +0000 (+0200) Subject: tools lib: Add bitmap_alloc function X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=98c032967a299ee4bf14ef19eded02b65df32e6f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tools lib: Add bitmap_alloc function Adding bitmap_alloc function to dynamically allocate bitmap. Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20160802113302.GA7479@krava Signed-off-by: Arnaldo Carvalho de Melo --- 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 #include +#include #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 */