node/deps/uv/include/uv-private/ngx-queue.h

130 lines
5.1 KiB
C
Raw Normal View History

2011-07-08 02:32:12 +08:00
/*
* Copyright (C) Igor Sysoev
*/
2012-03-31 01:25:07 +08:00
#ifndef NGX_QUEUE_H_INCLUDED_
#define NGX_QUEUE_H_INCLUDED_
2011-07-08 02:32:12 +08:00
typedef struct ngx_queue_s ngx_queue_t;
struct ngx_queue_s {
ngx_queue_t *prev;
ngx_queue_t *next;
};
#define ngx_queue_init(q) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(q)->prev = q; \
2012-10-07 05:04:30 +08:00
(q)->next = q; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#define ngx_queue_empty(h) \
(h == (h)->prev)
#define ngx_queue_insert_head(h, x) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(x)->next = (h)->next; \
(x)->next->prev = x; \
(x)->prev = h; \
2012-10-07 05:04:30 +08:00
(h)->next = x; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#define ngx_queue_insert_after ngx_queue_insert_head
#define ngx_queue_insert_tail(h, x) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(x)->prev = (h)->prev; \
(x)->prev->next = x; \
(x)->next = h; \
2012-10-07 05:04:30 +08:00
(h)->prev = x; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#define ngx_queue_head(h) \
(h)->next
#define ngx_queue_last(h) \
(h)->prev
#define ngx_queue_sentinel(h) \
(h)
#define ngx_queue_next(q) \
(q)->next
#define ngx_queue_prev(q) \
(q)->prev
2012-08-21 00:41:07 +08:00
#if defined(NGX_DEBUG)
2011-07-08 02:32:12 +08:00
#define ngx_queue_remove(x) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(x)->next->prev = (x)->prev; \
(x)->prev->next = (x)->next; \
(x)->prev = NULL; \
2012-10-07 05:04:30 +08:00
(x)->next = NULL; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#else
#define ngx_queue_remove(x) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(x)->next->prev = (x)->prev; \
2012-10-07 05:04:30 +08:00
(x)->prev->next = (x)->next; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#endif
#define ngx_queue_split(h, q, n) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(n)->prev = (h)->prev; \
(n)->prev->next = n; \
(n)->next = q; \
(h)->prev = (q)->prev; \
(h)->prev->next = h; \
2012-10-07 05:04:30 +08:00
(q)->prev = n; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#define ngx_queue_add(h, n) \
2012-10-07 05:04:30 +08:00
do { \
2011-07-08 02:32:12 +08:00
(h)->prev->next = (n)->next; \
(n)->next->prev = (h)->prev; \
(h)->prev = (n)->prev; \
2012-10-07 05:04:30 +08:00
(h)->prev->next = h; \
} \
while (0)
2011-07-08 02:32:12 +08:00
#define ngx_queue_data(q, type, link) \
2012-10-07 05:04:30 +08:00
((type *) ((unsigned char *) q - offsetof(type, link)))
2011-07-08 02:32:12 +08:00
2011-12-21 03:55:14 +08:00
#define ngx_queue_foreach(q, h) \
2012-06-13 01:19:26 +08:00
for ((q) = ngx_queue_head(h); \
2012-10-31 06:06:03 +08:00
(q) != ngx_queue_sentinel(h) && !ngx_queue_empty(h); \
2012-06-13 01:19:26 +08:00
(q) = ngx_queue_next(q))
2011-12-21 03:55:14 +08:00
2012-03-31 01:25:07 +08:00
#endif /* NGX_QUEUE_H_INCLUDED_ */