Rename the adler struct to adler32.

This commit is contained in:
Nigel Tao committed 2017-10-19 20:49:20 +11:00
1 parent f9cea5c17c
commit 74f3b76b09
4 files changed
+33 -33

No files matched your search

+15 -15
View File
@@ -237,7 +237,7 @@ typedef struct {
typedef struct { typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI // Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so. Instead, use the // compatibility or safety guarantee if you do so. Instead, use the
// puffs_flate_adler_etc functions. // puffs_flate_adler32_etc functions.
// //
// In C++, these fields would be "private", but C does not support that. // In C++, these fields would be "private", but C does not support that.
// //
@@ -249,7 +249,7 @@ typedef struct {
uint32_t f_state; uint32_t f_state;
} private_impl; } private_impl;
} puffs_flate_adler; } puffs_flate_adler32;
typedef struct { typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI // Do not access the private_impl's fields directly. There is no API/ABI
@@ -264,7 +264,7 @@ typedef struct {
uint32_t magic; uint32_t magic;
puffs_flate_decoder f_dec; puffs_flate_decoder f_dec;
puffs_flate_adler f_adler; puffs_flate_adler32 f_adler;
struct { struct {
uint32_t coro_susp_point; uint32_t coro_susp_point;
@@ -665,9 +665,9 @@ static const uint32_t puffs_flate_dcode_magic_numbers[32] = {
// ---------------- Private Initializer Prototypes // ---------------- Private Initializer Prototypes
void puffs_flate_adler_initialize(puffs_flate_adler* self, void puffs_flate_adler32_initialize(puffs_flate_adler32* self,
uint32_t puffs_version, uint32_t puffs_version,
uint32_t for_internal_use_only); uint32_t for_internal_use_only);
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
@@ -697,8 +697,8 @@ puffs_flate_status puffs_flate_decoder_init_huff(puffs_flate_decoder* self,
uint32_t a_n_codes1, uint32_t a_n_codes1,
uint32_t a_base_symbol); uint32_t a_base_symbol);
uint32_t puffs_flate_adler_update(puffs_flate_adler* self, uint32_t puffs_flate_adler32_update(puffs_flate_adler32* self,
puffs_base_slice_u8 a_x); puffs_base_slice_u8 a_x);
// ---------------- Initializer Implementations // ---------------- Initializer Implementations
@@ -732,9 +732,9 @@ void puffs_flate_decoder_initialize(puffs_flate_decoder* self,
self->private_impl.magic = PUFFS_MAGIC; self->private_impl.magic = PUFFS_MAGIC;
} }
void puffs_flate_adler_initialize(puffs_flate_adler* self, void puffs_flate_adler32_initialize(puffs_flate_adler32* self,
uint32_t puffs_version, uint32_t puffs_version,
uint32_t for_internal_use_only) { uint32_t for_internal_use_only) {
if (!self) { if (!self) {
return; return;
} }
@@ -765,8 +765,8 @@ void puffs_flate_zlib_decoder_initialize(puffs_flate_zlib_decoder* self,
self->private_impl.magic = PUFFS_MAGIC; self->private_impl.magic = PUFFS_MAGIC;
puffs_flate_decoder_initialize(&self->private_impl.f_dec, PUFFS_VERSION, puffs_flate_decoder_initialize(&self->private_impl.f_dec, PUFFS_VERSION,
PUFFS_ALREADY_ZEROED); PUFFS_ALREADY_ZEROED);
puffs_flate_adler_initialize(&self->private_impl.f_adler, PUFFS_VERSION, puffs_flate_adler32_initialize(&self->private_impl.f_adler, PUFFS_VERSION,
PUFFS_ALREADY_ZEROED); PUFFS_ALREADY_ZEROED);
} }
// ---------------- Function Implementations // ---------------- Function Implementations
@@ -2420,8 +2420,8 @@ short_read_src:
goto suspend; goto suspend;
} }
uint32_t puffs_flate_adler_update(puffs_flate_adler* self, uint32_t puffs_flate_adler32_update(puffs_flate_adler32* self,
puffs_base_slice_u8 a_x) { puffs_base_slice_u8 a_x) {
uint32_t v_s1; uint32_t v_s1;
uint32_t v_s2; uint32_t v_s2;
puffs_base_slice_u8 v_remaining; puffs_base_slice_u8 v_remaining;
+3 -3
View File
@@ -237,7 +237,7 @@ typedef struct {
typedef struct { typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI // Do not access the private_impl's fields directly. There is no API/ABI
// compatibility or safety guarantee if you do so. Instead, use the // compatibility or safety guarantee if you do so. Instead, use the
// puffs_flate_adler_etc functions. // puffs_flate_adler32_etc functions.
// //
// In C++, these fields would be "private", but C does not support that. // In C++, these fields would be "private", but C does not support that.
// //
@@ -249,7 +249,7 @@ typedef struct {
uint32_t f_state; uint32_t f_state;
} private_impl; } private_impl;
} puffs_flate_adler; } puffs_flate_adler32;
typedef struct { typedef struct {
// Do not access the private_impl's fields directly. There is no API/ABI // Do not access the private_impl's fields directly. There is no API/ABI
@@ -264,7 +264,7 @@ typedef struct {
uint32_t magic; uint32_t magic;
puffs_flate_decoder f_dec; puffs_flate_decoder f_dec;
puffs_flate_adler f_adler; puffs_flate_adler32 f_adler;
struct { struct {
uint32_t coro_susp_point; uint32_t coro_susp_point;
+3 -3
View File
@@ -20,7 +20,7 @@ pub error "TODO: unsupported zlib preset dictionary"
pub struct zlib_decoder?( pub struct zlib_decoder?(
dec decoder, dec decoder,
adler adler, adler adler32,
) )
pub func zlib_decoder.decode?(dst writer1, src reader1)() { pub func zlib_decoder.decode?(dst writer1, src reader1)() {
@@ -43,11 +43,11 @@ pub func zlib_decoder.decode?(dst writer1, src reader1)() {
} }
// TODO: drop the '?' but still generate puffs_flate_adler_initialize? // TODO: drop the '?' but still generate puffs_flate_adler_initialize?
pri struct adler?( pri struct adler32?(
state u32 = 1, state u32 = 1,
) )
pri func adler.update(x[] u8)(checksum u32) { pri func adler32.update(x[] u8)(checksum u32) {
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in // The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
// RFC 1950. // RFC 1950.
+12 -12
View File
@@ -157,13 +157,13 @@ void test_puffs_adler32() {
if (!read_file(&src, test_cases[i].filename)) { if (!read_file(&src, test_cases[i].filename)) {
return; return;
} }
puffs_flate_adler checksum; puffs_flate_adler32 checksum;
puffs_flate_adler_initialize(&checksum, PUFFS_VERSION, 0); puffs_flate_adler32_initialize(&checksum, PUFFS_VERSION, 0);
uint32_t got = uint32_t got =
puffs_flate_adler_update(&checksum, ((puffs_base_slice_u8){ puffs_flate_adler32_update(&checksum, ((puffs_base_slice_u8){
.ptr = src.ptr + src.ri, .ptr = src.ptr + src.ri,
.len = src.wi - src.ri, .len = src.wi - src.ri,
})); }));
if (got != test_cases[i].want) { if (got != test_cases[i].want) {
FAIL("i=%d, filename=\"%s\": got 0x%08" PRIX32 ", want 0x%08" PRIX32 "\n", FAIL("i=%d, filename=\"%s\": got 0x%08" PRIX32 ", want 0x%08" PRIX32 "\n",
i, test_cases[i].filename, got, test_cases[i].want); i, test_cases[i].filename, got, test_cases[i].want);
@@ -694,13 +694,13 @@ const char* puffs_bench_adler32(puffs_base_buf1* dst,
uint64_t wlimit, uint64_t wlimit,
uint64_t rlimit) { uint64_t rlimit) {
// TODO: don't ignore wlimit and rlimit. // TODO: don't ignore wlimit and rlimit.
puffs_flate_adler checksum; puffs_flate_adler32 checksum;
puffs_flate_adler_initialize(&checksum, PUFFS_VERSION, 0); puffs_flate_adler32_initialize(&checksum, PUFFS_VERSION, 0);
global_puffs_flate_unused_u32 = global_puffs_flate_unused_u32 =
puffs_flate_adler_update(&checksum, ((puffs_base_slice_u8){ puffs_flate_adler32_update(&checksum, ((puffs_base_slice_u8){
.ptr = src->ptr + src->ri, .ptr = src->ptr + src->ri,
.len = src->wi - src->ri, .len = src->wi - src->ri,
})); }));
src->ri = src->wi; src->ri = src->wi;
return NULL; return NULL;
} }