includes/std: Added hash module

This commit is contained in:
WerWolv
2021-10-07 11:39:07 +02:00
parent 34abca0ee3
commit 8e2ea5c330

27
includes/libstd/hash.pat Normal file
View File

@@ -0,0 +1,27 @@
namespace std::hash {
fn crc32(u128 address, u64 size, u32 init, u32 poly) {
u8 byte;
u32 crc, mask;
crc = init;
u64 i;
while (i < size) {
byte = std::mem::read_unsigned(address + i, 1);
crc = crc ^ byte;
u8 j;
while (j < 8) {
mask = u32(-(crc & 1));
crc = (crc >> 1) ^ (poly & mask);
j = j + 1;
}
i = i + 1;
}
return u32(~crc);
};
}