mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 17:01:35 +01:00
Rename some files as std/foo/common_bar.wuffs
This commit is contained in:
1 parent
c479907bff
commit
351fa593c6
5 files changed
+107
-94
No files matched your search
+59
-59
@@ -1750,6 +1750,65 @@ void wuffs_zlib__decoder__initialize(wuffs_zlib__decoder* self,
|
|||||||
|
|
||||||
// ---------------- Function Implementations
|
// ---------------- Function Implementations
|
||||||
|
|
||||||
|
static uint32_t wuffs_zlib__adler32__update(wuffs_zlib__adler32* self,
|
||||||
|
wuffs_base__slice_u8 a_x) {
|
||||||
|
uint32_t v_s1;
|
||||||
|
uint32_t v_s2;
|
||||||
|
wuffs_base__slice_u8 v_remaining;
|
||||||
|
|
||||||
|
v_s1 = ((self->private_impl.f_state) & ((1 << (16)) - 1));
|
||||||
|
v_s2 = ((self->private_impl.f_state) >> (32 - (16)));
|
||||||
|
while (((uint64_t)(a_x.len)) > 0) {
|
||||||
|
v_remaining = ((wuffs_base__slice_u8){});
|
||||||
|
if (((uint64_t)(a_x.len)) > 5552) {
|
||||||
|
v_remaining = wuffs_base__slice_u8__subslice_i(a_x, 5552);
|
||||||
|
a_x = wuffs_base__slice_u8__subslice_j(a_x, 5552);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
wuffs_base__slice_u8 i_slice_p = a_x;
|
||||||
|
uint8_t* v_p = i_slice_p.ptr;
|
||||||
|
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
|
||||||
|
while (v_p < i_end0_p) {
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
}
|
||||||
|
uint8_t* i_end1_p = i_slice_p.ptr + i_slice_p.len;
|
||||||
|
while (v_p < i_end1_p) {
|
||||||
|
v_s1 += ((uint32_t)(*v_p));
|
||||||
|
v_s2 += v_s1;
|
||||||
|
v_p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v_s1 %= 65521;
|
||||||
|
v_s2 %= 65521;
|
||||||
|
a_x = v_remaining;
|
||||||
|
}
|
||||||
|
self->private_impl.f_state = (((v_s2 & 65535) << 16) | (v_s1 & 65535));
|
||||||
|
return self->private_impl.f_state;
|
||||||
|
}
|
||||||
|
|
||||||
void wuffs_zlib__decoder__set_ignore_checksum(wuffs_zlib__decoder* self,
|
void wuffs_zlib__decoder__set_ignore_checksum(wuffs_zlib__decoder* self,
|
||||||
bool a_ic) {
|
bool a_ic) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
@@ -2011,62 +2070,3 @@ short_read_src:
|
|||||||
status = WUFFS_ZLIB__SUSPENSION_SHORT_READ;
|
status = WUFFS_ZLIB__SUSPENSION_SHORT_READ;
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t wuffs_zlib__adler32__update(wuffs_zlib__adler32* self,
|
|
||||||
wuffs_base__slice_u8 a_x) {
|
|
||||||
uint32_t v_s1;
|
|
||||||
uint32_t v_s2;
|
|
||||||
wuffs_base__slice_u8 v_remaining;
|
|
||||||
|
|
||||||
v_s1 = ((self->private_impl.f_state) & ((1 << (16)) - 1));
|
|
||||||
v_s2 = ((self->private_impl.f_state) >> (32 - (16)));
|
|
||||||
while (((uint64_t)(a_x.len)) > 0) {
|
|
||||||
v_remaining = ((wuffs_base__slice_u8){});
|
|
||||||
if (((uint64_t)(a_x.len)) > 5552) {
|
|
||||||
v_remaining = wuffs_base__slice_u8__subslice_i(a_x, 5552);
|
|
||||||
a_x = wuffs_base__slice_u8__subslice_j(a_x, 5552);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
wuffs_base__slice_u8 i_slice_p = a_x;
|
|
||||||
uint8_t* v_p = i_slice_p.ptr;
|
|
||||||
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
|
|
||||||
while (v_p < i_end0_p) {
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
}
|
|
||||||
uint8_t* i_end1_p = i_slice_p.ptr + i_slice_p.len;
|
|
||||||
while (v_p < i_end1_p) {
|
|
||||||
v_s1 += ((uint32_t)(*v_p));
|
|
||||||
v_s2 += v_s1;
|
|
||||||
v_p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
v_s1 %= 65521;
|
|
||||||
v_s2 %= 65521;
|
|
||||||
a_x = v_remaining;
|
|
||||||
}
|
|
||||||
self->private_impl.f_state = (((v_s2 & 65535) << 16) | (v_s1 & 65535));
|
|
||||||
return self->private_impl.f_state;
|
|
||||||
}
|
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright 2017 The Wuffs Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// TODO: drop the '?' but still generate wuffs_zlib__adler32__initialize?
|
||||||
|
pri struct adler32?(
|
||||||
|
state base.u32 = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO: add a ! as this function is impure.
|
||||||
|
pri func adler32.update(x slice base.u8)(checksum base.u32) {
|
||||||
|
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
|
||||||
|
// RFC 1950.
|
||||||
|
|
||||||
|
var s1 base.u32 = this.state.low_bits(n:16)
|
||||||
|
var s2 base.u32 = this.state.high_bits(n:16)
|
||||||
|
|
||||||
|
while in.x.length() > 0 {
|
||||||
|
var remaining slice base.u8
|
||||||
|
if in.x.length() > 5552 {
|
||||||
|
remaining = in.x[5552:]
|
||||||
|
in.x = in.x[:5552]
|
||||||
|
}
|
||||||
|
|
||||||
|
iterate[8](p ptr base.u8:in.x) {
|
||||||
|
s1 ~+= deref p as base.u32
|
||||||
|
s2 ~+= s1
|
||||||
|
}
|
||||||
|
|
||||||
|
s1 %= 65521
|
||||||
|
s2 %= 65521
|
||||||
|
|
||||||
|
in.x = remaining
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = ((s2 & 0xFFFF) << 16) | (s1 & 0xFFFF)
|
||||||
|
return this.state
|
||||||
|
}
|
||||||
@@ -66,38 +66,3 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
|||||||
return error "checksum mismatch"
|
return error "checksum mismatch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: drop the '?' but still generate wuffs_zlib__adler32__initialize?
|
|
||||||
pri struct adler32?(
|
|
||||||
state base.u32 = 1,
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO: add a ! as this function is impure.
|
|
||||||
pri func adler32.update(x slice base.u8)(checksum base.u32) {
|
|
||||||
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
|
|
||||||
// RFC 1950.
|
|
||||||
|
|
||||||
var s1 base.u32 = this.state.low_bits(n:16)
|
|
||||||
var s2 base.u32 = this.state.high_bits(n:16)
|
|
||||||
|
|
||||||
while in.x.length() > 0 {
|
|
||||||
var remaining slice base.u8
|
|
||||||
if in.x.length() > 5552 {
|
|
||||||
remaining = in.x[5552:]
|
|
||||||
in.x = in.x[:5552]
|
|
||||||
}
|
|
||||||
|
|
||||||
iterate[8](p ptr base.u8:in.x) {
|
|
||||||
s1 ~+= deref p as base.u32
|
|
||||||
s2 ~+= s1
|
|
||||||
}
|
|
||||||
|
|
||||||
s1 %= 65521
|
|
||||||
s2 %= 65521
|
|
||||||
|
|
||||||
in.x = remaining
|
|
||||||
}
|
|
||||||
|
|
||||||
this.state = ((s2 & 0xFFFF) << 16) | (s1 & 0xFFFF)
|
|
||||||
return this.state
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user