1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2010 Lennart Poettering
8 Copyright 2014 Michal Schmidt
12 #include "siphash24.h"
14 typedef void (*hash_func_t
)(const void *p
, struct siphash
*state
);
15 typedef int (*compare_func_t
)(const void *a
, const void *b
);
19 compare_func_t compare
;
22 void string_hash_func(const void *p
, struct siphash
*state
);
23 int string_compare_func(const void *a
, const void *b
) _pure_
;
24 extern const struct hash_ops string_hash_ops
;
26 void path_hash_func(const void *p
, struct siphash
*state
);
27 int path_compare_func(const void *a
, const void *b
) _pure_
;
28 extern const struct hash_ops path_hash_ops
;
30 /* This will compare the passed pointers directly, and will not dereference them. This is hence not useful for strings
32 void trivial_hash_func(const void *p
, struct siphash
*state
);
33 int trivial_compare_func(const void *a
, const void *b
) _const_
;
34 extern const struct hash_ops trivial_hash_ops
;
36 /* 32bit values we can always just embed in the pointer itself, but in order to support 32bit archs we need store 64bit
37 * values indirectly, since they don't fit in a pointer. */
38 void uint64_hash_func(const void *p
, struct siphash
*state
);
39 int uint64_compare_func(const void *a
, const void *b
) _pure_
;
40 extern const struct hash_ops uint64_hash_ops
;
42 /* On some archs dev_t is 32bit, and on others 64bit. And sometimes it's 64bit on 32bit archs, and sometimes 32bit on
43 * 64bit archs. Yuck! */
45 void devt_hash_func(const void *p
, struct siphash
*state
) _pure_
;
46 int devt_compare_func(const void *a
, const void *b
) _pure_
;
47 extern const struct hash_ops devt_hash_ops
;
49 #define devt_hash_func uint64_hash_func
50 #define devt_compare_func uint64_compare_func
51 #define devt_hash_ops uint64_hash_ops