Skip to content

Commit

Permalink
src: make build pass with GCC < 4.5
Browse files Browse the repository at this point in the history
Building node with GCC > 4.4 on CentOS makes the node binary depend on a
more recent version of the C/C++ runtime that is not installed by
default on these older CentOS platforms, and probably on other platforms
as well.

Building node with the default gcc and g++ compilers that come with
these older versions of CentOS allows to ship a node binary that runs
out of the box on these setups with older C/C++ runtimes.

This change works around a bug that was fixed in GCC 4.5. Versions of
GCC < 4.5 would not support using the injected-class-name of a
template base class as a type name.

This change also fixes a lot of strict-aliasing warnings due to type
casts in the src/queue.h headers.

Fixes nodejs#9079.
  • Loading branch information
Julien Gilli committed Jan 26, 2015
1 parent de5f24a commit ae15b94
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class GetAddrInfoReqWrap : public ReqWrap<uv_getaddrinfo_t> {

GetAddrInfoReqWrap::GetAddrInfoReqWrap(Environment* env,
Local<Object> req_wrap_obj)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_GETADDRINFOREQWRAP) {
: ReqWrap<uv_getaddrinfo_t>(env,
req_wrap_obj,
AsyncWrap::PROVIDER_GETADDRINFOREQWRAP) {
Wrap(req_wrap_obj, this);
}

Expand All @@ -90,7 +92,9 @@ class GetNameInfoReqWrap : public ReqWrap<uv_getnameinfo_t> {

GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env,
Local<Object> req_wrap_obj)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_GETNAMEINFOREQWRAP) {
: ReqWrap<uv_getnameinfo_t>(env,
req_wrap_obj,
AsyncWrap::PROVIDER_GETNAMEINFOREQWRAP) {
Wrap(req_wrap_obj, this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FSReqWrap: public ReqWrap<uv_fs_t> {
Local<Object> req,
const char* syscall,
char* data = NULL)
: ReqWrap(env, req, AsyncWrap::PROVIDER_FSREQWRAP),
: ReqWrap<uv_fs_t>(env, req, AsyncWrap::PROVIDER_FSREQWRAP),
syscall_(syscall),
data_(data),
dest_len_(0) {
Expand Down
2 changes: 1 addition & 1 deletion src/pipe_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PipeConnectWrap : public ReqWrap<uv_connect_t> {


PipeConnectWrap::PipeConnectWrap(Environment* env, Local<Object> req_wrap_obj)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPEWRAP) {
: ReqWrap<uv_connect_t>(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPEWRAP) {
Wrap(req_wrap_obj, this);
}

Expand Down
14 changes: 7 additions & 7 deletions src/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
typedef void *QUEUE[2];

/* Private macros. */
#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0]))
#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1]))
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q)))
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q)))
#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) - ((char *) &((type *) 0)->field)))

#define QUEUE_FOREACH(q, h) \
for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q))
for ((q) = (QUEUE *) QUEUE_NEXT(h); (q) != (h); (q) = (QUEUE *) QUEUE_NEXT(q))

#define QUEUE_EMPTY(q) \
((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q))
((q) == QUEUE_NEXT(q))

#define QUEUE_HEAD(q) \
(QUEUE_NEXT(q))
((QUEUE*)QUEUE_NEXT(q))

#define QUEUE_INIT(q) \
do { \
Expand Down
6 changes: 4 additions & 2 deletions src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class StreamWrap;
class ShutdownWrap : public ReqWrap<uv_shutdown_t> {
public:
ShutdownWrap(Environment* env, v8::Local<v8::Object> req_wrap_obj)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_SHUTDOWNWRAP) {
: ReqWrap<uv_shutdown_t>(env,
req_wrap_obj,
AsyncWrap::PROVIDER_SHUTDOWNWRAP) {
Wrap(req_wrap_obj, this);
}

Expand All @@ -50,7 +52,7 @@ class WriteWrap: public ReqWrap<uv_write_t> {
// TODO(trevnorris): WrapWrap inherits from ReqWrap, which I've globbed
// into the same provider. How should these be broken apart?
WriteWrap(Environment* env, v8::Local<v8::Object> obj, StreamWrap* wrap)
: ReqWrap(env, obj, AsyncWrap::PROVIDER_WRITEWRAP),
: ReqWrap<uv_write_t>(env, obj, AsyncWrap::PROVIDER_WRITEWRAP),
wrap_(wrap) {
Wrap(obj, this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TCPConnectWrap : public ReqWrap<uv_connect_t> {


TCPConnectWrap::TCPConnectWrap(Environment* env, Local<Object> req_wrap_obj)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPWRAP) {
: ReqWrap<uv_connect_t>(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPWRAP) {
Wrap(req_wrap_obj, this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SendWrap : public ReqWrap<uv_udp_send_t> {
SendWrap::SendWrap(Environment* env,
Local<Object> req_wrap_obj,
bool have_callback)
: ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_UDPWRAP),
: ReqWrap<uv_udp_send_t>(env, req_wrap_obj, AsyncWrap::PROVIDER_UDPWRAP),
have_callback_(have_callback) {
Wrap(req_wrap_obj, this);
}
Expand Down

0 comments on commit ae15b94

Please sign in to comment.