mbgtools-lx  4.2.8
mbgklist.h File Reference
#include <mbg_cof.h>

Go to the source code of this file.

Data Structures

struct  mbg_klist_head
 

Macros

#define _ext   extern
 
#define MBG_KLIST_INIT(name)   { &(name), &(name) }
 
#define MBG_KLIST_DECLARE(name)   struct mbg_klist_head name = MBG_KLIST_INIT(name)
 
#define mbg_klist_for_each(head, pos)   for (pos = (head)->next; pos != (head); pos = pos->next)
 
#define mbg_klist_for_each_safe(head, pos, n)
 
#define mbg_klist_for_each_rev(head, pos)   for (pos = (head)->prev; pos != (head); pos = pos->prev)
 
#define mbg_klist_for_each_rev_safe(head, pos, n)
 
#define mbg_klist_nth_item(head, pos, n)
 
#define mbg_klist_entry(ptr, type, member)   mbg_container_of(ptr, type, member)
 
#define mbg_klist_first_entry(ptr, type, member)   mbg_klist_entry((ptr)->next, type, member)
 
#define mbg_klist_last_entry(ptr, type, member)   mbg_klist_entry((ptr)->prev, type, member)
 

Functions

static __mbg_inline void mbg_klist_init (struct mbg_klist_head *head)
 
static __mbg_inline void __mbg_klist_add_item (struct mbg_klist_head *item, struct mbg_klist_head *prev, struct mbg_klist_head *next)
 
static __mbg_inline void mbg_klist_prepend_item (struct mbg_klist_head *head, struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_append_item (struct mbg_klist_head *head, struct mbg_klist_head *item)
 
static __mbg_inline void __mbg_klist_delete_item (struct mbg_klist_head *prev, struct mbg_klist_head *next)
 
static __mbg_inline void mbg_klist_delete_item (struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_delete_item_init (struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_replace_item (struct mbg_klist_head *old, struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_replace_item_init (struct mbg_klist_head *old, struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_move_prepend_item (struct mbg_klist_head *head, struct mbg_klist_head *item)
 
static __mbg_inline void mbg_klist_move_append_item (struct mbg_klist_head *head, struct mbg_klist_head *item)
 
static __mbg_inline int mbg_klist_is_first (const struct mbg_klist_head *head, const struct mbg_klist_head *item)
 
static __mbg_inline int mbg_klist_is_last (const struct mbg_klist_head *head, const struct mbg_klist_head *item)
 
static __mbg_inline int mbg_klist_is_empty (const struct mbg_klist_head *head)
 
static __mbg_inline void __mbg_klist_add_list (const struct mbg_klist_head *list, struct mbg_klist_head *prev, struct mbg_klist_head *next)
 
static __mbg_inline void mbg_klist_prepend_list (struct mbg_klist_head *head, const struct mbg_klist_head *list)
 
static __mbg_inline void mbg_klist_append_list (struct mbg_klist_head *head, const struct mbg_klist_head *list)
 
static __mbg_inline void mbg_klist_prepend_list_init (struct mbg_klist_head *head, struct mbg_klist_head *list)
 
static __mbg_inline void mbg_klist_append_list_init (struct mbg_klist_head *head, struct mbg_klist_head *list)
 
void mbg_klist_sort (void *priv, struct mbg_klist_head *head, int(*cmp)(void *priv, struct mbg_klist_head *a, struct mbg_klist_head *b))
 Sort a list. More...
 

Macro Definition Documentation

◆ _ext

#define _ext   extern

Definition at line 39 of file mbgklist.h.

◆ MBG_KLIST_DECLARE

#define MBG_KLIST_DECLARE (   name)    struct mbg_klist_head name = MBG_KLIST_INIT(name)

Definition at line 52 of file mbgklist.h.

◆ mbg_klist_entry

#define mbg_klist_entry (   ptr,
  type,
  member 
)    mbg_container_of(ptr, type, member)

Definition at line 77 of file mbgklist.h.

◆ mbg_klist_first_entry

#define mbg_klist_first_entry (   ptr,
  type,
  member 
)    mbg_klist_entry((ptr)->next, type, member)

Definition at line 80 of file mbgklist.h.

Referenced by free_all_ucap_info(), and mbg_get_all_ucap_info().

◆ mbg_klist_for_each

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

Definition at line 55 of file mbgklist.h.

◆ mbg_klist_for_each_rev

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

Definition at line 63 of file mbgklist.h.

◆ mbg_klist_for_each_rev_safe

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

Definition at line 66 of file mbgklist.h.

◆ mbg_klist_for_each_safe

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

Definition at line 58 of file mbgklist.h.

◆ MBG_KLIST_INIT

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

Definition at line 50 of file mbgklist.h.

◆ mbg_klist_last_entry

#define mbg_klist_last_entry (   ptr,
  type,
  member 
)    mbg_klist_entry((ptr)->prev, type, member)

Definition at line 83 of file mbgklist.h.

◆ mbg_klist_nth_item

#define mbg_klist_nth_item (   head,
  pos,
 
)
Value:
do { \
unsigned i; \
for (pos = (head)->next, i = 0; i < n; pos = pos->next, ++i); \
} while ( 0 )

Definition at line 71 of file mbgklist.h.

Function Documentation

◆ __mbg_klist_add_item()

static __mbg_inline void __mbg_klist_add_item ( struct mbg_klist_head item,
struct mbg_klist_head prev,
struct mbg_klist_head next 
)
static

Definition at line 139 of file mbgklist.h.

References mbg_klist_head::next, and mbg_klist_head::prev.

Referenced by mbg_klist_append_item(), and mbg_klist_prepend_item().

◆ __mbg_klist_add_list()

static __mbg_inline void __mbg_klist_add_list ( const struct mbg_klist_head list,
struct mbg_klist_head prev,
struct mbg_klist_head next 
)
static

◆ __mbg_klist_delete_item()

static __mbg_inline void __mbg_klist_delete_item ( struct mbg_klist_head prev,
struct mbg_klist_head next 
)
static

Definition at line 163 of file mbgklist.h.

References mbg_klist_head::next, and mbg_klist_head::prev.

Referenced by mbg_klist_delete_item(), and mbg_klist_delete_item_init().

◆ mbg_klist_append_item()

static __mbg_inline void mbg_klist_append_item ( struct mbg_klist_head head,
struct mbg_klist_head item 
)
static

Definition at line 156 of file mbgklist.h.

References __mbg_klist_add_item(), and mbg_klist_head::prev.

Referenced by mbg_get_all_ucap_info(), and mbg_klist_move_append_item().

◆ mbg_klist_append_list()

static __mbg_inline void mbg_klist_append_list ( struct mbg_klist_head head,
const struct mbg_klist_head list 
)
static

Definition at line 263 of file mbgklist.h.

References __mbg_klist_add_list(), mbg_klist_is_empty(), and mbg_klist_head::prev.

◆ mbg_klist_append_list_init()

static __mbg_inline void mbg_klist_append_list_init ( struct mbg_klist_head head,
struct mbg_klist_head list 
)
static

◆ mbg_klist_delete_item()

static __mbg_inline void mbg_klist_delete_item ( struct mbg_klist_head item)
static

◆ mbg_klist_delete_item_init()

static __mbg_inline void mbg_klist_delete_item_init ( struct mbg_klist_head item)
static

◆ mbg_klist_init()

◆ mbg_klist_is_empty()

static __mbg_inline int mbg_klist_is_empty ( const struct mbg_klist_head head)
static

◆ mbg_klist_is_first()

static __mbg_inline int mbg_klist_is_first ( const struct mbg_klist_head head,
const struct mbg_klist_head item 
)
static

Definition at line 220 of file mbgklist.h.

References mbg_klist_head::prev.

◆ mbg_klist_is_last()

static __mbg_inline int mbg_klist_is_last ( const struct mbg_klist_head head,
const struct mbg_klist_head item 
)
static

Definition at line 227 of file mbgklist.h.

References mbg_klist_head::next.

◆ mbg_klist_move_append_item()

static __mbg_inline void mbg_klist_move_append_item ( struct mbg_klist_head head,
struct mbg_klist_head item 
)
static

Definition at line 212 of file mbgklist.h.

References mbg_klist_append_item(), and mbg_klist_delete_item().

◆ mbg_klist_move_prepend_item()

static __mbg_inline void mbg_klist_move_prepend_item ( struct mbg_klist_head head,
struct mbg_klist_head item 
)
static

Definition at line 204 of file mbgklist.h.

References mbg_klist_delete_item(), and mbg_klist_prepend_item().

◆ mbg_klist_prepend_item()

static __mbg_inline void mbg_klist_prepend_item ( struct mbg_klist_head head,
struct mbg_klist_head item 
)
static

Definition at line 149 of file mbgklist.h.

References __mbg_klist_add_item(), and mbg_klist_head::next.

Referenced by mbg_klist_move_prepend_item().

◆ mbg_klist_prepend_list()

static __mbg_inline void mbg_klist_prepend_list ( struct mbg_klist_head head,
const struct mbg_klist_head list 
)
static

Definition at line 255 of file mbgklist.h.

References __mbg_klist_add_list(), mbg_klist_is_empty(), and mbg_klist_head::next.

◆ mbg_klist_prepend_list_init()

static __mbg_inline void mbg_klist_prepend_list_init ( struct mbg_klist_head head,
struct mbg_klist_head list 
)
static

◆ mbg_klist_replace_item()

static __mbg_inline void mbg_klist_replace_item ( struct mbg_klist_head old,
struct mbg_klist_head item 
)
static

Definition at line 186 of file mbgklist.h.

References mbg_klist_head::next, and mbg_klist_head::prev.

Referenced by mbg_klist_replace_item_init().

◆ mbg_klist_replace_item_init()

static __mbg_inline void mbg_klist_replace_item_init ( struct mbg_klist_head old,
struct mbg_klist_head item 
)
static

Definition at line 196 of file mbgklist.h.

References mbg_klist_init(), and mbg_klist_replace_item().

◆ mbg_klist_sort()

void mbg_klist_sort ( void *  priv,
struct mbg_klist_head head,
int(*)(void *priv, struct mbg_klist_head *a, struct mbg_klist_head *b)  cmp 
)

Sort a list.

Parameters
[in]privPrivate data, opaque to mbg_klist_sort, passed to cmp
[in]headThe list to sort
[in]cmpThe elements comparison function

This function implements "merge sort", which has O(nlog(n)) complexity.

The comparison function cmp must return a negative value if a should sort before b, and a positive value if a should sort after b. If a and b are equivalent, and their original relative ordering is to be preserved, cmp must return 0.

Referenced by mbg_klist_append_list_init().