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

[Xen-changelog] [xen master] arm: rename BIT_{WORD/MASK/PER_WORD) to BITOP_*



commit f492e9d03f497f66a656bb31e0e26c97a621d242
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Wed Feb 19 11:22:54 2020 +0100
Commit:     Julien Grall <julien@xxxxxxx>
CommitDate: Wed Feb 19 12:34:21 2020 +0000

    arm: rename BIT_{WORD/MASK/PER_WORD) to BITOP_*
    
    So BIT_WORD can be imported from Linux. The difference between current
    Linux implementation of BIT_WORD is that the size of the word unit is
    a long integer, while the Xen one is hardcoded to 32 bits.
    
    Current users of BITOP_WORD on Arm (which considers a word a long
    integer) are switched to use the generic BIT_WORD which also operates
    on long integers.
    
    No functional change intended.
    
    Suggested-by: Julien Grall <julien@xxxxxxx>
    Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Julien Grall <julien@xxxxxxx>
---
 xen/arch/arm/arm32/lib/bitops.c        | 10 +++++-----
 xen/arch/arm/arm64/lib/bitops.c        | 10 +++++-----
 xen/arch/arm/arm64/lib/find_next_bit.c | 10 ++++------
 xen/include/asm-arm/bitops.h           | 20 ++++++++++----------
 xen/include/xen/bitops.h               |  2 ++
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/xen/arch/arm/arm32/lib/bitops.c b/xen/arch/arm/arm32/lib/bitops.c
index 3dca769bf0..ceddd76d1b 100644
--- a/xen/arch/arm/arm32/lib/bitops.c
+++ b/xen/arch/arm/arm32/lib/bitops.c
@@ -33,8 +33,8 @@
 static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
                                      unsigned int max_try)                  \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
-    const uint32_t mask = BIT_MASK((unsigned int)nr);                       \
+    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    const uint32_t mask = BITOP_MASK((unsigned int)nr);                     \
     unsigned long res, tmp;                                                 \
                                                                             \
     ASSERT(((vaddr_t)p & 0x3) == 0);                                        \
@@ -71,9 +71,9 @@ bool name##_timeout(int nr, volatile void *p, unsigned int 
max_try)         \
 static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
                                      bool timeout, unsigned int max_try)    \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
-    unsigned int bit = (unsigned int)nr % BITS_PER_WORD;                    \
-    const uint32_t mask = BIT_MASK(bit);                                    \
+    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    unsigned int bit = (unsigned int)nr % BITOP_BITS_PER_WORD;              \
+    const uint32_t mask = BITOP_MASK(bit);                                  \
     unsigned long res, tmp;                                                 \
                                                                             \
     ASSERT(((vaddr_t)p & 0x3) == 0);                                        \
diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitops.c
index 27688e5418..20e3f3d6ce 100644
--- a/xen/arch/arm/arm64/lib/bitops.c
+++ b/xen/arch/arm/arm64/lib/bitops.c
@@ -32,8 +32,8 @@
 static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
                                      unsigned int max_try)                  \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
-    const uint32_t mask = BIT_MASK((unsigned int)nr);                       \
+    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    const uint32_t mask = BITOP_MASK((unsigned int)nr);                     \
     unsigned long res, tmp;                                                 \
                                                                             \
     do                                                                      \
