Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
hashtable.h File Reference
#include <linux/list.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/hash.h>
#include <linux/rculist.h>

Go to the source code of this file.

Macros

#define DEFINE_HASHTABLE(name, bits)
 
#define DECLARE_HASHTABLE(name, bits)   struct hlist_head name[1 << (bits)]
 
#define HASH_SIZE(name)   (ARRAY_SIZE(name))
 
#define HASH_BITS(name)   ilog2(HASH_SIZE(name))
 
#define hash_min(val, bits)   (sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))
 
#define hash_init(hashtable)   __hash_init(hashtable, HASH_SIZE(hashtable))
 
#define hash_add(hashtable, node, key)   hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
 
#define hash_add_rcu(hashtable, node, key)   hlist_add_head_rcu(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
 
#define hash_empty(hashtable)   __hash_empty(hashtable, HASH_SIZE(hashtable))
 
: hashtable to iterate

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

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

#define hash_for_each(name, bkt, node, obj, member)
 
#define hash_for_each_rcu(name, bkt, node, obj, member)
 
#define hash_for_each_safe(name, bkt, node, tmp, obj, member)
 
#define hash_for_each_possible(name, obj, node, member, key)   hlist_for_each_entry(obj, node, &name[hash_min(key, HASH_BITS(name))], member)
 
#define hash_for_each_possible_rcu(name, obj, node, member, key)   hlist_for_each_entry_rcu(obj, node, &name[hash_min(key, HASH_BITS(name))], member)
 
#define hash_for_each_possible_safe(name, obj, node, tmp, member, key)
 

Macro Definition Documentation

#define DECLARE_HASHTABLE (   name,
  bits 
)    struct hlist_head name[1 << (bits)]

Definition at line 19 of file hashtable.h.

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

Definition at line 15 of file hashtable.h.

#define hash_add (   hashtable,
  node,
  key 
)    hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])

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

Definition at line 55 of file hashtable.h.

#define hash_add_rcu (   hashtable,
  node,
  key 
)    hlist_add_head_rcu(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])

hash_add_rcu - add an object to a rcu enabled hashtable : hashtable to add to : the &struct hlist_node of the object to be added : the key of the object to be added

Definition at line 64 of file hashtable.h.

#define HASH_BITS (   name)    ilog2(HASH_SIZE(name))

Definition at line 23 of file hashtable.h.

#define hash_empty (   hashtable)    __hash_empty(hashtable, HASH_SIZE(hashtable))

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

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

Definition at line 94 of file hashtable.h.

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

Definition at line 122 of file hashtable.h.

#define hash_for_each_possible (   name,
  obj,
  node,
  member,
  key 
)    hlist_for_each_entry(obj, node, &name[hash_min(key, HASH_BITS(name))], member)

Definition at line 161 of file hashtable.h.

#define hash_for_each_possible_rcu (   name,
  obj,
  node,
  member,
  key 
)    hlist_for_each_entry_rcu(obj, node, &name[hash_min(key, HASH_BITS(name))], member)

Definition at line 174 of file hashtable.h.

#define hash_for_each_possible_safe (   name,
  obj,
  node,
  tmp,
  member,
  key 
)
Value:

Definition at line 187 of file hashtable.h.

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

Definition at line 134 of file hashtable.h.

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

Definition at line 148 of file hashtable.h.

#define hash_init (   hashtable)    __hash_init(hashtable, HASH_SIZE(hashtable))

hash_init - initialize a hash table : 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.

Definition at line 47 of file hashtable.h.

#define hash_min (   val,
  bits 
)    (sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))

Definition at line 26 of file hashtable.h.

#define HASH_SIZE (   name)    (ARRAY_SIZE(name))

Definition at line 22 of file hashtable.h.