Skip to content

Commit 98c0329

Browse files
Jiri Olsaacmel
authored andcommitted
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>
1 parent 979a70a commit 98c0329

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tools/include/linux/bitmap.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <string.h>
55
#include <linux/bitops.h>
6+
#include <stdlib.h>
67

78
#define DECLARE_BITMAP(name,bits) \
89
unsigned long name[BITS_TO_LONGS(bits)]
@@ -65,4 +66,13 @@ static inline int test_and_set_bit(int nr, unsigned long *addr)
6566
return (old & mask) != 0;
6667
}
6768

69+
/**
70+
* bitmap_alloc - Allocate bitmap
71+
* @nr: Bit to set
72+
*/
73+
static inline unsigned long *bitmap_alloc(int nbits)
74+
{
75+
return calloc(1, BITS_TO_LONGS(nbits) * sizeof(unsigned long));
76+
}
77+
6878
#endif /* _PERF_BITOPS_H */

0 commit comments

Comments
 (0)