source: rtems/cpukit/libdrvmgr/drvmgr_list.h @ 2fb0912

4.115
Last change on this file since 2fb0912 was 65d1f35, checked in by Daniel Hellstrom <daniel@…>, on 02/27/15 at 15:42:36

DRVMGR: updated copyright into one line only

  • Property mode set to 100644
File size: 2.2 KB
Line 
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.com/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
23/*! List description, Singly link list with head and tail pointers. */
24struct drvmgr_list {
25        void    *head;  /*!< First entry in queue */
26        void    *tail;  /*!< Last entry in queue */
27        int     ofs;    /*!< Offset into head and tail to find next field */
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
51/*! Initialize a list during runtime
52 *
53 * \param list    The list to initialize
54 * \param offset  The number of bytes into the entry structure the next pointer
55 *                is found
56 */
57extern void drvmgr_list_init(struct drvmgr_list *list, int offset);
58
59/*! Clear list */
60extern void drvmgr_list_empty(struct drvmgr_list *list);
61
62/*! Add entry to front of list */
63extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry);
64
65/*! Add entry to end of list */
66extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry);
67
68/*! Remove entry from front of list */
69extern void drvmgr_list_remove_head(struct drvmgr_list *list);
70
71/*! Remove entry from anywhere in list */
72extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif
Note: See TracBrowser for help on using the repository browser.