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

Commit

Permalink
v8: fix openbsd build
Browse files Browse the repository at this point in the history
This is [1] applied ahead of time. Summary:

    OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
    and is a typedef for struct sigcontext. There is no uc_mcontext.

[1] https://codereview.chromium.org/21705003/
  • Loading branch information
bnoordhuis committed Aug 5, 2013
1 parent ea7b817 commit 222e523
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deps/v8/src/sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
#include <signal.h>
#include <sys/time.h>
#include <sys/syscall.h>
#if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T)
// OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
// and is a typedef for struct sigcontext. There is no uc_mcontext.
#if (!defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T)) \
&& !defined(__OpenBSD__)
#include <ucontext.h>
#endif
#include <unistd.h>
Expand Down Expand Up @@ -330,7 +333,9 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
#else
// Extracting the sample from the context is extremely machine dependent.
ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
#if !defined(__OpenBSD__)
mcontext_t& mcontext = ucontext->uc_mcontext;
#endif
#if defined(__linux__) || defined(__ANDROID__)
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
Expand Down Expand Up @@ -384,7 +389,6 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
#endif // V8_HOST_ARCH_*
#elif defined(__OpenBSD__)
USE(mcontext);
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(ucontext->sc_eip);
state.sp = reinterpret_cast<Address>(ucontext->sc_esp);
Expand Down

0 comments on commit 222e523

Please sign in to comment.