-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Software crc32c produces wrong results on big endian CPUs #34
Comments
I am pretty sure the issue comes from some edge case with endianess. PowerPC has 3 different architectures:
Tests against PowerPC 64le are passing:
|
might the issue be here?: Line 33 in 47c2999
edit: (this is called in the software impl here: Line 24 in 47c2999
|
Hum this is a good hunch.. Writing |
if this is the case, then some change needs to be made either in this function or at callsites (or both). expanding further on the previous points, #[repr(transparent)]
#[derive(Clone, Copy)]
struct U64Le(u64);
impl U64Le {
#[inline]
pub const fn get(self) -> u64 {
u64::from_le(self.0)
}
} which would be safe to transmute to in the original function because it has the same layout as a u64 with the |
im trying this fix out, could you see if it works correctly on those big endian targets? EDIT: didn't see you used $ cross test --target powerpc-unknown-linux-gnu
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Finished test [unoptimized + debuginfo] target(s) in 0.09s
Running unittests src/lib.rs (/target/powerpc-unknown-linux-gnu/debug/deps/crc32c-52b9b02f194c0936)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/simple.rs (/target/powerpc-unknown-linux-gnu/debug/deps/simple-0ffe959d1ae05e6c)
running 6 tests
test crc ... ok
test crc_append ... ok
test crc_combine ... ok
test long_string ... ok
test very_big ... ok
test very_small ... ok
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s seems to work, nice! i'll open a pull request then |
This is neat. Tomorrow I'll rerun all the tests I have on my side! |
I ran all the tests on my side and looks great. |
I am trying to run some code which uses
crc32c
on powerpc 32 and 64 bit and I noticed it produces incorrect results.I have tried to run the test suite of this crate using
cross
and they indeed fail:The text was updated successfully, but these errors were encountered: