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 04:38:08 UTC
[GitHub] [incubator-nuttx] anjiahao1 opened a new pull request, #7505: include/endian:add openbsd style macro
anjiahao1 opened a new pull request, #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505
add this macro bemtoh htobem lemtoh htolem
Signed-off-by: anjiahao <an...@xiaomi.com>
## Summary
add some endian macro
## Impact
nothing
## Testing
ci
--
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
[GitHub] [incubator-nuttx] anjiahao1 commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
anjiahao1 commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1011305181
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(uint16_t *)(x))
Review Comment:
Basic macros are already defined
--
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
[GitHub] [incubator-nuttx] yamt commented on pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
yamt commented on PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#issuecomment-1299739262
> > do you have an example of apps which uses these api?
>
> [crypto](https://github.com/apache/incubator-nuttx/actions/runs/3343702821/jobs/5537455268) crypto use it
ok. thank you
--
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
[GitHub] [incubator-nuttx] yamt commented on pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
yamt commented on PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#issuecomment-1299600549
do you have an example of apps which uses these api?
--
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
[GitHub] [incubator-nuttx] yamt commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
yamt commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1011331269
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(uint16_t *)(x))
+#define htobem16(x, v) (*(uint16_t *)(x) = htobe16(v))
+#define lemtoh16(x) htole16(*(uint16_t *)(x))
Review Comment:
i guess it's simpler to read if you use letoh16 instead of htole16.
ditto for other macros.
--
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
[GitHub] [incubator-nuttx] yamt commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1012548135
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(uint16_t *)(x))
Review Comment:
FAR
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1011307014
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(uint16_t *)(x))
Review Comment:
Sorry. Missed that
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1011303350
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(uint16_t *)(x))
Review Comment:
Why this is not depending on big or little endian?
--
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
[GitHub] [incubator-nuttx] anjiahao1 commented on pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
anjiahao1 commented on PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#issuecomment-1299689841
> do you have an example of apps which uses these api?
[crypto](https://github.com/apache/incubator-nuttx/actions/runs/3343702821/jobs/5537455268) crypto use it
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1012923057
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(FAR uint16_t *)(x))
Review Comment:
Whyit is not
```suggestion
#define bemtoh16(x) betoh16(*(FAR uint16_t *)(x))
```
Even it it results to the same it seems to be not intuitive as it is now
--
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
[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505
--
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
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7505: include/endian:add openbsd style macro
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7505:
URL: https://github.com/apache/incubator-nuttx/pull/7505#discussion_r1013411539
##########
include/endian.h:
##########
@@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
+#define bemtoh16(x) htobe16(*(FAR uint16_t *)(x))
+#define htobem16(x, v) (*(FAR uint16_t *)(x) = htobe16(v))
+#define lemtoh16(x) htole16(*(FAR uint16_t *)(x))
Review Comment:
Why not
```suggestion
#define lemtoh16(x) letoh16(*(FAR uint16_t *)(x))
```
--
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