Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
ulist.c File Reference
#include <linux/slab.h>
#include <linux/module.h>
#include "ulist.h"

Go to the source code of this file.

Functions

void ulist_init (struct ulist *ulist)
 
 EXPORT_SYMBOL (ulist_init)
 
void ulist_fini (struct ulist *ulist)
 
 EXPORT_SYMBOL (ulist_fini)
 
void ulist_reinit (struct ulist *ulist)
 
 EXPORT_SYMBOL (ulist_reinit)
 
struct ulistulist_alloc (gfp_t gfp_mask)
 
 EXPORT_SYMBOL (ulist_alloc)
 
void ulist_free (struct ulist *ulist)
 
 EXPORT_SYMBOL (ulist_free)
 
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)
 
 EXPORT_SYMBOL (ulist_add)
 
struct ulist_nodeulist_next (struct ulist *ulist, struct ulist_iterator *uiter)
 
 EXPORT_SYMBOL (ulist_next)
 

Function Documentation

EXPORT_SYMBOL ( ulist_init  )
EXPORT_SYMBOL ( ulist_fini  )
EXPORT_SYMBOL ( ulist_reinit  )
EXPORT_SYMBOL ( ulist_alloc  )
EXPORT_SYMBOL ( ulist_free  )
EXPORT_SYMBOL ( ulist_add  )
EXPORT_SYMBOL ( ulist_next  )
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)
read

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 
)
read

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.