Skip to content

Commit

Permalink
v8: fix compilation on PPC64 when libc musl is used instead of glibc
Browse files Browse the repository at this point in the history
Musl on Power does not define regs member as a pt_regs pointer
type, hence it's necessary to use member gp_regs instead.
  • Loading branch information
Gustavo Romero committed Mar 27, 2017
1 parent 66e7dc5 commit 975a7a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions deps/v8/src/libsampler/sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,17 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
state->sp = reinterpret_cast<void*>(mcontext.gregs[29]);
state->fp = reinterpret_cast<void*>(mcontext.gregs[30]);
#elif V8_HOST_ARCH_PPC
#if V8_LIBC_GLIBC
state->pc = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->nip);
state->sp =
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R1]);
state->fp =
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R31]);
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R1]);
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R31]);
#else
// Some C libraries, notably Musl, define regs member as a void pointer,
// so gp_regs is used instead.
state->pc = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[32]);
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[1]);
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[31]);
#endif
#elif V8_HOST_ARCH_S390
#if V8_TARGET_ARCH_32_BIT
// 31-bit target will have bit 0 (MSB) of the PSW set to denote addressing
Expand Down

0 comments on commit 975a7a2

Please sign in to comment.