Commit f57d7ff1 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

powerpc: introduce little-endian bitops

Introduce little-endian bit operations by renaming existing powerpc native
little-endian bit operations and changing them to take any pointer types.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a56560b3
...@@ -281,27 +281,42 @@ unsigned long __arch_hweight64(__u64 w); ...@@ -281,27 +281,42 @@ unsigned long __arch_hweight64(__u64 w);
/* Little-endian versions */ /* Little-endian versions */
static __inline__ int test_le_bit(unsigned long nr, static __inline__ int test_bit_le(unsigned long nr,
__const__ unsigned long *addr) __const__ void *addr)
{ {
__const__ unsigned char *tmp = (__const__ unsigned char *) addr; __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
return (tmp[nr >> 3] >> (nr & 7)) & 1; return (tmp[nr >> 3] >> (nr & 7)) & 1;
} }
#define __set_le_bit(nr, addr) \ static inline void __set_bit_le(int nr, void *addr)
__set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) {
#define __clear_le_bit(nr, addr) \ __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
__clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) }
static inline void __clear_bit_le(int nr, void *addr)
{
__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
}
#define test_and_set_le_bit(nr, addr) \ static inline int test_and_set_bit_le(int nr, void *addr)
test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) {
#define test_and_clear_le_bit(nr, addr) \ return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) }
#define __test_and_set_le_bit(nr, addr) \ static inline int test_and_clear_bit_le(int nr, void *addr)
__test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) {
#define __test_and_clear_le_bit(nr, addr) \ return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
__test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) }
static inline int __test_and_set_bit_le(int nr, void *addr)
{
return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
}
static inline int __test_and_clear_bit_le(int nr, void *addr)
{
return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
}
#define find_first_zero_bit_le(addr, size) \ #define find_first_zero_bit_le(addr, size) \
find_next_zero_bit_le((addr), (size), 0) find_next_zero_bit_le((addr), (size), 0)
...@@ -313,16 +328,16 @@ unsigned long find_next_bit_le(const void *addr, ...@@ -313,16 +328,16 @@ unsigned long find_next_bit_le(const void *addr,
/* Bitmap functions for the ext2 filesystem */ /* Bitmap functions for the ext2 filesystem */
#define ext2_set_bit(nr,addr) \ #define ext2_set_bit(nr,addr) \
__test_and_set_le_bit((nr), (unsigned long*)addr) __test_and_set_bit_le((nr), (unsigned long*)addr)
#define ext2_clear_bit(nr, addr) \ #define ext2_clear_bit(nr, addr) \
__test_and_clear_le_bit((nr), (unsigned long*)addr) __test_and_clear_bit_le((nr), (unsigned long*)addr)
#define ext2_set_bit_atomic(lock, nr, addr) \ #define ext2_set_bit_atomic(lock, nr, addr) \
test_and_set_le_bit((nr), (unsigned long*)addr) test_and_set_bit_le((nr), (unsigned long*)addr)
#define ext2_clear_bit_atomic(lock, nr, addr) \ #define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_le_bit((nr), (unsigned long*)addr) test_and_clear_bit_le((nr), (unsigned long*)addr)
#define ext2_test_bit(nr, addr) test_le_bit((nr),(unsigned long*)addr) #define ext2_test_bit(nr, addr) test_bit_le((nr),(unsigned long*)addr)
#define ext2_find_first_zero_bit(addr, size) \ #define ext2_find_first_zero_bit(addr, size) \
find_first_zero_bit_le((unsigned long*)addr, size) find_first_zero_bit_le((unsigned long*)addr, size)
...@@ -334,13 +349,13 @@ unsigned long find_next_bit_le(const void *addr, ...@@ -334,13 +349,13 @@ unsigned long find_next_bit_le(const void *addr,
/* Bitmap functions for the minix filesystem. */ /* Bitmap functions for the minix filesystem. */
#define minix_test_and_set_bit(nr,addr) \ #define minix_test_and_set_bit(nr,addr) \
__test_and_set_le_bit(nr, (unsigned long *)addr) __test_and_set_bit_le(nr, (unsigned long *)addr)
#define minix_set_bit(nr,addr) \ #define minix_set_bit(nr,addr) \
__set_le_bit(nr, (unsigned long *)addr) __set_bit_le(nr, (unsigned long *)addr)
#define minix_test_and_clear_bit(nr,addr) \ #define minix_test_and_clear_bit(nr,addr) \
__test_and_clear_le_bit(nr, (unsigned long *)addr) __test_and_clear_bit_le(nr, (unsigned long *)addr)
#define minix_test_bit(nr,addr) \ #define minix_test_bit(nr,addr) \
test_le_bit(nr, (unsigned long *)addr) test_bit_le(nr, (unsigned long *)addr)
#define minix_find_first_zero_bit(addr,size) \ #define minix_find_first_zero_bit(addr,size) \
find_first_zero_bit_le((unsigned long *)addr, size) find_first_zero_bit_le((unsigned long *)addr, size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment