Print this page
XXXX update sendmail to 8.14.9
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/sendmail/include/sm/tailq.h
+++ new/usr/src/cmd/sendmail/include/sm/tailq.h
1 1 /* $OpenBSD: queue.h,v 1.30 2005/10/25 06:37:47 otto Exp $ */
2 2 /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
3 3
4 4 /*
5 5 * Copyright (c) 1991, 1993
6 6 * The Regents of the University of California. All rights reserved.
7 7 *
8 8 * Redistribution and use in source and binary forms, with or without
9 9 * modification, are permitted provided that the following conditions
10 10 * are met:
11 11 * 1. Redistributions of source code must retain the above copyright
12 12 * notice, this list of conditions and the following disclaimer.
13 13 * 2. Redistributions in binary form must reproduce the above copyright
14 14 * notice, this list of conditions and the following disclaimer in the
15 15 * documentation and/or other materials provided with the distribution.
16 16 * 3. Neither the name of the University nor the names of its contributors
17 17 * may be used to endorse or promote products derived from this software
18 18 * without specific prior written permission.
19 19 *
20 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
28 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 30 * SUCH DAMAGE.
31 31 *
32 32 * @(#)queue.h 8.5 (Berkeley) 8/20/94
33 33 */
34 34
35 35 #ifndef SM_TAILQ_H_
36 36 #define SM_TAILQ_H_
37 37
38 -#pragma ident "%Z%%M% %I% %E% SMI"
39 -
40 38 /*
41 - * $Id: tailq.h,v 1.2 2007/06/29 23:09:57 ca Exp $
39 + * $Id: tailq.h,v 1.3 2012-01-21 00:12:14 ashish Exp $
42 40 *
43 41 * This file is a modified copy of queue.h from a BSD system:
44 42 * we only need tail queues here.
45 43 * We do not use queue.h directly because there is a conflict with
46 44 * some versions of that file on some OSs.
47 45 *
48 46 * A tail queue is headed by a pair of pointers, one to the head of the
49 47 * list and the other to the tail of the list. The elements are doubly
50 48 * linked so that an arbitrary element can be removed without a need to
51 49 * traverse the list. New elements can be added to the list before or
52 50 * after an existing element, at the head of the list, or at the end of
53 51 * the list. A tail queue may be traversed in either direction.
54 52 */
55 53
56 54 /*
57 55 * Tail queue definitions.
58 56 */
59 57 #define SM_TAILQ_HEAD(name, type) \
60 58 struct name { \
61 59 struct type *tqh_first; /* first element */ \
62 60 struct type **tqh_last; /* addr of last next element */ \
63 61 }
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
64 62
65 63 #define SM_TAILQ_HEAD_INITIALIZER(head) \
66 64 { NULL, &(head).tqh_first }
67 65
68 66 #define SM_TAILQ_ENTRY(type) \
69 67 struct { \
70 68 struct type *tqe_next; /* next element */ \
71 69 struct type **tqe_prev; /* address of previous next element */ \
72 70 }
73 71
74 -/*
75 - * tail queue access methods
72 +/*
73 + * tail queue access methods
76 74 */
77 75 #define SM_TAILQ_FIRST(head) ((head)->tqh_first)
78 76 #define SM_TAILQ_END(head) NULL
79 77 #define SM_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
80 78 #define SM_TAILQ_LAST(head, headname) \
81 79 (*(((struct headname *)((head)->tqh_last))->tqh_last))
82 80 /* XXX */
83 81 #define SM_TAILQ_PREV(elm, headname, field) \
84 82 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
85 83 #define SM_TAILQ_EMPTY(head) \
86 84 (SM_TAILQ_FIRST(head) == SM_TAILQ_END(head))
87 85
88 86 #define SM_TAILQ_FOREACH(var, head, field) \
89 87 for((var) = SM_TAILQ_FIRST(head); \
90 88 (var) != SM_TAILQ_END(head); \
91 89 (var) = SM_TAILQ_NEXT(var, field))
92 90
93 91 #define SM_TAILQ_FOREACH_REVERSE(var, head, headname, field) \
94 92 for((var) = SM_TAILQ_LAST(head, headname); \
95 93 (var) != SM_TAILQ_END(head); \
96 94 (var) = SM_TAILQ_PREV(var, headname, field))
97 95
98 96 /*
99 97 * Tail queue functions.
100 98 */
101 99 #define SM_TAILQ_INIT(head) do { \
102 100 (head)->tqh_first = NULL; \
103 101 (head)->tqh_last = &(head)->tqh_first; \
104 102 } while (0)
105 103
106 104 #define SM_TAILQ_INSERT_HEAD(head, elm, field) do { \
107 105 if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
108 106 (head)->tqh_first->field.tqe_prev = \
109 107 &(elm)->field.tqe_next; \
110 108 else \
111 109 (head)->tqh_last = &(elm)->field.tqe_next; \
112 110 (head)->tqh_first = (elm); \
113 111 (elm)->field.tqe_prev = &(head)->tqh_first; \
114 112 } while (0)
115 113
116 114 #define SM_TAILQ_INSERT_TAIL(head, elm, field) do { \
117 115 (elm)->field.tqe_next = NULL; \
118 116 (elm)->field.tqe_prev = (head)->tqh_last; \
119 117 *(head)->tqh_last = (elm); \
120 118 (head)->tqh_last = &(elm)->field.tqe_next; \
121 119 } while (0)
122 120
123 121 #define SM_TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
124 122 if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
125 123 (elm)->field.tqe_next->field.tqe_prev = \
126 124 &(elm)->field.tqe_next; \
127 125 else \
128 126 (head)->tqh_last = &(elm)->field.tqe_next; \
129 127 (listelm)->field.tqe_next = (elm); \
130 128 (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
131 129 } while (0)
132 130
133 131 #define SM_TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
134 132 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
135 133 (elm)->field.tqe_next = (listelm); \
136 134 *(listelm)->field.tqe_prev = (elm); \
137 135 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
138 136 } while (0)
139 137
140 138 #define SM_TAILQ_REMOVE(head, elm, field) do { \
141 139 if (((elm)->field.tqe_next) != NULL) \
142 140 (elm)->field.tqe_next->field.tqe_prev = \
143 141 (elm)->field.tqe_prev; \
144 142 else \
145 143 (head)->tqh_last = (elm)->field.tqe_prev; \
146 144 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
147 145 } while (0)
148 146
149 147 #define SM_TAILQ_REPLACE(head, elm, elm2, field) do { \
150 148 if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
151 149 (elm2)->field.tqe_next->field.tqe_prev = \
152 150 &(elm2)->field.tqe_next; \
153 151 else \
154 152 (head)->tqh_last = &(elm2)->field.tqe_next; \
155 153 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
156 154 *(elm2)->field.tqe_prev = (elm2); \
157 155 } while (0)
158 156
159 157 #endif /* !SM_TAILQ_H_ */
|
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX