-
Notifications
You must be signed in to change notification settings - Fork 0
/
slist.h
117 lines (89 loc) · 5.47 KB
/
slist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
*********************************************************************************************************
* uC/Common
* Common Features for Micrium Stacks
*
* Copyright 2013-2020 Silicon Laboratories Inc. www.silabs.com
*
* SPDX-License-Identifier: APACHE-2.0
*
* This software is subject to an open source license and is distributed by
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* uC/Common - Singly-linked Lists (SList)
*
* Filename : slist.h
* Version : V1.02.00
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) This library header file is protected from multiple pre-processor inclusion through
* use of the library module present pre-processor macro definition.
*********************************************************************************************************
*********************************************************************************************************
*/
#ifndef COLL_SLIST_MODULE_PRESENT /* See Note #1. */
#define COLL_SLIST_MODULE_PRESENT
/*
*********************************************************************************************************
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*********************************************************************************************************
*/
#include <cpu.h>
/*
*********************************************************************************************************
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*********************************************************************************************************
*/
typedef struct slist_member SLIST_MEMBER;
struct slist_member {
SLIST_MEMBER *p_next;
};
/*
*********************************************************************************************************
*********************************************************************************************************
* MACROS
*********************************************************************************************************
*********************************************************************************************************
*/
#define OFFSET_OF(type, member) ((CPU_SIZE_T)&(((type *)0)->member))
#define CONTAINER_OF(p_member, parent_type, member) (parent_type *)((CPU_ADDR)(p_member) - ((CPU_ADDR)(&((parent_type *)0)->member)))
#define SLIST_FOR_EACH(list_head, iterator) for ((iterator) = (list_head); (iterator) != DEF_NULL; (iterator) = (iterator)->p_next)
#define SLIST_FOR_EACH_ENTRY(list_head, entry, type, member) for ( (entry) = SLIST_ENTRY(list_head, type, member); \
&((entry)->member.p_next) != DEF_NULL; \
(entry) = SLIST_ENTRY((entry)->member.p_next, type, member))
#define SLIST_ENTRY CONTAINER_OF
/*
*********************************************************************************************************
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*********************************************************************************************************
*/
void SList_Init (SLIST_MEMBER **p_head_ptr);
void SList_Push (SLIST_MEMBER **p_head_ptr,
SLIST_MEMBER *p_item);
void SList_PushBack (SLIST_MEMBER **p_head_ptr,
SLIST_MEMBER *p_item);
SLIST_MEMBER *SList_Pop (SLIST_MEMBER **p_head_ptr);
void SList_Add (SLIST_MEMBER *p_item,
SLIST_MEMBER *p_pos);
void SList_Rem (SLIST_MEMBER **p_head_ptr,
SLIST_MEMBER *p_item);
void SList_Sort (SLIST_MEMBER **p_head_ptr,
CPU_BOOLEAN (*cmp_fnct)(SLIST_MEMBER *p_item_l, SLIST_MEMBER *p_item_r));
#endif /* COLL_SLIST_MODULE_PRESENT */