-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkhash_internal.h
61 lines (51 loc) · 1.78 KB
/
khash_internal.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
/*
* KHASH
* An ultra fast hash table in kernel space based on hashtable.h
* Copyright (C) 2016-2017 - Athonet s.r.l. - All Rights Reserved
*
* Authors:
* Paolo Missiaggia, <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* 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 KHASH_INTERNAL_H
#define KHASH_INTERNAL_H
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
#include "hashtable.h"
#else
#include <linux/hashtable.h>
#endif
#include <linux/jhash.h>
#define DEFINE_KHASH_STRUCT(__bucket_size__) \
uint32_t count; \
uint8_t ht_is_static; \
uint8_t ht_static_idx; \
uint32_t bck_size; \
uint32_t ht_count[__bucket_size__]; \
struct hlist_head ht[__bucket_size__];
/* Hash table size MUST be a power of 2 */
#define KHASH_BCK_SIZE_16 (1 << 4)
#define KHASH_BCK_SIZE_1k (1 << 10)
#define KHASH_BCK_SIZE_512k (1 << 19)
struct khash_t {
DEFINE_KHASH_STRUCT(KHASH_BCK_SIZE_16)
};
typedef struct khash_t khash_16_t;
typedef struct {
DEFINE_KHASH_STRUCT(KHASH_BCK_SIZE_1k)
} khash_1k_t;
typedef struct {
DEFINE_KHASH_STRUCT(KHASH_BCK_SIZE_512k)
} khash_512k_t;
#endif