Fix compilation on OpenBSD and FreeBSD
authorBrian White <mscdex@mscdex.net>
Fri, 17 Dec 2010 03:57:41 +0000 (22:57 -0500)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 17 Dec 2010 17:06:31 +0000 (09:06 -0800)
While it compiles fine on FreeBSD, at least on amd64 node dies with:
"CALL_AND_RETRY_0 allocation failed - process out of memory"

deps/libeio/eio.h
deps/v8/src/platform-freebsd.cc
deps/v8/src/platform-openbsd.cc
src/node_stdio.cc
wscript

index 129cc4c..5e2bdfe 100644 (file)
@@ -47,6 +47,10 @@ extern "C" {
 #include <stddef.h>
 #include <sys/types.h>
 
+#ifdef __OpenBSD__
+# include <inttypes.h>
+#endif
+
 #ifdef _WIN32
 # define uid_t int
 # define gid_t int
index b58d066..3c454d4 100644 (file)
@@ -500,6 +500,16 @@ class FreeBSDMutex : public Mutex {
     return result;
   }
 
+  virtual bool TryLock() {
+    int result = pthread_mutex_trylock(&mutex_);
+    // Return false if the lock is busy and locking failed.
+    if (result == EBUSY) {
+      return false;
+    }
+    ASSERT(result == 0);  // Verify no other errors.
+    return true;
+  }
+
  private:
   pthread_mutex_t mutex_;   // Pthread mutex for POSIX platforms.
 };
@@ -577,14 +587,12 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
 
   TickSample sample;
 
-  // We always sample the VM state.
-  sample.state = VMState::current_state();
-
   // If profiling, we extract the current pc and sp.
   if (active_sampler_->IsProfiling()) {
     // Extracting the sample from the context is extremely machine dependent.
     ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
     mcontext_t& mcontext = ucontext->uc_mcontext;
+    sample.state = Top::current_vm_state();
 #if V8_HOST_ARCH_IA32
     sample.pc = reinterpret_cast<Address>(mcontext.mc_eip);
     sample.sp = reinterpret_cast<Address>(mcontext.mc_esp);
index b698d16..7658272 100644 (file)
@@ -476,6 +476,16 @@ class OpenBSDMutex : public Mutex {
     return result;
   }
 
+  virtual bool TryLock() {
+    int result = pthread_mutex_trylock(&mutex_);
+    // Return false if the lock is busy and locking failed.
+    if (result == EBUSY) {
+      return false;
+    }
+    ASSERT(result == 0);  // Verify no other errors.
+    return true;
+  }
+
  private:
   pthread_mutex_t mutex_;   // Pthread mutex for POSIX platforms.
 };
@@ -554,7 +564,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
   TickSample sample;
 
   // We always sample the VM state.
-  sample.state = VMState::current_state();
+  sample.state = Top::current_vm_state();
 
   active_sampler_->Tick(&sample);
 }
index 213bd33..ad09835 100644 (file)
@@ -5,8 +5,10 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__OpenBSD__)
 # include <util.h>
+#elif __FreeBSD__
+# include <libutil.h>
 #elif defined(__sun)
 # include <stropts.h> // for openpty ioctls
 #else
diff --git a/wscript b/wscript
index f9ce5e3..016b2b0 100644 (file)
--- a/wscript
+++ b/wscript
@@ -178,6 +178,7 @@ def configure(conf):
   o = Options.options
 
   conf.env["USE_DEBUG"] = o.debug
+  conf.env["SNAPSHOT_V8"] = not o.without_snapshot
   if sys.platform.startswith("sunos"):
     conf.env["SNAPSHOT_V8"] = False
   conf.env["USE_PROFILING"] = o.profile