![]() |
|
|||
File indexing completed on 2025-05-11 08:24:11
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @brief Linked list help functions used by driver manager. 0007 */ 0008 0009 /* 0010 * COPYRIGHT (c) 2009 Cobham Gaisler AB. 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 1. Redistributions of source code must retain the above copyright 0016 * notice, this list of conditions and the following disclaimer. 0017 * 2. Redistributions in binary form must reproduce the above copyright 0018 * notice, this list of conditions and the following disclaimer in the 0019 * documentation and/or other materials provided with the distribution. 0020 * 0021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0031 * POSSIBILITY OF SUCH DAMAGE. 0032 */ 0033 0034 /* 0035 * Help functions for the Driver Manager. Implements a singly linked list 0036 * with head and tail pointers for fast insertions/deletions to head and 0037 * tail in list. 0038 */ 0039 0040 #ifndef _DRVIVER_MANAGER_LIST_H_ 0041 #define _DRVIVER_MANAGER_LIST_H_ 0042 0043 #ifdef __cplusplus 0044 extern "C" { 0045 #endif 0046 0047 /*! List description, Singly link list with head and tail pointers. */ 0048 struct drvmgr_list { 0049 void *head; /*!< First entry in queue */ 0050 void *tail; /*!< Last entry in queue */ 0051 int ofs; /*!< Offset into head and tail to find next field */ 0052 }; 0053 0054 /* Static initialization of list */ 0055 #define LIST_INITIALIZER(type, field) {NULL, NULL, offsetof(type, field)} 0056 0057 /* Return the first element in list */ 0058 #define LIST_HEAD(list, type) ((type *)(list)->head) 0059 0060 /* Return the last element in list */ 0061 #define LIST_TAIL(list, type) ((type *)(list)->tail) 0062 0063 /* Get the next pointer of an entry */ 0064 #define LIST_FIELD(list, entry) (*(void **)((char *)(entry) + (list)->ofs)) 0065 0066 /* Return the next emlement in list */ 0067 #define LIST_NEXT(list, entry, type) ((type *)(LIST_FIELD(list, entry))) 0068 0069 /* Iterate through all entries in list */ 0070 #define LIST_FOR_EACH(list, entry, type) \ 0071 for (entry = LIST_HEAD(list, type); \ 0072 entry; \ 0073 entry = LIST_NEXT(list, entry, type)) 0074 0075 /*! Initialize a list during runtime 0076 * 0077 * \param list The list to initialize 0078 * \param offset The number of bytes into the entry structure the next pointer 0079 * is found 0080 */ 0081 extern void drvmgr_list_init(struct drvmgr_list *list, int offset); 0082 0083 /*! Clear list */ 0084 extern void drvmgr_list_empty(struct drvmgr_list *list); 0085 0086 /*! Add entry to front of list */ 0087 extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry); 0088 0089 /*! Add entry to end of list */ 0090 extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry); 0091 0092 /*! Remove entry from front of list */ 0093 extern void drvmgr_list_remove_head(struct drvmgr_list *list); 0094 0095 /*! Remove entry from anywhere in list */ 0096 extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry); 0097 0098 #ifdef __cplusplus 0099 } 0100 #endif 0101 0102 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |