Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
include/uk/bitmap.h | 18 ++++++------
include/uk/bitops.h | 70 ++++++++++++++++++++++-----------------------
2 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/include/uk/bitmap.h b/include/uk/bitmap.h
index 13178b6..f3c54f7 100644
--- a/include/uk/bitmap.h
+++ b/include/uk/bitmap.h
@@ -41,7 +41,7 @@ bitmap_zero(unsigned long *addr, const unsigned int size)
static inline void
bitmap_fill(unsigned long *addr, const unsigned int size)
{
- const unsigned int tail = size & (BITS_PER_LONG - 1);
+ const unsigned int tail = size & (UK_BITS_PER_LONG - 1);
memset(addr, 0xff, BIT_WORD(size) * sizeof(long));
@@ -53,7 +53,7 @@ static inline int
bitmap_full(unsigned long *addr, const unsigned int size)
{
const unsigned int end = BIT_WORD(size);
- const unsigned int tail = size & (BITS_PER_LONG - 1);
+ const unsigned int tail = size & (UK_BITS_PER_LONG - 1);
unsigned int i;
for (i = 0; i != end; i++) {
@@ -74,7 +74,7 @@ static inline int
bitmap_empty(unsigned long *addr, const unsigned int size)
{
const unsigned int end = BIT_WORD(size);
- const unsigned int tail = size & (BITS_PER_LONG - 1);
+ const unsigned int tail = size & (UK_BITS_PER_LONG - 1);
unsigned int i;
for (i = 0; i != end; i++) {
@@ -95,7 +95,7 @@ static inline void
bitmap_set(unsigned long *map, unsigned int start, int nr)
{
const unsigned int size = start + nr;
- int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
+ int bits_to_set = UK_BITS_PER_LONG - (start % UK_BITS_PER_LONG);
unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
map += BIT_WORD(start);
@@ -103,7 +103,7 @@ bitmap_set(unsigned long *map, unsigned int start, int nr)
while (nr - bits_to_set >= 0) {
*map |= mask_to_set;
nr -= bits_to_set;
- bits_to_set = BITS_PER_LONG;
+ bits_to_set = UK_BITS_PER_LONG;
mask_to_set = ~0UL;
map++;
}
@@ -118,7 +118,7 @@ static inline void
bitmap_clear(unsigned long *map, unsigned int start, int nr)
{
const unsigned int size = start + nr;
- int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+ int bits_to_clear = UK_BITS_PER_LONG - (start % UK_BITS_PER_LONG);
unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
map += BIT_WORD(start);
@@ -126,7 +126,7 @@ bitmap_clear(unsigned long *map, unsigned int start, int nr)
while (nr - bits_to_clear >= 0) {
*map &= ~mask_to_clear;
nr -= bits_to_clear;
- bits_to_clear = BITS_PER_LONG;
+ bits_to_clear = UK_BITS_PER_LONG;
mask_to_clear = ~0UL;
map++;
}
@@ -208,7 +208,7 @@ static inline unsigned int
bitmap_weight(unsigned long *addr, const unsigned int size)
{
const unsigned int end = BIT_WORD(size);
- const unsigned int tail = size & (BITS_PER_LONG - 1);
+ const unsigned int tail = size & (UK_BITS_PER_LONG - 1);
unsigned int retval = 0;
unsigned int i;
@@ -228,7 +228,7 @@ bitmap_equal(const unsigned long *pa,
const unsigned long *pb, unsigned int size)
{
const unsigned int end = BIT_WORD(size);
- const unsigned int tail = size & (BITS_PER_LONG - 1);
+ const unsigned int tail = size & (UK_BITS_PER_LONG - 1);
unsigned int i;
for (i = 0; i != end; i++) {
diff --git a/include/uk/bitops.h b/include/uk/bitops.h
index 56de694..6e9f7be 100644
--- a/include/uk/bitops.h
+++ b/include/uk/bitops.h
@@ -42,22 +42,22 @@
#define BIT(nr) (1UL << (nr))
#define BIT_ULL(nr) (1ULL << (nr))
#ifdef __LP64__
-#define BITS_PER_LONG 64
+#define UK_BITS_PER_LONG 64
#else
-#define BITS_PER_LONG 32
+#define UK_BITS_PER_LONG 32
#endif
-#define BITS_PER_LONG_LONG 64
+#define UK_BITS_PER_LONG_LONG 64
-#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
-#define BITMAP_LAST_WORD_MASK(n) (~0UL >> (BITS_PER_LONG - (n)))
-#define BITS_TO_LONGS(n) howmany((n), BITS_PER_LONG)
-#define BIT_MASK(nr) (1UL << ((nr) & (BITS_PER_LONG -
1)))
-#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) %
UK_BITS_PER_LONG))
+#define BITMAP_LAST_WORD_MASK(n) (~0UL >> (UK_BITS_PER_LONG -
(n)))
+#define BITS_TO_LONGS(n) howmany((n), UK_BITS_PER_LONG)
+#define BIT_MASK(nr) (1UL << ((nr) &
(UK_BITS_PER_LONG - 1)))
+#define BIT_WORD(nr) ((nr) / UK_BITS_PER_LONG)
#define GENMASK(h, l) \
- (((~0UL) >> (BITS_PER_LONG - (h) - 1)) & ((~0UL) << (l)))
+ (((~0UL) >> (UK_BITS_PER_LONG - (h) - 1)) & ((~0UL) << (l)))
#define GENMASK_ULL(h, l) \
- (((~0ULL) >> (BITS_PER_LONG_LONG - (h) - 1)) & ((~0ULL) << (l)))
+ (((~0ULL) >> (UK_BITS_PER_LONG_LONG - (h) - 1)) & ((~0ULL) << (l)))
#define BITS_PER_BYTE 8
#define hweight8(x) uk_bitcount((uint8_t)(x))
@@ -96,8 +96,8 @@ find_first_bit(const unsigned long *addr, unsigned long size)
long mask;
int bit;
- for (bit = 0; size >= BITS_PER_LONG;
- size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+ for (bit = 0; size >= UK_BITS_PER_LONG;
+ size -= UK_BITS_PER_LONG, bit += UK_BITS_PER_LONG, addr++) {
if (*addr == 0)
continue;
return (bit + ukarch_ffsl(*addr));
@@ -118,8 +118,8 @@ find_first_zero_bit(const unsigned long *addr, unsigned
long size)
long mask;
int bit;
- for (bit = 0; size >= BITS_PER_LONG;
- size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+ for (bit = 0; size >= UK_BITS_PER_LONG;
+ size -= UK_BITS_PER_LONG, bit += UK_BITS_PER_LONG, addr++) {
if (~(*addr) == 0)
continue;
return (bit + ukarch_ffsl(~(*addr)));
@@ -142,9 +142,9 @@ find_last_bit(const unsigned long *addr, unsigned long size)
int bit;
int pos;
- pos = size / BITS_PER_LONG;
- offs = size % BITS_PER_LONG;
- bit = BITS_PER_LONG * pos;
+ pos = size / UK_BITS_PER_LONG;
+ offs = size % UK_BITS_PER_LONG;
+ bit = UK_BITS_PER_LONG * pos;
addr += pos;
if (offs) {
mask = (*addr) & BITMAP_LAST_WORD_MASK(offs);
@@ -153,7 +153,7 @@ find_last_bit(const unsigned long *addr, unsigned long size)
}
while (pos--) {
addr--;
- bit -= BITS_PER_LONG;
+ bit -= UK_BITS_PER_LONG;
if (*addr)
return (bit + ukarch_flsl(*addr));
}
@@ -171,21 +171,21 @@ find_next_bit(const unsigned long *addr, unsigned long
size,
if (offset >= size)
return (size);
- pos = offset / BITS_PER_LONG;
- offs = offset % BITS_PER_LONG;
- bit = BITS_PER_LONG * pos;
+ pos = offset / UK_BITS_PER_LONG;
+ offs = offset % UK_BITS_PER_LONG;
+ bit = UK_BITS_PER_LONG * pos;
addr += pos;
if (offs) {
mask = (*addr) & ~BITMAP_LAST_WORD_MASK(offs);
if (mask)
return (bit + ukarch_ffsl(mask));
- if (size - bit <= BITS_PER_LONG)
+ if (size - bit <= UK_BITS_PER_LONG)
return (size);
- bit += BITS_PER_LONG;
+ bit += UK_BITS_PER_LONG;
addr++;
}
- for (size -= bit; size >= BITS_PER_LONG;
- size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+ for (size -= bit; size >= UK_BITS_PER_LONG;
+ size -= UK_BITS_PER_LONG, bit += UK_BITS_PER_LONG, addr++) {
if (*addr == 0)
continue;
return (bit + ukarch_ffsl(*addr));
@@ -211,21 +211,21 @@ find_next_zero_bit(const unsigned long *addr, unsigned
long size,
if (offset >= size)
return (size);
- pos = offset / BITS_PER_LONG;
- offs = offset % BITS_PER_LONG;
- bit = BITS_PER_LONG * pos;
+ pos = offset / UK_BITS_PER_LONG;
+ offs = offset % UK_BITS_PER_LONG;
+ bit = UK_BITS_PER_LONG * pos;
addr += pos;
if (offs) {
mask = ~(*addr) & ~BITMAP_LAST_WORD_MASK(offs);
if (mask)
return (bit + ukarch_ffsl(mask));
- if (size - bit <= BITS_PER_LONG)
+ if (size - bit <= UK_BITS_PER_LONG)
return (size);
- bit += BITS_PER_LONG;
+ bit += UK_BITS_PER_LONG;
addr++;
}
- for (size -= bit; size >= BITS_PER_LONG;
- size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+ for (size -= bit; size >= UK_BITS_PER_LONG;
+ size -= UK_BITS_PER_LONG, bit += UK_BITS_PER_LONG, addr++) {
if (~(*addr) == 0)
continue;
return (bit + ukarch_ffsl(~(*addr)));
@@ -289,10 +289,10 @@ linux_reg_op(unsigned long *bitmap, int pos, int order,
int reg_op)
int ret = 0;
nbits_reg = 1 << order;
- index = pos / BITS_PER_LONG;
- offset = pos - (index * BITS_PER_LONG);
+ index = pos / UK_BITS_PER_LONG;
+ offset = pos - (index * UK_BITS_PER_LONG);
nlongs_reg = BITS_TO_LONGS(nbits_reg);
- nbitsinlong = MIN(nbits_reg, BITS_PER_LONG);
+ nbitsinlong = MIN(nbits_reg, UK_BITS_PER_LONG);
mask = (1UL << (nbitsinlong - 1));
mask += mask - 1;