Conversation
|
This is not quite ready yet, but as I can't run the tests manually because of https://issues.dlang.org/show_bug.cgi?id=17107 , I have to rely on autotester. |
bcee6d5 to
689e438
Compare
|
Alright this is in better shape now. Tests are green? No idea what circle is unhappy about. |
|
cc @wilzbach |
|
Also, among interesting questions, CRC64 has 2 standards: ECMA and ISO. The algorithm is the same, but the polynomial is different ( 0xD800000000000000 for OSI, 0xC96C5795D7870F42 for ECMA ). ECMA is generally considered better, but maybe we'd like to support both ? |
|
Ok Added support for both CRC64-ECMA and CRC64-ISO, that wasn't significantly harder, and can be leveraged to do CRC32C and other variations as well. |
|
I have no idea why circle is complaining. That'd be great if someone would look at this is less than a week. |
|
There seems to be a dearth of reviews in Phobos right now. Do you know of anyone who would be qualified to review this code? |
|
@JackStouffer I asked someone who dug into this CRC thing with me to figure it out. He'll be able to assert the validitity of the algorithm, but is not an experimented D coder, so that'd be great to have someone checks that. Also, I'd be glad if someone could explain me what circle is complaining about. |
|
|
||
| /** | ||
| * Generic Template API used for CRC32 and CRC64 implementations. | ||
| * See $(D std.digest.digest) for differences between template and OOP API. |
There was a problem hiding this comment.
needs Params section for N and P
|
|
||
| static immutable T[256][8] tables = genTables!T(P); | ||
|
|
||
| alias R = ubyte[T.sizeof]; |
There was a problem hiding this comment.
This needs to be documented as it shows up in the docs
|
Also, needs a changelog entry |
std/digest/crc.d
Outdated
| unittest | ||
| { | ||
| CRC32 dig; | ||
| CRC dig; |
There was a problem hiding this comment.
That's the reason why CircleCi fails with:
out/std_digest_crc.d(46): Error: struct std.digest.crc.CRC(uint N, ulong P) if (N == 32 || N == 64) is used as a type
out/std_digest_crc.d(59): Error: struct std.digest.crc.CRC(uint N, ulong P) if (N == 32 || N == 64) is used as a type
out/std_digest_crc.d(71): Error: struct std.digest.crc.CRC(uint N, ulong P) if (N == 32 || N == 64) is used as a type
out/std_digest_crc.d(73): Error: undefined identifier 'R'The script at CircleCi seperates all public unittests and tries to run them with the newly compiled release library to ensure that all unittests on dlang.org are runnable as they are.
Btw I remember there was a long discussion last summer about the problems of using unittest blocks in templated code - in short in theory it's discouraged at Phobos because the unittest block gets instantiated very every new instance.
There was a problem hiding this comment.
Indeed, the test is generated for each templates, it is a 3 line tests, so I don't think there is really any problem here.
|
Sadly I find myself unable to continue this work. https://issues.dlang.org/show_bug.cgi?id=17236 I was already required to jump though hoops to run the tests, but this is getting out of hands. |
As mentioned on the NG I am still not sure what your exact problem is. |
|
Added doc for N, P and R. Rebased. I got various merge conflicts for style changes that arguably do not improve the code in any way. Especially the one which puts template constraint on their own line. |
| * CRC64-ECMA of data | ||
| */ | ||
| //simple alias doesn't work here, hope this gets inlined... | ||
| ubyte[8] crc64ECMAOf(T...)(T data) |
There was a problem hiding this comment.
According to Circle, this needs an example
There was a problem hiding this comment.
I'm not sure what I'm expected to do here. I looked at crc32Of and there is no example. Is there a piece of code I can look at to know what to do ?
| * CRC64-ISO of data | ||
| */ | ||
| //simple alias doesn't work here, hope this gets inlined... | ||
| ubyte[8] crc64ISOOf(T...)(T data) |
|
@deadalnix Was that person you mentioned able to verify the CRC code correctness? |
|
@ftrader , we need you :) |
|
You can check it matches the test vector from go here: https://golang.org/src/hash/crc64/crc64_test.go |
601c8b7 to
f216ed6
Compare
|
@deadalnix Sorry, I only just saw your comment about verification. Any chance you can fix the public example issue so this can be pulled? |
|
FWIW, I had a CRC64 (ECMA variant) implementation on top of std.digest lying around. I plugged the unittests from here into my implementation, and everything worked. |
|
OK @CyberShadow confirm that the result are good, which is pretty convincing the algorithm is correct (this is a hash function after all, so you'd expect to get very different results). So I rebased and I want to get that in good shape so we can merge it. |
|
Looks like circle is happy. Do we move forward with that one ? |
| * Type of the finished CRC hash. | ||
| * ubyte[8] if N is 32, ubyte[16] if N is 64. | ||
| */ | ||
| alias R = ubyte[T.sizeof]; |
There was a problem hiding this comment.
Shouldn't R be ubyte[4] for 32 bit? Because finish used to return ubyte[4] originally and now it returns ubyte[8].
There was a problem hiding this comment.
The code is correct, but the comment is wrong. Fixing.
|
Fixed. |
As per title.