Windows: fix checked UNICODE build of talocale
[openafs.git] / src / WINNT / client_osi / osiqueue.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Copyright (C) 1994 Cazamar Systems, Inc. */
11
12 #ifndef _OSI_QUEUE_H_ENV_
13 #define _OSI_QUEUE_H_ENV_ 1
14
15 /* this package implements a doubly linked queue of elements.
16  * Each element starts with an osi_queue_t element.
17  *
18  * Utility functions are passed a pointer to a pointer to the first
19  * element in the list; this word is NULL if the list is empty (the
20  * pointer to it, of course, is not NULL).
21  * The list is *not* circularly linked; rather prevp of the first
22  * element and nextp of the last element are both NULL; this makes
23  * checking for the end of the list easier, and still provides us a
24  * quick deletion.
25  *
26  * Some of these things are macros for performance reasons.
27  */
28
29 typedef struct osi_queue {
30         struct osi_queue *nextp;
31         struct osi_queue *prevp;
32 } osi_queue_t;
33
34 typedef struct osi_queueData {
35         osi_queue_t q;
36         void *datap;
37 } osi_queueData_t;
38
39 /* # of elements to allocate at once */
40 #define OSI_NQDALLOC            64
41
42 /* add an element to the head of a queue, first parm is
43  * address of head pointer, and second parm is addr of
44  * element to add.
45  */
46 extern void osi_QAdd(osi_queue_t **headpp, osi_queue_t *eltp);
47
48 /* add an element to the tail of a queue, first parm is
49  * address of head pointer, second is addr of ptr to tail elt,
50  * and third parm is addr of element to add.
51  */
52 extern void osi_QAddT(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp);
53
54 /* add to the head (like osi_QAdd) only be prepared to set tailpp if necessary */
55 extern void osi_QAddH(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp);
56
57 /* remove an element from a queue; takes address of head list, and
58  * element to remove as parameters.
59  */
60 extern void osi_QRemove(osi_queue_t **headpp, osi_queue_t *eltp);
61
62 /* remove an element from a queue with both head and tail pointers;
63  * takes address of head and tail lists, and element to remove as parameters.
64  */
65 extern void osi_QRemoveHT(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp);
66
67 /* initialize the queue package */
68 extern void osi_InitQueue(void);
69
70 /* allocate a queue element with one data ptr */
71 extern osi_queueData_t *osi_QDAlloc(void);
72
73 /* free a single element queue pointer */
74 extern void osi_QDFree(osi_queueData_t *);
75
76 /* retrieve the queue data from a one-element block */
77 #define osi_GetQData(x)         ((x)->datap)
78
79 /* set the queue data in a one-element block */
80 #define osi_SetQData(x,y)       ((x)->datap = (y))
81
82 /* get the next ptr from a queue element */
83 #define osi_QNext(x)    ((x)->nextp)
84
85 /* get the prev ptr from a queue element */
86 #define osi_QPrev(x)    ((x)->prevp)
87
88 /* find out if a queue is empty */
89 #define osi_QIsEmpty(x) ((*x) == ((osi_queue_t *) 0))
90
91 #endif /* _OSI_QUEUE_H_ENV_ */