Skip to content

Commit 5bd0c44

Browse files
authored
[libc] Match the names of BSD sys/queue.h member names (#82696)
While these names are technically internal implemenetation detail, there's an existing code which relies on these details and using different names makes LLVM libc implementation incompatible. Since our goal is for LLVM libc to be a drop in replacement, use the same name as BSD sys/queue.h version.
1 parent e8740d4 commit 5bd0c44

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

libc/include/llvm-libc-macros/sys-queue-macros.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
#define SLIST_HEAD(name, type) \
2424
struct name { \
25-
struct type *first; \
25+
struct type *slh_first; \
2626
}
2727

2828
#define SLIST_CLASS_HEAD(name, type) \
2929
struct name { \
30-
class type *first; \
30+
class type *slh_first; \
3131
}
3232

3333
#define SLIST_HEAD_INITIALIZER(head) \
@@ -45,8 +45,8 @@
4545

4646
// Singly-linked list access methods.
4747

48-
#define SLIST_EMPTY(head) ((head)->first == NULL)
49-
#define SLIST_FIRST(head) ((head)->first)
48+
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
49+
#define SLIST_FIRST(head) ((head)->slh_first)
5050
#define SLIST_NEXT(elem, field) ((elem)->field.next)
5151

5252
#define SLIST_FOREACH(var, head, field) \
@@ -132,18 +132,18 @@
132132

133133
#define STAILQ_HEAD(name, type) \
134134
struct name { \
135-
struct type *first; \
136-
struct type **last; \
135+
struct type *stqh_first; \
136+
struct type **stqh_last; \
137137
}
138138

139139
#define STAILQ_CLASS_HEAD(name, type) \
140140
struct name { \
141-
class type *first; \
142-
class type **last; \
141+
class type *stqh_first; \
142+
class type **stqh_last; \
143143
}
144144

145145
#define STAILQ_HEAD_INITIALIZER(head) \
146-
{ NULL, &(head).first }
146+
{ NULL, &(head).stqh_first }
147147

148148
#define STAILQ_ENTRY(type) \
149149
struct { \
@@ -157,12 +157,12 @@
157157

158158
// Singly-linked tail queue access methods.
159159

160-
#define STAILQ_EMPTY(head) ((head)->first == NULL)
161-
#define STAILQ_FIRST(head) ((head)->first)
160+
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
161+
#define STAILQ_FIRST(head) ((head)->stqh_first)
162162
#define STAILQ_LAST(head, type, field) \
163163
(STAILQ_EMPTY(head) \
164164
? NULL \
165-
: __containerof((head)->last, QUEUE_TYPEOF(type), field.next))
165+
: __containerof((head)->stqh_last, QUEUE_TYPEOF(type), field.next))
166166
#define STAILQ_NEXT(elem, field) ((elem)->field.next)
167167

168168
#define STAILQ_FOREACH(var, head, field) \
@@ -187,37 +187,37 @@
187187
#define STAILQ_CONCAT(head1, head2, type, field) \
188188
do { \
189189
if (!STAILQ_EMPTY(head2)) { \
190-
*(head1)->last = (head2)->first; \
191-
(head1)->last = (head2)->last; \
190+
*(head1)->stqh_last = (head2)->stqh_first; \
191+
(head1)->stqh_last = (head2)->stqh_last; \
192192
STAILQ_INIT(head2); \
193193
} \
194194
} while (0)
195195

196196
#define STAILQ_INIT(head) \
197197
do { \
198198
STAILQ_FIRST(head) = NULL; \
199-
(head)->last = &STAILQ_FIRST(head); \
199+
(head)->stqh_last = &STAILQ_FIRST(head); \
200200
} while (0)
201201

202202
#define STAILQ_INSERT_AFTER(head, listelem, elem, field) \
203203
do { \
204204
if ((STAILQ_NEXT(elem, field) = STAILQ_NEXT(listelem, field)) == NULL) \
205-
(head)->last = &STAILQ_NEXT(elem, field); \
205+
(head)->stqh_last = &STAILQ_NEXT(elem, field); \
206206
STAILQ_NEXT(listelem, field) = (elem); \
207207
} while (0)
208208

209209
#define STAILQ_INSERT_HEAD(head, elem, field) \
210210
do { \
211211
if ((STAILQ_NEXT(elem, field) = STAILQ_FIRST(head)) == NULL) \
212-
(head)->last = &STAILQ_NEXT(elem, field); \
212+
(head)->stqh_last = &STAILQ_NEXT(elem, field); \
213213
STAILQ_FIRST(head) = (elem); \
214214
} while (0)
215215

216216
#define STAILQ_INSERT_TAIL(head, elem, field) \
217217
do { \
218218
STAILQ_NEXT(elem, field) = NULL; \
219-
*(head)->last = (elem); \
220-
(head)->last = &STAILQ_NEXT(elem, field); \
219+
*(head)->stqh_last = (elem); \
220+
(head)->stqh_last = &STAILQ_NEXT(elem, field); \
221221
} while (0)
222222

223223
#define STAILQ_REMOVE(head, elem, type, field) \
@@ -236,27 +236,27 @@
236236
do { \
237237
if ((STAILQ_NEXT(elem, field) = \
238238
STAILQ_NEXT(STAILQ_NEXT(elem, field), field)) == NULL) \
239-
(head)->last = &STAILQ_NEXT(elem, field); \
239+
(head)->stqh_last = &STAILQ_NEXT(elem, field); \
240240
} while (0)
241241

242242
#define STAILQ_REMOVE_HEAD(head, field) \
243243
do { \
244244
if ((STAILQ_FIRST(head) = STAILQ_NEXT(STAILQ_FIRST(head), field)) == NULL) \
245-
(head)->last = &STAILQ_FIRST(head); \
245+
(head)->stqh_last = &STAILQ_FIRST(head); \
246246
} while (0)
247247

248248
#define STAILQ_SWAP(head1, head2, type) \
249249
do { \
250250
QUEUE_TYPEOF(type) *first = STAILQ_FIRST(head1); \
251-
QUEUE_TYPEOF(type) **last = (head1)->last; \
251+
QUEUE_TYPEOF(type) **last = (head1)->stqh_last; \
252252
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
253-
(head1)->last = (head2)->last; \
253+
(head1)->stqh_last = (head2)->stqh_last; \
254254
STAILQ_FIRST(head2) = first; \
255-
(head2)->last = last; \
255+
(head2)->stqh_last = last; \
256256
if (STAILQ_EMPTY(head1)) \
257-
(head1)->last = &STAILQ_FIRST(head1); \
257+
(head1)->stqh_last = &STAILQ_FIRST(head1); \
258258
if (STAILQ_EMPTY(head2)) \
259-
(head2)->last = &STAILQ_FIRST(head2); \
259+
(head2)->stqh_last = &STAILQ_FIRST(head2); \
260260
} while (0)
261261

262262
#endif // __LLVM_LIBC_MACROS_SYS_QUEUE_MACROS_H

0 commit comments

Comments
 (0)