convert little-endian bitops macros to inline functions
Subsystems (7)
cover convert little-endian bitops macros to inline functions
The little-endian bitops patch series has been added to the -mm tree. This additional patch series converts all little-endian bitops macros to static inline functions with proper prototypes.
Akinobu Mita (6):
asm-generic: convert little-endian bitops macros to static inline
functions
powerpc: convert little-endian bitops macros to static inline
functions
s390: convert little-endian bitops macros to static inline functions
arm: convert little-endian bitops macros to static inline functions
m68k: convert little-endian bitops macros to static inline functions
m68knommu: convert little-endian bitops macros to static inline
functions
arch/arm/include/asm/bitops.h | 70 +++++++++++++++++++++++++---------- arch/m68k/include/asm/bitops_mm.h | 41 +++++++++++++++------ arch/m68k/include/asm/bitops_no.h | 12 ++++-- arch/powerpc/include/asm/bitops.h | 43 +++++++++++++++------- arch/s390/include/asm/bitops.h | 48 +++++++++++++++++------- include/asm-generic/bitops/le.h | 73 ++++++++++++++++++++++++++----------- 6 files changed, 201 insertions(+), 86 deletions(-)
Signature · 1 line
1.7.3.4
PATCH 1/6 asm-generic: convert little-endian bitops macros to static inline functions
(This patch is intended to be folded into the patch in -mm:
asm-generic-change-little-endian-bitops-to-take-any-pointer-types.patch)
The little-endian bitops on asm-generic are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- include/asm-generic/bitops/le.h | 73 +++++++++++++++++++++++++++------------ 1 files changed, 51 insertions(+), 22 deletions(-)
include/asm-generic/bitops/le.h +51 -22
@@ -8,12 +8,23 @@#define BITOP_LE_SWIZZLE 0 -#define find_next_zero_bit_le (addr, size, offset) \ - find_next_zero_bit((unsigned long *)(addr), size, offset) -#define find_next_bit_le (addr, size, offset) \ - find_next_bit((unsigned long *)(addr), size, offset) -#define find_first_zero_bit_le (addr, size) \ - find_first_zero_bit((unsigned long *)(addr), size) +static inline unsigned long find_next_zero_bit_le (const void *addr, +unsigned long size,unsigned long offset) +{ +return find_next_zero_bit (addr, size, offset); +} + +static inline unsigned long find_next_bit_le (const void *addr, +unsigned long size,unsigned long offset) +{ +return find_next_bit (addr, size, offset); +} + +static inline unsigned long find_first_zero_bit_le (const void *addr, +unsigned long size) +{ +return find_first_zero_bit (addr, size); +}#elif defined(__BIG_ENDIAN)
@@ -31,21 +42,39 @@ extern unsigned long find_next_bit_le(const void *addr,#error "Please fix <asm/byteorder.h>"#endif -#define test_bit_le (nr, addr) \ - test_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define __set_bit_le (nr, addr) \ - __set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) - -#define test_and_set_bit_le (nr, addr) \ - test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define test_and_clear_bit_le (nr, addr) \ - test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) - -#define __test_and_set_bit_le (nr, addr) \ - __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define __test_and_clear_bit_le (nr, addr) \ - __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline int test_bit_le (int nr,const void *addr) +{ +return test_bit (nr ^BITOP_LE_SWIZZLE , addr); +} + +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (nr ^BITOP_LE_SWIZZLE , addr); +} + +static inline void __clear_bit_le (int nr,void *addr) +{ +__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); +} + +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); +}#endif /* _ASM_GENERIC_BITOPS_LE_H_ */
Signature · 1 line
1.7.3.4
PATCH 2/6 powerpc: convert little-endian bitops macros to static inline functions
In reply to Akinobu Mita(This patch is intended to be folded into the patch in -mm:
powerpc-introduce-little-endian-bitops.patch)
The little-endian bitops on powerpc are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- arch/powerpc/include/asm/bitops.h | 43 +++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/bitops.h +29 -14
@@ -288,20 +288,35 @@ static __inline__ int test_bit_le(unsigned long nr,return (tmp[nr >>3 ] >> (nr &7 )) &1 ; } -#define __set_bit_le (nr, addr) \ - __set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) - -#define test_and_set_bit_le (nr, addr) \ - test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define test_and_clear_bit_le (nr, addr) \ - test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) - -#define __test_and_set_bit_le (nr, addr) \ - __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) -#define __test_and_clear_bit_le (nr, addr) \ - __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (nr ^BITOP_LE_SWIZZLE , addr); +} + +static inline void __clear_bit_le (int nr,void *addr) +{ +__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); +} + +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) \ find_next_zero_bit_le((addr), (size), 0)
Signature · 1 line
1.7.3.4
PATCH 3/6 s390: convert little-endian bitops macros to static inline functions
In reply to Akinobu Mita(This patch is intended to be folded into the patch in -mm:
s390-introduce-little-endian-bitops.patch)
The little-endian bitops on s390 are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- arch/s390/include/asm/bitops.h | 48 ++++++++++++++++++++++++++++----------- 1 files changed, 34 insertions(+), 14 deletions(-)
arch/s390/include/asm/bitops.h +34 -14
@@ -742,20 +742,40 @@ static inline int sched_find_first_bit(unsigned long *b)* 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 */ -#define __set_bit_le (nr, addr) \ - __set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define __test_and_set_bit_le (nr, addr) \ - __test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define test_and_set_bit_le (nr, addr) \ - test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define __test_and_clear_bit_le (nr, addr) \ - __test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define test_and_clear_bit_le (nr, addr) \ - test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) -#define test_bit_le (nr, addr) \ - test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)(addr)) +static inline void __set_bit_le (unsigned long nr,void *addr) +{ +__set_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline void __clear_bit_le (unsigned long nr,void *addr) +{ +__clear_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline int __test_and_set_bit_le (unsigned long nr,void *addr) +{ +return __test_and_set_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline int test_and_set_bit_le (unsigned long nr,void *addr) +{ +return test_and_set_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline int __test_and_clear_bit_le (unsigned long nr,void *addr) +{ +return __test_and_clear_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline int test_and_clear_bit_le (unsigned long nr,void *addr) +{ +return test_and_clear_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +} + +static inline int test_bit_le (unsigned long nr,const void *addr) +{ +return test_bit (nr ^ (__BITOPS_WORDSIZE -8 ), addr); +}static inline int find_first_zero_bit_le (void *vaddr,unsigned int size) {
Signature · 1 line
1.7.3.4
PATCH 4/6 arm: convert little-endian bitops macros to static inline functions
In reply to Akinobu Mita(This patch is intended to be folded into the patch in -mm:
arm-introduce-little-endian-bitops.patch)
The little-endian bitops on arm are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- arch/arm/include/asm/bitops.h | 70 +++++++++++++++++++++++++++++------------ 1 files changed, 50 insertions(+), 20 deletions(-)
arch/arm/include/asm/bitops.h +50 -20
@@ -303,26 +303,56 @@ static inline int fls(int x)#include <asm-generic/bitops/hweight.h> #include <asm-generic/bitops/lock.h> -#define __set_bit_le (nr, p) \ - __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define __clear_bit_le (nr, p) \ - __clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define __test_and_set_bit_le (nr, p) \ - __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define test_and_set_bit_le (nr, p) \ - test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define __test_and_clear_bit_le (nr, p) \ - __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define test_and_clear_bit_le (nr, p) \ - test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define test_bit_le (nr, p) \ - test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) -#define find_first_zero_bit_le (p, sz) \ - _find_first_zero_bit_le(p, sz) -#define find_next_zero_bit_le (p, sz, off) \ - _find_next_zero_bit_le(p, sz, off) -#define find_next_bit_le (p, sz, off) \ - _find_next_bit_le((unsigned long *)(p), sz, off) +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline void __clear_bit_le (int nr,void *addr) +{ +__clear_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int __test_and_set_bit_le (int nr,void *addr) +{ +return __test_and_set_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int test_and_set_bit_le (int nr,void *addr) +{ +return test_and_set_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int __test_and_clear_bit_le (int nr,void *addr) +{ +return __test_and_clear_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int test_and_clear_bit_le (int nr,void *addr) +{ +return test_and_clear_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int test_bit_le (int nr,const void *addr) +{ +return test_bit (WORD_BITOFF_TO_LE (nr), addr); +} + +static inline int find_first_zero_bit_le (const void *p,unsigned size) +{ +return _find_first_zero_bit_le (p, size); +} + +static inline int find_next_zero_bit_le (const void *p,int size,int offset) +{ +return _find_next_zero_bit_le (p, size, offset); +} + +static inline int find_next_bit_le (const void *p,int size,int offset) +{ +return _find_next_bit_le (p, size, offset); +} +/* * Ext2 is defined to use little-endian byte ordering. */
Signature · 1 line
1.7.3.4
PATCH 5/6 m68k: convert little-endian bitops macros to static inline functions
In reply to Akinobu Mita(This patch is intended to be folded into the patch in -mm:
m68k-introduce-little-endian-bitops.patch)
The little-endian bitops on m68k are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- arch/m68k/include/asm/bitops_mm.h | 41 ++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 12 deletions(-)
arch/m68k/include/asm/bitops_mm.h +29 -12
@@ -327,18 +327,35 @@ static inline int __fls(int x)/* Bitmap functions for the little endian bitmap. */ -#define __set_bit_le (nr, addr) \ - __set_bit((nr) ^ 24, (unsigned long *)(addr)) -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr) ^ 24, (unsigned long *)(addr)) -#define __test_and_set_bit_le (nr, addr) \ - __test_and_set_bit((nr) ^ 24, (unsigned long *)(addr)) -#define test_and_set_bit_le (nr, addr) \ - test_and_set_bit((nr) ^ 24, (unsigned long *)(addr)) -#define __test_and_clear_bit_le (nr, addr) \ - __test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr)) -#define test_and_clear_bit_le (nr, addr) \ - test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr)) +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (nr ^24 , addr); +} + +static inline void __clear_bit_le (int nr,void *addr) +{ +__clear_bit (nr ^24 , addr); +} + +static inline int __test_and_set_bit_le (int nr,void *addr) +{ +return __test_and_set_bit (nr ^24 , addr); +} + +static inline int test_and_set_bit_le (int nr,void *addr) +{ +return test_and_set_bit (nr ^24 , addr); +} + +static inline int __test_and_clear_bit_le (int nr,void *addr) +{ +return __test_and_clear_bit (nr ^24 , addr); +} + +static inline int test_and_clear_bit_le (int nr,void *addr) +{ +return test_and_clear_bit (nr ^24 , addr); +}static inline int test_bit_le (int nr,const void *vaddr) {
Signature · 1 line
1.7.3.4
PATCH 6/6 m68knommu: convert little-endian bitops macros to static inline functions
In reply to Akinobu Mita(This patch is intended to be folded into the patch in -mm:
m68knommu-introduce-little-endian-bitops.patch)
A few little-endian bitops on m68knommu are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
This converts the little-endian bitops macros to static inline functions with proper prototypes.
--- arch/m68k/include/asm/bitops_no.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
arch/m68k/include/asm/bitops_no.h +8 -4
@@ -198,11 +198,15 @@ static __inline__ int __test_bit(int nr, const volatile unsigned long * addr)#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) -#define __set_bit_le (nr, addr) \ - __set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (nr ^BITOP_LE_SWIZZLE , addr); +} -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline void __clear_bit_le (int nr,void *addr) +{ +__clear_bit (nr ^BITOP_LE_SWIZZLE , addr); +}static inline int __test_and_set_bit_le (int nr,volatile void *addr) {
Signature · 1 line
1.7.3.4
Re: [PATCH -mm 6/6] m68knommu: convert little-endian bitops macros to static inline functions
Quoted 8 lines · Akinobu Mita
(This patch is intended to be folded into the patch in -mm:
m68knommu-introduce-little-endian-bitops.patch)A few little-endian bitops on m68knommu are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
Quoted 7 lines
This converts the little-endian bitops macros to static inline functions with proper prototypes.
Suggested-by "H. Peter Anvin"<[email protected]>Signed-off-by Akinobu Mita<[email protected]>Cc Greg Ungerer<[email protected]>Cc Greg Ungerer<[email protected]>
You drop both of these "CC"'s and add:
Quoted 31 lines
Cc Geert Uytterhoeven<[email protected]>Cc Roman Zippel<[email protected]>Cc Andreas Schwab<[email protected]>--- arch/m68k/include/asm/bitops_no.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)arch/m68k/include/asm/bitops_no.h +8
-4@@ -198,11 +198,15 @@ static __inline__ int __test_bit(int nr, const volatile unsigned long * addr)#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1)& ~0x7) -#define __set_bit_le (nr, addr) \ - __set_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline void __set_bit_le (int nr,void *addr) +{ +__set_bit (nr ^BITOP_LE_SWIZZLE , addr); +} -#define __clear_bit_le (nr, addr) \ - __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (unsigned long *)(addr)) +static inline void __clear_bit_le (int nr,void *addr) +{ +__clear_bit (nr ^BITOP_LE_SWIZZLE , addr); +}static inline int __test_and_set_bit_le (int nr,volatile void *addr) {
Signature · 5 lines
------------------------------------------------------------------------ Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
Re: [PATCH -mm 2/6] powerpc: convert little-endian bitops macros to static inline functions
In reply to Akinobu MitaQuoted 10 lines · Akinobu Mita
(This patch is intended to be folded into the patch in -mm:
powerpc-introduce-little-endian-bitops.patch)The little-endian bitops on powerpc are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.This converts the little-endian bitops macros to static inline functions with proper prototypes.
No objection to the powerpc variant of the patches. What is the status with the wholes series tho ? Does it looks like its going to be accepted ? Do you expect my Ack and will merge the whole thing at once ? Does it break bisection unless it's merged as one single giant patch ?
Cheers,
Ben.
Re: [PATCH -mm 2/6] powerpc: convert little-endian bitops macros to static inline functions
2011/2/7 Benjamin Herrenschmidt <[email protected]>:
Quoted 9 lines · Akinobu Mita
Quoted 8 lines
(This patch is intended to be folded into the patch in -mm:
powerpc-introduce-little-endian-bitops.patch)The little-endian bitops on powerpc are written as preprocessor macros with the cast to "unsigned long *".
This means that even non-pointers will be accepted without an error, and that is a Very Bad Thing.
Quoted 6 lines
Quoted 2 lines
This converts the little-endian bitops macros to static inline functions with proper prototypes.
No objection to the powerpc variant of the patches. What is the status with the wholes series tho ? Does it looks like its going to be accepted ? Do you expect my Ack and will merge the whole thing at once ?
The whole series now seems acceptable since I fixed two issues that Linus found annoying. (the naming and the change of prototype)
Please give your ack if it is OK.
I should have fixed them quickly so that the series went upstream in the last merge windows. But I couldn't because I spent some time fixing and compile testing for a bisection hole.
Quoted 1 line
Does it break bisection unless it's merged as one single giant patch ?
I think there is no known problem that breaks bisectability by this patch series.