RTEMS 6.1-rc7
Loading...
Searching...
No Matches
drvmgr_list.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
9/*
10 * COPYRIGHT (c) 2009 Cobham Gaisler AB.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Help functions for the Driver Manager. Implements a singly linked list
36 * with head and tail pointers for fast insertions/deletions to head and
37 * tail in list.
38 */
39
40#ifndef _DRVIVER_MANAGER_LIST_H_
41#define _DRVIVER_MANAGER_LIST_H_
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
49 void *head;
50 void *tail;
51 int ofs;
52};
53
54/* Static initialization of list */
55#define LIST_INITIALIZER(type, field) {NULL, NULL, offsetof(type, field)}
56
57/* Return the first element in list */
58#define LIST_HEAD(list, type) ((type *)(list)->head)
59
60/* Return the last element in list */
61#define LIST_TAIL(list, type) ((type *)(list)->tail)
62
63/* Get the next pointer of an entry */
64#define LIST_FIELD(list, entry) (*(void **)((char *)(entry) + (list)->ofs))
65
66/* Return the next emlement in list */
67#define LIST_NEXT(list, entry, type) ((type *)(LIST_FIELD(list, entry)))
68
69/* Iterate through all entries in list */
70#define LIST_FOR_EACH(list, entry, type) \
71 for (entry = LIST_HEAD(list, type); \
72 entry; \
73 entry = LIST_NEXT(list, entry, type))
74
81extern void drvmgr_list_init(struct drvmgr_list *list, int offset);
82
84extern void drvmgr_list_empty(struct drvmgr_list *list);
85
87extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry);
88
90extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry);
91
93extern void drvmgr_list_remove_head(struct drvmgr_list *list);
94
96extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry);
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif
void drvmgr_list_remove(struct drvmgr_list *list, void *entry)
Definition: drvmgr_list.c:70
void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry)
Definition: drvmgr_list.c:53
void drvmgr_list_init(struct drvmgr_list *list, int offset)
Definition: drvmgr_list.c:34
void drvmgr_list_add_head(struct drvmgr_list *list, void *entry)
Definition: drvmgr_list.c:45
void drvmgr_list_remove_head(struct drvmgr_list *list)
Definition: drvmgr_list.c:63
void drvmgr_list_empty(struct drvmgr_list *list)
Definition: drvmgr_list.c:40
Definition: drvmgr_list.h:48
void * head
Definition: drvmgr_list.h:49
int ofs
Definition: drvmgr_list.h:51
void * tail
Definition: drvmgr_list.h:50
Definition: mmu-config.c:53