diff options
| author | 2022-08-06 15:49:55 +0200 | |
|---|---|---|
| committer | 2022-08-06 15:49:55 +0200 | |
| commit | f9840532ed954b1bafb600b9c9b1e9b597bb7fef (patch) | |
| tree | a4f3a4f1cd17f153bf9fb307b6ac6591a437e4ee | |
| parent | b8d9ad1f6636f46a832b0f949ce7525ae08f53bd (diff) | |
fnv1a fix
| -rw-r--r-- | bootstrap/all.h | 17 | ||||
| -rw-r--r-- | bootstrap/util.c | 19 |
2 files changed, 19 insertions, 17 deletions
diff --git a/bootstrap/all.h b/bootstrap/all.h index ff20c25..3410d1f 100644 --- a/bootstrap/all.h +++ b/bootstrap/all.h @@ -448,20 +448,11 @@ bswap64(u64 x) { ///////////////////////////////// /** util.c **/ -#define FNV1A_INI 0x84222325u +#define FNV1A_INI 0x811c9dc5u u32 fnv1a(u32 hash, const void *data, size_t length); -static inline u32 -fnv1ai(u32 hash, int i) { - return fnv1a(hash, &i, sizeof i); -} -static inline u32 -fnv1aI(u32 hash, i64 i) { - return fnv1a(hash, &i, sizeof i); -} -static inline u32 -fnv1az(u32 hash, size_t i) { - return fnv1a(hash, &i, sizeof i); -} +u32 fnv1ai(u32 hash, int i); +u32 fnv1aI(u32 hash, i64 i); +u32 fnv1az(u32 hash, size_t i); int addfilepath(const char *); const char *fileid2path(int); void *xmalloc(size_t); diff --git a/bootstrap/util.c b/bootstrap/util.c index bd6f951..43aa1b4 100644 --- a/bootstrap/util.c +++ b/bootstrap/util.c @@ -4,12 +4,23 @@ u32 fnv1a(u32 h, const void *p, size_t length) { const u8 *data = p; size_t i = 0; - u64 H = h; while (i != length) { - H ^= data[i++]; - H *= 0x100000001b3; + h ^= data[i++]; + h *= 0x01000193; } - return H; + return h; +} +u32 +fnv1ai(u32 hash, int i) { + return fnv1a(hash, &i, sizeof i); +} +u32 +fnv1aI(u32 hash, i64 i) { + return fnv1a(hash, &i, sizeof i); +} +u32 +fnv1az(u32 hash, size_t i) { + return fnv1a(hash, &i, sizeof i); } static const char *filepaths[100]; |