[Skiboot] [PATCH V2 04/10] include: Provide endian conversion functions

Christophe Lombard clombard at linux.vnet.ibm.com
Tue Mar 15 23:49:08 AEDT 2022


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 at linux.vnet.ibm.com>
---
 include/endian.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 include/endian.h

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_ */
-- 
2.35.1



More information about the Skiboot mailing list