Skip to content

Commit a7820a1

Browse files
committed
src: replace ngx-queue.h with queue.h
No functional changes, just one less entry in the LICENSE file.
1 parent 72b92e9 commit a7820a1

8 files changed

Lines changed: 110 additions & 152 deletions

File tree

LICENSE

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -431,34 +431,6 @@ maintained libraries. The externally maintained libraries used by Node are:
431431
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
432432
"""
433433

434-
- src/ngx-queue.h. ngx-queue.h is taken from the nginx source tree. nginx's
435-
license follows:
436-
"""
437-
Copyright (C) 2002-2012 Igor Sysoev
438-
Copyright (C) 2011,2012 Nginx, Inc.
439-
440-
Redistribution and use in source and binary forms, with or without
441-
modification, are permitted provided that the following conditions
442-
are met:
443-
1. Redistributions of source code must retain the above copyright
444-
notice, this list of conditions and the following disclaimer.
445-
2. Redistributions in binary form must reproduce the above copyright
446-
notice, this list of conditions and the following disclaimer in the
447-
documentation and/or other materials provided with the distribution.
448-
449-
THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
450-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
451-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
452-
ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
453-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
454-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
455-
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
456-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
457-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
458-
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
459-
SUCH DAMAGE.
460-
"""
461-
462434
- wrk is located at tools/wrk. wrk's license follows:
463435
"""
464436

node.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@
129129
'src/node_string.h',
130130
'src/node_version.h',
131131
'src/node_watchdog.h',
132-
'src/ngx-queue.h',
133132
'src/pipe_wrap.h',
133+
'src/queue.h',
134134
'src/tty_wrap.h',
135135
'src/tcp_wrap.h',
136136
'src/udp_wrap.h',

src/handle_wrap.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
#include "node.h"
23-
#include "ngx-queue.h"
23+
#include "queue.h"
2424
#include "handle_wrap.h"
2525

2626
namespace node {
@@ -43,7 +43,7 @@ using v8::Value;
4343

4444

4545
// defined in node.cc
46-
extern ngx_queue_t handle_wrap_queue;
46+
extern QUEUE handle_wrap_queue;
4747
static Persistent<String> close_sym;
4848

4949

@@ -115,13 +115,13 @@ HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
115115
assert(object->InternalFieldCount() > 0);
116116
object_ = v8::Persistent<v8::Object>::New(node_isolate, object);
117117
object_->SetAlignedPointerInInternalField(0, this);
118-
ngx_queue_insert_tail(&handle_wrap_queue, &handle_wrap_queue_);
118+
QUEUE_INSERT_TAIL(&handle_wrap_queue, &handle_wrap_queue_);
119119
}
120120

121121

122122
HandleWrap::~HandleWrap() {
123123
assert(object_.IsEmpty());
124-
ngx_queue_remove(&handle_wrap_queue_);
124+
QUEUE_REMOVE(&handle_wrap_queue_);
125125
}
126126

127127

src/handle_wrap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef HANDLE_WRAP_H_
2323
#define HANDLE_WRAP_H_
2424

25-
#include "ngx-queue.h"
25+
#include "queue.h"
2626

