diff mbox series

[V3,4/9] include: Provide endian conversion functions

Message ID 20230511162418.10408-5-clombard@linux.ibm.com
State Superseded
Headers show
Series Import external libraries for MCTP/PLDM protocols | expand

Commit Message

Christophe Lombard May 11, 2023, 4:24 p.m. UTC
Implement the BSD endian conversion functions in terms of the ccan
ones since the external libraries: libpldm and libmctp use them heavily.

Signed-off-by: Christophe Lombard <clombard@linux.ibm.com>
---
 include/endian.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 include/endian.h
diff mbox series

Patch

diff --git a/include/endian.h b/include/endian.h
new file mode 100644
index 00000000..6b2cff29
--- /dev/null
+++ b/include/endian.h
@@ -0,0 +1,21 @@ 
+#ifndef _ENDIAN_H_
+#define _ENDIAN_H_
+
+#include <ccan/endian/endian.h>
+
+/* use the ccan endian conversion functions */
+#define htobe16 cpu_to_be16
+#define htobe32 cpu_to_be32
+#define htole16 cpu_to_le16
+#define htole32 cpu_to_le32
+#define htobe64 cpu_to_be64
+#define htole64 cpu_to_le64
+
+#define be16toh be16_to_cpu
+#define be32toh be32_to_cpu
+#define le16toh le16_to_cpu
+#define le32toh le32_to_cpu
+#define le64toh le64_to_cpu
+#define be64toh be64_to_cpu
+
+#endif /* _ENDIAN_H_ */