1 #ifndef _PARISC_BYTEORDER_H
2 #define _PARISC_BYTEORDER_H
8 static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
11 __asm__("shd %0, %0, 16, %1\n\t" /* shift abcdabcd -> cdab */
12 "dep %1, 15, 8, %1\n\t" /* deposit cdab -> cbab */
13 "shd %0, %1, 8, %0" /* shift abcdcbab -> dcba */
14 : "=r" (x), "=&r" (temp)
20 #if BITS_PER_LONG > 32
22 ** From "PA-RISC 2.0 Architecture", HP Professional Books.
23 ** See Appendix I page 8 , "Endian Byte Swapping".
25 ** Pretty cool algorithm: (* == zero'd bits)
26 ** PERMH 01234567 -> 67452301 into %0
27 ** HSHL 67452301 -> 7*5*3*1* into %1
28 ** HSHR 67452301 -> *6*4*2*0 into %0
29 ** OR %0 | %1 -> 76543210 into %0 (all done!)
31 static __inline__ __const__ __u64 ___arch__swab64(__u64 x) {
33 __asm__("permh 3210, %0, %0\n\t"
35 "hshr u, %0, 8, %0\n\t"
37 : "=r" (x), "=&r" (temp)
41 #define __arch__swab64(x) ___arch__swab64(x)
43 static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
46 __u32 t2 = (__u32) ((x) >> 32);
49 return (((__u64) t1 << 32) + ((__u64) t2));
54 static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
56 __asm__("dep %0, 15, 8, %0\n\t" /* deposit 00ab -> 0bab */
57 "shd %r0, %0, 8, %0" /* shift 000000ab -> 00ba */
63 #define __arch__swab32(x) ___arch__swab32(x)
64 #define __arch__swab16(x) ___arch__swab16(x)
66 #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
67 # define __BYTEORDER_HAS_U64__
68 # define __SWAB_64_THRU_32__
73 #include <linux/byteorder/big_endian.h>
75 #endif /* _PARISC_BYTEORDER_H */