yumapro  24.10-2
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
101/*********************************************************************
102* *
103* C H A N G E H I S T O R Y *
104* *
105*********************************************************************
106
107date init comment
108----------------------------------------------------------------------
10906-jan-89 abb Begun.
11018-jan-91 abb adapted for depend project
11112-mar-91 abb adapted for DAVID sbee project
11214-jun-91 abb changed que.h to dlq.h
11327-apr-05 abb update docs and use for netconf project
11415-feb-06 abb make DLQ module const compatible
115 get rid of dlq_hdrPT, as this doesn't work
116 for const pointers.
11715-sep-06 abb added dlq_swap function
11826-jan-07 abb added dlq_hdr_t alias for NCX naming conventions
11912-oct-07 abb add dlq_count
120*/
121
122#include "procdefs.h"
123
124#ifdef __cplusplus
125extern "C" {
126#endif
127
128/********************************************************************
129*
130* C O N S T A N T S
131*
132*********************************************************************/
133
134/* que header types */
135#define DLQ_NULL_NODE 1313
136#define DLQ_SHDR_NODE 2727
137#define DLQ_DHDR_NODE 3434
138#define DLQ_DATA_NODE 5757
139#define DLQ_DEL_NODE 8686
140#define DLQ_DEL_DHDR 9696
141
142#define dlq_hdr_t dlq_hdrT
143
144
145/********************************************************************
146*
147* T Y P E S
148*
149*********************************************************************/
150
154typedef struct TAGdlq_hdrT
155{
156 unsigned short hdr_typ;
157 struct TAGdlq_hdrT *prev;
158 struct TAGdlq_hdrT *next;
159} YPACK dlq_hdrT;
160
161
162/* shorthand macros */
163#define _hdr_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_SHDR_NODE \
164 || ((const dlq_hdrT *)(P))->hdr_typ==DLQ_DHDR_NODE)
165
166#define _data_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_DATA_NODE)
167
168#define _del_node(P) (((const dlq_hdrT *)(P))->hdr_typ==DLQ_DEL_NODE)
169
170
171#define dlq_hdr_node(P) _hdr_node(P)
172
173#define dlq_data_node(P) _data_node(P)
174
175
176#ifdef PTHREADS
177#define DLQ_HAS_NEXT_NODE(P) (((const dlq_hdrT *)(P))->next)
178#endif
179
180/*
181 * Define enter and exit critical section hooks here:
182 * This was ENTER_FAST_CS but causing crashes with lots of threads
183 */
184
185//#define ENTER_CRIT ENTER_FAST_CS
186//#define EXIT_CRIT EXIT_FAST_CS
187
188#define ENTER_CRIT ENTER_CS
189#define EXIT_CRIT EXIT_CS
190
191
192/********************************************************************
193*
194* F U N C T I O N S
195*
196*********************************************************************/
197
198#ifdef CPP_DEBUG
204extern void dlq_dumpHdr (const void *nodeP);
205#endif
206
207
214extern dlq_hdrT * dlq_createQue (void);
215
216
222extern void dlq_createSQue (dlq_hdrT * queAddr);
223
224
231extern void dlq_destroyQue (dlq_hdrT * listP);
232
233
241extern void dlq_enque (REG void *newP, REG dlq_hdrT * listP);
242
243
251extern void *dlq_deque (dlq_hdrT * listP);
252
253
261#if defined(CPP_NO_MACROS)
262extern void *dlq_nextEntry (const void *nodeP);
263#else
264#define dlq_nextEntry(nodeP) (_data_node(((const dlq_hdrT *) (nodeP))->next) ? \
265 ((const dlq_hdrT *) (nodeP))->next : NULL)
266#endif /* END CPP_NO_MACROS */
267
268
276#if defined(CPP_NO_MACROS)
277extern void *dlq_prevEntry (const void *nodeP);
278#else
279#define dlq_prevEntry(nodeP) (_data_node(((const dlq_hdrT *) (nodeP))->prev ) ? \
280 ((const dlq_hdrT *) (nodeP))->prev : NULL)
281#endif /* CPP_NO_MACROS */
282
283
290extern void dlq_insertAhead (void *newP, void *nodeP);
291
292
299extern void dlq_insertAfter (void *newP, void *nodeP);
300
301
309extern void dlq_remove (void *nodeP);
310
311
323extern void dlq_swap (void *new_node, void *cur_node);
324
325
333#if defined(CPP_NO_MACROS)
334extern void *dlq_firstEntry (const dlq_hdrT * listP);
335#else
336#define dlq_firstEntry(listP) ((listP) != ((const dlq_hdrT *)(listP))->next ? \
337 ((const dlq_hdrT *)(listP))->next : NULL)
338#endif /* CPP_NO_MACROS */
339
340
348#if defined(CPP_NO_MACROS)
349extern void *dlq_lastEntry (const dlq_hdrT * listP);
350#else
351#define dlq_lastEntry(listP) ((listP) != ((const dlq_hdrT *)(listP))->next ? \
352 ((const dlq_hdrT *)(listP))->prev : NULL)
353#endif /* CPP_NO_MACROS */
354
355
363#if defined(CPP_NO_MACROS)
364extern boolean dlq_empty (const dlq_hdrT * listP);
365#else
366#define dlq_empty(listP) (boolean)((listP)==((const dlq_hdrT *)(listP))->next)
367#endif /* CPP_NO_MACROS */
368
369
377extern void dlq_block_enque (dlq_hdrT * srcP, dlq_hdrT * dstP);
378
379
388extern void dlq_block_insertAhead (dlq_hdrT *srcP, void *dstP);
389
390
399extern void dlq_block_insertAfter (dlq_hdrT *srcP, void *dstP);
400
401
408extern unsigned int dlq_count (const dlq_hdrT *listP);
409
410
418extern boolean dlq_onQueue (const dlq_hdrT *nodeP);
419
420
426extern void dlq_reverse_que (dlq_hdr_t *que);
427
428
431#ifdef __cplusplus
432} /* end extern 'C' */
433#endif
434
435#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:245
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:264
void dlq_destroyQue(dlq_hdrT *listP)
free a dynamic queue header previously allocated with dlq_createQue
Definition: dlq.c:205
unsigned int dlq_count(const dlq_hdrT *listP)
get the number of queue entries in the listP queue list
Definition: dlq.c:928
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:176
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:862
void dlq_reverse_que(dlq_hdr_t *que)
Reverse the order of all the entries in a Q.
Definition: dlq.c:1004
void dlq_insertAfter(void *newP, void *nodeP)
insert the new queue entry after the current entry
Definition: dlq.c:481
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:799
void dlq_insertAhead(void *newP, void *nodeP)
insert the new queue entry before the current entry
Definition: dlq.c:446
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:561
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:366
#define dlq_lastEntry(listP)
get the last entry in the queue list
Definition: dlq.h:351
dlq_hdrT * dlq_createQue(void)
create a dynamic queue header
Definition: dlq.c:145
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:336
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:285
boolean dlq_onQueue(const dlq_hdrT *nodeP)
Determine where a data node header is on a queue or not.
Definition: dlq.c:973
#define dlq_prevEntry(nodeP)
get the previous queue entry before the current entry
Definition: dlq.h:279
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:730
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:518
dlq header used for both the control block for a queue and also a queue header node within another st...
Definition: dlq.h:155
struct TAGdlq_hdrT * prev
previous header
Definition: dlq.h:157
struct TAGdlq_hdrT * next
next header
Definition: dlq.h:158
unsigned short hdr_typ
queue header type
Definition: dlq.h:156