Generic Trace Generator (GTG)  0.1
Data Structures | Macros | Typedefs | Functions
GTGList.h File Reference

Go to the source code of this file.

Data Structures

struct  gtg_list
 

Macros

#define GTG_LIST_INIT(ptr)
 initialize a list. More...
 
#define GTG_LIST(name)
 declare and initialize a list. More...
 
#define gtg_list_entry(ptr, type, member)    ((type *)((char *)(ptr) - (char *)(&((type *)0)->member)))
 get the structure corresponding to a list entry More...
 
#define gtg_list_for_each(pos, head)    for (pos = (head)->next; pos != (head); pos = pos->next)
 
#define gtg_list_for_each_reverse(pos, head)    for (pos = (head)->prev; pos != (head); pos = pos->prev)
 
#define gtg_list_for_each_safe(pos, n, head)
 
#define gtg_list_for_each_entry(pos, head, member)
 iterate over list of given type More...
 
#define gtg_list_for_each_entry_safe(pos, n, head, member)
 iterate over list of given type safe against removal of list entry More...
 

Typedefs

typedef struct gtg_listgtg_list_t
 

Functions

static void __gtg_list_add (gtg_list_t lnew, gtg_list_t prev, gtg_list_t next)
 
static void gtg_list_add (gtg_list_t lnew, gtg_list_t head)
 Insert a new entry after the specified head. More...
 
static void gtg_list_add_tail (gtg_list_t lnew, gtg_list_t head)
 Insert a new entry before the specified head (ie. at the tail of the list). More...
 
static void __gtg_list_del (gtg_list_t prev, gtg_list_t next)
 
static void gtg_list_del (gtg_list_t entry)
 delete an entry from its list and reinitialize it. More...
 
static int gtg_list_size (gtg_list_t l)
 

Macro Definition Documentation

◆ GTG_LIST

GTG_LIST (   name)
Value:
struct gtg_list name; \
GTG_LIST_INIT(&name)
Definition: GTGList.h:4

declare and initialize a list.

Parameters
nameName of the variable

◆ gtg_list_entry

gtg_list_entry (   ptr,
  type,
  member 
)     ((type *)((char *)(ptr) - (char *)(&((type *)0)->member)))

get the structure corresponding to a list entry

Parameters
ptrpointer to the list entry (gtg_list_t)
typethe type of the struct this is embedded in.
memberthe name of the struct gtg_list member within the struct.

◆ gtg_list_for_each

#define gtg_list_for_each (   pos,
  head 
)     for (pos = (head)->next; pos != (head); pos = pos->next)

◆ gtg_list_for_each_entry

#define gtg_list_for_each_entry (   pos,
  head,
  member 
)
Value:
for (pos = gtg_list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = gtg_list_entry(pos->member.next, typeof(*pos), member))
#define gtg_list_entry(ptr, type, member)
get the structure corresponding to a list entry
Definition: GTGList.h:39

iterate over list of given type

gtg_list_for_each_entry(pos, head, member)

Parameters
posthe type * to use as a loop counter.
headthe head for the list.
memberthe name of the struct gtg_list member within the struct.

◆ gtg_list_for_each_entry_safe

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

iterate over list of given type safe against removal of list entry

gtg_list_for_each_entry_safe(pos, n, head, member)

Parameters
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for the list.
memberthe name of the struct gtg_list member within the struct.

◆ gtg_list_for_each_reverse

#define gtg_list_for_each_reverse (   pos,
  head 
)     for (pos = (head)->prev; pos != (head); pos = pos->prev)

◆ gtg_list_for_each_safe

#define gtg_list_for_each_safe (   pos,
  n,
  head 
)
Value:
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)

◆ GTG_LIST_INIT

GTG_LIST_INIT (   ptr)
Value:
do { \
(ptr)->prev = (ptr); \
(ptr)->next = (ptr); \
} while(0)

initialize a list.

Parameters
ptrpointer to the list (gtg_list_t).

Typedef Documentation

◆ gtg_list_t

typedef struct gtg_list* gtg_list_t

Function Documentation

◆ __gtg_list_add()

static void __gtg_list_add ( gtg_list_t  lnew,
gtg_list_t  prev,
gtg_list_t  next 
)
inlinestatic

◆ __gtg_list_del()

static void __gtg_list_del ( gtg_list_t  prev,
gtg_list_t  next 
)
inlinestatic

Delete a list entry by making the prev/next entries point to each other.

This is only for internal list manipulation where we know the prev/next entries already!

◆ gtg_list_add()

void gtg_list_add ( gtg_list_t  lnew,
gtg_list_t  head 
)
inlinestatic

Insert a new entry after the specified head.

Parameters
lnewnew entry to be added
headlist head to add it after

◆ gtg_list_add_tail()

void gtg_list_add_tail ( gtg_list_t  lnew,
gtg_list_t  head 
)
inlinestatic

Insert a new entry before the specified head (ie. at the tail of the list).

Parameters
lnewnew entry to be added
headlist head to add it after

◆ gtg_list_del()

void gtg_list_del ( gtg_list_t  entry)
inlinestatic

delete an entry from its list and reinitialize it.

Parameters
entrythe element to delete from the list.

◆ gtg_list_size()

static int gtg_list_size ( gtg_list_t  l)
inlinestatic