Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
ulist.h File Reference

Go to the source code of this file.

Data Structures

struct  ulist_iterator
struct  ulist_node
struct  ulist


#define ULIST_SIZE   16
#define ULIST_ITER_INIT(uiter)   ((uiter)->i = 0)


void ulist_init (struct ulist *ulist)
void ulist_fini (struct ulist *ulist)
void ulist_reinit (struct ulist *ulist)
struct ulistulist_alloc (gfp_t gfp_mask)
void ulist_free (struct ulist *ulist)
int ulist_add (struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask)
int ulist_add_merge (struct ulist *ulist, u64 val, u64 aux, u64 *old_aux, gfp_t gfp_mask)
struct ulist_nodeulist_next (struct ulist *ulist, struct ulist_iterator *uiter)

Macro Definition Documentation

#define ULIST_ITER_INIT (   uiter)    ((uiter)->i = 0)

Definition at line 74 of file ulist.h.

#define ULIST_SIZE   16

Definition at line 25 of file ulist.h.

Function Documentation

int ulist_add ( struct ulist ulist,
u64  val,
u64  aux,
gfp_t  gfp_mask 

ulist_add - add an element to the ulist : ulist to add the element to : value to add to ulist : auxiliary value to store along with val : flags to use for allocation

Note: locking must be provided by the caller. In case of rwlocks write locking is needed

Add an element to a ulist. The will only be added if it doesn't already exist. If it is added, the auxiliary value is stored along with it. In case already exists in the ulist, is ignored, even if it differs from the already stored value.

ulist_add returns 0 if already exists in ulist and 1 if has been inserted. In case of allocation failure -ENOMEM is returned and the ulist stays unaltered.

Definition at line 146 of file ulist.c.

int ulist_add_merge ( struct ulist ulist,
u64  val,
u64  aux,
u64 old_aux,
gfp_t  gfp_mask 

Definition at line 151 of file ulist.c.

struct ulist* ulist_alloc ( gfp_t  gfp_mask)

ulist_alloc - dynamically allocate a ulist : allocation flags to for base allocation

The allocated ulist will be returned in an initialized state.

Definition at line 98 of file ulist.c.

void ulist_fini ( struct ulist ulist)

ulist_fini - free up additionally allocated memory for the ulist : the ulist from which to free the additional memory

This is useful in cases where the base 'struct ulist' has been statically allocated.

Definition at line 66 of file ulist.c.

void ulist_free ( struct ulist ulist)

ulist_free - free dynamically allocated ulist : ulist to free

It is not necessary to call ulist_fini before.

Definition at line 117 of file ulist.c.

void ulist_init ( struct ulist ulist)

ulist_init - freshly initialize a ulist : the ulist to initialize

Note: don't use this function to init an already used ulist, use ulist_reinit instead.

Definition at line 51 of file ulist.c.

struct ulist_node* ulist_next ( struct ulist ulist,
struct ulist_iterator uiter 

ulist_next - iterate ulist : ulist to iterate : iterator variable, initialized with ULIST_ITER_INIT(&iterator)

Note: locking must be provided by the caller. In case of rwlocks only read locking is needed

This function is used to iterate an ulist. It returns the next element from the ulist or NULL when the end is reached. No guarantee is made with respect to the order in which the elements are returned. They might neither be returned in order of addition nor in ascending order. It is allowed to call ulist_add during an enumeration. Newly added items are guaranteed to show up in the running enumeration.

Definition at line 212 of file ulist.c.

void ulist_reinit ( struct ulist ulist)

ulist_reinit - prepare a ulist for reuse : ulist to be reused

Free up all additional memory allocated for the list elements and reinit the ulist.

Definition at line 85 of file ulist.c.