ELinks 0.16.1.1
lists.h File Reference
#include "util/error.h"
Include dependency graph for lists.h:

Data Structures

struct  list_head
struct  xlist_head

Macros

#define LISTDEBUG
 Lists debugging.
#define list_head   list_head_elinks
#define LISTMAGIC1   ((void *) 0xdadababa)
#define LISTMAGIC2   ((void *) 0xd0d0b0b0)
#define LISTMAGIC3   ((void *) 0x25254545)
#define list_del_enforce(x)
#define list_magic_error(where, what)
#define list_magic_set(x)
#define list_magic_correct(x)
 Backend for list_magic_check() and list_magic_chkbool().
#define list_magic_check(x, where)
#define list_magic_chkbool(x, where)
#define NULL_LIST_HEAD   LISTMAGIC1, NULL, NULL, LISTMAGIC2
#define D_LIST_HEAD(x)
#define LIST_HEAD(x)
#define LIST_SET_MAGIC(x)
#define LIST_OF(element_T)
 A list intended to contain elements of a specific type.
#define INIT_LIST_OF(element_T, x)
 Define and initialize a list variable.
#define list_typeof(x)
#define list_typeof2(x)
#define init_list(x)
#define list_empty(x)
#define list_is_singleton(x)
#define list_has_prev(l, p)
#define list_has_next(l, p)
#define del_from_list(x)
#define add_at_pos(p, x)
#define add_to_list(l, x)
#define add_to_list_end(l, x)
#define foreach(e, l)
#define foreachback(e, l)
#define foreachsafe(e, n, l)
#define foreachbacksafe(e, p, l)
#define free_list(l)
#define move_to_top_of_list(list, item)

Functions

static int list_size (struct list_head *list)

Macro Definition Documentation

◆ add_at_pos

#define add_at_pos ( p,
x )
Value:
do { \
list_magic_check(p, "add_at_pos"); \
list_magic_set(*(x)); \
do_not_optimize_here_gcc_2_7(p); \
(x)->next = (p)->next; \
(x)->prev = (p); \
(p)->next = (x); \
(x)->next->prev = (x); \
do_not_optimize_here_gcc_2_7(p); \
} while (0)

◆ add_to_list

#define add_to_list ( l,
x )
Value:
add_at_pos((list_typeof(x)) &(l), (list_typeof(x)) (x))
#define add_at_pos(p, x)
Definition lists.h:174
#define list_typeof(x)
Definition lists.h:138

◆ add_to_list_end

#define add_to_list_end ( l,
x )
Value:
add_at_pos((list_typeof(x)) (l).prev, (list_typeof(x)) (x))

◆ D_LIST_HEAD

#define D_LIST_HEAD ( x)
Value:
#define LISTMAGIC2
Definition lists.h:66
#define LISTMAGIC1
Definition lists.h:65

◆ del_from_list

#define del_from_list ( x)
Value:
do { \
list_magic_check(x, "del_from_list"); \
do_not_optimize_here_gcc_2_7(x); \
((struct list_head *) (x)->next)->prev = (x)->prev; \
((struct list_head *) (x)->prev)->next = (x)->next; \
list_del_enforce(x); \
do_not_optimize_here_gcc_2_7(x); \
} while (0)
#define list_head
Definition lists.h:33

◆ foreach

#define foreach ( e,
l )
Value:
for ((e) = (list_typeof2(e))(l).next; \
(list_typeof(e)) (e) != (list_typeof(e)) &(l); \
(e) = (list_typeof2(e))(e)->next)
#define list_typeof2(x)
Definition lists.h:139

◆ foreachback

#define foreachback ( e,
l )
Value:
for ((e) = (list_typeof2(e))(l).prev; \
(list_typeof(e)) (e) != (list_typeof(e)) &(l); \
(e) = (list_typeof2(e))(e)->prev)

◆ foreachbacksafe

#define foreachbacksafe ( e,
p,
l )
Value:
for ((e) = (list_typeof2(e))(l).prev, (p) = (list_typeof2(e))(e)->prev; \
(list_typeof(e)) (e) != (list_typeof(e)) &(l); \
(e) = (p), (p) = (list_typeof2(e))(e)->prev)

◆ foreachsafe

#define foreachsafe ( e,
n,
l )
Value:
for ((e) = (list_typeof2(e))(l).next, (n) = (list_typeof2(e))(e)->next; \
(list_typeof(e)) (e) != (list_typeof(e)) &(l); \
(e) = (n), (n) = (list_typeof2(e))(e)->next)
int n
Definition general.c:825

◆ free_list

#define free_list ( l)
Value:
do { \
struct xlist_head *head, *next; \
\
list_magic_check(&(l), "free_list"); \
do_not_optimize_here_gcc_2_7(&l); \
foreach (head, (l)) do_not_optimize_here_gcc_3_x(head); /* AA */ \
foreachback (head, (l)) do_not_optimize_here_gcc_3_x(head); /* AA */ \
foreachsafe (head, next, l) { \
del_from_list(head); \
mem_free(head); \
} \
do_not_optimize_here_gcc_2_7(&l); \
} while (0)
#define do_not_optimize_here_gcc_3_x(x)
Definition error.h:222
Definition lists.h:107

