You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/02 05:36:11 UTC
[GitHub] [incubator-nuttx] yamt commented on a diff in pull request #7505: include/endian:add openbsd style macro
yamt commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1011212770
##########
include/endian.h:
##########
@@ -140,18 +140,47 @@
/* OpenBSD style */
+#define __bemtoh16(x) htobe16(*(uint16_t *)(x))
+#define __htobem16(x, v) (*(uint16_t *)(x) = htobe16(v))
+#define __lemtoh16(x) htole16(*(uint16_t *)(x))
+#define __htolem16(x, v) (*(__uint16_t *)(x) = htole16(v))
+
+#define __bemtoh32(x) htobe32(*(uint32_t *)(x))
+#define __htobem32(x, v) (*(uint32_t *)(x) = htobe32(v))
+#define __lemtoh32(x) htole32(*(uint32_t *)(x))
+#define __htolem32(x, v) (*(__uint32_t *)(x) = htole32(v))
+
+#ifdef CONFIG_HAVE_LONG_LONG
+#define __bemtoh64(x) htobe64(*(uint64_t *)(x))
+#define __htobem64(x, v) (*(uint64_t *)(x) = htobe64(v))
+#define __lemtoh64(x) htole64(*(uint64_t *)(x))
+#define __htolem64(x, v) (*(__uint64_t *)(x) = htole64(v))
Review Comment:
why do you use uint64_t in some places and __uint64_t in the other places?
##########
include/endian.h:
##########
@@ -140,18 +140,47 @@
/* OpenBSD style */
+#define __bemtoh16(x) htobe16(*(uint16_t *)(x))
+#define __htobem16(x, v) (*(uint16_t *)(x) = htobe16(v))
+#define __lemtoh16(x) htole16(*(uint16_t *)(x))
+#define __htolem16(x, v) (*(__uint16_t *)(x) = htole16(v))
+
+#define __bemtoh32(x) htobe32(*(uint32_t *)(x))
+#define __htobem32(x, v) (*(uint32_t *)(x) = htobe32(v))
+#define __lemtoh32(x) htole32(*(uint32_t *)(x))
+#define __htolem32(x, v) (*(__uint32_t *)(x) = htole32(v))
+
+#ifdef CONFIG_HAVE_LONG_LONG
+#define __bemtoh64(x) htobe64(*(uint64_t *)(x))
+#define __htobem64(x, v) (*(uint64_t *)(x) = htobe64(v))
+#define __lemtoh64(x) htole64(*(uint64_t *)(x))
+#define __htolem64(x, v) (*(__uint64_t *)(x) = htole64(v))
+#endif
+
#define swap16 __swap_uint16
#define swap32 __swap_uint32
#define swap64 __swap_uint64
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16 __bemtoh16
+#define htobem16 __htobem16
+#define lemtoh16 __lemtoh16
+#define htolem16 __htolem16
#define betoh32 be32toh
#define letoh32 le32toh
+#define bemtoh32 __bemtoh32
Review Comment:
why do you use __bemtoh32 indirection?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org