| ... | ... | @@ -36,6 +36,20 @@ const xxhash = @import("hash/xxhash.zig"); |
| 36 | 36 | pub const XxHash64 = xxhash.XxHash64; |
| 37 | 37 | pub const XxHash32 = xxhash.XxHash32; |
| 38 | 38 | |
| 39 | /// This is handy if you have a u32 and want a u32 and don't want to take a |
| 40 | /// detour through many layers of abstraction elsewhere in the std.hash |
| 41 | /// namespace. |
| 42 | /// Copied from https://nullprogram.com/blog/2018/07/31/ |
| 43 | pub fn uint32(input: u32) u32 { |
| 44 | var x: u32 = input; |
| 45 | x ^= x >> 16; |
| 46 | x *%= 0x7feb352d; |
| 47 | x ^= x >> 15; |
| 48 | x *%= 0x846ca68b; |
| 49 | x ^= x >> 16; |
| 50 | return x; |
| 51 | } |
| 52 | |
| 39 | 53 | test { |
| 40 | 54 | _ = adler; |
| 41 | 55 | _ = auto_hash; |