author | Olivier Brunel
<jjk@jjacky.com> 2023-02-17 09:57:46 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-02-20 09:02:14 UTC |
parent | a534042339907e45b2366efd4545075ae7841152 |
doc/u16_pack.3.md | +33 | -0 |
doc/u32_pack.3.md | +33 | -0 |
doc/u64_pack.3.md | +3 | -3 |
include/blake3.h | +1 | -0 |
include/limb/int.h | +0 | -11 |
include/limb/u16.h | +12 | -0 |
include/limb/u32.h | +12 | -0 |
include/limb/u64.h | +15 | -0 |
include/limb/uint64.h | +1 | -1 |
src/nextsplit_buz.c | +1 | -0 |
src/nextsplit_rabin.c | +1 | -0 |
src/tools/mkrabintables.c | +1 | -1 |
diff --git a/doc/u16_pack.3.md b/doc/u16_pack.3.md new file mode 100644 index 0000000..94e5900 --- /dev/null +++ b/doc/u16_pack.3.md @@ -0,0 +1,33 @@ +% limb manual +% u16_pack(3) + +# NAME + +u16\_pack, u16\_unpack, u16\_pack\_big, u16\_unpack\_big - pack\/unpack an +integer (u16) into\/from a byte array + +# SYNOPSIS + + #include <limb/u16.h> + +```pre hl +void u16_pack(u16 <em>val</em>, void *<em>dst</em>) +void u16_unpack(const void *<em>sce</em>, u16 *<em>val</em>) +void u16_pack_big(u16 <em>val</em>, void *<em>dst</em>) +void 164_unpack_big(const void *<em>sce</em>, u16 *<em>val</em>) +``` + +# DESCRIPTION + +All of these aim to either pack the given integer (u16) `val` into the specified +byte array `dst`, or unpack from the specified byte array `sce` the integer +value into the pointed `val`. + +The `u16_pack`() function packs `val` into 8 bytes encoded as little endian, the +`u16_pack_big`() function does the same encoded as big endian. + +The `u16_unpack` family does the same, only unpacking from the byte array `sce` +into `val` + +These are actually macros to the relevant `uint16_*` functions, offering a +slightly different interface. diff --git a/doc/u32_pack.3.md b/doc/u32_pack.3.md new file mode 100644 index 0000000..c1b7780 --- /dev/null +++ b/doc/u32_pack.3.md @@ -0,0 +1,33 @@ +% limb manual +% u32_pack(3) + +# NAME + +u32\_pack, u32\_unpack, u32\_pack\_big, u32\_unpack\_big - pack\/unpack an +integer (u32) into\/from a byte array + +# SYNOPSIS + + #include <limb/u32.h> + +```pre hl +void u32_pack(u32 <em>val</em>, void *<em>dst</em>) +void u32_unpack(const void *<em>sce</em>, u32 *<em>val</em>) +void u32_pack_big(u32 <em>val</em>, void *<em>dst</em>) +void 324_unpack_big(const void *<em>sce</em>, u32 *<em>val</em>) +``` + +# DESCRIPTION + +All of these aim to either pack the given integer (u32) `val` into the specified +byte array `dst`, or unpack from the specified byte array `sce` the integer +value into the pointed `val`. + +The `u32_pack`() function packs `val` into 8 bytes encoded as little endian, the +`u32_pack_big`() function does the same encoded as big endian. + +The `u32_unpack` family does the same, only unpacking from the byte array `sce` +into `val` + +These are actually macros to the relevant `uint32_*` functions, offering a +slightly different interface. diff --git a/doc/u64_pack.3.md b/doc/u64_pack.3.md index 01af0b7..7572874 100644 --- a/doc/u64_pack.3.md +++ b/doc/u64_pack.3.md @@ -10,7 +10,7 @@ u64\_unpack\_trim - pack\/unpack an integer (u64) into\/from a byte array # SYNOPSIS - #include <limb/int.h> + #include <limb/u64.h> ```pre hl void u64_pack(u64 <em>val</em>, void *<em>dst</em>) @@ -37,8 +37,8 @@ See [uint64_pack_trim](3) for more. The `u64_unpack` family does the same, only unpacking from the byte array `sce` into `val` -These are actually macros to the relevant functions, offering a slightly -different interface. +These are actually macros to the relevant `uint64_*` functions, offering a +slightly different interface. # RETURN VALUE diff --git a/include/blake3.h b/include/blake3.h index c5ca3a6..22d4753 100644 --- a/include/blake3.h +++ b/include/blake3.h @@ -2,6 +2,7 @@ #define LIMB_BLAKE3_BLAKE3_H #include "limb/blake3.h" +#include "limb/uint64.h" /* internal flags */ enum blake3_flags { diff --git a/include/limb/int.h b/include/limb/int.h index c730d6b..a71ec72 100644 --- a/include/limb/int.h +++ b/include/limb/int.h @@ -2,8 +2,6 @@ #define LIMB_INT_H #include <stdint.h> -#include <skalibs/uint64.h> -#include "limb/uint64.h" typedef uint8_t u8; typedef uint16_t u16; @@ -15,13 +13,4 @@ typedef uint64_t u64; #define U32_C(u) UINT32_C(u) #define U64_C(u) UINT64_C(u) -extern int msb64(u64 val); - -#define u64_pack(val,dst) uint64_pack((char *) (dst), val) -#define u64_unpack(sce,val) uint64_unpack((const char *) (sce), val) -#define u64_pack_big(val,dst) uint64_pack_big((char *) (dst), val) -#define u64_unpack_big(sce,val) uint64_unpack_big((const char *) (sce), val) -#define u64_pack_trim(val,dst) uint64_pack_trim((char *) (dst), val) -#define u64_unpack_trim(sce,val) uint64_unpack_trim((const char *) (sce), val) - #endif /* LIMB_INT_H */ diff --git a/include/limb/u16.h b/include/limb/u16.h new file mode 100644 index 0000000..28cc4e9 --- /dev/null +++ b/include/limb/u16.h @@ -0,0 +1,12 @@ +#ifndef LIMB_U16_H +#define LIMB_U16_H + +#include <skalibs/uint16.h> +#include "limb/int.h" + +#define u16_pack(val,dst) uint16_pack((char *) (dst), val) +#define u16_unpack(sce,val) uint16_unpack((const char *) (sce), val) +#define u16_pack_big(val,dst) uint16_pack_big((char *) (dst), val) +#define u16_unpack_big(sce,val) uint16_unpack_big((const char *) (sce), val) + +#endif /* LIMB_U16_H */ diff --git a/include/limb/u32.h b/include/limb/u32.h new file mode 100644 index 0000000..6a3baca --- /dev/null +++ b/include/limb/u32.h @@ -0,0 +1,12 @@ +#ifndef LIMB_U32_H +#define LIMB_U32_H + +#include <skalibs/uint32.h> +#include "limb/int.h" + +#define u32_pack(val,dst) uint32_pack((char *) (dst), val) +#define u32_unpack(sce,val) uint32_unpack((const char *) (sce), val) +#define u32_pack_big(val,dst) uint32_pack_big((char *) (dst), val) +#define u32_unpack_big(sce,val) uint32_unpack_big((const char *) (sce), val) + +#endif /* LIMB_U32_H */ diff --git a/include/limb/u64.h b/include/limb/u64.h new file mode 100644 index 0000000..439bca7 --- /dev/null +++ b/include/limb/u64.h @@ -0,0 +1,15 @@ +#ifndef LIMB_U64_H +#define LIMB_U64_H + +#include <skalibs/uint64.h> +#include "limb/int.h" +#include "limb/uint64.h" + +#define u64_pack(val,dst) uint64_pack((char *) (dst), val) +#define u64_unpack(sce,val) uint64_unpack((const char *) (sce), val) +#define u64_pack_big(val,dst) uint64_pack_big((char *) (dst), val) +#define u64_unpack_big(sce,val) uint64_unpack_big((const char *) (sce), val) +#define u64_pack_trim(val,dst) uint64_pack_trim((char *) (dst), val) +#define u64_unpack_trim(sce,val) uint64_unpack_trim((const char *) (sce), val) + +#endif /* LIMB_U64_H */ diff --git a/include/limb/uint64.h b/include/limb/uint64.h index 1643bd2..63feccd 100644 --- a/include/limb/uint64.h +++ b/include/limb/uint64.h @@ -1,7 +1,7 @@ #ifndef LIMB_UINT64_H #define LIMB_UINT64_H -#include <stdint.h> +#include "limb/int.h" extern int msb64(uint64_t val); diff --git a/src/nextsplit_buz.c b/src/nextsplit_buz.c index 6595741..5d122ed 100644 --- a/src/nextsplit_buz.c +++ b/src/nextsplit_buz.c @@ -30,6 +30,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "limb/nextsplit.h" +#include "limb/uint64.h" size_t nextsplit_buz(size_t min, size_t avg, const void *data, size_t dlen) diff --git a/src/nextsplit_rabin.c b/src/nextsplit_rabin.c index 99c7c8c..7adbf17 100644 --- a/src/nextsplit_rabin.c +++ b/src/nextsplit_rabin.c @@ -1,4 +1,5 @@ #include "limb/nextsplit.h" +#include "limb/uint64.h" #include "limb/rabin-tables.h" /* This is based on rabin fingerprint, using a miw of two different variants : diff --git a/src/tools/mkrabintables.c b/src/tools/mkrabintables.c index 56ae8fe..6812b8c 100644 --- a/src/tools/mkrabintables.c +++ b/src/tools/mkrabintables.c @@ -1,5 +1,5 @@ #include <skalibs/uint16.h> -#include "limb/int.h" +#include "limb/uint64.h" #include "limb/output.h" const char *PROG = "mkrabintables";