yumapro  22.10T-8
YumaPro SDK
Loading...
Searching...
No Matches
dlq.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2018
4 * Unless required by applicable law or agreed to in writing,
5 * software distributed under the License is distributed on an
6 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7 * KIND, either express or implied. See the License for the
8 * specific language governing permissions and limitations
9 * under the License.
10 */
11#ifndef _H_dlq
12#define _H_dlq
13/* FILE: dlq.h
14*********************************************************************
15* *
16* P U R P O S E *
17* *
18*********************************************************************/
19
102/*********************************************************************
103* *
104* C H A N G E H I S T O R Y *
105* *
106*********************************************************************
107
108date init comment
109----------------------------------------------------------------------
11006-jan-89 abb Begun.
11118-jan-91 abb adapted for depend project
11212-mar-91 abb adapted for DAVID sbee project
11314-jun-91 abb changed que.h to dlq.h
11427-apr-05 abb update docs and use for netconf project
11515-feb-06 abb make DLQ module const compatible
116 get rid of dlq_hdrPT, as this doesn't work
117 for const pointers.
11815-sep-06 abb added dlq_swap function
11926-jan-07 abb added dlq_hdr_t alias for NCX naming conventions
12012-oct-07 abb add dlq_count
121*/
122
123#include "procdefs.h"
124
125#ifdef __cplusplus
126extern "C" {
127#endif
128
129/********************************************************************
130*
131* C O N S T A N T S
132*
133*********************************************************************/
134
135/* que header types */
136#define DLQ_NULL_NODE 1313
137#define DLQ_SHDR_NODE 2727
138#define DLQ_DHDR_NODE 3434
139#define DLQ_DATA_NODE 5757
140#define DLQ_DEL_NODE 8686
141#define DLQ_DEL_DHDR 9696
142
143#define dlq_hdr_t dlq_hdrT
144
145
146/********************************************************************
147*
148* T Y P E S
149*
150*********************************************************************/
151
155typedef struct TAGdlq_hdrT
156{
157 unsigned short hdr_typ;
158 struct TAGdlq_hdrT *prev;
159 struct TAGdlq_hdrT *next;
160} YPACK dlq_hdrT;
161
162
163/* shorthand macros */
164#define _hdr_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_SHDR_NODE \
165 || ((const dlq_hdrT *)(P))->hdr_typ==DLQ_DHDR_NODE)
166
167#define _data_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_DATA_NODE)
168
169#define _del_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_DEL_NODE)
170
171
172#define dlq_hdr_node(P) _hdr_node(P)
173
174#define dlq_data_node(P) _data_node(P)
175
176
177#ifdef PTHREADS
178#define DLQ_HAS_NEXT_NODE(P) (((const dlq_hdrT *)(P))->next)
179#endif
180
181/*
182 * Define enter and exit critical section hooks here:
183 * This was ENTER_FAST_CS but causing crashes with lots of threads
184 */
185
186//#define ENTER_CRIT ENTER_FAST_CS
187//#define EXIT_CRIT EXIT_FAST_CS
188
189#define ENTER_CRIT ENTER_CS
190#define EXIT_CRIT EXIT_CS
191
192
193/********************************************************************
194*
195* F U N C T I O N S
196*
197*********************************************************************/
198
199#ifdef CPP_DEBUG
205extern void dlq_dumpHdr (const void *nodeP);
206#endif
207
208
215extern dlq_hdrT * dlq_createQue (void);
216
217
223extern void dlq_createSQue (dlq_hdrT * queAddr);
224
225
232extern void dlq_destroyQue (dlq_hdrT * listP);
233
234
242extern void dlq_enque (REG void *newP, REG dlq_hdrT * listP);
243
244
252extern void *dlq_deque (dlq_hdrT * listP);
253
254
262#if defined(CPP_NO_MACROS)
263extern void *dlq_nextEntry (const void *nodeP);
264#else
265#define dlq_nextEntry(nodeP) (_data_node(((const dlq_hdrT *) (nodeP))->next) ? \
266 ((const dlq_hdrT *) (nodeP))->next : NULL)
267#endif /* END CPP_NO_MACROS */
268
269
277#if defined(CPP_NO_MACROS)
278extern void *dlq_prevEntry (const void *nodeP);
279#else
280#define dlq_prevEntry(nodeP) (_data_node(((const dlq_hdrT *) (nodeP))->prev ) ? \
281 ((const dlq_hdrT *) (nodeP))->prev : NULL)
282#endif /* CPP_NO_MACROS */
283
284
291extern void dlq_insertAhead (void *newP, void *nodeP);
292
293
300extern void dlq_insertAfter (void *newP, void *nodeP);
301
302
310extern void dlq_remove (void *nodeP);
311
312
324extern void dlq_swap (void *new_node, void *cur_node);
325
326
334#if defined(CPP_NO_MACROS)
335extern void *dlq_firstEntry (const dlq_hdrT * listP);
336#else
337#define dlq_firstEntry(listP) ((listP) != ((const dlq_hdrT *)(listP))->next ? \
338 ((const dlq_hdrT *)(listP))->next : NULL)
339#endif /* CPP_NO_MACROS */
340
341
349#if defined(CPP_NO_MACROS)
350extern void *dlq_lastEntry (const dlq_hdrT * listP);
351#else
352#define dlq_lastEntry(listP) ((listP) != ((const dlq_hdrT *)(listP))->next ? \
353 ((const dlq_hdrT *)(listP))->prev : NULL)
354#endif /* CPP_NO_MACROS */
355
356
364#if defined(CPP_NO_MACROS)
365extern boolean dlq_empty (const dlq_hdrT * listP);
366#else
367#define dlq_empty(listP) (boolean)((listP)==((const dlq_hdrT *)(listP))->next)
368#endif /* CPP_NO_MACROS */
369
370
378extern void dlq_block_enque (dlq_hdrT * srcP, dlq_hdrT * dstP);
379
380
389extern void dlq_block_insertAhead (dlq_hdrT *srcP, void *dstP);
390
391
400extern void dlq_block_insertAfter (dlq_hdrT *srcP, void *dstP);
401
402
415extern void dlq_block_move (dlq_hdrT *srcQ, void *srcP, dlq_hdrT * dstQ);
416
417
424extern unsigned int dlq_count (const dlq_hdrT *listP);
425
426
434extern boolean dlq_onQueue (const dlq_hdrT *nodeP);
435
436
442extern void dlq_reverse_que (dlq_hdr_t *que);
443
444
447#ifdef __cplusplus
448} /* end extern 'C' */
449#endif
450
451#endif /* _H_dlq */
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
void dlq_block_move(dlq_hdrT *srcQ, void *srcP, dlq_hdrT *dstQ)
enque from [srcP .
Definition: dlq.c:931
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
void dlq_destroyQue(dlq_hdrT *listP)
free a dynamic queue header previously allocated with dlq_createQue
Definition: dlq.c:206
unsigned int dlq_count(const dlq_hdrT *listP)
get the number of queue entries in the listP queue list
Definition: dlq.c:994
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
void dlq_block_insertAfter(dlq_hdrT *srcP, void *dstP)
insert all the entries in the srcP queue list after the dstP queue entry
Definition: dlq.c:863
void dlq_reverse_que(dlq_hdr_t *que)
Reverse the order of all the entries in a Q.
Definition: dlq.c:1070
void dlq_insertAfter(void *newP, void *nodeP)
insert the new queue entry after the current entry
Definition: dlq.c:482
void dlq_block_insertAhead(dlq_hdrT *srcP, void *dstP)
insert all the entries in the srcP queue list before the dstP queue entry
Definition: dlq.c:800
void dlq_insertAhead(void *newP, void *nodeP)
insert the new queue entry before the current entry
Definition: dlq.c:447
void dlq_swap(void *new_node, void *cur_node)
remove the cur_node queue entry from its queue list and replace it with the new_node
Definition: dlq.c:562
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
#define dlq_lastEntry(listP)
get the last entry in the queue list
Definition: dlq.h:352
dlq_hdrT * dlq_createQue(void)
create a dynamic queue header
Definition: dlq.c:146
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
boolean dlq_onQueue(const dlq_hdrT *nodeP)
Determine where a data node header is on a queue or not.
Definition: dlq.c:1039
#define dlq_prevEntry(nodeP)
get the previous queue entry before the current entry
Definition: dlq.h:280
void dlq_block_enque(dlq_hdrT *srcP, dlq_hdrT *dstP)
add all the queue entries in the srcP queue list to the end of the dstP queue list
Definition: dlq.c:731
void dlq_remove(void *nodeP)
remove the queue entry from its queue list entry MUST have been enqueued somehow before this function...
Definition: dlq.c:519
dlq header used for both the control block for a queue and also a queue header node within another st...
Definition: dlq.h:156
struct TAGdlq_hdrT * prev
previous header
Definition: dlq.h:158
struct TAGdlq_hdrT * next
next header
Definition: dlq.h:159
unsigned short hdr_typ
queue header type
Definition: dlq.h:157