mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Rename crc32.ieee to crc32.ieee_hasher
This commit is contained in:
1 parent
035b138cb1
commit
eecdaba4e8
8 files changed
+68
-67
No files matched your search
@@ -315,7 +315,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
}
|
}
|
||||||
if isThatMethod(g.tm, n, g.tm.ByName("update"), 1) {
|
if isThatMethod(g.tm, n, g.tm.ByName("update"), 1) {
|
||||||
// TODO: don't hard-code the class name or this.checksum.
|
// TODO: don't hard-code the class name or this.checksum.
|
||||||
class := "wuffs_crc32__ieee"
|
class := "wuffs_crc32__ieee_hasher"
|
||||||
if g.pkgName == "zlib" {
|
if g.pkgName == "zlib" {
|
||||||
class = "wuffs_adler32__hasher"
|
class = "wuffs_adler32__hasher"
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -1066,7 +1066,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s);
|
|||||||
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
|
||||||
// wuffs_crc32__ieee__etc functions.
|
// wuffs_crc32__ieee_hasher__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.
|
||||||
//
|
//
|
||||||
@@ -1078,23 +1078,23 @@ typedef struct {
|
|||||||
uint32_t f_state;
|
uint32_t f_state;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_crc32__ieee;
|
} wuffs_crc32__ieee_hasher;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_crc32__ieee__initialize is an initializer function.
|
// wuffs_crc32__ieee_hasher__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_crc32__ieee__* function.
|
// It should be called before any other wuffs_crc32__ieee_hasher__* function.
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
|
||||||
uint32_t wuffs_version,
|
uint32_t wuffs_version,
|
||||||
uint32_t for_internal_use_only);
|
uint32_t for_internal_use_only);
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
|
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||||
wuffs_base__slice_u8 a_x);
|
wuffs_base__slice_u8 a_x);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
@@ -1566,9 +1566,9 @@ static const uint32_t wuffs_crc32__ieee_table[256] = {
|
|||||||
|
|
||||||
// ---------------- Initializer Implementations
|
// ---------------- Initializer Implementations
|
||||||
|
|
||||||
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
|
||||||
uint32_t wuffs_version,
|
uint32_t wuffs_version,
|
||||||
uint32_t for_internal_use_only) {
|
uint32_t for_internal_use_only) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1584,8 +1584,8 @@ void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
|||||||
|
|
||||||
// ---------------- Function Implementations
|
// ---------------- Function Implementations
|
||||||
|
|
||||||
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
|
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||||
wuffs_base__slice_u8 a_x) {
|
wuffs_base__slice_u8 a_x) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-13
@@ -1075,7 +1075,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s);
|
|||||||
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
|
||||||
// wuffs_crc32__ieee__etc functions.
|
// wuffs_crc32__ieee_hasher__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.
|
||||||
//
|
//
|
||||||
@@ -1087,23 +1087,23 @@ typedef struct {
|
|||||||
uint32_t f_state;
|
uint32_t f_state;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_crc32__ieee;
|
} wuffs_crc32__ieee_hasher;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_crc32__ieee__initialize is an initializer function.
|
// wuffs_crc32__ieee_hasher__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_crc32__ieee__* function.
|
// It should be called before any other wuffs_crc32__ieee_hasher__* function.
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
|
||||||
uint32_t wuffs_version,
|
uint32_t wuffs_version,
|
||||||
uint32_t for_internal_use_only);
|
uint32_t for_internal_use_only);
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
|
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||||
wuffs_base__slice_u8 a_x);
|
wuffs_base__slice_u8 a_x);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
@@ -1354,7 +1354,7 @@ typedef struct {
|
|||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
wuffs_deflate__decoder f_flate;
|
wuffs_deflate__decoder f_flate;
|
||||||
wuffs_crc32__ieee f_checksum;
|
wuffs_crc32__ieee_hasher f_checksum;
|
||||||
bool f_ignore_checksum;
|
bool f_ignore_checksum;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@@ -1841,8 +1841,9 @@ void wuffs_gzip__decoder__initialize(wuffs_gzip__decoder* self,
|
|||||||
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
||||||
wuffs_deflate__decoder__initialize(&self->private_impl.f_flate, WUFFS_VERSION,
|
wuffs_deflate__decoder__initialize(&self->private_impl.f_flate, WUFFS_VERSION,
|
||||||
WUFFS_BASE__ALREADY_ZEROED);
|
WUFFS_BASE__ALREADY_ZEROED);
|
||||||
wuffs_crc32__ieee__initialize(&self->private_impl.f_checksum, WUFFS_VERSION,
|
wuffs_crc32__ieee_hasher__initialize(&self->private_impl.f_checksum,
|
||||||
WUFFS_BASE__ALREADY_ZEROED);
|
WUFFS_VERSION,
|
||||||
|
WUFFS_BASE__ALREADY_ZEROED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------- Function Implementations
|
// ---------------- Function Implementations
|
||||||
@@ -2103,7 +2104,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
|||||||
v_z = t_8;
|
v_z = t_8;
|
||||||
}
|
}
|
||||||
if (!self->private_impl.f_ignore_checksum) {
|
if (!self->private_impl.f_ignore_checksum) {
|
||||||
v_checksum_got = wuffs_crc32__ieee__update(
|
v_checksum_got = wuffs_crc32__ieee_hasher__update(
|
||||||
&self->private_impl.f_checksum,
|
&self->private_impl.f_checksum,
|
||||||
((wuffs_base__slice_u8){
|
((wuffs_base__slice_u8){
|
||||||
.ptr = a_dst.private_impl.mark,
|
.ptr = a_dst.private_impl.mark,
|
||||||
|
|||||||
+9
-9
@@ -1066,7 +1066,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s);
|
|||||||
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
|
||||||
// wuffs_crc32__ieee__etc functions.
|
// wuffs_crc32__ieee_hasher__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.
|
||||||
//
|
//
|
||||||
@@ -1078,23 +1078,23 @@ typedef struct {
|
|||||||
uint32_t f_state;
|
uint32_t f_state;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_crc32__ieee;
|
} wuffs_crc32__ieee_hasher;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_crc32__ieee__initialize is an initializer function.
|
// wuffs_crc32__ieee_hasher__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_crc32__ieee__* function.
|
// It should be called before any other wuffs_crc32__ieee_hasher__* function.
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
|
||||||
uint32_t wuffs_version,
|
uint32_t wuffs_version,
|
||||||
uint32_t for_internal_use_only);
|
uint32_t for_internal_use_only);
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
|
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||||
wuffs_base__slice_u8 a_x);
|
wuffs_base__slice_u8 a_x);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
+10
-10
@@ -1075,7 +1075,7 @@ const char* wuffs_crc32__status__string(wuffs_crc32__status s);
|
|||||||
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
|
||||||
// wuffs_crc32__ieee__etc functions.
|
// wuffs_crc32__ieee_hasher__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.
|
||||||
//
|
//
|
||||||
@@ -1087,23 +1087,23 @@ typedef struct {
|
|||||||
uint32_t f_state;
|
uint32_t f_state;
|
||||||
|
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_crc32__ieee;
|
} wuffs_crc32__ieee_hasher;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_crc32__ieee__initialize is an initializer function.
|
// wuffs_crc32__ieee_hasher__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_crc32__ieee__* function.
|
// It should be called before any other wuffs_crc32__ieee_hasher__* function.
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_crc32__ieee__initialize(wuffs_crc32__ieee* self,
|
void wuffs_crc32__ieee_hasher__initialize(wuffs_crc32__ieee_hasher* self,
|
||||||
uint32_t wuffs_version,
|
uint32_t wuffs_version,
|
||||||
uint32_t for_internal_use_only);
|
uint32_t for_internal_use_only);
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
uint32_t wuffs_crc32__ieee__update(wuffs_crc32__ieee* self,
|
uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
||||||
wuffs_base__slice_u8 a_x);
|
wuffs_base__slice_u8 a_x);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
@@ -1354,7 +1354,7 @@ typedef struct {
|
|||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
wuffs_deflate__decoder f_flate;
|
wuffs_deflate__decoder f_flate;
|
||||||
wuffs_crc32__ieee f_checksum;
|
wuffs_crc32__ieee_hasher f_checksum;
|
||||||
bool f_ignore_checksum;
|
bool f_ignore_checksum;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
packageid "crc3"
|
packageid "crc3"
|
||||||
|
|
||||||
// TODO: drop the '?' but still generate wuffs_crc32__ieee__initialize?
|
// TODO: drop the '?' but still generate wuffs_crc32__ieee_hasher__initialize?
|
||||||
pub struct ieee?(
|
pub struct ieee_hasher?(
|
||||||
state base.u32,
|
state base.u32,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ pub struct ieee?(
|
|||||||
// TODO: should it be ? instead of ! because it's public, and might need a way
|
// TODO: should it be ? instead of ! because it's public, and might need a way
|
||||||
// to signal "initializer not called"? Should the return type, in the generated
|
// to signal "initializer not called"? Should the return type, in the generated
|
||||||
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
|
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
|
||||||
pub func ieee.update(x slice base.u8)(checksum base.u32) {
|
pub func ieee_hasher.update(x slice base.u8)(checksum base.u32) {
|
||||||
var s base.u32 = 0xFFFFFFFF ^ this.state
|
var s base.u32 = 0xFFFFFFFF ^ this.state
|
||||||
|
|
||||||
iterate[1](p ptr base.u8:in.x) {
|
iterate[1](p ptr base.u8:in.x) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub error "invalid gzip encoding flags"
|
|||||||
|
|
||||||
pub struct decoder?(
|
pub struct decoder?(
|
||||||
flate deflate.decoder,
|
flate deflate.decoder,
|
||||||
checksum crc32.ieee,
|
checksum crc32.ieee_hasher,
|
||||||
ignore_checksum base.bool,
|
ignore_checksum base.bool,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -105,8 +105,8 @@ void test_wuffs_crc32_ieee_golden() {
|
|||||||
|
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
wuffs_crc32__ieee checksum;
|
wuffs_crc32__ieee_hasher checksum;
|
||||||
wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0);
|
wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0);
|
||||||
|
|
||||||
uint32_t got;
|
uint32_t got;
|
||||||
size_t num_fragments = 0;
|
size_t num_fragments = 0;
|
||||||
@@ -120,7 +120,7 @@ void test_wuffs_crc32_ieee_golden() {
|
|||||||
if ((j > 0) && (data.len > limit)) {
|
if ((j > 0) && (data.len > limit)) {
|
||||||
data.len = limit;
|
data.len = limit;
|
||||||
}
|
}
|
||||||
got = wuffs_crc32__ieee__update(&checksum, data);
|
got = wuffs_crc32__ieee_hasher__update(&checksum, data);
|
||||||
num_fragments++;
|
num_fragments++;
|
||||||
num_bytes += data.len;
|
num_bytes += data.len;
|
||||||
} while (num_bytes < src.wi);
|
} while (num_bytes < src.wi);
|
||||||
@@ -164,13 +164,13 @@ void test_wuffs_crc32_ieee_pi() {
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 64; i++) {
|
for (i = 0; i < 64; i++) {
|
||||||
wuffs_crc32__ieee checksum;
|
wuffs_crc32__ieee_hasher checksum;
|
||||||
wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0);
|
wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0);
|
||||||
uint32_t got =
|
uint32_t got = wuffs_crc32__ieee_hasher__update(
|
||||||
wuffs_crc32__ieee__update(&checksum, ((wuffs_base__slice_u8){
|
&checksum, ((wuffs_base__slice_u8){
|
||||||
.ptr = (uint8_t*)(digits),
|
.ptr = (uint8_t*)(digits),
|
||||||
.len = i,
|
.len = i,
|
||||||
}));
|
}));
|
||||||
if (got != wants[i]) {
|
if (got != wants[i]) {
|
||||||
FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32 "\n", i, got,
|
FAIL("i=%d: got 0x%08" PRIX32 ", want 0x%08" PRIX32 "\n", i, got,
|
||||||
wants[i]);
|
wants[i]);
|
||||||
@@ -188,13 +188,13 @@ const char* wuffs_bench_crc32_ieee(wuffs_base__io_buffer* 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.
|
||||||
wuffs_crc32__ieee checksum;
|
wuffs_crc32__ieee_hasher checksum;
|
||||||
wuffs_crc32__ieee__initialize(&checksum, WUFFS_VERSION, 0);
|
wuffs_crc32__ieee_hasher__initialize(&checksum, WUFFS_VERSION, 0);
|
||||||
global_wuffs_crc32_unused_u32 =
|
global_wuffs_crc32_unused_u32 =
|
||||||
wuffs_crc32__ieee__update(&checksum, ((wuffs_base__slice_u8){
|
wuffs_crc32__ieee_hasher__update(&checksum, ((wuffs_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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user