-
-
Notifications
You must be signed in to change notification settings - Fork 284
/
core-hash.h
71 lines (65 loc) · 3.57 KB
/
core-hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright (C) 2022-2024 Colin Ian King
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CORE_HASH_H
#define CORE_HASH_H
#include "core-attribute.h"
/* hash linked list type */
typedef struct stress_hash {
struct stress_hash *next; /* next hash item */
} stress_hash_t;
/* hash table */
typedef struct {
stress_hash_t **table; /* hash table */
size_t n; /* number of hash items in table */
} stress_hash_table_t;
/*
* Hashing core functions
*/
extern WARN_UNUSED stress_hash_table_t *stress_hash_create(const size_t n);
extern stress_hash_t *stress_hash_add(stress_hash_table_t *hash_table,
const char *str);
extern WARN_UNUSED stress_hash_t *stress_hash_get(
stress_hash_table_t *hash_table, const char *str);
extern void stress_hash_delete(stress_hash_table_t *hash_table);
extern WARN_UNUSED uint32_t stress_hash_adler32(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_coffin(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_coffin32_be(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_coffin32_le(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_crc32c(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_djb2a(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_fnv1a(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_jenkin(const uint8_t *data, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_kandr(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_knuth(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_loselose(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_mid5(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_muladd32(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_muladd64(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_mulxror64(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_mulxror32(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_xorror64(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_xorror32(const char *str, const size_t len) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_murmur3_32(const uint8_t *key, size_t len, uint32_t seed) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_nhash(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_pjw(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_sdbm(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_x17(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_sedgwick(const char *str) NONNULL(1);
extern WARN_UNUSED uint32_t stress_hash_sobel(const char *str) NONNULL(1);
#endif