@@ -9,7 +9,7 @@
#define BIT_ALIGN_DOWN(n) ((n) & ~(BITMAP_WORD_BITS - 1))
#define BIT_ALIGN_UP(n) BIT_ALIGN_DOWN((n) + BITMAP_WORD_BITS - 1)
-void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m)
+void bitmap_zero_range(bitmap_t *bitmap, unsigned long n, unsigned long m)
{
unsigned long an = BIT_ALIGN_UP(n);
unsigned long am = BIT_ALIGN_DOWN(m);
@@ -34,7 +34,7 @@ void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m)
BITMAP_WORD(bitmap, m) &= ~bitmap_bswap(tailmask);
}
-void bitmap_fill_range(bitmap *bitmap, unsigned long n, unsigned long m)
+void bitmap_fill_range(bitmap_t *bitmap, unsigned long n, unsigned long m)
{
unsigned long an = BIT_ALIGN_UP(n);
unsigned long am = BIT_ALIGN_DOWN(m);
@@ -76,7 +76,7 @@ static int bitmap_clz(bitmap_word w)
#endif
}
-unsigned long bitmap_ffs(const bitmap *bitmap,
+unsigned long bitmap_ffs(const bitmap_t *bitmap,
unsigned long n, unsigned long m)
{
unsigned long an = BIT_ALIGN_UP(n);
@@ -20,10 +20,10 @@ typedef unsigned long bitmap_word;
*/
typedef struct {
bitmap_word w;
-} bitmap;
+} bitmap_t;
#define BITMAP_DECLARE(_name, _nbits) \
- bitmap (_name)[BITMAP_NWORDS(_nbits)]
+ bitmap_t (_name)[BITMAP_NWORDS(_nbits)]
static inline size_t bitmap_sizeof(unsigned long nbits)
{
@@ -55,47 +55,47 @@ static inline bitmap_word bitmap_bswap(bitmap_word w)
#define BITMAP_TAIL(_bm, _nbits) \
(BITMAP_TAILWORD(_bm, _nbits) & BITMAP_TAILBITS(_nbits))
-static inline void bitmap_set_bit(bitmap *bitmap, unsigned long n)
+static inline void bitmap_set_bit(bitmap_t *bitmap, unsigned long n)
{
BITMAP_WORD(bitmap, n) |= BITMAP_WORDBIT(n);
}
-static inline void bitmap_clear_bit(bitmap *bitmap, unsigned long n)
+static inline void bitmap_clear_bit(bitmap_t *bitmap, unsigned long n)
{
BITMAP_WORD(bitmap, n) &= ~BITMAP_WORDBIT(n);
}
-static inline void bitmap_change_bit(bitmap *bitmap, unsigned long n)
+static inline void bitmap_change_bit(bitmap_t *bitmap, unsigned long n)
{
BITMAP_WORD(bitmap, n) ^= BITMAP_WORDBIT(n);
}
-static inline bool bitmap_test_bit(const bitmap *bitmap, unsigned long n)
+static inline bool bitmap_test_bit(const bitmap_t *bitmap, unsigned long n)
{
return !!(BITMAP_WORD(bitmap, n) & BITMAP_WORDBIT(n));
}
-void bitmap_zero_range(bitmap *bitmap, unsigned long n, unsigned long m);
-void bitmap_fill_range(bitmap *bitmap, unsigned long n, unsigned long m);
+void bitmap_zero_range(bitmap_t *bitmap, unsigned long n, unsigned long m);
+void bitmap_fill_range(bitmap_t *bitmap, unsigned long n, unsigned long m);
-static inline void bitmap_zero(bitmap *bitmap, unsigned long nbits)
+static inline void bitmap_zero(bitmap_t *bitmap, unsigned long nbits)
{
memset(bitmap, 0, bitmap_sizeof(nbits));
}
-static inline void bitmap_fill(bitmap *bitmap, unsigned long nbits)
+static inline void bitmap_fill(bitmap_t *bitmap, unsigned long nbits)
{
memset(bitmap, 0xff, bitmap_sizeof(nbits));
}
-static inline void bitmap_copy(bitmap *dst, const bitmap *src,
+static inline void bitmap_copy(bitmap_t *dst, const bitmap_t *src,
unsigned long nbits)
{
memcpy(dst, src, bitmap_sizeof(nbits));
}
#define BITMAP_DEF_BINOP(_name, _op) \
- static inline void bitmap_##_name(bitmap *dst, bitmap *src1, bitmap *src2, \
+ static inline void bitmap_##_name(bitmap_t *dst, bitmap_t *src1, bitmap_t *src2, \
unsigned long nbits) \
{ \
unsigned long i = 0; \
@@ -111,7 +111,7 @@ BITMAP_DEF_BINOP(andnot, & ~)
#undef BITMAP_DEF_BINOP
-static inline void bitmap_complement(bitmap *dst, const bitmap *src,
+static inline void bitmap_complement(bitmap_t *dst, const bitmap_t *src,
unsigned long nbits)
{
unsigned long i;
@@ -120,7 +120,7 @@ static inline void bitmap_complement(bitmap *dst, const bitmap *src,
dst[i].w = ~src[i].w;
}
-static inline bool bitmap_equal(const bitmap *src1, const bitmap *src2,
+static inline bool bitmap_equal(const bitmap_t *src1, const bitmap_t *src2,
unsigned long nbits)
{
return (memcmp(src1, src2, BITMAP_HEADBYTES(nbits)) == 0)
@@ -128,7 +128,7 @@ static inline bool bitmap_equal(const bitmap *src1, const bitmap *src2,
|| (BITMAP_TAIL(src1, nbits) == BITMAP_TAIL(src2, nbits)));
}
-static inline bool bitmap_intersects(const bitmap *src1, const bitmap *src2,
+static inline bool bitmap_intersects(const bitmap_t *src1, const bitmap_t *src2,
unsigned long nbits)
{
unsigned long i;
@@ -143,7 +143,7 @@ static inline bool bitmap_intersects(const bitmap *src1, const bitmap *src2,
return false;
}
-static inline bool bitmap_subset(const bitmap *src1, const bitmap *src2,
+static inline bool bitmap_subset(const bitmap_t *src1, const bitmap_t *src2,
unsigned long nbits)
{
unsigned long i;
@@ -158,7 +158,7 @@ static inline bool bitmap_subset(const bitmap *src1, const bitmap *src2,
return true;
}
-static inline bool bitmap_full(const bitmap *bitmap, unsigned long nbits)
+static inline bool bitmap_full(const bitmap_t *bitmap, unsigned long nbits)
{
unsigned long i;
@@ -173,7 +173,7 @@ static inline bool bitmap_full(const bitmap *bitmap, unsigned long nbits)
return true;
}
-static inline bool bitmap_empty(const bitmap *bitmap, unsigned long nbits)
+static inline bool bitmap_empty(const bitmap_t *bitmap, unsigned long nbits)
{
unsigned long i;
@@ -187,20 +187,20 @@ static inline bool bitmap_empty(const bitmap *bitmap, unsigned long nbits)
return true;
}
-unsigned long bitmap_ffs(const bitmap *bitmap,
+unsigned long bitmap_ffs(const bitmap_t *bitmap,
unsigned long n, unsigned long m);
/*
* Allocation functions
*/
-static inline bitmap *bitmap_alloc(unsigned long nbits)
+static inline bitmap_t *bitmap_alloc(unsigned long nbits)
{
return malloc(bitmap_sizeof(nbits));
}
-static inline bitmap *bitmap_alloc0(unsigned long nbits)
+static inline bitmap_t *bitmap_alloc0(unsigned long nbits)
{
- bitmap *bitmap;
+ bitmap_t *bitmap;
bitmap = bitmap_alloc(nbits);
if (bitmap)
@@ -208,9 +208,9 @@ static inline bitmap *bitmap_alloc0(unsigned long nbits)
return bitmap;
}
-static inline bitmap *bitmap_alloc1(unsigned long nbits)
+static inline bitmap_t *bitmap_alloc1(unsigned long nbits)
{
- bitmap *bitmap;
+ bitmap_t *bitmap;
bitmap = bitmap_alloc(nbits);
if (bitmap)
@@ -218,7 +218,7 @@ static inline bitmap *bitmap_alloc1(unsigned long nbits)
return bitmap;
}
-static inline bitmap *bitmap_realloc0(bitmap *bitmap,
+static inline bitmap_t *bitmap_realloc0(bitmap_t *bitmap,
unsigned long obits, unsigned long nbits)
{
bitmap = realloc(bitmap, bitmap_sizeof(nbits));
@@ -229,7 +229,7 @@ static inline bitmap *bitmap_realloc0(bitmap *bitmap,
return bitmap;
}
-static inline bitmap *bitmap_realloc1(bitmap *bitmap,
+static inline bitmap_t *bitmap_realloc1(bitmap_t *bitmap,
unsigned long obits, unsigned long nbits)
{
bitmap = realloc(bitmap, bitmap_sizeof(nbits));
Having the typedef named the same as an instance of the struct causes gcc with -Wshadow to spew warnings like: ./ccan/bitmap/bitmap.h: In function ‘bitmap_clear_bit’: ./ccan/bitmap/bitmap.h:63:45: warning: declaration of ‘bitmap’ shadows a global declaration [-Wshadow] static inline void bitmap_clear_bit(bitmap *bitmap, unsigned long n) ^~~~~~ ./ccan/bitmap/bitmap.h:23:3: note: shadowed declaration is here } bitmap; ^~~~~~ Stop these by converting the typedef to bitmap_t so that it doesn't conflict with the many places a 'bitmap' variable is used. Cc: Dan Williams <dan.j.williams@intel.com> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- ccan/bitmap/bitmap.c | 6 +++--- ccan/bitmap/bitmap.h | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 29 deletions(-)