[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v4 12/16] include/uk: add prefix to BITS_PER_LONG



Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
Reviewed-by: Florian Schmidt <florian.schmidt@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 cd0f098..23b1483 100644
--- a/include/uk/bitmap.h
+++ b/include/uk/bitmap.h
@@ -41,7 +41,7 @@ uk_bitmap_zero(unsigned long *addr, const unsigned int size)
 static inline void
 uk_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
 uk_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
 uk_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
 uk_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 @@ uk_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
 uk_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 @@ uk_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
 uk_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 @@ uk_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 f9f0329..82399e1 100644
--- a/include/uk/bitops.h
+++ b/include/uk/bitops.h
@@ -43,23 +43,23 @@
 #define        UK_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        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        UK_BIT_MASK(nr) \
-       (1UL << ((nr) & (BITS_PER_LONG - 1)))
-#define BIT_WORD(nr)                   ((nr) / BITS_PER_LONG)
+       (1UL << ((nr) & (UK_BITS_PER_LONG - 1)))
+#define BIT_WORD(nr)                   ((nr) / UK_BITS_PER_LONG)
 #define        UK_GENMASK(h, l) \
-       (((~0UL) >> (BITS_PER_LONG - (h) - 1)) & ((~0UL) << (l)))
+       (((~0UL) >> (UK_BITS_PER_LONG - (h) - 1)) & ((~0UL) << (l)))
 #define        UK_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))
@@ -98,8 +98,8 @@ uk_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));
@@ -120,8 +120,8 @@ uk_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)));
@@ -144,9 +144,9 @@ uk_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);
@@ -155,7 +155,7 @@ uk_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));
        }
@@ -173,21 +173,21 @@ uk_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));
@@ -213,21 +213,21 @@ uk_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)));
@@ -291,10 +291,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;
-- 
2.18.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.