Mercurial > hg > nginx
annotate src/core/ngx_queue.h @ 9320:cf73b65983c2 default tip
release-1.27.3 tag
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Aug 2024 17:26:33 +0300 |
parents | 3038bd4d7816 |
children |
rev | line source |
---|---|
1646 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
1646 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 | |
11 | |
12 #ifndef _NGX_QUEUE_H_INCLUDED_ | |
13 #define _NGX_QUEUE_H_INCLUDED_ | |
14 | |
15 | |
16 typedef struct ngx_queue_s ngx_queue_t; | |
17 | |
18 struct ngx_queue_s { | |
19 ngx_queue_t *prev; | |
20 ngx_queue_t *next; | |
21 }; | |
22 | |
23 | |
1684 | 24 #define ngx_queue_init(q) \ |
25 (q)->prev = q; \ | |
1763 | 26 (q)->next = q |
1684 | 27 |
28 | |
1646 | 29 #define ngx_queue_empty(h) \ |
30 (h == (h)->prev) | |
31 | |
32 | |
33 #define ngx_queue_insert_head(h, x) \ | |
34 (x)->next = (h)->next; \ | |
35 (x)->next->prev = x; \ | |
36 (x)->prev = h; \ | |
37 (h)->next = x | |
38 | |
39 | |
2026 | 40 #define ngx_queue_insert_after ngx_queue_insert_head |
41 | |
42 | |
43 #define ngx_queue_insert_tail(h, x) \ | |
44 (x)->prev = (h)->prev; \ | |
45 (x)->prev->next = x; \ | |
46 (x)->next = h; \ | |
47 (h)->prev = x | |
48 | |
49 | |
9167
3038bd4d7816
Core: changed ngx_queue_sort() to use merge sort.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
50 #define ngx_queue_insert_before ngx_queue_insert_tail |
3038bd4d7816
Core: changed ngx_queue_sort() to use merge sort.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
51 |
3038bd4d7816
Core: changed ngx_queue_sort() to use merge sort.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
52 |
1646 | 53 #define ngx_queue_head(h) \ |
54 (h)->next | |
55 | |
56 | |
57 #define ngx_queue_last(h) \ | |
58 (h)->prev | |
59 | |
60 | |
2026 | 61 #define ngx_queue_sentinel(h) \ |
62 (h) | |
63 | |
64 | |
65 #define ngx_queue_next(q) \ | |
66 (q)->next | |
67 | |
68 | |
69 #define ngx_queue_prev(q) \ | |
70 (q)->prev | |
71 | |
72 | |
1646 | 73 #if (NGX_DEBUG) |
74 | |
75 #define ngx_queue_remove(x) \ | |
76 (x)->next->prev = (x)->prev; \ | |
77 (x)->prev->next = (x)->next; \ | |
78 (x)->prev = NULL; \ | |
79 (x)->next = NULL | |
80 | |
81 #else | |
82 | |
83 #define ngx_queue_remove(x) \ | |
84 (x)->next->prev = (x)->prev; \ | |
85 (x)->prev->next = (x)->next | |
86 | |
87 #endif | |
88 | |
89 | |
2026 | 90 #define ngx_queue_split(h, q, n) \ |
91 (n)->prev = (h)->prev; \ | |
92 (n)->prev->next = n; \ | |
93 (n)->next = q; \ | |
94 (h)->prev = (q)->prev; \ | |
95 (h)->prev->next = h; \ | |
96 (q)->prev = n; | |
97 | |
98 | |
99 #define ngx_queue_add(h, n) \ | |
100 (h)->prev->next = (n)->next; \ | |
101 (n)->next->prev = (h)->prev; \ | |
102 (h)->prev = (n)->prev; \ | |
103 (h)->prev->next = h; | |
104 | |
105 | |
1646 | 106 #define ngx_queue_data(q, type, link) \ |
107 (type *) ((u_char *) q - offsetof(type, link)) | |
108 | |
109 | |
2026 | 110 ngx_queue_t *ngx_queue_middle(ngx_queue_t *queue); |
111 void ngx_queue_sort(ngx_queue_t *queue, | |
112 ngx_int_t (*cmp)(const ngx_queue_t *, const ngx_queue_t *)); | |
113 | |
114 | |
1646 | 115 #endif /* _NGX_QUEUE_H_INCLUDED_ */ |