Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
hash.c
Go to the documentation of this file.
1#include <hash.h>
2
3uint64_t hash(const char* str, size_t max_size) {
4 uint64_t h = 0xcbf29ce484222325ULL;
5
6 const char* p = str;
7 while (*p) {
8 h ^= (uint64_t) (unsigned char) *p++;
9 h *= 0x9e3779b97f4a7c15ULL;
10 }
11 h ^= h >> 32;
12
13 return max_size ? (h % max_size) : h;
14}
15
16uint32_t hash32(const char* str, size_t max_size) {
17 uint32_t h = 0xcbf29ce4ULL;
18
19 const char* p = str;
20 while (*p) {
21 h ^= (uint32_t) (unsigned char) *p++;
22 h *= 0x9e3779bULL;
23 }
24
25 return max_size ? (h % max_size) : h;
26}
struct SDT h
Definition acpi.h:0
uint32_t hash
Definition dentry.h:3
uint32_t hash32(const char *str, size_t max_size)
Definition hash.c:16
kstring str(const char *str)
unsigned int uint32_t
Definition type.h:19
unsigned long uint64_t
Definition type.h:25