@@ -67,9 +67,9 @@ bool name##_timeout(int nr, volatile void *p, unsigned int 
max_try)         \
 static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
                                      bool timeout, unsigned int max_try)    \
 {                                                                           \
-    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
-    unsigned int bit = (unsigned int)nr % BITS_PER_WORD;                    \
-    const uint32_t mask = BIT_MASK(bit);                                    \
+    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
+    unsigned int bit = (unsigned int)nr % BITOP_BITS_PER_WORD;              \
+    const uint32_t mask = BITOP_MASK(bit);                                  \
     unsigned long res, tmp;                                                 \
                                                                             \
     do                                                                      \
diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c 
b/xen/arch/arm/arm64/lib/find_next_bit.c
index 17cb176266..8ebf8bfe97 100644
--- a/xen/arch/arm/arm64/lib/find_next_bit.c
+++ b/xen/arch/arm/arm64/lib/find_next_bit.c
@@ -12,8 +12,6 @@
 #include <asm/types.h>
 #include <asm/byteorder.h>
 
-#define BITOP_WORD(nr)         ((nr) / BITS_PER_LONG)
-
 #ifndef find_next_bit
 /*
  * Find the next set bit in a memory region.
@@ -21,7 +19,7 @@
 unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
                            unsigned long offset)
 {
-       const unsigned long *p = addr + BITOP_WORD(offset);
+       const unsigned long *p = addr + BIT_WORD(offset);
        unsigned long result = offset & ~(BITS_PER_LONG-1);
        unsigned long tmp;
 
@@ -67,7 +65,7 @@ EXPORT_SYMBOL(find_next_bit);
 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
                                 unsigned long offset)
 {
-       const unsigned long *p = addr + BITOP_WORD(offset);
+       const unsigned long *p = addr + BIT_WORD(offset);
        unsigned long result = offset & ~(BITS_PER_LONG-1);
        unsigned long tmp;
 
@@ -197,7 +195,7 @@ unsigned long find_next_zero_bit_le(const void *addr, 
unsigned
 
        if (offset >= size)
                return size;
-       p += BITOP_WORD(offset);
+       p += BIT_WORD(offset);
        size -= result;
        offset &= (BITS_PER_LONG - 1UL);
        if (offset) {
@@ -243,7 +241,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
 
        if (offset >= size)
                return size;
-       p += BITOP_WORD(offset);
+       p += BIT_WORD(offset);
        size -= result;
        offset &= (BITS_PER_LONG - 1UL);
        if (offset) {
diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h
index fbb4b82413..71ae14cab3 100644
--- a/xen/include/asm-arm/bitops.h
+++ b/xen/include/asm-arm/bitops.h
@@ -20,9 +20,9 @@
 #define __set_bit(n,p)            set_bit(n,p)
 #define __clear_bit(n,p)          clear_bit(n,p)
 
-#define BITS_PER_WORD           32
-#define BIT_MASK(nr)            (1UL << ((nr) % BITS_PER_WORD))
-#define BIT_WORD(nr)            ((nr) / BITS_PER_WORD)
+#define BITOP_BITS_PER_WORD     32
+#define BITOP_MASK(nr)          (1UL << ((nr) % BITOP_BITS_PER_WORD))
+#define BITOP_WORD(nr)          ((nr) / BITOP_BITS_PER_WORD)
 #define BITS_PER_BYTE           8
 
 #define ADDR (*(volatile int *) addr)
@@ -85,9 +85,9 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p,
  */
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
-        unsigned int mask = BIT_MASK(nr);
+        unsigned int mask = BITOP_MASK(nr);
         volatile unsigned int *p =
-                ((volatile unsigned int *)addr) + BIT_WORD(nr);
+                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
         unsigned int old = *p;
 
         *p = old | mask;
@@ -105,9 +105,9 @@ static inline int __test_and_set_bit(int nr, volatile void 
*addr)
  */
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
-        unsigned int mask = BIT_MASK(nr);
+        unsigned int mask = BITOP_MASK(nr);
         volatile unsigned int *p =
-                ((volatile unsigned int *)addr) + BIT_WORD(nr);
+                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
         unsigned int old = *p;
 
         *p = old & ~mask;
@@ -118,9 +118,9 @@ static inline int __test_and_clear_bit(int nr, volatile 
void *addr)
 static inline int __test_and_change_bit(int nr,
                                             volatile void *addr)
 {
-        unsigned int mask = BIT_MASK(nr);
+        unsigned int mask = BITOP_MASK(nr);
         volatile unsigned int *p =
-                ((volatile unsigned int *)addr) + BIT_WORD(nr);
+                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
         unsigned int old = *p;
 
         *p = old ^ mask;
@@ -135,7 +135,7 @@ static inline int __test_and_change_bit(int nr,
 static inline int test_bit(int nr, const volatile void *addr)
 {
         const volatile unsigned int *p = (const volatile unsigned int *)addr;
-        return 1UL & (p[BIT_WORD(nr)] >> (nr & (BITS_PER_WORD-1)));
+        return 1UL & (p[BITOP_WORD(nr)] >> (nr & (BITOP_BITS_PER_WORD-1)));
 }
 
 /*
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index dfb70417c2..a64595f68e 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -245,4 +245,6 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
           (bit) < (size);                               \
           (bit) = find_next_bit(addr, size, (bit) + 1) )
 
+#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+
 #endif
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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