Skip to contentSkip to conversation

parisc: use the new byteorder headers

PATCH In review Harvey Harrison 2 participants 6 messages Jul 18, 2008 – Aug 4, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 14/20 parisc: use the new byteorder headers

---
 include/asm-parisc/byteorder.h |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)
include/asm-parisc/byteorder.h +12 -25
index db14831..5e56b1b 100644
@@ -4,9 +4,10 @@
 #include <asm/types.h>
 #include <linux/compiler.h>
 
-#ifdef __GNUC__
+#define __LITTLE_ENDIAN
+#define __SWAB_64_THRU_32__
 
-static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
+static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
 {
 	__asm__("dep %0, 15, 8, %0\n\t"		/* deposit 00ab -> 0bab */
 		"shd %%r0, %0, 8, %0"		/* shift 000000ab -> 00ba */
@@ -14,8 +15,9 @@ static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
 		: "0" (x));
 	return x;
 }
+#define HAVE_ARCH_SWAB16
 
-static __inline__ __attribute_const__ __u32 ___arch__swab24(__u32 x)
+static inline __attribute_const__ __u32 __arch_swab24(__u32 x)
 {
 	__asm__("shd %0, %0, 8, %0\n\t"		/* shift xabcxabc -> cxab */
 		"dep %0, 15, 8, %0\n\t"		/* deposit cxab -> cbab */
@@ -25,7 +27,7 @@ static __inline__ __attribute_const__ __u32 ___arch__swab24(__u32 x)
 	return x;
 }
 
-static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
+static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
 {
 	unsigned int temp;
 	__asm__("shd %0, %0, 16, %1\n\t"	/* shift abcdabcd -> cdab */
@@ -35,7 +37,7 @@ static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 		: "0" (x));
 	return x;
 }
-
+#define HAVE_ARCH_SWAB32
 
 #if BITS_PER_LONG > 32
 /*
@@ -48,7 +50,8 @@ static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 **      HSHR    67452301 -> *6*4*2*0 into %0
 **      OR      %0 | %1  -> 76543210 into %0 (all done!)
 */
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) {
+static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
+{
 	__u64 temp;
 	__asm__("permh,3210 %0, %0\n\t"
 		"hshl %0, 8, %1\n\t"
@@ -58,25 +61,9 @@ static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) {
 		: "0" (x));
 	return x;
 }
-#define __arch__swab64(x) ___arch__swab64(x)
-#define __BYTEORDER_HAS_U64__
-#elif !defined(__STRICT_ANSI__)
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
-{
-	__u32 t1 = ___arch__swab32((__u32) x);
-	__u32 t2 = ___arch__swab32((__u32) (x >> 32));
-	return (((__u64) t1 << 32) | t2);
-}
-#define __arch__swab64(x) ___arch__swab64(x)
-#define __BYTEORDER_HAS_U64__
-#endif
-
-#define __arch__swab16(x) ___arch__swab16(x)
-#define __arch__swab24(x) ___arch__swab24(x)
-#define __arch__swab32(x) ___arch__swab32(x)
-
-#endif /* __GNUC__ */
+#define HAVE_ARCH_SWAB64
+#endif /* BITS_PER_LONG > 32 */
 
-#include <linux/byteorder/big_endian.h>
+#include <linux/byteorder.h>
 
 #endif /* _PARISC_BYTEORDER_H */
Signature · 1 line
1.5.6.3.569.ga9185
#1 lore raw
Quoted 10 lines · Harvey Harrison
---
 include/asm-parisc/byteorder.h |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)
include/asm-parisc/byteorder.h +0 -0
index db14831..5e56b1b 100644

include/asm-parisc/byteorder.h line 7

Quoted 5 lines
include/asm-parisc/byteorder.h +1 -1
@@ -4,9 +4,10 @@
 #include <asm/types.h>
 #include <linux/compiler.h>
 
-#ifdef __GNUC__
+#define __LITTLE_ENDIAN

Sorry, this looks wrong. parisc is big endian.

include/asm-parisc/byteorder.h line 8

Quoted 1 line
include/asm-parisc/byteorder.h +1 -0
+#define __SWAB_64_THRU_32__

Should this only be defined if BITS_PER_LONG is <=32 ?

thanks,
grant

Quoted 77 lines
include/asm-parisc/byteorder.h +10 -24
-static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
+static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
 {
 	__asm__("dep %0, 15, 8, %0\n\t"		/* deposit 00ab -> 0bab */
 		"shd %%r0, %0, 8, %0"		/* shift 000000ab -> 00ba */
@@ -14,8 +15,9 @@ static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
 		: "0" (x));
 	return x;
 }
+#define HAVE_ARCH_SWAB16
 