2727
namespace node {
2828

@@ -70,7 +70,7 @@ class HandleWrap {
7070
private:
7171
friend v8::Handle<v8::Value> GetActiveHandles(const v8::Arguments&);
7272
static void OnClose(uv_handle_t* handle);
73-
ngx_queue_t handle_wrap_queue_;
73+
QUEUE handle_wrap_queue_;
7474
// Using double underscore due to handle_ member in tcp_wrap. Probably
7575
// tcp_wrap should rename it's member to 'handle'.
7676
uv_handle_t* handle__;

src/ngx-queue.h

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/node.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ extern char **environ;
9393

9494
namespace node {
9595

96-
ngx_queue_t handle_wrap_queue = { &handle_wrap_queue, &handle_wrap_queue };
97-
ngx_queue_t req_wrap_queue = { &req_wrap_queue, &req_wrap_queue };
96+
QUEUE handle_wrap_queue = { &handle_wrap_queue, &handle_wrap_queue };
97+
QUEUE req_wrap_queue = { &req_wrap_queue, &req_wrap_queue };
9898

9999
// declared in req_wrap.h
100100
Persistent<String> process_symbol;
@@ -1249,10 +1249,10 @@ static Handle<Value> GetActiveRequests(const Arguments& args) {
12491249
HandleScope scope(node_isolate);
12501250

12511251
Local<Array> ary = Array::New();
1252-
ngx_queue_t* q = NULL;
1252+
QUEUE* q = NULL;
12531253
int i = 0;
12541254

1255-
ngx_queue_foreach(q, &req_wrap_queue) {
1255+
QUEUE_FOREACH(q, &req_wrap_queue) {
12561256
ReqWrap<uv_req_t>* w = container_of(q, ReqWrap<uv_req_t>, req_wrap_queue_);
12571257
if (w->object_.IsEmpty()) continue;
12581258
ary->Set(i++, w->object_);
@@ -1268,12 +1268,12 @@ Handle<Value> GetActiveHandles(const Arguments& args) {
12681268
HandleScope scope(node_isolate);
12691269

12701270
Local<Array> ary = Array::New();
1271-
ngx_queue_t* q = NULL;
1271+
QUEUE* q = NULL;
12721272
int i = 0;
12731273

12741274
Local<String> owner_sym = String::New("owner");
12751275

1276-
ngx_queue_foreach(q, &handle_wrap_queue) {
1276+
QUEUE_FOREACH(q, &handle_wrap_queue) {
12771277
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
12781278
if (w->object_.IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
12791279
Local<Value> obj = w->object_->Get(owner_sym);

src/queue.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
2+
*
3+
* Permission to use, copy, modify, and/or distribute this software for any
4+
* purpose with or without fee is hereby granted, provided that the above
5+
* copyright notice and this permission notice appear in all copies.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
*/
15+
16+
#ifndef QUEUE_H_
17+
#define QUEUE_H_
18+
19+
typedef void *QUEUE[2];
20+
21+
/* Private macros. */
22+
#define QUEUE_NEXT(q) ((*(q))[0])
23+
#define QUEUE_PREV(q) ((*(q))[1])
24+
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT((QUEUE *) QUEUE_PREV(q)))
25+
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV((QUEUE *) QUEUE_NEXT(q)))
26+
27+
/* Public macros. */
28+
#define QUEUE_DATA(ptr, type, field) \
29+
((type *) ((char *) (ptr) - ((long) &((type *) 0)->field)))
30+
31+
#define QUEUE_FOREACH(q, h) \
32+
for ((q) = (QUEUE *) (*(h))[0]; (q) != (h); (q) = (QUEUE *) (*(q))[0])
33+
34+
#define QUEUE_EMPTY(q) \
35+
(QUEUE_NEXT(q) == (q))
36+
37+
#define QUEUE_HEAD(q) \
38+
(QUEUE_NEXT(q))
39+
40+
#define QUEUE_INIT(q) \
41+
do { \
42+
QUEUE_NEXT(q) = (q); \
43+
QUEUE_PREV(q) = (q); \
44+
} \
45+
while (0)
46+
47+
#define QUEUE_ADD(h, n) \
48+
do { \
49+
QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \
50+
QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \
51+
QUEUE_PREV(h) = QUEUE_PREV(n); \
52+
QUEUE_PREV_NEXT(h) = (h); \
53+
} \
54+
while (0)
55+
56+
#define QUEUE_SPLIT(h, q, n) \
57+
do { \
58+
QUEUE_PREV(n) = QUEUE_PREV(h); \
59+
QUEUE_PREV_NEXT(n) = (n); \
60+
QUEUE_NEXT(n) = (q); \
61+
QUEUE_PREV(h) = QUEUE_PREV(q); \
62+
QUEUE_PREV_NEXT(h) = (h); \
63+
QUEUE_PREV(q) = (n); \
64+
} \
65+
while (0)
66+
67+
#define QUEUE_INSERT_HEAD(h, q) \
68+
do { \
69+
QUEUE_NEXT(q) = QUEUE_NEXT(h); \
70+
QUEUE_PREV(q) = (h); \
71+
QUEUE_NEXT_PREV(q) = (q); \
72+
QUEUE_NEXT(h) = (q); \
73+
} \
74+
while (0)
75+
76+
#define QUEUE_INSERT_TAIL(h, q) \
77+
do { \
78+
QUEUE_NEXT(q) = (h); \
79+
QUEUE_PREV(q) = QUEUE_PREV(h); \
80+
QUEUE_PREV_NEXT(q) = (q); \
81+
QUEUE_PREV(h) = (q); \
82+
} \
83+
while (0)
84+
85+
#define QUEUE_REMOVE(q) \
86+
do { \
87+
QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \
88+
QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \
89+
} \
90+
while (0)
91+
92+
#endif /* QUEUE_H_ */

src/req_wrap.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
#ifndef REQ_WRAP_H_
2323
#define REQ_WRAP_H_
2424

25-
#include "ngx-queue.h"
25+
#include "queue.h"
2626
#include "node_internals.h"
2727

2828
namespace node {
2929

3030
// defined in node.cc
3131
extern v8::Persistent<v8::String> process_symbol;
3232
extern v8::Persistent<v8::String> domain_symbol;
33-
extern ngx_queue_t req_wrap_queue;
33+
extern QUEUE req_wrap_queue;
3434

3535
template <typename T>
3636
class ReqWrap {
@@ -51,12 +51,12 @@ class ReqWrap {
5151
}
5252
}
5353

54-
ngx_queue_insert_tail(&req_wrap_queue, &req_wrap_queue_);
54+
QUEUE_INSERT_TAIL(&req_wrap_queue, &req_wrap_queue_);
5555
}
5656

5757

5858
~ReqWrap() {
59-
ngx_queue_remove(&req_wrap_queue_);
59+
QUEUE_REMOVE(&req_wrap_queue_);
6060
// Assert that someone has called Dispatched()
6161
assert(req_.data == this);
6262
assert(!object_.IsEmpty());
@@ -70,7 +70,7 @@ class ReqWrap {
7070
}
7171

7272
v8::Persistent<v8::Object> object_;
73-
ngx_queue_t req_wrap_queue_;
73+
QUEUE req_wrap_queue_;
7474
void* data_;
7575
T req_; // *must* be last, GetActiveRequests() in node.cc depends on it
7676
};

0 commit comments

Comments
 (0)