Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
98c03296 979a70a2

+10
+10
tools/include/linux/bitmap.h
··· 3 3 4 4 #include <string.h> 5 5 #include <linux/bitops.h> 6 + #include <stdlib.h> 6 7 7 8 #define DECLARE_BITMAP(name,bits) \ 8 9 unsigned long name[BITS_TO_LONGS(bits)] ··· 64 63 *p = old | mask; 65 64 66 65 return (old & mask) != 0; 66 + } 67 + 68 + /** 69 + * bitmap_alloc - Allocate bitmap 70 + * @nr: Bit to set 71 + */ 72 + static inline unsigned long *bitmap_alloc(int nbits) 73 + { 74 + return calloc(1, BITS_TO_LONGS(nbits) * sizeof(unsigned long)); 67 75 } 68 76 69 77 #endif /* _PERF_BITOPS_H */