elemy-utils 1.0.0
Data Structures | Macros | Typedefs | Functions
pslist.h File Reference

header library for kernel's like lists of any type structs More...

#include "elutils/c_decls.h"
Include dependency graph for pslist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  psl_hd
 

Macros

#define offsetof(TYPE, MEMBER)   ((size_t) &((TYPE *)0)->MEMBER)
 
#define container_of(ptr, type, member)   ({ const typeof( ((type *)0)->member ) *__mptr = (ptr); (type *)( (char *)__mptr - offsetof(type,member) );})
 
#define PSL_HD_INIT(name)   { &(name), &(name) }
 static initializer. used for static initialize list More...
 
#define PSL_HD(name)   struct psl_hd name = PSL_HD_INIT(name)
 declaration of name wich is PSL_HD with init. used for declare static initialized list. More...
 
#define psl_entry(ptr, type, member)   container_of(ptr, type, member)
 
#define psl_for_each_entry(pos, head, member)
 
#define psl_for_each_entry_safe(pos, n, head, member)
 
#define psl_count(TYPE, head, member, pcount)
 
#define LIST_POISON1   ((void *) 0x00100100)
 
#define LIST_POISON2   ((void *) 0x00200200)
 
#define PSL_FIRST_ENTRY(ptr, type, member)   psl_entry(ptr->next, type, member)
 
#define PSL_SHOW_STRING(PSL_HD, TYPE, PSL_LINK, STRING_NAME)
 

Typedefs

typedef struct psl_hd psl_hd_t
 

Functions

static void psl_init (psl_hd_t *list)
 init allocated list element. used for initialize dynamic allocated list. More...
 
static int psl_empty (const struct psl_hd *head)
 
static void __psl_add (struct psl_hd *_new, struct psl_hd *prev, struct psl_hd *next)
 
static void psl_add (struct psl_hd *_new, struct psl_hd *head)
 
static void psl_add_tail (struct psl_hd *_new, struct psl_hd *head)
 
static void __psl_del (struct psl_hd *prev, struct psl_hd *next)
 
static void psl_del (struct psl_hd *entry)
 
static int psl_is_head (const struct psl_hd *list, const struct psl_hd *head)
 
static struct psl_hdpsl_first (const struct psl_hd *head)
 
static void psl_move_head2head (psl_hd_t *new_hd, psl_hd_t *old_hd)
 

Detailed Description

header library for kernel's like lists of any type structs

Author: ps (c) Sergey Pankov, 1997

Partly copied from include/linux/...

Macro Definition Documentation

◆ container_of

#define container_of (   ptr,
  type,
  member 
)    ({ const typeof( ((type *)0)->member ) *__mptr = (ptr); (type *)( (char *)__mptr - offsetof(type,member) );})

container_of - cast a member of a structure out to the containing structure @ptr: the pointer to the member. @type: the type of the container struct this is embedded in. @member: the name of the member within the struct.

◆ LIST_POISON1

#define LIST_POISON1   ((void *) 0x00100100)

◆ LIST_POISON2

#define LIST_POISON2   ((void *) 0x00200200)

◆ offsetof

#define offsetof (   TYPE,
  MEMBER 
)    ((size_t) &((TYPE *)0)->MEMBER)

◆ psl_count

#define psl_count (   TYPE,
  head,
  member,
  pcount 
)
Value:
{ *pcount = 0; TYPE *pos; \
for (pos = psl_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = psl_entry(pos->member.next, typeof(*pos), member)) { \
*pcount++; \
} \
}
#define psl_entry(ptr, type, member)
Definition: pslist.h:57

psl_count - count list of given type @TYPE: the type to use as a loop cursor. @head: the head for your list. @member: the name of the list_head within the struct. @res reference to counting result

◆ psl_entry

#define psl_entry (   ptr,
  type,
  member 
)    container_of(ptr, type, member)

psl_entry - get the struct for this entry @ptr: the &struct list_head pointer. @type: the type of the struct this is embedded in. @member: the name of the list_head within the struct.

◆ PSL_FIRST_ENTRY

