4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
7 Copyright 2014 Michal Schmidt
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "siphash24.h"
26 typedef void (*hash_func_t)(const void *p, struct siphash *state);
27 typedef int (*compare_func_t)(const void *a, const void *b);
31 compare_func_t compare;
34 void string_hash_func(const void *p, struct siphash *state);
35 int string_compare_func(const void *a, const void *b) _pure_;
36 extern const struct hash_ops string_hash_ops;
38 /* This will compare the passed pointers directly, and will not
39 * dereference them. This is hence not useful for strings or
41 void trivial_hash_func(const void *p, struct siphash *state);
42 int trivial_compare_func(const void *a, const void *b) _const_;
43 extern const struct hash_ops trivial_hash_ops;
45 /* 32bit values we can always just embed in the pointer itself, but
46 * in order to support 32bit archs we need store 64bit values
47 * indirectly, since they don't fit in a pointer. */
48 void uint64_hash_func(const void *p, struct siphash *state);
49 int uint64_compare_func(const void *a, const void *b) _pure_;
50 extern const struct hash_ops uint64_hash_ops;
52 /* On some archs dev_t is 32bit, and on others 64bit. And sometimes
53 * it's 64bit on 32bit archs, and sometimes 32bit on 64bit archs. Yuck! */
55 void devt_hash_func(const void *p, struct siphash *state) _pure_;
56 int devt_compare_func(const void *a, const void *b) _pure_;
57 extern const struct hash_ops devt_hash_ops = {
58 .hash = devt_hash_func,
59 .compare = devt_compare_func
62 #define devt_hash_func uint64_hash_func
63 #define devt_compare_func uint64_compare_func
64 #define devt_hash_ops uint64_hash_ops