RTEMS: cpukit/include/drvmgr/drvmgr_list.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
drvmgr_list.h
1/* Linked list help functions used by driver manager.
2 *
3 * COPYRIGHT (c) 2009 Cobham Gaisler AB.
4 *
5 * The license and distribution terms for this file may be
6 * found in the file LICENSE in this distribution or at
7 * http://www.rtems.org/license/LICENSE.
8 */
9
10/*
11 * Help functions for the Driver Manager. Implements a singly linked list
12 * with head and tail pointers for fast insertions/deletions to head and
13 * tail in list.
14 */
15
16#ifndef _DRVIVER_MANAGER_LIST_H_
17#define _DRVIVER_MANAGER_LIST_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
24 struct drvmgr_list {
25 void *head;
26 void *tail;
27 int ofs;
28};
29
30/* Static initialization of list */
31#define LIST_INITIALIZER(type, field) {NULL, NULL, offsetof(type, field)}
32
33/* Return the first element in list */
34#define LIST_HEAD(list, type) ((type *)(list)->head)
35
36/* Return the last element in list */
37#define LIST_TAIL(list, type) ((type *)(list)->tail)
38
39/* Get the next pointer of an entry */
40#define LIST_FIELD(list, entry) (*(void **)((char *)(entry) + (list)->ofs))
41
42/* Return the next emlement in list */
43#define LIST_NEXT(list, entry, type) ((type *)(LIST_FIELD(list, entry)))
44
45/* Iterate through all entries in list */
46#define LIST_FOR_EACH(list, entry, type) \
47 for (entry = LIST_HEAD(list, type); \
48 entry; \
49 entry = LIST_NEXT(list, entry, type))
50
57extern void drvmgr_list_init(struct drvmgr_list *list, int offset);
58
60extern void drvmgr_list_empty(struct drvmgr_list *list);
61
63extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry);
64
66extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry);
67
69extern void drvmgr_list_remove_head(struct drvmgr_list *list);
70
72extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif
drvmgr_list
Definition: drvmgr_list.h:24
drvmgr_list::head
void * head
Definition: drvmgr_list.h:25
drvmgr_list::ofs
int ofs
Definition: drvmgr_list.h:27
drvmgr_list::tail
void * tail
Definition: drvmgr_list.h:26
entry
Definition: mmu-config.c:40