[PATCH BlueZ v3 05/20] shared: Add put_le128()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add helper to put uint128 values to the given pointer using little-endian
representation. This helper is only a wrapper of cpu_to_le128().
---
 src/shared/util.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/shared/util.h b/src/shared/util.h
index cc2dbcd..f3db8fb 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -26,6 +26,8 @@
 #include <alloca.h>
 #include <byteswap.h>
 
+#include <bluetooth/bluetooth.h>
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define le16_to_cpu(val) (val)
 #define le32_to_cpu(val) (val)
@@ -56,6 +58,27 @@
 #error "Unknown byte order"
 #endif
 
+#if __BYTE_ORDER == __BIG_ENDIAN
+
+static inline void cpu_to_le128(const uint128_t *src, uint128_t *dst)
+{
+	int i;
+
+	for (i = 0; i < 16; i++)
+		dst->data[15 - i] = src->data[i];
+}
+
+#else
+
+static inline void cpu_to_le128(const uint128_t *src, uint128_t *dst)
+{
+	*dst = *src;
+}
+
+#endif
+
+#define put_le128(val, dst) cpu_to_le128(val, dst)
+
 #define get_unaligned(ptr)			\
 ({						\
 	struct __attribute__((packed)) {	\
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux