mirror of https://github.com/lukechilds/node.git
36 changed files with 409 additions and 415 deletions
@ -1,129 +0,0 @@ |
|||
|
|||
/*
|
|||
* Copyright (C) Igor Sysoev |
|||
*/ |
|||
|
|||
|
|||
#ifndef NGX_QUEUE_H_INCLUDED_ |
|||
#define NGX_QUEUE_H_INCLUDED_ |
|||
|
|||
|
|||
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) \ |
|||
do { \ |
|||
(q)->prev = q; \ |
|||
(q)->next = q; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
|
|||
#define ngx_queue_empty(h) \ |
|||
(h == (h)->prev) |
|||
|
|||
|
|||
#define ngx_queue_insert_head(h, x) \ |
|||
do { \ |
|||
(x)->next = (h)->next; \ |
|||
(x)->next->prev = x; \ |
|||
(x)->prev = h; \ |
|||
(h)->next = x; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
|
|||
#define ngx_queue_insert_after ngx_queue_insert_head |
|||
|
|||
|
|||
#define ngx_queue_insert_tail(h, x) \ |
|||
do { \ |
|||
(x)->prev = (h)->prev; \ |
|||
(x)->prev->next = x; \ |
|||
(x)->next = h; \ |
|||
(h)->prev = x; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
|
|||
#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 |
|||
|
|||
|
|||
#if defined(NGX_DEBUG) |
|||
|
|||
#define ngx_queue_remove(x) \ |
|||
do { \ |
|||
(x)->next->prev = (x)->prev; \ |
|||
(x)->prev->next = (x)->next; \ |
|||
(x)->prev = NULL; \ |
|||
(x)->next = NULL; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#else |
|||
|
|||
#define ngx_queue_remove(x) \ |
|||
do { \ |
|||
(x)->next->prev = (x)->prev; \ |
|||
(x)->prev->next = (x)->next; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#endif |
|||
|
|||
|
|||
#define ngx_queue_split(h, q, n) \ |
|||
do { \ |
|||
(n)->prev = (h)->prev; \ |
|||
(n)->prev->next = n; \ |
|||
(n)->next = q; \ |
|||
(h)->prev = (q)->prev; \ |
|||
(h)->prev->next = h; \ |
|||
(q)->prev = n; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
|
|||
#define ngx_queue_add(h, n) \ |
|||
do { \ |
|||
(h)->prev->next = (n)->next; \ |
|||
(n)->next->prev = (h)->prev; \ |
|||
(h)->prev = (n)->prev; \ |
|||
(h)->prev->next = h; \ |
|||
} \ |
|||
while (0) |
|||
|
|||
|
|||
#define ngx_queue_data(q, type, link) \ |
|||
((type *) ((unsigned char *) q - offsetof(type, link))) |
|||
|
|||
|
|||
#define ngx_queue_foreach(q, h) \ |
|||
for ((q) = ngx_queue_head(h); \ |
|||
(q) != ngx_queue_sentinel(h) && !ngx_queue_empty(h); \ |
|||
(q) = ngx_queue_next(q)) |
|||
|
|||
|
|||
#endif /* NGX_QUEUE_H_INCLUDED_ */ |
@ -0,0 +1,92 @@ |
|||
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
|
|||
* |
|||
* Permission to use, copy, modify, and/or distribute this software for any |
|||
* purpose with or without fee is hereby granted, provided that the above |
|||
* copyright notice and this permission notice appear in all copies. |
|||
* |
|||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#ifndef QUEUE_H_ |
|||
#define QUEUE_H_ |
|||
|
|||
typedef void *QUEUE[2]; |
|||
|
|||
/* Private macros. */ |
|||
#define QUEUE_NEXT(q) ((*(q))[0]) |
|||
#define QUEUE_PREV(q) ((*(q))[1]) |
|||
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT((QUEUE *) QUEUE_PREV(q))) |
|||
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV((QUEUE *) QUEUE_NEXT(q))) |
|||
|
|||
/* Public macros. */ |
|||
#define QUEUE_DATA(ptr, type, field) \ |
|||
((type *) ((char *) (ptr) - ((long) &((type *) 0)->field))) |
|||
|
|||
#define QUEUE_FOREACH(q, h) \ |
|||
for ((q) = (*(h))[0]; (q) != (h); (q) = (*(q))[0]) |
|||
|
|||
#define QUEUE_EMPTY(q) \ |
|||
(QUEUE_NEXT(q) == (q)) |
|||
|
|||
#define QUEUE_HEAD(q) \ |
|||
(QUEUE_NEXT(q)) |
|||
|
|||
#define QUEUE_INIT(q) \ |
|||
do { \ |
|||
QUEUE_NEXT(q) = (q); \ |
|||
QUEUE_PREV(q) = (q); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#define QUEUE_ADD(h, n) \ |
|||
do { \ |
|||
QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ |
|||
QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ |
|||
QUEUE_PREV(h) = QUEUE_PREV(n); \ |
|||
QUEUE_PREV_NEXT(h) = (h); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#define QUEUE_SPLIT(h, q, n) \ |
|||
do { \ |
|||
QUEUE_PREV(n) = QUEUE_PREV(h); \ |
|||
QUEUE_PREV_NEXT(n) = (n); \ |
|||
QUEUE_NEXT(n) = (q); \ |
|||
QUEUE_PREV(h) = QUEUE_PREV(q); \ |
|||
QUEUE_PREV_NEXT(h) = (h); \ |
|||
QUEUE_PREV(q) = (n); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#define QUEUE_INSERT_HEAD(h, q) \ |
|||
do { \ |
|||
QUEUE_NEXT(q) = QUEUE_NEXT(h); \ |
|||
QUEUE_PREV(q) = (h); \ |
|||
QUEUE_NEXT_PREV(q) = (q); \ |
|||
QUEUE_NEXT(h) = (q); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#define QUEUE_INSERT_TAIL(h, q) \ |
|||
do { \ |
|||
QUEUE_NEXT(q) = (h); \ |
|||
QUEUE_PREV(q) = QUEUE_PREV(h); \ |
|||
QUEUE_PREV_NEXT(q) = (q); \ |
|||
QUEUE_PREV(h) = (q); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#define QUEUE_REMOVE(q) \ |
|||
do { \ |
|||
QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ |
|||
QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ |
|||
} \ |
|||
while (0) |
|||
|
|||
#endif /* QUEUE_H_ */ |
Loading…
Reference in new issue