From e88276fdec7b3b94ec939f5eb1c8def004ee3878 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 1 Jun 2022 12:36:34 +0000 Subject: Rework endianness conversion primitives Signed-off-by: Laurent Bercot --- src/headers/bits-bendian | 8 +++++--- src/headers/bits-lendian | 9 ++++++--- src/headers/bits-template | 3 ++- src/headers/unsigned-template | 10 ++++++---- 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src/headers') diff --git a/src/headers/bits-bendian b/src/headers/bits-bendian index 6caf1e7..ac1169f 100644 --- a/src/headers/bits-bendian +++ b/src/headers/bits-bendian @@ -1,6 +1,8 @@ -#define uint@BITS@_little_endian(s, n) uint@BITS@_reverse((s), (n)) -#define uint@BITS@_big_endian(s, n) - #define uint@BITS@_little(u) uint@BITS@_bswap(u) #define uint@BITS@_big(u) (u) +#define uint@BITS@_littlep(u) uint@BITS@_bswapp(u) +#define uint@BITS@_bigp(u) + +#define uint@BITS@_littlen(array, n) uint@BITS@_bswapn(array, n) +#define uint@BITS@_bign(array, n) diff --git a/src/headers/bits-lendian b/src/headers/bits-lendian index 7528d46..e2358d3 100644 --- a/src/headers/bits-lendian +++ b/src/headers/bits-lendian @@ -1,6 +1,9 @@ -#define uint@BITS@_little_endian(s, n) -#define uint@BITS@_big_endian(s, n) uint@BITS@_reverse((s), (n)) - #define uint@BITS@_little(u) (u) #define uint@BITS@_big(u) uint@BITS@_bswap(u) +#define uint@BITS@_littlep(u) +#define uint@BITS@_bigp(u) uint@BITS@_bswapp(u) + +#define uint@BITS@_littlen(array, n) +#define uint@BITS@_bign(array, n) uint@BITS@_bswapn(array, n) + diff --git a/src/headers/bits-template b/src/headers/bits-template index f6cde95..306076d 100644 --- a/src/headers/bits-template +++ b/src/headers/bits-template @@ -2,8 +2,9 @@ extern void uint@BITS@_pack (char *, uint@BITS@_t) ; extern void uint@BITS@_pack_big (char *, uint@BITS@_t) ; extern void uint@BITS@_unpack (char const *, uint@BITS@_t *) ; extern void uint@BITS@_unpack_big (char const *, uint@BITS@_t *) ; -extern void uint@BITS@_reverse (char *, size_t) ; extern uint@BITS@_t uint@BITS@_bswap (uint@BITS@_t) ; +extern void uint@BITS@_bswapp (uint@BITS@_t *) ; +extern void uint@BITS@_bswapn (uint@BITS@_t *, size_t) ; #define UINT@BITS@_FMT @DFMT@ #define UINT@BITS@_OFMT @OFMT@ diff --git a/src/headers/unsigned-template b/src/headers/unsigned-template index 8ef6db4..d7496a0 100644 --- a/src/headers/unsigned-template +++ b/src/headers/unsigned-template @@ -4,9 +4,12 @@ #define @type@_unpack uint@BITS@_unpack #define @type@_unpack_big uint@BITS@_unpack_big -#define @type@_reverse uint@BITS@_reverse -#define @type@_big_endian uint@BITS@_big_endian -#define @type@_little_endian uint@BITS@_little_endian +#define @type@_little uint@BITS@_little +#define @type@_big uint@BITS@_big +#define @type@_littlep uint@BITS@_littlep +#define @type@_bigp uint@BITS@_bigp +#define @type@_littlen uint@BITS@_littlen +#define @type@_bign uint@BITS@_bign #define @TYPE@_FMT UINT@BITS@_FMT #define @TYPE@_OFMT UINT@BITS@_OFMT @@ -39,4 +42,3 @@ #define @type@_bscan(s, u) @type@_scan_base(s, (u), 2) #define @type@0_bscan(s, u) @type@0_scan_base(s, (u), 2) - -- cgit v1.2.3