include/endian:add openbsd style macro

bemtoh htobem lemtoh htolem

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2022-11-02 12:33:42 +08:00 committed by Xiang Xiao
parent f43f046983
commit 64ebdb0339
1 changed files with 12 additions and 0 deletions

View File

@ -146,12 +146,24 @@
#define betoh16 be16toh
#define letoh16 le16toh
#define bemtoh16(x) betoh16(*(FAR uint16_t *)(x))
#define htobem16(x, v) (*(FAR uint16_t *)(x) = htobe16(v))
#define lemtoh16(x) letoh16(*(FAR uint16_t *)(x))
#define htolem16(x, v) (*(FAR uint16_t *)(x) = htole16(v))
#define betoh32 be32toh
#define letoh32 le32toh
#define bemtoh32(x) htobe32(*(FAR uint32_t *)(x))
#define htobem32(x, v) (*(FAR uint32_t *)(x) = htobe32(v))
#define lemtoh32(x) letoh32(*(FAR uint32_t *)(x))
#define htolem32(x, v) (*(FAR uint32_t *)(x) = htole32(v))
#ifdef CONFIG_HAVE_LONG_LONG
#define betoh64 be64toh
#define letoh64 le64toh
#define bemtoh64(x) htobe64(*(FAR uint64_t *)(x))
#define htobem64(x, v) (*(FAR uint64_t *)(x) = htobe64(v))
#define lemtoh64(x) letoh64(*(FAR uint64_t *)(x))
#define htolem64(x, v) (*(FAR uint64_t *)(x) = htole64(v))
#endif
#endif /* __INCLUDE_ENDIAN_H */