static void setup_frame(int sig, struct target_sigaction *ka,

                        target_sigset_t *set, CPUPPCState *env)

{

    struct target_sigframe *frame;

    struct target_sigcontext *sc;

    target_ulong frame_addr, newsp;

    int err = 0;

    int signal;



    frame_addr = get_sigframe(ka, env, sizeof(*frame));

    if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))

        goto sigsegv;

    sc = &frame->sctx;



    signal = current_exec_domain_sig(sig);



    __put_user(ka->_sa_handler, &sc->handler);

    __put_user(set->sig[0], &sc->oldmask);

#if defined(TARGET_PPC64)

    __put_user(set->sig[0] >> 32, &sc->_unused[3]);

#else

    __put_user(set->sig[1], &sc->_unused[3]);

#endif

    __put_user(h2g(&frame->mctx), &sc->regs);

    __put_user(sig, &sc->signal);



    /* Save user regs.  */

    err |= save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn);



    /* The kernel checks for the presence of a VDSO here.  We don't

       emulate a vdso, so use a sigreturn system call.  */

    env->lr = (target_ulong) h2g(frame->mctx.tramp);



    /* Turn off all fp exceptions.  */

    env->fpscr = 0;



    /* Create a stack frame for the caller of the handler.  */

    newsp = frame_addr - SIGNAL_FRAMESIZE;

    err |= put_user(env->gpr[1], newsp, target_ulong);



    if (err)

        goto sigsegv;



    /* Set up registers for signal handler.  */

    env->gpr[1] = newsp;

    env->gpr[3] = signal;

    env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx);

    env->nip = (target_ulong) ka->_sa_handler;

    /* Signal handlers are entered in big-endian mode.  */

    env->msr &= ~MSR_LE;



    unlock_user_struct(frame, frame_addr, 1);

    return;



sigsegv:

    unlock_user_struct(frame, frame_addr, 1);

    qemu_log("segfaulting from setup_frame\n");

    force_sig(TARGET_SIGSEGV);

}

static void setup_frame(int sig, struct target_sigaction *ka,

                        target_sigset_t *set, CPUPPCState *env)

{

    struct target_sigframe *frame;

    struct target_sigcontext *sc;

    target_ulong frame_addr, newsp;

    int err = 0;

    int signal;



    frame_addr = get_sigframe(ka, env, sizeof(*frame));

    if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))

        goto sigsegv;

    sc = &frame->sctx;



    signal = current_exec_domain_sig(sig);



    __put_user(ka->_sa_handler, &sc->handler);

    __put_user(set->sig[0], &sc->oldmask);

#if defined(TARGET_PPC64)

    __put_user(set->sig[0] >> 32, &sc->_unused[3]);

#else

    __put_user(set->sig[1], &sc->_unused[3]);

#endif

    __put_user(h2g(&frame->mctx), &sc->regs);

    __put_user(sig, &sc->signal);



    

    err |= save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn);



    



    env->lr = (target_ulong) h2g(frame->mctx.tramp);



    

    env->fpscr = 0;



    

    newsp = frame_addr - SIGNAL_FRAMESIZE;

    err |= put_user(env->gpr[1], newsp, target_ulong);



    if (err)

        goto sigsegv;



    

    env->gpr[1] = newsp;

    env->gpr[3] = signal;

    env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx);

    env->nip = (target_ulong) ka->_sa_handler;

    

    env->msr &= ~MSR_LE;



    unlock_user_struct(frame, frame_addr, 1);

    return;



sigsegv:

    unlock_user_struct(frame, frame_addr, 1);

    qemu_log("segfaulting from setup_frame\n");

    force_sig(TARGET_SIGSEGV);

}

static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,

                        target_sigset_t *VAR_2, CPUPPCState *VAR_3)

{

    struct target_sigframe *VAR_4;

    struct target_sigcontext *VAR_5;

    target_ulong frame_addr, newsp;

    int VAR_6 = 0;

    int VAR_7;



    frame_addr = get_sigframe(VAR_1, VAR_3, sizeof(*VAR_4));

    if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 1))

        goto sigsegv;

    VAR_5 = &VAR_4->sctx;



    VAR_7 = current_exec_domain_sig(VAR_0);



    __put_user(VAR_1->_sa_handler, &VAR_5->handler);

    __put_user(VAR_2->VAR_0[0], &VAR_5->oldmask);

#if defined(TARGET_PPC64)

    __put_user(VAR_2->VAR_0[0] >> 32, &VAR_5->_unused[3]);

#else

    __put_user(VAR_2->VAR_0[1], &VAR_5->_unused[3]);

#endif

    __put_user(h2g(&VAR_4->mctx), &VAR_5->regs);

    __put_user(VAR_0, &VAR_5->VAR_7);



    

    VAR_6 |= save_user_regs(VAR_3, &VAR_4->mctx, TARGET_NR_sigreturn);



    



    VAR_3->lr = (target_ulong) h2g(VAR_4->mctx.tramp);



    

    VAR_3->fpscr = 0;



    

    newsp = frame_addr - SIGNAL_FRAMESIZE;

    VAR_6 |= put_user(VAR_3->gpr[1], newsp, target_ulong);



    if (VAR_6)

        goto sigsegv;



    

    VAR_3->gpr[1] = newsp;

    VAR_3->gpr[3] = VAR_7;

    VAR_3->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx);

    VAR_3->nip = (target_ulong) VAR_1->_sa_handler;

    

    VAR_3->msr &= ~MSR_LE;



    unlock_user_struct(VAR_4, frame_addr, 1);

    return;



sigsegv:

    unlock_user_struct(VAR_4, frame_addr, 1);

    qemu_log("segfaulting from FUNC_0\n");

    force_sig(TARGET_SIGSEGV);

}

static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_sigset_t *VAR_2, CPUPPCState *VAR_3)
{ struct target_sigframe *VAR_4; struct target_sigcontext *VAR_5; target_ulong frame_addr, newsp; int VAR_6 = 0; int VAR_7; frame_addr = get_sigframe(VAR_1, VAR_3, sizeof(*VAR_4)); if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 1))
goto sigsegv; VAR_5 = &VAR_4->sctx; VAR_7 = current_exec_domain_sig(VAR_0); __put_user(VAR_1->_sa_handler, &VAR_5->handler); __put_user(VAR_2->VAR_0[0], &VAR_5->oldmask); #if defined(TARGET_PPC64)
__put_user(VAR_2->VAR_0[0] >> 32, &VAR_5->_unused[3]); #else
__put_user(VAR_2->VAR_0[1], &VAR_5->_unused[3]); #endif
__put_user(h2g(&VAR_4->mctx), &VAR_5->regs); __put_user(VAR_0, &VAR_5->VAR_7); VAR_6 |= save_user_regs(VAR_3, &VAR_4->mctx, TARGET_NR_sigreturn); VAR_3->lr = (target_ulong) h2g(VAR_4->mctx.tramp); VAR_3->fpscr = 0; newsp = frame_addr - SIGNAL_FRAMESIZE; VAR_6 |= put_user(VAR_3->gpr[1], newsp, target_ulong); if (VAR_6)
goto sigsegv; VAR_3->gpr[1] = newsp; VAR_3->gpr[3] = VAR_7; VAR_3->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx); VAR_3->nip = (target_ulong) VAR_1->_sa_handler; VAR_3->msr &= ~MSR_LE; unlock_user_struct(VAR_4, frame_addr, 1); return; sigsegv:
unlock_user_struct(VAR_4, frame_addr, 1); qemu_log("segfaulting from FUNC_0\n"); force_sig(TARGET_SIGSEGV); }