]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
758dd67e LP |
2 | #pragma once |
3 | ||
758dd67e LP |
4 | #include "macro.h" |
5 | #include "siphash24.h" | |
6 | ||
7 | typedef void (*hash_func_t)(const void *p, struct siphash *state); | |
8 | typedef int (*compare_func_t)(const void *a, const void *b); | |
9 | ||
10 | struct hash_ops { | |
11 | hash_func_t hash; | |
12 | compare_func_t compare; | |
13 | }; | |
14 | ||
15 | void string_hash_func(const void *p, struct siphash *state); | |
16 | int string_compare_func(const void *a, const void *b) _pure_; | |
17 | extern const struct hash_ops string_hash_ops; | |
18 | ||
46e16b34 LP |
19 | void path_hash_func(const void *p, struct siphash *state); |
20 | int path_compare_func(const void *a, const void *b) _pure_; | |
21 | extern const struct hash_ops path_hash_ops; | |
22 | ||
23 | /* This will compare the passed pointers directly, and will not dereference them. This is hence not useful for strings | |
24 | * or suchlike. */ | |
758dd67e LP |
25 | void trivial_hash_func(const void *p, struct siphash *state); |
26 | int trivial_compare_func(const void *a, const void *b) _const_; | |
27 | extern const struct hash_ops trivial_hash_ops; | |
28 | ||
9bac7d42 LP |
29 | /* 32bit values we can always just embed in the pointer itself, but in order to support 32bit archs we need store 64bit |
30 | * values indirectly, since they don't fit in a pointer. */ | |
758dd67e LP |
31 | void uint64_hash_func(const void *p, struct siphash *state); |
32 | int uint64_compare_func(const void *a, const void *b) _pure_; | |
33 | extern const struct hash_ops uint64_hash_ops; | |
34 | ||
9bac7d42 LP |
35 | /* On some archs dev_t is 32bit, and on others 64bit. And sometimes it's 64bit on 32bit archs, and sometimes 32bit on |
36 | * 64bit archs. Yuck! */ | |
758dd67e LP |
37 | #if SIZEOF_DEV_T != 8 |
38 | void devt_hash_func(const void *p, struct siphash *state) _pure_; | |
39 | int devt_compare_func(const void *a, const void *b) _pure_; | |
9bac7d42 | 40 | extern const struct hash_ops devt_hash_ops; |
758dd67e LP |
41 | #else |
42 | #define devt_hash_func uint64_hash_func | |
43 | #define devt_compare_func uint64_compare_func | |
44 | #define devt_hash_ops uint64_hash_ops | |
45 | #endif |