patch-2.1.43 linux/include/asm-i386/byteorder.h
Next file: linux/include/asm-i386/keyboard.h
Previous file: linux/include/asm-i386/bugs.h
Back to the patch index
Back to the overall index
- Lines: 92
- Date:
Sun Jun 15 15:12:29 1997
- Orig file:
v2.1.42/linux/include/asm-i386/byteorder.h
- Orig date:
Thu Jun 12 15:28:32 1997
diff -u --recursive --new-file v2.1.42/linux/include/asm-i386/byteorder.h linux/include/asm-i386/byteorder.h
@@ -17,21 +17,6 @@
/* For avoiding bswap on i386 */
#ifdef __KERNEL__
#include <linux/config.h>
-
-/*
- * In-kernel byte order macros to handle stuff like
- * byte-order-dependent filesystems etc.
- */
-#define cpu_to_le32(x) (x)
-#define le32_to_cpu(x) (x)
-#define cpu_to_le16(x) (x)
-#define le16_to_cpu(x) (x)
-
-#define cpu_to_be32(x) htonl((x))
-#define be32_to_cpu(x) ntohl((x))
-#define cpu_to_be16(x) htons((x))
-#define be16_to_cpu(x) ntohs((x))
-
#endif
extern unsigned long int ntohl(unsigned long int);
@@ -101,5 +86,69 @@
__constant_htons((x)) : \
__htons((x)))
#endif
+
+#ifdef __KERNEL__
+/*
+ * In-kernel byte order macros to handle stuff like
+ * byte-order-dependent filesystems etc.
+ */
+#define cpu_to_le32(x) (x)
+#define cpu_to_le16(x) (x)
+
+#define cpu_to_be32(x) htonl((x))
+#define cpu_to_be16(x) htons((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);
+}
+
+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. */
+#define cpu_to_le16s(x) do { } while (0)
+#define cpu_to_le32s(x) do { } while (0)
+
+extern __inline__ void cpu_to_be16s(__u16 *addr)
+{
+ *addr = cpu_to_be16(*addr);
+}
+
+extern __inline__ void cpu_to_be32s(__u32 *addr)
+{
+ *addr = cpu_to_be32(*addr);
+}
+
+/* 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
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov