diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-10-12 03:54:29 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-10-12 03:54:29 +0000 |
commit | b305bf616804db7176601bc2acd3495f0217e1c4 (patch) | |
tree | 872d15cd162204ec273199e7d0495bb163daa1b4 /src/headers | |
parent | 4fa9aa58a926275c2db31a4cc98122e7883c714a (diff) | |
download | skalibs-b305bf616804db7176601bc2acd3495f0217e1c4.tar.xz |
Add UINT??_BSWAP as constexp macro; rip off typedef uint?? bandaid
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/headers')
-rw-r--r-- | src/headers/bits-bendian | 4 | ||||
-rw-r--r-- | src/headers/bits-footer | 2 | ||||
-rw-r--r-- | src/headers/bits-lendian | 5 | ||||
-rw-r--r-- | src/headers/bits-template | 1 | ||||
-rw-r--r-- | src/headers/uint16-bswap | 2 | ||||
-rw-r--r-- | src/headers/uint32-bswap | 2 | ||||
-rw-r--r-- | src/headers/uint64-bswap | 2 | ||||
-rw-r--r-- | src/headers/uint64-include | 1 |
8 files changed, 16 insertions, 3 deletions
diff --git a/src/headers/bits-bendian b/src/headers/bits-bendian index ac1169f..19b4bff 100644 --- a/src/headers/bits-bendian +++ b/src/headers/bits-bendian @@ -1,3 +1,7 @@ + +#define UINT@BITS@_LITTLE(u) UINT@BITS@_BSWAP(u) +#define UINT@BITS@_BIG(u) (u) + #define uint@BITS@_little(u) uint@BITS@_bswap(u) #define uint@BITS@_big(u) (u) diff --git a/src/headers/bits-footer b/src/headers/bits-footer index b6f75a9..ddd5dae 100644 --- a/src/headers/bits-footer +++ b/src/headers/bits-footer @@ -1,4 +1,2 @@ -typedef uint@BITS@_t uint@BITS@ ; - #endif diff --git a/src/headers/bits-lendian b/src/headers/bits-lendian index e2358d3..e0017f5 100644 --- a/src/headers/bits-lendian +++ b/src/headers/bits-lendian @@ -1,3 +1,7 @@ + +#define UINT@BITS@_LITTLE(u) (u) +#define UINT@BITS@_BIG(u) UINT@BITS@_BSWAP(u) + #define uint@BITS@_little(u) (u) #define uint@BITS@_big(u) uint@BITS@_bswap(u) @@ -6,4 +10,3 @@ #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 23222d6..f0b71df 100644 --- a/src/headers/bits-template +++ b/src/headers/bits-template @@ -1,3 +1,4 @@ + 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 *) ; diff --git a/src/headers/uint16-bswap b/src/headers/uint16-bswap new file mode 100644 index 0000000..2bf5c8e --- /dev/null +++ b/src/headers/uint16-bswap @@ -0,0 +1,2 @@ + +#define UINT16_BSWAP(a) (((a) & 0x00ffu) << 8 | ((a) & 0xff00u) >> 8) diff --git a/src/headers/uint32-bswap b/src/headers/uint32-bswap new file mode 100644 index 0000000..4ba4d9b --- /dev/null +++ b/src/headers/uint32-bswap @@ -0,0 +1,2 @@ + +#define UINT32_BSWAP(a) (((a) & 0x000000ffu) << 24 | ((a) & 0x0000ff00u) << 8 | ((a) & 0x00ff0000u) >> 8 | ((a) & 0xff000000u) >> 24) diff --git a/src/headers/uint64-bswap b/src/headers/uint64-bswap new file mode 100644 index 0000000..3ebd512 --- /dev/null +++ b/src/headers/uint64-bswap @@ -0,0 +1,2 @@ + +#define UINT64_BSWAP(a) (((a) & 0x00000000000000ffull) << 56 | ((a) & 0x000000000000ff00ull) << 40 | ((a) & 0x0000000000ff0000ull) << 24 | ((a) & 0x00000000ff000000ull) << 8 | ((a) & 0x000000ff00000000ull) >> 8 | ((a) & 0x0000ff0000000000ull) >> 24 | ((a) & 0x00ff000000000000ull) >> 40 | ((a) & 0xff00000000000000ull) >> 56) diff --git a/src/headers/uint64-include b/src/headers/uint64-include index 12a0936..079bc2d 100644 --- a/src/headers/uint64-include +++ b/src/headers/uint64-include @@ -1 +1,2 @@ + #include <skalibs/uint64.h> |