Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #include <ngx_config.h>
0009 #include <ngx_core.h>
0010 
0011 
0012 #ifndef _NGX_QUEUE_H_INCLUDED_
0013 #define _NGX_QUEUE_H_INCLUDED_
0014 
0015 
0016 typedef struct ngx_queue_s  ngx_queue_t;
0017 
0018 struct ngx_queue_s {
0019     ngx_queue_t  *prev;
0020     ngx_queue_t  *next;
0021 };
0022 
0023 
0024 #define ngx_queue_init(q)                                                     \
0025     (q)->prev = q;                                                            \
0026     (q)->next = q
0027 
0028 
0029 #define ngx_queue_empty(h)                                                    \
0030     (h == (h)->prev)
0031 
0032 
0033 #define ngx_queue_insert_head(h, x)                                           \
0034     (x)->next = (h)->next;                                                    \
0035     (x)->next->prev = x;                                                      \
0036     (x)->prev = h;                                                            \
0037     (h)->next = x
0038 
0039 
0040 #define ngx_queue_insert_after   ngx_queue_insert_head
0041 
0042 
0043 #define ngx_queue_insert_tail(h, x)                                           \
0044     (x)->prev = (h)->prev;                                                    \
0045     (x)->prev->next = x;                                                      \
0046     (x)->next = h;                                                            \
0047     (h)->prev = x
0048 
0049 
0050 #define ngx_queue_head(h)                                                     \
0051     (h)->next
0052 
0053 
0054 #define ngx_queue_last(h)                                                     \
0055     (h)->prev
0056 
0057 
0058 #define ngx_queue_sentinel(h)                                                 \
0059     (h)
0060 
0061 
0062 #define ngx_queue_next(q)                                                     \
0063     (q)->next
0064 
0065 
0066 #define ngx_queue_prev(q)                                                     \
0067     (q)->prev
0068 
0069 
0070 #if (NGX_DEBUG)
0071 
0072 #define ngx_queue_remove(x)                                                   \
0073     (x)->next->prev = (x)->prev;                                              \
0074     (x)->prev->next = (x)->next;                                              \
0075     (x)->prev = NULL;                                                         \
0076     (x)->next = NULL
0077 
0078 #else
0079 
0080 #define ngx_queue_remove(x)                                                   \
0081     (x)->next->prev = (x)->prev;                                              \
0082     (x)->prev->next = (x)->next
0083 
0084 #endif
0085 
0086 
0087 #define ngx_queue_split(h, q, n)                                              \
0088     (n)->prev = (h)->prev;                                                    \
0089     (n)->prev->next = n;                                                      \
0090     (n)->next = q;                                                            \
0091     (h)->prev = (q)->prev;                                                    \
0092     (h)->prev->next = h;                                                      \
0093     (q)->prev = n;
0094 
0095 
0096 #define ngx_queue_add(h, n)                                                   \
0097     (h)->prev->next = (n)->next;                                              \
0098     (n)->next->prev = (h)->prev;                                              \
0099     (h)->prev = (n)->prev;                                                    \
0100     (h)->prev->next = h;
0101 
0102 
0103 #define ngx_queue_data(q, type, link)                                         \
0104     (type *) ((u_char *) q - offsetof(type, link))
0105 
0106 
0107 ngx_queue_t *ngx_queue_middle(ngx_queue_t *queue);
0108 void ngx_queue_sort(ngx_queue_t *queue,
0109     ngx_int_t (*cmp)(const ngx_queue_t *, const ngx_queue_t *));
0110 
0111 
0112 #endif /* _NGX_QUEUE_H_INCLUDED_ */