#define PSL_FIRST_ENTRY (   ptr,
  type,
  member 
)    psl_entry(ptr->next, type, member)

◆ psl_for_each_entry

#define psl_for_each_entry (   pos,
  head,
  member 
)
Value:
for (pos = psl_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = psl_entry(pos->member.next, typeof(*pos), member))

psl_for_each_entry - iterate over list of given type @pos: the type * to use as a loop cursor. @head: the head for your list. @member: the name of the list_head within the struct.

◆ psl_for_each_entry_safe

#define psl_for_each_entry_safe (   pos,
  n,
  head,
  member 
)
Value:
for (pos = psl_entry((head)->next, typeof(*pos), member), \
n = psl_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = psl_entry(n->member.next, typeof(*n), member))

psl_for_each_entry_safe - iterate over list of given type safe against removal of list entry @pos: the type * to use as a loop cursor.
: another type * to use as temporary storage @head: the head for your list. @member: the name of the list_head within the struct.

◆ PSL_HD

#define PSL_HD (   name)    struct psl_hd name = PSL_HD_INIT(name)

declaration of name wich is PSL_HD with init. used for declare static initialized list.

◆ PSL_HD_INIT

#define PSL_HD_INIT (   name)    { &(name), &(name) }

static initializer. used for static initialize list

◆ PSL_SHOW_STRING

#define PSL_SHOW_STRING (   PSL_HD,
  TYPE,
  PSL_LINK,
  STRING_NAME 
)
Value:
{ int i = 0; TYPE *pos; \
psl_for_each_entry(pos, PSL_HD, PSL_LINK) { \
char *str = pos->STRING_NAME; \
MB_DBG("%i: '%s'\n", i, str); \
i++; \
} \
}
#define PSL_HD(name)
declaration of name wich is PSL_HD with init. used for declare static initialized list.
Definition: pslist.h:42

Typedef Documentation

◆ psl_hd_t

typedef struct psl_hd psl_hd_t

Function Documentation

◆ __psl_add()

static void __psl_add ( struct psl_hd _new,
struct psl_hd prev,
struct psl_hd next 
)
inlinestatic
Here is the caller graph for this function:

◆ __psl_del()

static void __psl_del ( struct psl_hd prev,
struct psl_hd next 
)
inlinestatic
Here is the caller graph for this function:

◆ psl_add()

static void psl_add ( struct psl_hd _new,
struct psl_hd head 
)
inlinestatic

list_add - add a new entry @new: new entry to be added @head: list head to add it after

Insert a new entry after the specified head. This is good for implementing stacks.

Here is the call graph for this function:

◆ psl_add_tail()

static void psl_add_tail ( struct psl_hd _new,
struct psl_hd head 
)
inlinestatic

psl_add_tail - add a new entry @new: new entry to be added @head: list head to add it before

Insert a new entry before the specified head. This is useful for implementing queues.

Here is the call graph for this function:

◆ psl_del()

static void psl_del ( struct psl_hd entry)
inlinestatic

list_del - deletes entry from list. @entry: the element to delete from the list. Note: list_empty() on entry does not return true after this, the entry is in an undefined state.

Here is the call graph for this function:

◆ psl_empty()

static int psl_empty ( const struct psl_hd head)
inlinestatic

psl_empty - tests whether a list is empty @head: the list to test.

◆ psl_first()

static struct psl_hd * psl_first ( const struct psl_hd head)
inlinestatic
Parameters
headremeber that parameter is external var as head of list

◆ psl_init()

static void psl_init ( psl_hd_t list)
inlinestatic

init allocated list element. used for initialize dynamic allocated list.

Here is the caller graph for this function:

◆ psl_is_head()

static int psl_is_head ( const struct psl_hd list,
const struct psl_hd head 
)
inlinestatic

psl_is_head - tests whether @list is the list @head @list: the entry to test @head: the head of the list

◆ psl_move_head2head()

static void psl_move_head2head ( psl_hd_t new_hd,
psl_hd_t old_hd 
)
inlinestatic
Here is the call graph for this function: