diff --git a/includes/libstd/hash.pat b/includes/libstd/hash.pat new file mode 100644 index 0000000..ebd3756 --- /dev/null +++ b/includes/libstd/hash.pat @@ -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); + }; + +} \ No newline at end of file