-static __inline__ __attribute_const__ __u32 ___arch__swab24(__u32 x)
+static inline __attribute_const__ __u32 __arch_swab24(__u32 x)
 {
 	__asm__("shd %0, %0, 8, %0\n\t"		/* shift xabcxabc -> cxab */
 		"dep %0, 15, 8, %0\n\t"		/* deposit cxab -> cbab */
@@ -25,7 +27,7 @@ static __inline__ __attribute_const__ __u32 ___arch__swab24(__u32 x)
 	return x;
 }
 
-static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
+static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
 {
 	unsigned int temp;
 	__asm__("shd %0, %0, 16, %1\n\t"	/* shift abcdabcd -> cdab */
@@ -35,7 +37,7 @@ static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 		: "0" (x));
 	return x;
 }
-
+#define HAVE_ARCH_SWAB32
 
 #if BITS_PER_LONG > 32
 /*
@@ -48,7 +50,8 @@ static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 **      HSHR    67452301 -> *6*4*2*0 into %0
 **      OR      %0 | %1  -> 76543210 into %0 (all done!)
 */
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) {
+static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
+{
 	__u64 temp;
 	__asm__("permh,3210 %0, %0\n\t"
 		"hshl %0, 8, %1\n\t"
@@ -58,25 +61,9 @@ static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) {
 		: "0" (x));
 	return x;
 }
-#define __arch__swab64(x) ___arch__swab64(x)
-#define __BYTEORDER_HAS_U64__
-#elif !defined(__STRICT_ANSI__)
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
-{
-	__u32 t1 = ___arch__swab32((__u32) x);
-	__u32 t2 = ___arch__swab32((__u32) (x >> 32));
-	return (((__u64) t1 << 32) | t2);
-}
-#define __arch__swab64(x) ___arch__swab64(x)
-#define __BYTEORDER_HAS_U64__
-#endif
-
-#define __arch__swab16(x) ___arch__swab16(x)
-#define __arch__swab24(x) ___arch__swab24(x)
-#define __arch__swab32(x) ___arch__swab32(x)
-
-#endif /* __GNUC__ */
+#define HAVE_ARCH_SWAB64
+#endif /* BITS_PER_LONG > 32 */
 
-#include <linux/byteorder/big_endian.h>
+#include <linux/byteorder.h>
 
 #endif /* _PARISC_BYTEORDER_H */
Signature · 1 line
1.5.6.3.569.ga9185
#2 lore raw
Quoted 14 lines · Grant Grundler
Quoted 13 lines · Harvey Harrison
---
 include/asm-parisc/byteorder.h |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)
include/asm-parisc/byteorder.h +0 -0
index db14831..5e56b1b 100644
@@ -4,9 +4,10 @@
 #include <asm/types.h>
 #include <linux/compiler.h>
 
Quoted 4 lines

include/asm-parisc/byteorder.h line 7

Quoted 2 lines
include/asm-parisc/byteorder.h +1 -1
-#ifdef __GNUC__
+#define __LITTLE_ENDIAN

Sorry, this looks wrong. parisc is big endian.

Sorry, it is wrong. It of course should be __BIG_ENDIAN

Quoted 4 lines

include/asm-parisc/byteorder.h line 8

Quoted 1 line
include/asm-parisc/byteorder.h +1 -0
+#define __SWAB_64_THRU_32__

Should this only be defined if BITS_PER_LONG is <=32 ?

The new byteorder headers only uses this if no __arch_swab64 is defined.

Further down in the parisc version, an __arch_swab64 is defined in the BITS_PER_LONG >=32 case, making this moot.

Quoted 1 line

From the new linux/swab.h:

static inline __attribute_const__ __u64 ___swab64(__u64 val) {

#ifdef __arch_swab64
	return __arch_swab64(val);
#elif defined(__arch_swab64p)
	return __arch_swab64p(&val);
#elif defined(__SWAB_64_THRU_32__)
	__u32 h = val >> 32;
	__u32 l = val & ((1ULL << 32) - 1);
	return (((__u64)___swab32(l)) << 32) | ((__u64)(___swab32(h)));
#else
	return __const_swab64(val);

#endif
}

Other than the endianness, any other concerns?

Harvey

#3 lore raw

On Fri, Aug 01, 2008 at 02:23:37PM -0700, Harvey Harrison wrote:
...

Quoted 6 lines
Quoted 1 line

Should this only be defined if BITS_PER_LONG is <=32 ?

The new byteorder headers only uses this if no __arch_swab64 is defined.

Further down in the parisc version, an __arch_swab64 is defined in the BITS_PER_LONG >=32 case, making this moot.

Ok.

...

Quoted 1 line

Other than the endianness, any other concerns?

Have you had a chance to test this?
Or can you point me at another big endian arch that has similar use of header files that has been successfully tested?

I can arrange for access to parisc HW if you have time/interest in testing this yourself.

thanks,
grant

Quoted 2 lines

Harvey

#4 lore raw

My reply yesterday didn't seem to make it out.

Quoted 4 lines · Grant Grundler
Quoted 1 line · Harvey Harrison

Other than the endianness, any other concerns?

Have you had a chance to test this?

le-only personally (X86-32).

Quoted 3 lines

Or can you point me at another big endian arch that has similar use of header files that has been successfully tested?

AVR32 got a maintainer ack, I'm assuming that was tested. It's not functionally any different than the existing code really, other than allowing compile-time folding in the cpu_to_{endian} helpers.

Mips was also acked, but that can be little or big endian.

Quoted 3 lines

I can arrange for access to parisc HW if you have time/interest in testing this yourself.

Sure, drop me a note.

I'll have intermittant connection for the next week, so there might be a few days before I can reply.

Harvey

#5 lore raw
In reply to Grant Grundler
Quoted 9 lines · Grant Grundler

On Fri, Aug 01, 2008 at 02:23:37PM -0700, Harvey Harrison wrote:
...

Quoted 6 lines
Quoted 1 line

Should this only be defined if BITS_PER_LONG is <=32 ?

The new byteorder headers only uses this if no __arch_swab64 is defined.

Further down in the parisc version, an __arch_swab64 is defined in the BITS_PER_LONG >=32 case, making this moot.

Quoted 6 lines

Ok.

...

Quoted 1 line

Other than the endianness, any other concerns?

Have you had a chance to test this?

le-only personally (X86-32).

Quoted 2 lines

Or can you point me at another big endian arch that has similar use of header files that has been successfully tested?

AVR32 got a maintainer ack, I'm assuming that was tested. It's not functionally any different than the existing code really, other than allowing compile-time folding in the cpu_to_{endian} helpers.

Mips was also acked, but that can be little or big endian.

Quoted 3 lines

I can arrange for access to parisc HW if you have time/interest in testing this yourself.

Sure, drop me a note.

Harvey