From d9977e8f1ff6ac64bfc7e0c0907f27ec020eff80 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 15:54:17 +0000 Subject: [PATCH 1/8] deps: fix v8 build on FreeBSD clang++ on FreeBSD was blaming v8 for using invalid casts from nullptr: reinterpret_cast from 'nullptr_t' to '...' is not allowed Replace casts with NULL, or NULL with 0 where applicable. fix #324 --- deps/v8/src/base/platform/platform-freebsd.cc | 2 +- deps/v8/src/base/platform/platform-posix.cc | 2 +- deps/v8/src/debug.cc | 2 +- deps/v8/src/preparser.h | 2 +- deps/v8/src/unique.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deps/v8/src/base/platform/platform-freebsd.cc b/deps/v8/src/base/platform/platform-freebsd.cc index 507b946f69f57f..58316f8bc1a9ab 100644 --- a/deps/v8/src/base/platform/platform-freebsd.cc +++ b/deps/v8/src/base/platform/platform-freebsd.cc @@ -141,7 +141,7 @@ std::vector OS::GetSharedLibraryAddresses() { if (bytes_read < 8) break; unsigned end = StringToLong(addr_buffer); char buffer[MAP_LENGTH]; - int bytes_read = -1; + bytes_read = -1; do { bytes_read++; if (bytes_read >= MAP_LENGTH - 1) diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index c2fa26a9ea9364..64aed2b8d1f2d0 100644 --- a/deps/v8/src/base/platform/platform-posix.cc +++ b/deps/v8/src/base/platform/platform-posix.cc @@ -261,7 +261,7 @@ int OS::GetCurrentThreadId() { #elif V8_OS_ANDROID return static_cast(gettid()); #else - return static_cast(pthread_self()); + return static_cast(reinterpret_cast(pthread_self())); #endif } diff --git a/deps/v8/src/debug.cc b/deps/v8/src/debug.cc index 93ef1cfc097393..cdcb0a759f0e43 100644 --- a/deps/v8/src/debug.cc +++ b/deps/v8/src/debug.cc @@ -573,7 +573,7 @@ void Debug::ThreadInit() { thread_local_.step_out_fp_ = 0; // TODO(isolates): frames_are_dropped_? base::NoBarrier_Store(&thread_local_.current_debug_scope_, - static_cast(NULL)); + static_cast(0)); thread_local_.restarter_frame_function_pointer_ = NULL; } diff --git a/deps/v8/src/preparser.h b/deps/v8/src/preparser.h index 18004a5096d4c2..ad27744e9d5730 100644 --- a/deps/v8/src/preparser.h +++ b/deps/v8/src/preparser.h @@ -467,7 +467,7 @@ class ParserBase : public Traits { void ReportMessageAt(Scanner::Location location, const char* message, bool is_reference_error = false) { Traits::ReportMessageAt(location, message, - reinterpret_cast(NULL), + reinterpret_cast(0), is_reference_error); } diff --git a/deps/v8/src/unique.h b/deps/v8/src/unique.h index 9232f859708366..321eb3683dbeda 100644 --- a/deps/v8/src/unique.h +++ b/deps/v8/src/unique.h @@ -117,7 +117,7 @@ class Unique { // TODO(titzer): this is a hack to migrate to Unique incrementally. static Unique CreateUninitialized(Handle handle) { - return Unique(reinterpret_cast
(NULL), handle); + return Unique(NULL, handle); } static Unique CreateImmovable(Handle handle) { From 9645fc25ddb50a7e705603e95c1872af27c11821 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 16:16:15 +0300 Subject: [PATCH 2/8] cares: 0-ify AI_V4MAPPED on FreeBSD FreeBSD does not support V4MAPPED. --- src/cares_wrap.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index fe8e5031ee9737..c55b696737d687 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1266,8 +1266,14 @@ static void Initialize(Handle target, Integer::New(env->isolate(), AF_UNSPEC)); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_ADDRCONFIG"), Integer::New(env->isolate(), AI_ADDRCONFIG)); +#ifdef __FreeBSD__ + // FreeBSD's getaddrinfo does not support AI_V4MAPPED + target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), + Integer::New(env->isolate(), 0)); +#else target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), Integer::New(env->isolate(), AI_V4MAPPED)); +#endif // __FreeBSD__ Local aiw = FunctionTemplate::New(env->isolate(), NewGetAddrInfoReqWrap); From c731055d170a7525e511ba1ee67a14a03355f1f1 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 16:23:21 +0300 Subject: [PATCH 3/8] test: loosen timeout in spawnsync-test for FreeBSD --- test/parallel/test-child-process-spawnsync-timeout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-child-process-spawnsync-timeout.js b/test/parallel/test-child-process-spawnsync-timeout.js index 0e95eb3c4adec8..f5b5987e4d1eaf 100644 --- a/test/parallel/test-child-process-spawnsync-timeout.js +++ b/test/parallel/test-child-process-spawnsync-timeout.js @@ -4,7 +4,7 @@ var assert = require('assert'); var spawnSync = require('child_process').spawnSync; var TIMER = 200; -var SLEEP = 1000; +var SLEEP = 5000; switch (process.argv[2]) { case 'child': From 36c79c7b46a0a1fa782f613e196655ea0891a7de Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 16:28:56 +0300 Subject: [PATCH 4/8] test: fix setproctitle on FreeBSD --- test/sequential/test-setproctitle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-setproctitle.js b/test/sequential/test-setproctitle.js index 961b20f3470af2..b7e6dd8b552a5d 100644 --- a/test/sequential/test-setproctitle.js +++ b/test/sequential/test-setproctitle.js @@ -24,7 +24,7 @@ exec('ps -p ' + process.pid + ' -o args=', function(error, stdout, stderr) { assert.equal(stderr, ''); // freebsd always add ' (procname)' to the process title - if (process.platform === 'freebsd') title += ' (node)'; + if (process.platform === 'freebsd') title += ' (iojs)'; // omitting trailing whitespace and \n assert.equal(stdout.replace(/\s+$/, ''), title); From 4e458d7eb55912f61873849fbaecb77eec78ca01 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 16:35:08 +0300 Subject: [PATCH 5/8] test: disable fs-readfile-error on FreeBSD FreeBSD does not return EISDIR when reading "/". --- test/parallel/test-fs-readfile-error.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/parallel/test-fs-readfile-error.js b/test/parallel/test-fs-readfile-error.js index 8f298eafd9ca19..732409bc91b34a 100644 --- a/test/parallel/test-fs-readfile-error.js +++ b/test/parallel/test-fs-readfile-error.js @@ -3,6 +3,12 @@ var assert = require('assert'); var exec = require('child_process').exec; var path = require('path'); +// `fs.readFile('/')` does not fail on FreeBSD +if (process.platform === 'freebsd') { + console.error('Skipping test, platform not supported.'); + process.exit(); +} + var callbacks = 0; function test(env, cb) { From 60a62a8382692f0eb5fd625b8c82e74188199554 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 20:13:00 +0300 Subject: [PATCH 6/8] v4mapped --- lib/dns.js | 3 +++ src/cares_wrap.cc | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/dns.js b/lib/dns.js index 0a6e84a435da02..cf6e5841a18083 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -106,6 +106,9 @@ exports.lookup = function lookup(hostname, options, callback) { hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) { throw new TypeError('invalid argument: hints must use valid flags'); } + + if (process.platform === 'freebsd' || family !== 6) + hints &= ~exports.V4MAPPED; } else { family = options >>> 0; } diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index c55b696737d687..fe8e5031ee9737 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1266,14 +1266,8 @@ static void Initialize(Handle target, Integer::New(env->isolate(), AF_UNSPEC)); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_ADDRCONFIG"), Integer::New(env->isolate(), AI_ADDRCONFIG)); -#ifdef __FreeBSD__ - // FreeBSD's getaddrinfo does not support AI_V4MAPPED - target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), - Integer::New(env->isolate(), 0)); -#else target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"), Integer::New(env->isolate(), AI_V4MAPPED)); -#endif // __FreeBSD__ Local aiw = FunctionTemplate::New(env->isolate(), NewGetAddrInfoReqWrap); From 22dd5a96d81444744122c4c3186fb553c74ac109 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 20:23:57 +0300 Subject: [PATCH 7/8] test-readfile --- test/parallel/test-fs-readfile-error.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-fs-readfile-error.js b/test/parallel/test-fs-readfile-error.js index 732409bc91b34a..b8cf3e01757092 100644 --- a/test/parallel/test-fs-readfile-error.js +++ b/test/parallel/test-fs-readfile-error.js @@ -3,7 +3,8 @@ var assert = require('assert'); var exec = require('child_process').exec; var path = require('path'); -// `fs.readFile('/')` does not fail on FreeBSD +// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read +// the directory there. if (process.platform === 'freebsd') { console.error('Skipping test, platform not supported.'); process.exit(); From 0ac4ee31c8ac26304c7416edbcf9d2ac2db4860c Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 13 Jan 2015 20:23:59 +0300 Subject: [PATCH 8/8] dns: proper comment --- lib/dns.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dns.js b/lib/dns.js index cf6e5841a18083..09aea0028f97c9 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -107,7 +107,9 @@ exports.lookup = function lookup(hostname, options, callback) { throw new TypeError('invalid argument: hints must use valid flags'); } - if (process.platform === 'freebsd' || family !== 6) + // FIXME(indutny): V4MAPPED on FreeBSD results in EAI_BADFLAGS, because + // the kernel does not support it + if (process.platform === 'freebsd' && family !== 6) hints &= ~exports.V4MAPPED; } else { family = options >>> 0;