feat: twifs - pseudo file system for lunaix kernel state exposure
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / hstr.h
1 #ifndef __LUNAIX_HSTR_H
2 #define __LUNAIX_HSTR_H
3
4 #include <lib/hash.h>
5
6 #define HSTR_FULL_HASH 32
7
8 struct hstr
9 {
10     unsigned int hash;
11     unsigned int len;
12     char* value;
13 };
14
15 #define HSTR(str, length)                                                      \
16     (struct hstr)                                                              \
17     {                                                                          \
18         .len = (length), .value = (str)                                        \
19     }
20
21 #define HSTR_EQ(str1, str2) ((str1)->hash == (str2)->hash)
22
23 inline void
24 hstr_rehash(struct hstr* hash_str, unsigned int truncate_to)
25 {
26     hash_str->hash = strhash_32(hash_str->value, truncate_to);
27 }
28
29 #endif /* __LUNAIX_HSTR_H */