All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/6v3] byteorder: add get/put endian helpers for the aligned case
@ 2008-05-28 19:33 Harvey Harrison
  0 siblings, 0 replies; only message in thread
From: Harvey Harrison @ 2008-05-28 19:33 UTC (permalink / raw)
  To: linux-arch; +Cc: Andrew Morton

Create helpers when working with aligned loads/stores, same
functionality as get_unaligned_* and put_unaligned_*

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 include/linux/byteorder.h |   84 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
index b4713ce..ad47244 100644
--- a/include/linux/byteorder.h
+++ b/include/linux/byteorder.h
@@ -278,6 +278,90 @@ static inline __be64 __cpu_to_be64p(const __u64 *p)
 # define htons(x) ___htons(x)
 # define ntohs(x) ___ntohs(x)
 
+static inline u16 get_le16(const __le16 *p)
+{
+#ifdef __LITTLE_ENDIAN
+	return (__force u16)*p;
+#else
+	return swab16p((__force u16 *)p);
+#endif
+}
+
+static inline u32 get_le32(const __le32 *p)
+{
+#ifdef __LITTLE_ENDIAN
+	return (__force u32)*p;
+#else
+	return swab32p((__force u32 *)p);
+#endif
+}
+
+static inline u64 get_le64(const __le64 *p)
+{
+#ifdef __LITTLE_ENDIAN
+	return (__force u64)*p;
+#else
+	return __swab64p((__force u64 *)p);
+#endif
+}
+
+static inline u16 get_be16(const __be16 *p)
+{
+#ifdef __BIG_ENDIAN
+	return (__force u16)*p;
+#else
+	return swab16p((__force u16 *)p);
+#endif
+}
+
+static inline u32 get_be32(const __be32 *p)
+{
+#ifdef __BIG_ENDIAN
+	return (__force u32)*p;
+#else
+	return swab32p((__force u32 *)p);
+#endif
+}
+
+static inline u64 get_be64(const __be64 *p)
+{
+#ifdef __BIG_ENDIAN
+	return (__force u64)*p;
+#else
+	return __swab64p((__force u64 *)p);
+#endif
+}
+
+static inline void put_le16(u16 val, __le16 *p)
+{
+	*p = cpu_to_le16(val);
+}
+
+static inline void put_le32(u32 val, __le32 *p)
+{
+	*p = cpu_to_le32(val);
+}
+
+static inline void put_le64(u64 val, __le64 *p)
+{
+	*p = cpu_to_le64(val);
+}
+
+static inline void put_be16(u16 val, __be16 *p)
+{
+	*p = cpu_to_be16(val);
+}
+
+static inline void put_be32(u32 val, __be32 *p)
+{
+	*p = cpu_to_be32(val);
+}
+
+static inline void put_be64(u64 val, __be64 *p)
+{
+	*p = cpu_to_be64(val);
+}
+
 static inline void le16_add_cpu(__le16 *var, u16 val)
 {
 	*var = cpu_to_le16(le16_to_cpup(var) + val);
-- 
1.5.5.1.579.g4e43

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-28 19:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-28 19:33 [PATCH 3/6v3] byteorder: add get/put endian helpers for the aligned case Harvey Harrison

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.