patch-2.1.43 linux/include/asm-ppc/byteorder.h
Next file: linux/include/asm-ppc/keyboard.h
Previous file: linux/include/asm-mips/keyboard.h
Back to the patch index
Back to the overall index
- Lines: 93
- Date:
Thu Jun 12 16:22:10 1997
- Orig file:
v2.1.42/linux/include/asm-ppc/byteorder.h
- Orig date:
Wed Dec 18 00:54:09 1996
diff -u --recursive --new-file v2.1.42/linux/include/asm-ppc/byteorder.h linux/include/asm-ppc/byteorder.h
@@ -19,38 +19,72 @@
#define __constant_htonl(x) ntohl(x)
#define __constant_htons(x) ntohs(x)
-/*
- * In-kernel byte order macros to handle stuff like
- * byte-order-dependent filesystems etc.
- */
+#ifdef __KERNEL__
-#define cpu_to_le32(x) le32_to_cpu((x))
-extern __inline__ unsigned long le32_to_cpu(unsigned long x)
+/* Convert from CPU byte order, to specified byte order. */
+extern __inline__ __u16 cpu_to_le16(__u16 value)
{
- return (((x & 0x000000ffU) << 24) |
- ((x & 0x0000ff00U) << 8) |
- ((x & 0x00ff0000U) >> 8) |
- ((x & 0xff000000U) >> 24));
+ return (value >> 8) | (value << 8);
}
-
-#define cpu_to_le16(x) le16_to_cpu((x))
-extern __inline__ unsigned short le16_to_cpu(unsigned short x)
+extern __inline__ __u32 cpu_to_le32(__u32 value)
{
- return (((x & 0x00ff) << 8) |
- ((x & 0xff00) >> 8));
+ return((value>>24) | ((value>>8)&0xff00) |
+ ((value<<8)&0xff0000) | (value<<24));
}
+#define cpu_to_be16(x) (x)
+#define cpu_to_be32(x) (x)
-#define cpu_to_be32(x) (x)
-#define be32_to_cpu(x) (x)
-#define cpu_to_be16(x) (x)
-#define be16_to_cpu(x) (x)
+/* The same, but returns converted value from the location pointer by addr. */
+extern __inline__ __u16 cpu_to_le16p(__u16 *addr)
+{
+ return cpu_to_le16(*addr);
+}
+extern __inline__ __u32 cpu_to_le32p(__u32 *addr)
+{
+ return cpu_to_le32(*addr);
+}
-#endif /* !(_PPC_BYTEORDER_H) */
+extern __inline__ __u16 cpu_to_be16p(__u16 *addr)
+{
+ return cpu_to_be16(*addr);
+}
+extern __inline__ __u32 cpu_to_be32p(__u32 *addr)
+{
+ return cpu_to_be32(*addr);
+}
+/* The same, but do the conversion in situ, ie. put the value back to addr. */
+extern __inline__ void cpu_to_le16s(__u16 *addr)
+{
+ *addr = cpu_to_le16(*addr);
+}
+extern __inline__ void cpu_to_le32s(__u32 *addr)
+{
+ *addr = cpu_to_le32(*addr);
+}
+#define cpu_to_be16s(x) do { } while (0)
+#define cpu_to_be32s(x) do { } while (0)
+/* Convert from specified byte order, to CPU byte order. */
+#define le16_to_cpu(x) cpu_to_le16(x)
+#define le32_to_cpu(x) cpu_to_le32(x)
+#define be16_to_cpu(x) cpu_to_be16(x)
+#define be32_to_cpu(x) cpu_to_be32(x)
+
+#define le16_to_cpup(x) cpu_to_le16p(x)
+#define le32_to_cpup(x) cpu_to_le32p(x)
+#define be16_to_cpup(x) cpu_to_be16p(x)
+#define be32_to_cpup(x) cpu_to_be32p(x)
+
+#define le16_to_cpus(x) cpu_to_le16s(x)
+#define le32_to_cpus(x) cpu_to_le32s(x)
+#define be16_to_cpus(x) cpu_to_be16s(x)
+#define be32_to_cpus(x) cpu_to_be32s(x)
+#endif /* __KERNEL__ */
+#endif /* !(_PPC_BYTEORDER_H) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov