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

Commit

Permalink
Fix compilation on OpenBSD and FreeBSD
Browse files Browse the repository at this point in the history
While it compiles fine on FreeBSD, at least on amd64 node dies with:
"CALL_AND_RETRY_0 allocation failed - process out of memory"
  • Loading branch information
mscdex authored and ry committed Dec 17, 2010
1 parent d0beac7 commit 9eaf232
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions deps/libeio/eio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions deps/v8/src/platform-freebsd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion deps/v8/src/platform-openbsd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/node_stdio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9eaf232

Please sign in to comment.