mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Factor out std/crc32/common_up_arm_crc32.wuffs
This commit is contained in:
1 parent
4c3f8ccfff
commit
9c1af68889
2 files changed
+36
-23
No files matched your search
@@ -69,29 +69,6 @@ pri func ieee_hasher.up!(x: slice base.u8),
|
||||
this.state = 0xFFFF_FFFF ^ s
|
||||
}
|
||||
|
||||
pri func ieee_hasher.up_arm_crc32!(x: slice base.u8),
|
||||
choose cpu_arch >= arm_crc32,
|
||||
{
|
||||
var s : base.arm_crc32_u32
|
||||
var p : slice base.u8
|
||||
|
||||
s = s.create(a: 0xFFFF_FFFF ^ this.state)
|
||||
|
||||
// Align to a 16-byte boundary.
|
||||
while (args.x.length() > 0) and ((15 & args.x.uintptr_low_12_bits()) <> 0) {
|
||||
s = s._crc32b(b: args.x[0])
|
||||
args.x = args.x[1 ..]
|
||||
} endwhile
|
||||
|
||||
iterate (p = args.x)(length: 8, advance: 8, unroll: 16) {
|
||||
s = s._crc32d(b: p.peek_u64le())
|
||||
} else (length: 1, advance: 1, unroll: 1) {
|
||||
s = s._crc32b(b: p[0])
|
||||
}
|
||||
|
||||
this.state = 0xFFFF_FFFF ^ s.value()
|
||||
}
|
||||
|
||||
// The table below was created by script/print-crc32-magic-numbers.go.
|
||||
|
||||
pri const IEEE_TABLE : array[16] array[256] base.u32 = [[
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2021 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.
|
||||
|
||||
pri func ieee_hasher.up_arm_crc32!(x: slice base.u8),
|
||||
choose cpu_arch >= arm_crc32,
|
||||
{
|
||||
var s : base.arm_crc32_u32
|
||||
var p : slice base.u8
|
||||
|
||||
s = s.create(a: 0xFFFF_FFFF ^ this.state)
|
||||
|
||||
// Align to a 16-byte boundary.
|
||||
while (args.x.length() > 0) and ((15 & args.x.uintptr_low_12_bits()) <> 0) {
|
||||
s = s._crc32b(b: args.x[0])
|
||||
args.x = args.x[1 ..]
|
||||
} endwhile
|
||||
|
||||
iterate (p = args.x)(length: 8, advance: 8, unroll: 16) {
|
||||
s = s._crc32d(b: p.peek_u64le())
|
||||
} else (length: 1, advance: 1, unroll: 1) {
|
||||
s = s._crc32b(b: p[0])
|
||||
}
|
||||
|
||||
this.state = 0xFFFF_FFFF ^ s.value()
|
||||
}
|
||||
Reference in new issue
Block a user