long do_sigreturn(CPUSPARCState *env)

{

    abi_ulong sf_addr;

    struct target_signal_frame *sf;

    uint32_t up_psr, pc, npc;

    target_sigset_t set;

    sigset_t host_set;

    int err=0, i;



    sf_addr = env->regwptr[UREG_FP];

    trace_user_do_sigreturn(env, sf_addr);

    if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {

        goto segv_and_exit;

    }



    /* 1. Make sure we are not getting garbage from the user */



    if (sf_addr & 3)

        goto segv_and_exit;



    __get_user(pc,  &sf->info.si_regs.pc);

    __get_user(npc, &sf->info.si_regs.npc);



    if ((pc | npc) & 3) {

        goto segv_and_exit;

    }



    /* 2. Restore the state */

    __get_user(up_psr, &sf->info.si_regs.psr);



    /* User can only change condition codes and FPU enabling in %psr. */

    env->psr = (up_psr & (PSR_ICC /* | PSR_EF */))

            | (env->psr & ~(PSR_ICC /* | PSR_EF */));



    env->pc = pc;

    env->npc = npc;

    __get_user(env->y, &sf->info.si_regs.y);

    for (i=0; i < 8; i++) {

        __get_user(env->gregs[i], &sf->info.si_regs.u_regs[i]);

    }

    for (i=0; i < 8; i++) {

        __get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8]);

    }



    /* FIXME: implement FPU save/restore:

         * __get_user(fpu_save, &sf->fpu_save);

         * if (fpu_save)

         *        err |= restore_fpu_state(env, fpu_save);

         */



    /* This is pretty much atomic, no amount locking would prevent

         * the races which exist anyways.

         */

    __get_user(set.sig[0], &sf->info.si_mask);

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

        __get_user(set.sig[i], &sf->extramask[i - 1]);

    }



    target_to_host_sigset_internal(&host_set, &set);

    do_sigprocmask(SIG_SETMASK, &host_set, NULL);



    if (err) {

        goto segv_and_exit;

    }

    unlock_user_struct(sf, sf_addr, 0);

    return env->regwptr[0];



segv_and_exit:

    unlock_user_struct(sf, sf_addr, 0);

    force_sig(TARGET_SIGSEGV);

}

long do_sigreturn(CPUSPARCState *env)

{

    abi_ulong sf_addr;

    struct target_signal_frame *sf;

    uint32_t up_psr, pc, npc;

    target_sigset_t set;

    sigset_t host_set;

    int err=0, i;



    sf_addr = env->regwptr[UREG_FP];

    trace_user_do_sigreturn(env, sf_addr);

    if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {

        goto segv_and_exit;

    }



    



    if (sf_addr & 3)

        goto segv_and_exit;



    __get_user(pc,  &sf->info.si_regs.pc);

    __get_user(npc, &sf->info.si_regs.npc);



    if ((pc | npc) & 3) {

        goto segv_and_exit;

    }



    

    __get_user(up_psr, &sf->info.si_regs.psr);



    

    env->psr = (up_psr & (PSR_ICC ))

            | (env->psr & ~(PSR_ICC ));



    env->pc = pc;

    env->npc = npc;

    __get_user(env->y, &sf->info.si_regs.y);

    for (i=0; i < 8; i++) {

        __get_user(env->gregs[i], &sf->info.si_regs.u_regs[i]);

    }

    for (i=0; i < 8; i++) {

        __get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8]);

    }



    











    





    __get_user(set.sig[0], &sf->info.si_mask);

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

        __get_user(set.sig[i], &sf->extramask[i - 1]);

    }



    target_to_host_sigset_internal(&host_set, &set);

    do_sigprocmask(SIG_SETMASK, &host_set, NULL);



    if (err) {

        goto segv_and_exit;

    }

    unlock_user_struct(sf, sf_addr, 0);

    return env->regwptr[0];



segv_and_exit:

    unlock_user_struct(sf, sf_addr, 0);

    force_sig(TARGET_SIGSEGV);

}

long FUNC_0(CPUSPARCState *VAR_0)

