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

                        target_sigset_t *set, CPUSH4State *regs)

{

    struct target_sigframe *frame;

    abi_ulong frame_addr;

    int i;

    int err = 0;

    int signal;



    frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));

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

	goto give_sigsegv;



    signal = current_exec_domain_sig(sig);



    err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);



    for (i = 0; i < TARGET_NSIG_WORDS - 1; i++) {

        __put_user(set->sig[i + 1], &frame->extramask[i]);

    }



    /* Set up to return from userspace.  If provided, use a stub

       already in userspace.  */

    if (ka->sa_flags & TARGET_SA_RESTORER) {

        regs->pr = (unsigned long) ka->sa_restorer;

    } else {

        /* Generate return code (system call to sigreturn) */

        __put_user(MOVW(2), &frame->retcode[0]);

        __put_user(TRAP_NOARG, &frame->retcode[1]);

        __put_user((TARGET_NR_sigreturn), &frame->retcode[2]);

        regs->pr = (unsigned long) frame->retcode;

    }



    if (err)

        goto give_sigsegv;



    /* Set up registers for signal handler */

    regs->gregs[15] = frame_addr;

    regs->gregs[4] = signal; /* Arg for signal handler */

    regs->gregs[5] = 0;

    regs->gregs[6] = frame_addr += offsetof(typeof(*frame), sc);

    regs->pc = (unsigned long) ka->_sa_handler;



    unlock_user_struct(frame, frame_addr, 1);

    return;



give_sigsegv:

    unlock_user_struct(frame, frame_addr, 1);

    force_sig(TARGET_SIGSEGV);

}

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

                        target_sigset_t *set, CPUSH4State *regs)

{

    struct target_sigframe *frame;

    abi_ulong frame_addr;

    int i;

    int err = 0;

    int signal;



    frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));

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

	goto give_sigsegv;



    signal = current_exec_domain_sig(sig);



    err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);



    for (i = 0; i < TARGET_NSIG_WORDS - 1; i++) {

        __put_user(set->sig[i + 1], &frame->extramask[i]);

    }



    



    if (ka->sa_flags & TARGET_SA_RESTORER) {

        regs->pr = (unsigned long) ka->sa_restorer;

    } else {

        

        __put_user(MOVW(2), &frame->retcode[0]);

        __put_user(TRAP_NOARG, &frame->retcode[1]);

        __put_user((TARGET_NR_sigreturn), &frame->retcode[2]);

        regs->pr = (unsigned long) frame->retcode;

    }



    if (err)

        goto give_sigsegv;



    

    regs->gregs[15] = frame_addr;

    regs->gregs[4] = signal; 

    regs->gregs[5] = 0;

    regs->gregs[6] = frame_addr += offsetof(typeof(*frame), sc);

    regs->pc = (unsigned long) ka->_sa_handler;



    unlock_user_struct(frame, frame_addr, 1);

    return;



give_sigsegv:

    unlock_user_struct(frame, frame_addr, 1);

    force_sig(TARGET_SIGSEGV);

}

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

                        target_sigset_t *VAR_2, CPUSH4State *VAR_3)

{

    struct target_sigframe *VAR_4;

    abi_ulong frame_addr;

    int VAR_5;

    int VAR_6 = 0;

    int VAR_7;



    frame_addr = get_sigframe(VAR_1, VAR_3->gregs[15], sizeof(*VAR_4));

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

	goto give_sigsegv;



    VAR_7 = current_exec_domain_sig(VAR_0);



    VAR_6 |= setup_sigcontext(&VAR_4->sc, VAR_3, VAR_2->VAR_0[0]);



    for (VAR_5 = 0; VAR_5 < TARGET_NSIG_WORDS - 1; VAR_5++) {

        __put_user(VAR_2->VAR_0[VAR_5 + 1], &VAR_4->extramask[VAR_5]);

    }



    



    if (VAR_1->sa_flags & TARGET_SA_RESTORER) {

        VAR_3->pr = (unsigned long) VAR_1->sa_restorer;

    } else {

        

        __put_user(MOVW(2), &VAR_4->retcode[0]);

        __put_user(TRAP_NOARG, &VAR_4->retcode[1]);

        __put_user((TARGET_NR_sigreturn), &VAR_4->retcode[2]);

        VAR_3->pr = (unsigned long) VAR_4->retcode;

    }



    if (VAR_6)

        goto give_sigsegv;



    

    VAR_3->gregs[15] = frame_addr;

    VAR_3->gregs[4] = VAR_7; 

    VAR_3->gregs[5] = 0;

    VAR_3->gregs[6] = frame_addr += offsetof(typeof(*VAR_4), sc);

    VAR_3->pc = (unsigned long) VAR_1->_sa_handler;



    unlock_user_struct(VAR_4, frame_addr, 1);

    return;



give_sigsegv:

    unlock_user_struct(VAR_4, frame_addr, 1);

    force_sig(TARGET_SIGSEGV);

}

static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_sigset_t *VAR_2, CPUSH4State *VAR_3)
{ struct target_sigframe *VAR_4; abi_ulong frame_addr; int VAR_5; int VAR_6 = 0; int VAR_7; frame_addr = get_sigframe(VAR_1, VAR_3->gregs[15], sizeof(*VAR_4)); if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 0))
goto give_sigsegv; VAR_7 = current_exec_domain_sig(VAR_0); VAR_6 |= setup_sigcontext(&VAR_4->sc, VAR_3, VAR_2->VAR_0[0]); for (VAR_5 = 0; VAR_5 < TARGET_NSIG_WORDS - 1; VAR_5++) { __put_user(VAR_2->VAR_0[VAR_5 + 1], &VAR_4->extramask[VAR_5]); } if (VAR_1->sa_flags & TARGET_SA_RESTORER) { VAR_3->pr = (unsigned long) VAR_1->sa_restorer; } else { __put_user(MOVW(2), &VAR_4->retcode[0]); __put_user(TRAP_NOARG, &VAR_4->retcode[1]); __put_user((TARGET_NR_sigreturn), &VAR_4->retcode[2]); VAR_3->pr = (unsigned long) VAR_4->retcode; } if (VAR_6)
goto give_sigsegv; VAR_3->gregs[15] = frame_addr; VAR_3->gregs[4] = VAR_7; VAR_3->gregs[5] = 0; VAR_3->gregs[6] = frame_addr += offsetof(typeof(*VAR_4), sc); VAR_3->pc = (unsigned long) VAR_1->_sa_handler; unlock_user_struct(VAR_4, frame_addr, 1); return; give_sigsegv:
unlock_user_struct(VAR_4, frame_addr, 1); force_sig(TARGET_SIGSEGV); }