Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98c03296 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

tools lib: Add bitmap_alloc function



Adding bitmap_alloc function to dynamically allocate bitmap.

Signed-off-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 979a70a2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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 */