Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src: replace ngx-queue.h with queue.h
Browse files Browse the repository at this point in the history
No functional changes, just one less entry in the LICENSE file.
  • Loading branch information
bnoordhuis committed Jun 4, 2013
1 parent 72b92e9 commit a7820a1
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 152 deletions.
28 changes: 0 additions & 28 deletions LICENSE
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -431,34 +431,6 @@ maintained libraries. The externally maintained libraries used by Node are:
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
""" """


- src/ngx-queue.h. ngx-queue.h is taken from the nginx source tree. nginx's
license follows:
"""
Copyright (C) 2002-2012 Igor Sysoev
Copyright (C) 2011,2012 Nginx, Inc.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
"""

- wrk is located at tools/wrk. wrk's license follows: - wrk is located at tools/wrk. wrk's license follows:
""" """


Expand Down
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
'src/node_string.h', 'src/node_string.h',
'src/node_version.h', 'src/node_version.h',
'src/node_watchdog.h', 'src/node_watchdog.h',
'src/ngx-queue.h',
'src/pipe_wrap.h', 'src/pipe_wrap.h',
'src/queue.h',
'src/tty_wrap.h', 'src/tty_wrap.h',
'src/tcp_wrap.h', 'src/tcp_wrap.h',
'src/udp_wrap.h', 'src/udp_wrap.h',
Expand Down
8 changes: 4 additions & 4 deletions src/handle_wrap.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE. // USE OR OTHER DEALINGS IN THE SOFTWARE.


#include "node.h" #include "node.h"
#include "ngx-queue.h" #include "queue.h"
#include "handle_wrap.h" #include "handle_wrap.h"


namespace node { namespace node {
Expand All @@ -43,7 +43,7 @@ using v8::Value;




// defined in node.cc // defined in node.cc
extern ngx_queue_t handle_wrap_queue; extern QUEUE handle_wrap_queue;
static Persistent<String> close_sym; static Persistent<String> close_sym;




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




HandleWrap::~HandleWrap() { HandleWrap::~HandleWrap() {
assert(object_.IsEmpty()); assert(object_.IsEmpty());
ngx_queue_remove(&handle_wrap_queue_); QUEUE_REMOVE(&handle_wrap_queue_);
} }




Expand Down
4 changes: 2 additions & 2 deletions src/handle_wrap.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef HANDLE_WRAP_H_ #ifndef HANDLE_WRAP_H_
#define HANDLE_WRAP_H_ #define HANDLE_WRAP_H_


#include "ngx-queue.h" #include "queue.h"


namespace node { namespace node {


Expand Down Expand Up @@ -70,7 +70,7 @@ class HandleWrap {
private: private:
friend v8::Handle<v8::Value> GetActiveHandles(const v8::Arguments&); friend v8::Handle<v8::Value> GetActiveHandles(const v8::Arguments&);
static void OnClose(uv_handle_t* handle); static void OnClose(uv_handle_t* handle);
ngx_queue_t handle_wrap_queue_; QUEUE handle_wrap_queue_;
// Using double underscore due to handle_ member in tcp_wrap. Probably // Using double underscore due to handle_ member in tcp_wrap. Probably
// tcp_wrap should rename it's member to 'handle'. // tcp_wrap should rename it's member to 'handle'.
uv_handle_t* handle__; uv_handle_t* handle__;
Expand Down
106 changes: 0 additions & 106 deletions src/ngx-queue.h

This file was deleted.

12 changes: 6 additions & 6 deletions src/node.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ extern char **environ;


namespace node { namespace node {


ngx_queue_t handle_wrap_queue = { &handle_wrap_queue, &handle_wrap_queue }; QUEUE handle_wrap_queue = { &handle_wrap_queue, &handle_wrap_queue };
ngx_queue_t req_wrap_queue = { &req_wrap_queue, &req_wrap_queue }; QUEUE req_wrap_queue = { &req_wrap_queue, &req_wrap_queue };


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


Local<Array> ary = Array::New(); Local<Array> ary = Array::New();
ngx_queue_t* q = NULL; QUEUE* q = NULL;
int i = 0; int i = 0;


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


Local<Array> ary = Array::New(); Local<Array> ary = Array::New();
ngx_queue_t* q = NULL; QUEUE* q = NULL;
int i = 0; int i = 0;


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


ngx_queue_foreach(q, &handle_wrap_queue) { QUEUE_FOREACH(q, &handle_wrap_queue) {
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_); HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
if (w->object_.IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue; if (w->object_.IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
Local<Value> obj = w->object_->Get(owner_sym); Local<Value> obj = w->object_->Get(owner_sym);
Expand Down
92 changes: 92 additions & 0 deletions src/queue.h
Original file line number Original file line Diff line number Diff line change
@@ -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) = (QUEUE *) (*(h))[0]; (q) != (h); (q) = (QUEUE *) (*(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_ */
10 changes: 5 additions & 5 deletions src/req_wrap.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
#ifndef REQ_WRAP_H_ #ifndef REQ_WRAP_H_
#define REQ_WRAP_H_ #define REQ_WRAP_H_


#include "ngx-queue.h" #include "queue.h"
#include "node_internals.h" #include "node_internals.h"


namespace node { namespace node {


// defined in node.cc // defined in node.cc
extern v8::Persistent<v8::String> process_symbol; extern v8::Persistent<v8::String> process_symbol;
extern v8::Persistent<v8::String> domain_symbol; extern v8::Persistent<v8::String> domain_symbol;
extern ngx_queue_t req_wrap_queue; extern QUEUE req_wrap_queue;


template <typename T> template <typename T>
class ReqWrap { class ReqWrap {
Expand All @@ -51,12 +51,12 @@ class ReqWrap {
} }
} }


ngx_queue_insert_tail(&req_wrap_queue, &req_wrap_queue_); QUEUE_INSERT_TAIL(&req_wrap_queue, &req_wrap_queue_);
} }




~ReqWrap() { ~ReqWrap() {
ngx_queue_remove(&req_wrap_queue_); QUEUE_REMOVE(&req_wrap_queue_);
// Assert that someone has called Dispatched() // Assert that someone has called Dispatched()
assert(req_.data == this); assert(req_.data == this);
assert(!object_.IsEmpty()); assert(!object_.IsEmpty());
Expand All @@ -70,7 +70,7 @@ class ReqWrap {
} }


v8::Persistent<v8::Object> object_; v8::Persistent<v8::Object> object_;
ngx_queue_t req_wrap_queue_; QUEUE req_wrap_queue_;
void* data_; void* data_;
T req_; // *must* be last, GetActiveRequests() in node.cc depends on it T req_; // *must* be last, GetActiveRequests() in node.cc depends on it
}; };
Expand Down

0 comments on commit a7820a1

Please sign in to comment.