◆ init_list

#define init_list ( x)
Value:
do { \
list_magic_set(x); \
do_not_optimize_here_gcc_3_x(&(x)); /* antialiasing ;) */ \
(x).next = (x).prev = &(x); \
do_not_optimize_here_gcc_3_x(&(x)); \
} while (0)

◆ INIT_LIST_OF

#define INIT_LIST_OF ( element_T,
x )
Value:
LIST_OF(element_T) x = { D_LIST_HEAD(x) }
#define D_LIST_HEAD(x)
Definition lists.h:116
#define LIST_OF(element_T)
A list intended to contain elements of a specific type.
Definition lists.h:127

Define and initialize a list variable.

The element_T parameter currently serves as documentation only; the compiler does not check that it matches.

◆ list_del_enforce

#define list_del_enforce ( x)
Value:
do { \
/* Little hack: we put LISTMAGIC3 in prev */ \
/* and the line number in next. Debugging purpose. */ \
(x)->prev = LISTMAGIC3; \
(x)->next = (void *) ((unsigned int) __LINE__); \
} while (0)
#define LISTMAGIC3
Definition lists.h:67

◆ list_empty

#define list_empty ( x)
Value:
(list_magic_chkbool(x, "list_empty") && (x).next == &(x))
#define list_magic_chkbool(x, where)
Definition lists.h:97

◆ list_has_next

#define list_has_next ( l,
p )
Value:
(list_magic_chkbool(l, "list_has_next") && (p)->next != (void *) &(l))

◆ list_has_prev

#define list_has_prev ( l,
p )
Value:
(list_magic_chkbool(l, "list_has_prev") && (p)->prev != (void *) &(l))

◆ LIST_HEAD

#define LIST_HEAD ( x)
Value:
void *magic1; x *next; x *prev; void *magic2

◆ list_head

#define list_head   list_head_elinks

◆ list_is_singleton

#define list_is_singleton ( x)
Value:
(list_magic_chkbool(x, "list_is_singleton") && (x).next == (x).prev \
&& !list_empty(x))
#define list_empty(x)
Definition lists.h:152

◆ list_magic_check

#define list_magic_check ( x,
where )
Value:
do { \
if (!list_magic_correct(*(x))) \
list_magic_error(where, x); \
} while (0)
#define list_magic_correct(x)
Backend for list_magic_check() and list_magic_chkbool().
Definition lists.h:89

◆ list_magic_chkbool

#define list_magic_chkbool ( x,
where )
Value:
(list_magic_correct(x) || (list_magic_error(where, x), 1))
#define list_magic_error(where, what)
Definition lists.h:78

◆ list_magic_correct

#define list_magic_correct ( x)
Value:
((x).magic1 == LISTMAGIC1 && (x).magic2 == LISTMAGIC2)

Backend for list_magic_check() and list_magic_chkbool().

◆ list_magic_error

#define list_magic_error ( where,
what )
Value:
INTERNAL("[%s] %s - bad list magic", where, #what)
#define INTERNAL
INTERNAL(format_string) is used to report fatal errors during the ELinks run.
Definition error.h:51

◆ list_magic_set

#define list_magic_set ( x)
Value:
do { \
(x).magic1 = LISTMAGIC1; \
(x).magic2 = LISTMAGIC2; \
} while (0)

◆ LIST_OF

#define LIST_OF ( element_T)
Value:
struct list_head

A list intended to contain elements of a specific type.

The element_T parameter currently serves as documentation only; the compiler does not check that it matches. Doxyfile defines this macro differently in order to get better collaboration diagrams.

◆ LIST_SET_MAGIC

#define LIST_SET_MAGIC ( x)
Value:
#define list_magic_set(x)
Definition lists.h:81

◆ list_typeof

#define list_typeof ( x)
Value:
struct xlist_head *

◆ list_typeof2

#define list_typeof2 ( x)
Value:
void *

◆ LISTDEBUG

#define LISTDEBUG

Lists debugging.

Two unsigned int magic number will be put before and after the next and prev pointers, these will be check on list operations. Some pointers are set to specific values after action.

◆ LISTMAGIC1

#define LISTMAGIC1   ((void *) 0xdadababa)

◆ LISTMAGIC2

#define LISTMAGIC2   ((void *) 0xd0d0b0b0)

◆ LISTMAGIC3

#define LISTMAGIC3   ((void *) 0x25254545)

◆ move_to_top_of_list

#define move_to_top_of_list ( list,
item )
Value:
do { \
if ((item) != (list).next) { \
del_from_list(item); \
add_to_list(list, item); \
} \
} while (0)
unicode_val_T * list
Definition charsets.c:208

◆ NULL_LIST_HEAD

#define NULL_LIST_HEAD   LISTMAGIC1, NULL, NULL, LISTMAGIC2

Function Documentation

◆ list_size()

int list_size ( struct list_head * list)
inlinestatic