{

    abi_ulong sf_addr;

    struct target_signal_frame *VAR_1;

    uint32_t up_psr, pc, npc;

    target_sigset_t set;

    sigset_t host_set;

    int VAR_2=0, VAR_3;



    sf_addr = VAR_0->regwptr[UREG_FP];

    trace_user_do_sigreturn(VAR_0, sf_addr);

    if (!lock_user_struct(VERIFY_READ, VAR_1, sf_addr, 1)) {

        goto segv_and_exit;

    }



    



    if (sf_addr & 3)

        goto segv_and_exit;



    __get_user(pc,  &VAR_1->info.si_regs.pc);

    __get_user(npc, &VAR_1->info.si_regs.npc);



    if ((pc | npc) & 3) {

        goto segv_and_exit;

    }



    

    __get_user(up_psr, &VAR_1->info.si_regs.psr);



    

    VAR_0->psr = (up_psr & (PSR_ICC ))

            | (VAR_0->psr & ~(PSR_ICC ));



    VAR_0->pc = pc;

    VAR_0->npc = npc;

    __get_user(VAR_0->y, &VAR_1->info.si_regs.y);

    for (VAR_3=0; VAR_3 < 8; VAR_3++) {

        __get_user(VAR_0->gregs[VAR_3], &VAR_1->info.si_regs.u_regs[VAR_3]);

    }

    for (VAR_3=0; VAR_3 < 8; VAR_3++) {

        __get_user(VAR_0->regwptr[VAR_3 + UREG_I0], &VAR_1->info.si_regs.u_regs[VAR_3+8]);

    }



    











    





    __get_user(set.sig[0], &VAR_1->info.si_mask);

    for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) {

        __get_user(set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1]);

    }



    target_to_host_sigset_internal(&host_set, &set);

    do_sigprocmask(SIG_SETMASK, &host_set, NULL);



    if (VAR_2) {

        goto segv_and_exit;

    }

    unlock_user_struct(VAR_1, sf_addr, 0);

    return VAR_0->regwptr[0];



segv_and_exit:

    unlock_user_struct(VAR_1, sf_addr, 0);

    force_sig(TARGET_SIGSEGV);

}

long FUNC_0(CPUSPARCState *VAR_0)
{ abi_ulong sf_addr; struct target_signal_frame *VAR_1; uint32_t up_psr, pc, npc; target_sigset_t set; sigset_t host_set; int VAR_2=0, VAR_3; sf_addr = VAR_0->regwptr[UREG_FP]; trace_user_do_sigreturn(VAR_0, sf_addr); if (!lock_user_struct(VERIFY_READ, VAR_1, sf_addr, 1)) { goto segv_and_exit; } if (sf_addr & 3)
goto segv_and_exit; __get_user(pc,  &VAR_1->info.si_regs.pc); __get_user(npc, &VAR_1->info.si_regs.npc); if ((pc | npc) & 3) { goto segv_and_exit; } __get_user(up_psr, &VAR_1->info.si_regs.psr); VAR_0->psr = (up_psr & (PSR_ICC ))
| (VAR_0->psr & ~(PSR_ICC )); VAR_0->pc = pc; VAR_0->npc = npc; __get_user(VAR_0->y, &VAR_1->info.si_regs.y); for (VAR_3=0; VAR_3 < 8; VAR_3++) { __get_user(VAR_0->gregs[VAR_3], &VAR_1->info.si_regs.u_regs[VAR_3]); } for (VAR_3=0; VAR_3 < 8; VAR_3++) { __get_user(VAR_0->regwptr[VAR_3 + UREG_I0], &VAR_1->info.si_regs.u_regs[VAR_3+8]); } __get_user(set.sig[0], &VAR_1->info.si_mask); for(VAR_3 = 1; VAR_3 < TARGET_NSIG_WORDS; VAR_3++) { __get_user(set.sig[VAR_3], &VAR_1->extramask[VAR_3 - 1]); } target_to_host_sigset_internal(&host_set, &set); do_sigprocmask(SIG_SETMASK, &host_set, NULL); if (VAR_2) { goto segv_and_exit; } unlock_user_struct(VAR_1, sf_addr, 0); return VAR_0->regwptr[0]; segv_and_exit:
unlock_user_struct(VAR_1, sf_addr, 0); force_sig(TARGET_SIGSEGV); }