diff mbox series

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

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

Commit Message

Christophe Lombard June 20, 2023, 2:52 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 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 include/endian.h

Comments

Nicholas Piggin June 21, 2023, 4:30 a.m. UTC | #1
On Wed Jun 21, 2023 at 12:52 AM AEST, Christophe Lombard wrote:
> 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>

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> ---
>  include/endian.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 include/endian.h
>
> diff --git a/include/endian.h b/include/endian.h
> new file mode 100644
> index 00000000..df1342e2
> --- /dev/null
> +++ b/include/endian.h
> @@ -0,0 +1,24 @@
> +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
> +/* Copyright 2013-2022 IBM Corp. */
> +
> +#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.40.1
>
> _______________________________________________
> Skiboot mailing list
> Skiboot@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
diff mbox series

Patch

diff --git a/include/endian.h b/include/endian.h
new file mode 100644
index 00000000..df1342e2
--- /dev/null
+++ b/include/endian.h
@@ -0,0 +1,24 @@ 
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/* Copyright 2013-2022 IBM Corp. */
+
+#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_ */