libosmocore 1.10.0
Osmocom core library
Loading...
Searching...
No Matches
hashtable.h File Reference

Go to the source code of this file.

Macros

#define DEFINE_HASHTABLE(name, bits)
 
#define DECLARE_HASHTABLE(name, bits)
 
#define HASH_SIZE(name)
 
#define HASH_BITS(name)
 
#define hash_min(val, bits)
 
#define hash_init(hashtable)
 hash_init - initialize a hash table @hashtable: hashtable to be initialized
 
#define hash_add(hashtable, node, key)
 hash_add - add an object to a hashtable @hashtable: hashtable to add to @node: the &struct hlist_node of the object to be added @key: the key of the object to be added
 
#define hash_empty(hashtable)
 hash_empty - check whether a hashtable is empty @hashtable: hashtable to check
 
: hashtable to iterate

hash_for_each_possible_safe - iterate over all possible objects hashing to the same bucket safe against removals

@obj: the type * to use as a loop cursor for each entry @tmp: a &struct hlist_node used for temporary storage @member: the name of the hlist_node within the struct @key: the key of the objects to iterate over

#define hash_for_each(name, bkt, obj, member)
 
#define hash_for_each_safe(name, bkt, tmp, obj, member)
 
#define hash_for_each_possible(name, obj, member, key)
 
#define hash_for_each_possible_safe(name, obj, tmp, member, key)
 

Functions

static void __hash_init (struct hlist_head *ht, unsigned int sz)
 
static bool hash_hashed (struct hlist_node *node)
 hash_hashed - check whether an object is in any hashtable @node: the &struct hlist_node of the object to be checked
 
static bool __hash_empty (struct hlist_head *ht, unsigned int sz)
 
static void hash_del (struct hlist_node *node)
 hash_del - remove an object from a hashtable @node: &struct hlist_node of the object to remove
 

Macro Definition Documentation

◆ DECLARE_HASHTABLE

#define DECLARE_HASHTABLE ( name,
bits )
Value:
struct hlist_head name[1 << (bits)]
char name[32]
source file name
Definition gsmtap.h:11
Double linked lists with a single pointer list head.
Definition linuxlist.h:410

◆ DEFINE_HASHTABLE

#define DEFINE_HASHTABLE ( name,
bits )
Value:
struct hlist_head name[1 << (bits)] = \
{ [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
#define HLIST_HEAD_INIT
Definition linuxlist.h:418

◆ hash_add

#define hash_add ( hashtable,
node,
key )
Value:
hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
struct cmd_node * node
static void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
add a new entry at the beginning of the hlist.
Definition linuxlist.h:508
#define hash_min(val, bits)
Definition hashtable.h:23
#define HASH_BITS(name)
Definition hashtable.h:20

hash_add - add an object to a hashtable @hashtable: hashtable to add to @node: the &struct hlist_node of the object to be added @key: the key of the object to be added

◆ HASH_BITS

#define HASH_BITS ( name)
Value:
#define HASH_SIZE(name)
Definition hashtable.h:19
#define ilog2(n)
ilog2 - log base 2 of 32-bit or a 64-bit unsigned value : parameter
Definition log2.h:177

◆ hash_empty

#define hash_empty ( hashtable)
Value:
__hash_empty(hashtable, HASH_SIZE(hashtable))
static bool __hash_empty(struct hlist_head *ht, unsigned int sz)
Definition hashtable.h:64

hash_empty - check whether a hashtable is empty @hashtable: hashtable to check

This has to be a macro since HASH_BITS() will not work on pointers since it calculates the size during preprocessing.

◆ hash_for_each

#define hash_for_each ( name,
bkt,
obj,
member )
Value:
for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
(bkt)++)\
hlist_for_each_entry(obj, &name[bkt], member)

◆ hash_for_each_possible

#define hash_for_each_possible ( name,
obj,
member,
key )
Value:
#define hlist_for_each_entry(pos, head, member)
iterate over list of given type.
Definition linuxlist.h:614

◆ hash_for_each_possible_safe

#define hash_for_each_possible_safe ( name,
obj,
tmp,
member,
key )
Value:
&name[hash_min(key, HASH_BITS(name))], member)
#define hlist_for_each_entry_safe(pos, n, head, member)
hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry.
Definition linuxlist.h:642

◆ hash_for_each_safe

#define hash_for_each_safe ( name,
bkt,
tmp,
obj,
member )
Value:
for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
(bkt)++)\
hlist_for_each_entry_safe(obj, tmp, &name[bkt], member)

◆ hash_init

#define hash_init ( hashtable)
Value:
__hash_init(hashtable, HASH_SIZE(hashtable))
static void __hash_init(struct hlist_head *ht, unsigned int sz)
Definition hashtable.h:26

hash_init - initialize a hash table @hashtable: hashtable to be initialized

Calculates the size of the hashtable from the given parameter, otherwise same as hash_init_size.

This has to be a macro since HASH_BITS() will not work on pointers since it calculates the size during preprocessing.

◆ hash_min

#define hash_min ( val,
bits )
Value:
(sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))
#define hash_32
Definition hash.h:65
#define hash_long(val, bits)
Definition hash.h:22

◆ HASH_SIZE

#define HASH_SIZE ( name)
Value:
#define ARRAY_SIZE(x)
Determine number of elements in an array of static size.
Definition utils.h:19

Function Documentation

◆ __hash_empty()

static bool __hash_empty ( struct hlist_head * ht,
unsigned int sz )
inlinestatic

References hlist_empty().

◆ __hash_init()

static void __hash_init ( struct hlist_head * ht,
unsigned int sz )
inlinestatic

References INIT_HLIST_HEAD.

◆ hash_del()

static void hash_del ( struct hlist_node * node)
inlinestatic

hash_del - remove an object from a hashtable @node: &struct hlist_node of the object to remove

References hlist_del_init().

◆ hash_hashed()

static bool hash_hashed ( struct hlist_node * node)
inlinestatic

hash_hashed - check whether an object is in any hashtable @node: the &struct hlist_node of the object to be checked

References hlist_unhashed().