patch-2.1.51 linux/include/asm-ppc/byteorder.h
Next file: linux/include/asm-ppc/checksum.h
Previous file: linux/include/asm-ppc/bitops.h
Back to the patch index
Back to the overall index
- Lines: 62
- Date:
Sat Aug 16 09:51:09 1997
- Orig file:
v2.1.50/linux/include/asm-ppc/byteorder.h
- Orig date:
Mon Aug 4 16:25:39 1997
diff -u --recursive --new-file v2.1.50/linux/include/asm-ppc/byteorder.h linux/include/asm-ppc/byteorder.h
@@ -4,17 +4,17 @@
#include <asm/types.h>
#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
#endif
#ifndef __BIG_ENDIAN_BITFIELD
#define __BIG_ENDIAN_BITFIELD
#endif
-#define ntohl(x) (x)
-#define ntohs(x) (x)
-#define htonl(x) (x)
-#define htons(x) (x)
+#define ntohl(x) ((unsigned long)(x))
+#define ntohs(x) ((unsigned short)(x))
+#define htonl(x) ((unsigned long)(x))
+#define htons(x) ((unsigned short)(x))
#define __htonl(x) ntohl(x)
#define __htons(x) ntohs(x)
@@ -54,7 +54,7 @@
asm volatile("stwbrx %0,0,%1" : : "r" (val), "r" (addr) : "memory");
}
-
+#if 0
extern __inline__ __u16 cpu_to_le16(__u16 value)
{
return ld_le16(&value);
@@ -63,6 +63,29 @@
{
return ld_le32(&value);
}
+#else
+extern __inline__ __u16 cpu_to_le16(__u16 value)
+{
+ __u16 result;
+
+ asm("rlwimi %0,%1,8,16,23"
+ : "=r" (result)
+ : "r" (value), "0" (value >> 8));
+ return result;
+}
+extern __inline__ __u32 cpu_to_le32(__u32 value)
+{
+ __u32 result;
+
+ asm("rlwimi %0,%1,24,16,23\n\t"
+ "rlwimi %0,%1,8,8,15\n\t"
+ "rlwimi %0,%1,24,0,7"
+ : "=r" (result)
+ : "r" (value), "0" (value >> 24));
+ return result;
+}
+#endif /* 0 */
+
#define cpu_to_be16(x) (x)
#define cpu_to_be32(x) (x)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov