Patchwork [RFC,v4,10/44] linux-user: Don't overuse CPUState

login
register
mail settings
Submitter Andreas Färber
Date March 10, 2012, 2:27 a.m.
Message ID <1331346496-10736-11-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/145833/
State New
Headers show

Comments

Andreas Färber - March 10, 2012, 2:27 a.m.
In target-specific code use CPU*State.

While at it, fix indentation on those lines.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 linux-user/elfload.c      |   24 +++---
 linux-user/m68k/syscall.h |    2 +-
 linux-user/main.c         |   28 +++---
 linux-user/signal.c       |  201 +++++++++++++++++++++++----------------------
 4 files changed, 131 insertions(+), 124 deletions(-)
Anthony Liguori - March 13, 2012, 6:08 p.m.
On 03/09/2012 08:27 PM, Andreas Färber wrote:
> In target-specific code use CPU*State.
>
> While at it, fix indentation on those lines.
>
> Signed-off-by: Andreas Färber<afaerber@suse.de>

Looks good, but make sure Riku agrees.

Regards,

Anthony Liguori

> ---
>   linux-user/elfload.c      |   24 +++---
>   linux-user/m68k/syscall.h |    2 +-
>   linux-user/main.c         |   28 +++---
>   linux-user/signal.c       |  201 +++++++++++++++++++++++----------------------
>   4 files changed, 131 insertions(+), 124 deletions(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 2fd4a93..48e3232 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -157,7 +157,7 @@ typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
>    *
>    * See linux kernel: arch/x86/include/asm/elf.h
>    */
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *env)
>   {
>       (*regs)[0] = env->regs[15];
>       (*regs)[1] = env->regs[14];
> @@ -229,7 +229,7 @@ typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
>    *
>    * See linux kernel: arch/x86/include/asm/elf.h
>    */
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *env)
>   {
>       (*regs)[0] = env->regs[R_EBX];
>       (*regs)[1] = env->regs[R_ECX];
> @@ -288,7 +288,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>   #define ELF_NREG    18
>   typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
>
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUARMState *env)
>   {
>       (*regs)[0] = tswapl(env->regs[0]);
>       (*regs)[1] = tswapl(env->regs[1]);
> @@ -307,7 +307,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
>       (*regs)[14] = tswapl(env->regs[14]);
>       (*regs)[15] = tswapl(env->regs[15]);
>
> -    (*regs)[16] = tswapl(cpsr_read((CPUState *)env));
> +    (*regs)[16] = tswapl(cpsr_read((CPUARMState *)env));
>       (*regs)[17] = tswapl(env->regs[0]); /* XXX */
>   }
>
> @@ -410,7 +410,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>   #define ELF_NREG    34
>   typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
>
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUUniCore32State *env)
>   {
>       (*regs)[0] = env->regs[0];
>       (*regs)[1] = env->regs[1];
> @@ -445,7 +445,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
>       (*regs)[30] = env->regs[30];
>       (*regs)[31] = env->regs[31];
>
> -    (*regs)[32] = cpu_asr_read((CPUState *)env);
> +    (*regs)[32] = cpu_asr_read((CPUUniCore32State *)env);
>       (*regs)[33] = env->regs[0]; /* XXX */
>   }
>
> @@ -572,7 +572,7 @@ enum {
>
>   static uint32_t get_elf_hwcap(void)
>   {
> -    CPUState *e = thread_env;
> +    CPUPPCState *e = thread_env;
>       uint32_t features = 0;
>
>       /* We don't have to be terribly complete here; the high points are
> @@ -628,7 +628,7 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
>   #define ELF_NREG 48
>   typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
>
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *env)
>   {
>       int i;
>       target_ulong ccr = 0;
> @@ -697,7 +697,7 @@ enum {
>   };
>
>   /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *env)
>   {
>       int i;
>
> @@ -749,7 +749,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>   typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
>
>   /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env)
>   {
>       int i, pos = 0;
>
> @@ -797,7 +797,7 @@ enum {
>   };
>
>   static inline void elf_core_copy_regs(target_elf_gregset_t *regs,
> -                                      const CPUState *env)
> +                                      const CPUSH4State *env)
>   {
>       int i;
>
> @@ -862,7 +862,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>   #define ELF_NREG 20
>   typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
>
> -static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
> +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *env)
>   {
>       (*regs)[0] = tswapl(env->dregs[1]);
>       (*regs)[1] = tswapl(env->dregs[2]);
> diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/syscall.h
> index 2fd85dd..2618793 100644
> --- a/linux-user/m68k/syscall.h
> +++ b/linux-user/m68k/syscall.h
> @@ -18,4 +18,4 @@ struct target_pt_regs {
>
>   #define UNAME_MACHINE "m68k"
>
> -void do_m68k_simcall(CPUState *, int);
> +void do_m68k_simcall(CPUM68KState *, int);
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 01129f2..3b48882 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -71,7 +71,7 @@ void gemu_log(const char *fmt, ...)
>   }
>
>   #if defined(TARGET_I386)
> -int cpu_get_pic_interrupt(CPUState *env)
> +int cpu_get_pic_interrupt(CPUX86State *env)
>   {
>       return -1;
>   }
> @@ -247,7 +247,7 @@ void cpu_list_unlock(void)
>   /***********************************************************/
>   /* CPUX86 core interface */
>
> -void cpu_smm_update(CPUState *env)
> +void cpu_smm_update(CPUX86State *env)
>   {
>   }
>
> @@ -889,7 +889,7 @@ void cpu_loop(CPUARMState *env)
>
>   #ifdef TARGET_UNICORE32
>
> -void cpu_loop(CPUState *env)
> +void cpu_loop(CPUUniCore32State *env)
>   {
>       int trapnr;
>       unsigned int n, insn;
> @@ -1226,36 +1226,36 @@ void cpu_loop (CPUSPARCState *env)
>   #endif
>
>   #ifdef TARGET_PPC
> -static inline uint64_t cpu_ppc_get_tb (CPUState *env)
> +static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
>   {
>       /* TO FIX */
>       return 0;
>   }
>
> -uint64_t cpu_ppc_load_tbl (CPUState *env)
> +uint64_t cpu_ppc_load_tbl(CPUPPCState *env)
>   {
>       return cpu_ppc_get_tb(env);
>   }
>
> -uint32_t cpu_ppc_load_tbu (CPUState *env)
> +uint32_t cpu_ppc_load_tbu(CPUPPCState *env)
>   {
>       return cpu_ppc_get_tb(env)>>  32;
>   }
>
> -uint64_t cpu_ppc_load_atbl (CPUState *env)
> +uint64_t cpu_ppc_load_atbl(CPUPPCState *env)
>   {
>       return cpu_ppc_get_tb(env);
>   }
>
> -uint32_t cpu_ppc_load_atbu (CPUState *env)
> +uint32_t cpu_ppc_load_atbu(CPUPPCState *env)
>   {
>       return cpu_ppc_get_tb(env)>>  32;
>   }
>
> -uint32_t cpu_ppc601_load_rtcu (CPUState *env)
> +uint32_t cpu_ppc601_load_rtcu(CPUPPCState *env)
>   __attribute__ (( alias ("cpu_ppc_load_tbu") ));
>
> -uint32_t cpu_ppc601_load_rtcl (CPUState *env)
> +uint32_t cpu_ppc601_load_rtcl(CPUPPCState *env)
>   {
>       return cpu_ppc_load_tbl(env)&  0x3FFFFF80;
>   }
> @@ -2276,7 +2276,7 @@ done_syscall:
>   #endif
>
>   #ifdef TARGET_SH4
> -void cpu_loop (CPUState *env)
> +void cpu_loop(CPUSH4State *env)
>   {
>       int trapnr, ret;
>       target_siginfo_t info;
> @@ -2335,7 +2335,7 @@ void cpu_loop (CPUState *env)
>   #endif
>
>   #ifdef TARGET_CRIS
> -void cpu_loop (CPUState *env)
> +void cpu_loop(CPUCRISState *env)
>   {
>       int trapnr, ret;
>       target_siginfo_t info;
> @@ -2393,7 +2393,7 @@ void cpu_loop (CPUState *env)
>   #endif
>
>   #ifdef TARGET_MICROBLAZE
> -void cpu_loop (CPUState *env)
> +void cpu_loop(CPUMBState *env)
>   {
>       int trapnr, ret;
>       target_siginfo_t info;
> @@ -2630,7 +2630,7 @@ static void do_store_exclusive(CPUAlphaState *env, int reg, int quad)
>       queue_signal(env, TARGET_SIGSEGV,&info);
>   }
>
> -void cpu_loop (CPUState *env)
> +void cpu_loop(CPUAlphaState *env)
>   {
>       int trapnr;
>       target_siginfo_t info;
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index cefd2ff..f44f78e 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -1205,14 +1205,14 @@ static const abi_ulong retcodes[4] = {
>
>   #define __get_user_error(x,p,e) __get_user(x, p)
>
> -static inline int valid_user_regs(CPUState *regs)
> +static inline int valid_user_regs(CPUARMState *regs)
>   {
>       return 1;
>   }
>
>   static void
>   setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
> -		 CPUState *env, abi_ulong mask)
> +                 CPUARMState *env, abi_ulong mask)
>   {
>   	__put_user(env->regs[0],&sc->arm_r0);
>   	__put_user(env->regs[1],&sc->arm_r1);
> @@ -1241,7 +1241,7 @@ setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
>   }
>
>   static inline abi_ulong
> -get_sigframe(struct target_sigaction *ka, CPUState *regs, int framesize)
> +get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize)
>   {
>   	unsigned long sp = regs->regs[13];
>
> @@ -1257,7 +1257,7 @@ get_sigframe(struct target_sigaction *ka, CPUState *regs, int framesize)
>   }
>
>   static int
> -setup_return(CPUState *env, struct target_sigaction *ka,
> +setup_return(CPUARMState *env, struct target_sigaction *ka,
>   	     abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr)
>   {
>   	abi_ulong handler = ka->_sa_handler;
> @@ -1295,7 +1295,7 @@ setup_return(CPUState *env, struct target_sigaction *ka,
>   	return 0;
>   }
>
> -static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUState *env)
> +static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env)
>   {
>       int i;
>       struct target_vfp_sigframe *vfpframe;
> @@ -1312,7 +1312,8 @@ static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUState *env)
>       return (abi_ulong*)(vfpframe+1);
>   }
>
> -static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, CPUState *env)
> +static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace,
> +                                           CPUARMState *env)
>   {
>       int i;
>       struct target_iwmmxt_sigframe *iwmmxtframe;
> @@ -1332,7 +1333,7 @@ static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, CPUState *env)
>   }
>
>   static void setup_sigframe_v2(struct target_ucontext_v2 *uc,
> -                              target_sigset_t *set, CPUState *env)
> +                              target_sigset_t *set, CPUARMState *env)
>   {
>       struct target_sigaltstack stack;
>       int i;
> @@ -1367,7 +1368,7 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc,
>
>   /* compare linux/arch/arm/kernel/signal.c:setup_frame() */
>   static void setup_frame_v1(int usig, struct target_sigaction *ka,
> -			   target_sigset_t *set, CPUState *regs)
> +                           target_sigset_t *set, CPUARMState *regs)
>   {
>   	struct sigframe_v1 *frame;
>   	abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
> @@ -1391,7 +1392,7 @@ end:
>   }
>
>   static void setup_frame_v2(int usig, struct target_sigaction *ka,
> -			   target_sigset_t *set, CPUState *regs)
> +                           target_sigset_t *set, CPUARMState *regs)
>   {
>   	struct sigframe_v2 *frame;
>   	abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
> @@ -1408,7 +1409,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka,
>   }
>
>   static void setup_frame(int usig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *regs)
> +                        target_sigset_t *set, CPUARMState *regs)
>   {
>       if (get_osversion()>= 0x020612) {
>           setup_frame_v2(usig, ka, set, regs);
> @@ -1420,7 +1421,7 @@ static void setup_frame(int usig, struct target_sigaction *ka,
>   /* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */
>   static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,
>                                 target_siginfo_t *info,
> -			      target_sigset_t *set, CPUState *env)
> +                              target_sigset_t *set, CPUARMState *env)
>   {
>   	struct rt_sigframe_v1 *frame;
>   	abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame));
> @@ -1464,7 +1465,7 @@ end:
>
>   static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
>                                 target_siginfo_t *info,
> -                              target_sigset_t *set, CPUState *env)
> +                              target_sigset_t *set, CPUARMState *env)
>   {
>   	struct rt_sigframe_v2 *frame;
>   	abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame));
> @@ -1490,7 +1491,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
>
>   static void setup_rt_frame(int usig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUARMState *env)
>   {
>       if (get_osversion()>= 0x020612) {
>           setup_rt_frame_v2(usig, ka, info, set, env);
> @@ -1500,7 +1501,7 @@ static void setup_rt_frame(int usig, struct target_sigaction *ka,
>   }
>
>   static int
> -restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
> +restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc)
>   {
>   	int err = 0;
>           uint32_t cpsr;
> @@ -1531,7 +1532,7 @@ restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
>   	return err;
>   }
>
> -static long do_sigreturn_v1(CPUState *env)
> +static long do_sigreturn_v1(CPUARMState *env)
>   {
>           abi_ulong frame_addr;
>   	struct sigframe_v1 *frame;
> @@ -1578,7 +1579,7 @@ badframe:
>   	return 0;
>   }
>
> -static abi_ulong *restore_sigframe_v2_vfp(CPUState *env, abi_ulong *regspace)
> +static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace)
>   {
>       int i;
>       abi_ulong magic, sz;
> @@ -1608,7 +1609,8 @@ static abi_ulong *restore_sigframe_v2_vfp(CPUState *env, abi_ulong *regspace)
>       return (abi_ulong*)(vfpframe + 1);
>   }
>
> -static abi_ulong *restore_sigframe_v2_iwmmxt(CPUState *env, abi_ulong *regspace)
> +static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env,
> +                                             abi_ulong *regspace)
>   {
>       int i;
>       abi_ulong magic, sz;
> @@ -1632,7 +1634,7 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUState *env, abi_ulong *regspace)
>       return (abi_ulong*)(iwmmxtframe + 1);
>   }
>
> -static int do_sigframe_return_v2(CPUState *env, target_ulong frame_addr,
> +static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr,
>                                    struct target_ucontext_v2 *uc)
>   {
>       sigset_t host_set;
> @@ -1671,7 +1673,7 @@ static int do_sigframe_return_v2(CPUState *env, target_ulong frame_addr,
>       return 0;
>   }
>
> -static long do_sigreturn_v2(CPUState *env)
> +static long do_sigreturn_v2(CPUARMState *env)
>   {
>           abi_ulong frame_addr;
>   	struct sigframe_v2 *frame;
> @@ -1700,7 +1702,7 @@ badframe:
>   	return 0;
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUARMState *env)
>   {
>       if (get_osversion()>= 0x020612) {
>           return do_sigreturn_v2(env);
> @@ -1709,7 +1711,7 @@ long do_sigreturn(CPUState *env)
>       }
>   }
>
> -static long do_rt_sigreturn_v1(CPUState *env)
> +static long do_rt_sigreturn_v1(CPUARMState *env)
>   {
>           abi_ulong frame_addr;
>   	struct rt_sigframe_v1 *frame;
> @@ -1750,7 +1752,7 @@ badframe:
>   	return 0;
>   }
>
> -static long do_rt_sigreturn_v2(CPUState *env)
> +static long do_rt_sigreturn_v2(CPUARMState *env)
>   {
>           abi_ulong frame_addr;
>   	struct rt_sigframe_v2 *frame;
> @@ -1779,7 +1781,7 @@ badframe:
>   	return 0;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUARMState *env)
>   {
>       if (get_osversion()>= 0x020612) {
>           return do_rt_sigreturn_v2(env);
> @@ -1888,7 +1890,8 @@ struct target_rt_signal_frame {
>   #define UREG_SP        UREG_O6
>
>   static inline abi_ulong get_sigframe(struct target_sigaction *sa,
> -                                     CPUState *env, unsigned long framesize)
> +                                     CPUSPARCState *env,
> +                                     unsigned long framesize)
>   {
>   	abi_ulong sp;
>
> @@ -1904,7 +1907,7 @@ static inline abi_ulong get_sigframe(struct target_sigaction *sa,
>   }
>
>   static int
> -setup___siginfo(__siginfo_t *si, CPUState *env, abi_ulong mask)
> +setup___siginfo(__siginfo_t *si, CPUSPARCState *env, abi_ulong mask)
>   {
>   	int err = 0, i;
>
> @@ -1925,7 +1928,7 @@ setup___siginfo(__siginfo_t *si, CPUState *env, abi_ulong mask)
>   #if 0
>   static int
>   setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
> -		 CPUState *env, unsigned long mask)
> +                 CPUSPARCState *env, unsigned long mask)
>   {
>   	int err = 0;
>
> @@ -1943,7 +1946,7 @@ setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
>   #define NF_ALIGNEDSZ  (((sizeof(struct target_signal_frame) + 7)&  (~7)))
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUSPARCState *env)
>   {
>           abi_ulong sf_addr;
>   	struct target_signal_frame *sf;
> @@ -2032,7 +2035,7 @@ sigsegv:
>   	force_sig(TARGET_SIGSEGV);
>   }
>   static inline int
> -restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
> +restore_fpu_state(CPUSPARCState *env, qemu_siginfo_fpu_t *fpu)
>   {
>           int err;
>   #if 0
> @@ -2073,12 +2076,12 @@ restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUSPARCState *env)
>   {
>       fprintf(stderr, "setup_rt_frame: not implemented\n");
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUSPARCState *env)
>   {
>           abi_ulong sf_addr;
>           struct target_signal_frame *sf;
> @@ -2151,7 +2154,7 @@ segv_and_exit:
>   	force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUSPARCState *env)
>   {
>       fprintf(stderr, "do_rt_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
> @@ -2427,25 +2430,25 @@ void sparc64_get_context(CPUSPARCState *env)
>   # warning signal handling not implemented
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUMIPSState *env)
>   {
>       fprintf(stderr, "setup_frame: not implemented\n");
>   }
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUMIPSState *env)
>   {
>       fprintf(stderr, "setup_rt_frame: not implemented\n");
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUMIPSState *env)
>   {
>       fprintf(stderr, "do_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUMIPSState *env)
>   {
>       fprintf(stderr, "do_rt_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
> @@ -2456,25 +2459,25 @@ long do_rt_sigreturn(CPUState *env)
>   # warning signal handling not implemented
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUMIPSState *env)
>   {
>       fprintf(stderr, "setup_frame: not implemented\n");
>   }
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUMIPSState *env)
>   {
>       fprintf(stderr, "setup_rt_frame: not implemented\n");
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUMIPSState *env)
>   {
>       fprintf(stderr, "do_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUMIPSState *env)
>   {
>       fprintf(stderr, "do_rt_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
> @@ -2546,7 +2549,7 @@ static inline int install_sigtramp(unsigned int *tramp,   unsigned int syscall)
>   }
>
>   static inline int
> -setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
> +setup_sigcontext(CPUMIPSState *regs, struct target_sigcontext *sc)
>   {
>       int err = 0;
>
> @@ -2621,7 +2624,7 @@ setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
>   }
>
>   static inline int
> -restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
> +restore_sigcontext(CPUMIPSState *regs, struct target_sigcontext *sc)
>   {
>       int err = 0;
>
> @@ -2692,7 +2695,7 @@ restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
>    * Determine which stack to use..
>    */
>   static inline abi_ulong
> -get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
> +get_sigframe(struct target_sigaction *ka, CPUMIPSState *regs, size_t frame_size)
>   {
>       unsigned long sp;
>
> @@ -2716,7 +2719,7 @@ get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
>
>   /* compare linux/arch/mips/kernel/signal.c:setup_frame() */
>   static void setup_frame(int sig, struct target_sigaction * ka,
> -                        target_sigset_t *set, CPUState *regs)
> +                        target_sigset_t *set, CPUMIPSState *regs)
>   {
>       struct sigframe *frame;
>       abi_ulong frame_addr;
> @@ -2764,7 +2767,7 @@ give_sigsegv:
>       return;
>   }
>
> -long do_sigreturn(CPUState *regs)
> +long do_sigreturn(CPUMIPSState *regs)
>   {
>       struct sigframe *frame;
>       abi_ulong frame_addr;
> @@ -2815,7 +2818,7 @@ badframe:
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUMIPSState *env)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -2873,7 +2876,7 @@ give_sigsegv:
>       return;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUMIPSState *env)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -2974,7 +2977,7 @@ static abi_ulong get_sigframe(struct target_sigaction *ka,
>   }
>
>   static int setup_sigcontext(struct target_sigcontext *sc,
> -			    CPUState *regs, unsigned long mask)
> +                            CPUSH4State *regs, unsigned long mask)
>   {
>       int err = 0;
>       int i;
> @@ -3005,7 +3008,7 @@ static int setup_sigcontext(struct target_sigcontext *sc,
>       return err;
>   }
>
> -static int restore_sigcontext(CPUState *regs, struct target_sigcontext *sc,
> +static int restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc,
>                                 target_ulong *r0_p)
>   {
>       unsigned int err = 0;
> @@ -3037,7 +3040,7 @@ static int restore_sigcontext(CPUState *regs, struct target_sigcontext *sc,
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *regs)
> +                        target_sigset_t *set, CPUSH4State *regs)
>   {
>       struct target_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -3089,7 +3092,7 @@ give_sigsegv:
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *regs)
> +                           target_sigset_t *set, CPUSH4State *regs)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -3150,7 +3153,7 @@ give_sigsegv:
>       force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_sigreturn(CPUState *regs)
> +long do_sigreturn(CPUSH4State *regs)
>   {
>       struct target_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -3190,7 +3193,7 @@ badframe:
>       return 0;
>   }
>
> -long do_rt_sigreturn(CPUState *regs)
> +long do_rt_sigreturn(CPUSH4State *regs)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -3257,7 +3260,7 @@ struct rt_signal_frame {
>       uint32_t tramp[2];
>   };
>
> -static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
> +static void setup_sigcontext(struct target_sigcontext *sc, CPUMBState *env)
>   {
>       __put_user(env->regs[0],&sc->regs.r0);
>       __put_user(env->regs[1],&sc->regs.r1);
> @@ -3294,7 +3297,7 @@ static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
>       __put_user(env->sregs[SR_PC],&sc->regs.pc);
>   }
>
> -static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
> +static void restore_sigcontext(struct target_sigcontext *sc, CPUMBState *env)
>   {
>       __get_user(env->regs[0],&sc->regs.r0);
>       __get_user(env->regs[1],&sc->regs.r1);
> @@ -3332,7 +3335,7 @@ static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
>   }
>
>   static abi_ulong get_sigframe(struct target_sigaction *ka,
> -                              CPUState *env, int frame_size)
> +                              CPUMBState *env, int frame_size)
>   {
>       abi_ulong sp = env->regs[1];
>
> @@ -3343,7 +3346,7 @@ static abi_ulong get_sigframe(struct target_sigaction *ka,
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUMBState *env)
>   {
>       struct target_signal_frame *frame;
>       abi_ulong frame_addr;
> @@ -3409,12 +3412,12 @@ static void setup_frame(int sig, struct target_sigaction *ka,
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUMBState *env)
>   {
>       fprintf(stderr, "Microblaze setup_rt_frame: not implemented\n");
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUMBState *env)
>   {
>       struct target_signal_frame *frame;
>       abi_ulong frame_addr;
> @@ -3449,7 +3452,7 @@ long do_sigreturn(CPUState *env)
>       force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUMBState *env)
>   {
>       fprintf(stderr, "Microblaze do_rt_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
> @@ -3478,7 +3481,7 @@ struct rt_signal_frame {
>           uint8_t retcode[8];       /* Trampoline code. */
>   };
>
> -static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
> +static void setup_sigcontext(struct target_sigcontext *sc, CPUCRISState *env)
>   {
>   	__put_user(env->regs[0],&sc->regs.r0);
>   	__put_user(env->regs[1],&sc->regs.r1);
> @@ -3501,7 +3504,7 @@ static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
>   	__put_user(env->pc,&sc->regs.erp);
>   }
>
> -static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
> +static void restore_sigcontext(struct target_sigcontext *sc, CPUCRISState *env)
>   {
>   	__get_user(env->regs[0],&sc->regs.r0);
>   	__get_user(env->regs[1],&sc->regs.r1);
> @@ -3524,7 +3527,7 @@ static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
>   	__get_user(env->pc,&sc->regs.erp);
>   }
>
> -static abi_ulong get_sigframe(CPUState *env, int framesize)
> +static abi_ulong get_sigframe(CPUCRISState *env, int framesize)
>   {
>   	abi_ulong sp;
>   	/* Align the stack downwards to 4.  */
> @@ -3533,7 +3536,7 @@ static abi_ulong get_sigframe(CPUState *env, int framesize)
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUCRISState *env)
>   {
>   	struct target_signal_frame *frame;
>   	abi_ulong frame_addr;
> @@ -3584,12 +3587,12 @@ static void setup_frame(int sig, struct target_sigaction *ka,
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUCRISState *env)
>   {
>       fprintf(stderr, "CRIS setup_rt_frame: not implemented\n");
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUCRISState *env)
>   {
>   	struct target_signal_frame *frame;
>   	abi_ulong frame_addr;
> @@ -3620,7 +3623,7 @@ long do_sigreturn(CPUState *env)
>   	force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUCRISState *env)
>   {
>       fprintf(stderr, "CRIS do_rt_sigreturn: not implemented\n");
>       return -TARGET_ENOSYS;
> @@ -3687,7 +3690,7 @@ typedef struct {
>   } rt_sigframe;
>
>   static inline abi_ulong
> -get_sigframe(struct target_sigaction *ka, CPUState *env, size_t frame_size)
> +get_sigframe(struct target_sigaction *ka, CPUS390XState *env, size_t frame_size)
>   {
>       abi_ulong sp;
>
> @@ -3712,7 +3715,7 @@ get_sigframe(struct target_sigaction *ka, CPUState *env, size_t frame_size)
>       return (sp - frame_size)&  -8ul;
>   }
>
> -static void save_sigregs(CPUState *env, target_sigregs *sregs)
> +static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)
>   {
>       int i;
>       //save_access_regs(current->thread.acrs); FIXME
> @@ -3738,7 +3741,7 @@ static void save_sigregs(CPUState *env, target_sigregs *sregs)
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUS390XState *env)
>   {
>       sigframe *frame;
>       abi_ulong frame_addr;
> @@ -3805,7 +3808,7 @@ give_sigsegv:
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -                           target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUS390XState *env)
>   {
>       int i;
>       rt_sigframe *frame;
> @@ -3869,7 +3872,7 @@ give_sigsegv:
>   }
>
>   static int
> -restore_sigregs(CPUState *env, target_sigregs *sc)
> +restore_sigregs(CPUS390XState *env, target_sigregs *sc)
>   {
>       int err = 0;
>       int i;
> @@ -3895,7 +3898,7 @@ restore_sigregs(CPUState *env, target_sigregs *sc)
>       return err;
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUS390XState *env)
>   {
>       sigframe *frame;
>       abi_ulong frame_addr = env->regs[15];
> @@ -3927,7 +3930,7 @@ badframe:
>       return 0;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUS390XState *env)
>   {
>       rt_sigframe *frame;
>       abi_ulong frame_addr = env->regs[15];
> @@ -4107,7 +4110,7 @@ struct target_rt_sigframe {
>
>   /* See arch/powerpc/kernel/signal.c.  */
>   static target_ulong get_sigframe(struct target_sigaction *ka,
> -                                 CPUState *env,
> +                                 CPUPPCState *env,
>                                    int frame_size)
>   {
>       target_ulong oldsp, newsp;
> @@ -4125,7 +4128,7 @@ static target_ulong get_sigframe(struct target_sigaction *ka,
>       return newsp;
>   }
>
> -static int save_user_regs(CPUState *env, struct target_mcontext *frame,
> +static int save_user_regs(CPUPPCState *env, struct target_mcontext *frame,
>                             int sigret)
>   {
>       target_ulong msr = env->msr;
> @@ -4221,7 +4224,7 @@ static int save_user_regs(CPUState *env, struct target_mcontext *frame,
>       return 0;
>   }
>
> -static int restore_user_regs(CPUState *env,
> +static int restore_user_regs(CPUPPCState *env,
>                                struct target_mcontext *frame, int sig)
>   {
>       target_ulong save_r2 = 0;
> @@ -4320,7 +4323,7 @@ static int restore_user_regs(CPUState *env,
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -                        target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUPPCState *env)
>   {
>       struct target_sigframe *frame;
>       struct target_sigcontext *sc;
> @@ -4382,7 +4385,7 @@ sigsegv:
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -                           target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUPPCState *env)
>   {
>       struct target_rt_sigframe *rt_sf;
>       struct target_mcontext *frame;
> @@ -4450,7 +4453,7 @@ sigsegv:
>
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUPPCState *env)
>   {
>       struct target_sigcontext *sc = NULL;
>       struct target_mcontext *sr = NULL;
> @@ -4493,7 +4496,7 @@ sigsegv:
>   }
>
>   /* See arch/powerpc/kernel/signal_32.c.  */
> -static int do_setcontext(struct target_ucontext *ucp, CPUState *env, int sig)
> +static int do_setcontext(struct target_ucontext *ucp, CPUPPCState *env, int sig)
>   {
>       struct target_mcontext *mcp;
>       target_ulong mcp_addr;
> @@ -4528,7 +4531,7 @@ sigsegv:
>   #endif
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUPPCState *env)
>   {
>       struct target_rt_sigframe *rt_sf = NULL;
>       target_ulong rt_sf_addr;
> @@ -4617,7 +4620,8 @@ struct target_rt_sigframe
>   };
>
>   static int
> -setup_sigcontext(struct target_sigcontext *sc, CPUState *env, abi_ulong mask)
> +setup_sigcontext(struct target_sigcontext *sc, CPUM68KState *env,
> +                 abi_ulong mask)
>   {
>       int err = 0;
>
> @@ -4634,7 +4638,7 @@ setup_sigcontext(struct target_sigcontext *sc, CPUState *env, abi_ulong mask)
>   }
>
>   static int
> -restore_sigcontext(CPUState *env, struct target_sigcontext *sc, int *pd0)
> +restore_sigcontext(CPUM68KState *env, struct target_sigcontext *sc, int *pd0)
>   {
>       int err = 0;
>       int temp;
> @@ -4656,7 +4660,8 @@ restore_sigcontext(CPUState *env, struct target_sigcontext *sc, int *pd0)
>    * Determine which stack to use..
>    */
>   static inline abi_ulong
> -get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
> +get_sigframe(struct target_sigaction *ka, CPUM68KState *regs,
> +             size_t frame_size)
>   {
>       unsigned long sp;
>
> @@ -4671,7 +4676,7 @@ get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -			target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUM68KState *env)
>   {
>       struct target_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -4725,7 +4730,7 @@ give_sigsegv:
>   }
>
>   static inline int target_rt_setup_ucontext(struct target_ucontext *uc,
> -                                           CPUState *env)
> +                                           CPUM68KState *env)
>   {
>       target_greg_t *gregs = uc->tuc_mcontext.gregs;
>       int err;
> @@ -4753,7 +4758,7 @@ static inline int target_rt_setup_ucontext(struct target_ucontext *uc,
>       return err;
>   }
>
> -static inline int target_rt_restore_ucontext(CPUState *env,
> +static inline int target_rt_restore_ucontext(CPUM68KState *env,
>                                                struct target_ucontext *uc,
>                                                int *pd0)
>   {
> @@ -4795,7 +4800,7 @@ badframe:
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUM68KState *env)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr;
> @@ -4866,7 +4871,7 @@ give_sigsegv:
>       force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUM68KState *env)
>   {
>       struct target_sigframe *frame;
>       abi_ulong frame_addr = env->aregs[7] - 4;
> @@ -4904,7 +4909,7 @@ badframe:
>       return 0;
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUM68KState *env)
>   {
>       struct target_rt_sigframe *frame;
>       abi_ulong frame_addr = env->aregs[7] - 4;
> @@ -4985,7 +4990,7 @@ struct target_rt_sigframe {
>   #define INSN_LDI_R0             0x201f0000
>   #define INSN_CALLSYS            0x00000083
>
> -static int setup_sigcontext(struct target_sigcontext *sc, CPUState *env,
> +static int setup_sigcontext(struct target_sigcontext *sc, CPUAlphaState *env,
>                               abi_ulong frame_addr, target_sigset_t *set)
>   {
>       int i, err = 0;
> @@ -5013,7 +5018,8 @@ static int setup_sigcontext(struct target_sigcontext *sc, CPUState *env,
>       return err;
>   }
>
> -static int restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
> +static int restore_sigcontext(CPUAlphaState *env,
> +                              struct target_sigcontext *sc)
>   {
>       uint64_t fpcr;
>       int i, err = 0;
> @@ -5034,7 +5040,8 @@ static int restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
>   }
>
>   static inline abi_ulong get_sigframe(struct target_sigaction *sa,
> -                                     CPUState *env, unsigned long framesize)
> +                                     CPUAlphaState *env,
> +                                     unsigned long framesize)
>   {
>       abi_ulong sp = env->ir[IR_SP];
>
> @@ -5046,7 +5053,7 @@ static inline abi_ulong get_sigframe(struct target_sigaction *sa,
>   }
>
>   static void setup_frame(int sig, struct target_sigaction *ka,
> -                        target_sigset_t *set, CPUState *env)
> +                        target_sigset_t *set, CPUAlphaState *env)
>   {
>       abi_ulong frame_addr, r26;
>       struct target_sigframe *frame;
> @@ -5090,7 +5097,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
>
>   static void setup_rt_frame(int sig, struct target_sigaction *ka,
>                              target_siginfo_t *info,
> -			   target_sigset_t *set, CPUState *env)
> +                           target_sigset_t *set, CPUAlphaState *env)
>   {
>       abi_ulong frame_addr, r26;
>       struct target_rt_sigframe *frame;
> @@ -5144,7 +5151,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
>       env->ir[IR_SP] = frame_addr;
>   }
>
> -long do_sigreturn(CPUState *env)
> +long do_sigreturn(CPUAlphaState *env)
>   {
>       struct target_sigcontext *sc;
>       abi_ulong sc_addr = env->ir[IR_A0];
> @@ -5174,7 +5181,7 @@ long do_sigreturn(CPUState *env)
>       force_sig(TARGET_SIGSEGV);
>   }
>
> -long do_rt_sigreturn(CPUState *env)
> +long do_rt_sigreturn(CPUAlphaState *env)
>   {
>       abi_ulong frame_addr = env->ir[IR_A0];
>       struct target_rt_sigframe *frame;

Patch

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 2fd4a93..48e3232 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -157,7 +157,7 @@  typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
  *
  * See linux kernel: arch/x86/include/asm/elf.h
  */
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *env)
 {
     (*regs)[0] = env->regs[15];
     (*regs)[1] = env->regs[14];
@@ -229,7 +229,7 @@  typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
  *
  * See linux kernel: arch/x86/include/asm/elf.h
  */
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *env)
 {
     (*regs)[0] = env->regs[R_EBX];
     (*regs)[1] = env->regs[R_ECX];
@@ -288,7 +288,7 @@  static inline void init_thread(struct target_pt_regs *regs,
 #define ELF_NREG    18
 typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
 
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUARMState *env)
 {
     (*regs)[0] = tswapl(env->regs[0]);
     (*regs)[1] = tswapl(env->regs[1]);
@@ -307,7 +307,7 @@  static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
     (*regs)[14] = tswapl(env->regs[14]);
     (*regs)[15] = tswapl(env->regs[15]);
 
-    (*regs)[16] = tswapl(cpsr_read((CPUState *)env));
+    (*regs)[16] = tswapl(cpsr_read((CPUARMState *)env));
     (*regs)[17] = tswapl(env->regs[0]); /* XXX */
 }
 
@@ -410,7 +410,7 @@  static inline void init_thread(struct target_pt_regs *regs,
 #define ELF_NREG    34
 typedef target_elf_greg_t  target_elf_gregset_t[ELF_NREG];
 
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUUniCore32State *env)
 {
     (*regs)[0] = env->regs[0];
     (*regs)[1] = env->regs[1];
@@ -445,7 +445,7 @@  static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
     (*regs)[30] = env->regs[30];
     (*regs)[31] = env->regs[31];
 
-    (*regs)[32] = cpu_asr_read((CPUState *)env);
+    (*regs)[32] = cpu_asr_read((CPUUniCore32State *)env);
     (*regs)[33] = env->regs[0]; /* XXX */
 }
 
@@ -572,7 +572,7 @@  enum {
 
 static uint32_t get_elf_hwcap(void)
 {
-    CPUState *e = thread_env;
+    CPUPPCState *e = thread_env;
     uint32_t features = 0;
 
     /* We don't have to be terribly complete here; the high points are
@@ -628,7 +628,7 @@  static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
 #define ELF_NREG 48
 typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
 
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *env)
 {
     int i;
     target_ulong ccr = 0;
@@ -697,7 +697,7 @@  enum {
 };
 
 /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *env)
 {
     int i;
 
@@ -749,7 +749,7 @@  static inline void init_thread(struct target_pt_regs *regs,
 typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
 
 /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs.  */
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env)
 {
     int i, pos = 0;
 
@@ -797,7 +797,7 @@  enum {
 };
 
 static inline void elf_core_copy_regs(target_elf_gregset_t *regs,
-                                      const CPUState *env)
+                                      const CPUSH4State *env)
 {
     int i;
 
@@ -862,7 +862,7 @@  static inline void init_thread(struct target_pt_regs *regs,
 #define ELF_NREG 20
 typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
 
-static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env)
+static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *env)
 {
     (*regs)[0] = tswapl(env->dregs[1]);
     (*regs)[1] = tswapl(env->dregs[2]);
diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/syscall.h
index 2fd85dd..2618793 100644
--- a/linux-user/m68k/syscall.h
+++ b/linux-user/m68k/syscall.h
@@ -18,4 +18,4 @@  struct target_pt_regs {
 
 #define UNAME_MACHINE "m68k"
 
-void do_m68k_simcall(CPUState *, int);
+void do_m68k_simcall(CPUM68KState *, int);
diff --git a/linux-user/main.c b/linux-user/main.c
index 01129f2..3b48882 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -71,7 +71,7 @@  void gemu_log(const char *fmt, ...)
 }
 
 #if defined(TARGET_I386)
-int cpu_get_pic_interrupt(CPUState *env)
+int cpu_get_pic_interrupt(CPUX86State *env)
 {
     return -1;
 }
@@ -247,7 +247,7 @@  void cpu_list_unlock(void)
 /***********************************************************/
 /* CPUX86 core interface */
 
-void cpu_smm_update(CPUState *env)
+void cpu_smm_update(CPUX86State *env)
 {
 }
 
@@ -889,7 +889,7 @@  void cpu_loop(CPUARMState *env)
 
 #ifdef TARGET_UNICORE32
 
-void cpu_loop(CPUState *env)
+void cpu_loop(CPUUniCore32State *env)
 {
     int trapnr;
     unsigned int n, insn;
@@ -1226,36 +1226,36 @@  void cpu_loop (CPUSPARCState *env)
 #endif
 
 #ifdef TARGET_PPC
-static inline uint64_t cpu_ppc_get_tb (CPUState *env)
+static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
 {
     /* TO FIX */
     return 0;
 }
 
-uint64_t cpu_ppc_load_tbl (CPUState *env)
+uint64_t cpu_ppc_load_tbl(CPUPPCState *env)
 {
     return cpu_ppc_get_tb(env);
 }
 
-uint32_t cpu_ppc_load_tbu (CPUState *env)
+uint32_t cpu_ppc_load_tbu(CPUPPCState *env)
 {
     return cpu_ppc_get_tb(env) >> 32;
 }
 
-uint64_t cpu_ppc_load_atbl (CPUState *env)
+uint64_t cpu_ppc_load_atbl(CPUPPCState *env)
 {
     return cpu_ppc_get_tb(env);
 }
 
-uint32_t cpu_ppc_load_atbu (CPUState *env)
+uint32_t cpu_ppc_load_atbu(CPUPPCState *env)
 {
     return cpu_ppc_get_tb(env) >> 32;
 }
 
-uint32_t cpu_ppc601_load_rtcu (CPUState *env)
+uint32_t cpu_ppc601_load_rtcu(CPUPPCState *env)
 __attribute__ (( alias ("cpu_ppc_load_tbu") ));
 
-uint32_t cpu_ppc601_load_rtcl (CPUState *env)
+uint32_t cpu_ppc601_load_rtcl(CPUPPCState *env)
 {
     return cpu_ppc_load_tbl(env) & 0x3FFFFF80;
 }
@@ -2276,7 +2276,7 @@  done_syscall:
 #endif
 
 #ifdef TARGET_SH4
-void cpu_loop (CPUState *env)
+void cpu_loop(CPUSH4State *env)
 {
     int trapnr, ret;
     target_siginfo_t info;
@@ -2335,7 +2335,7 @@  void cpu_loop (CPUState *env)
 #endif
 
 #ifdef TARGET_CRIS
-void cpu_loop (CPUState *env)
+void cpu_loop(CPUCRISState *env)
 {
     int trapnr, ret;
     target_siginfo_t info;
@@ -2393,7 +2393,7 @@  void cpu_loop (CPUState *env)
 #endif
 
 #ifdef TARGET_MICROBLAZE
-void cpu_loop (CPUState *env)
+void cpu_loop(CPUMBState *env)
 {
     int trapnr, ret;
     target_siginfo_t info;
@@ -2630,7 +2630,7 @@  static void do_store_exclusive(CPUAlphaState *env, int reg, int quad)
     queue_signal(env, TARGET_SIGSEGV, &info);
 }
 
-void cpu_loop (CPUState *env)
+void cpu_loop(CPUAlphaState *env)
 {
     int trapnr;
     target_siginfo_t info;
diff --git a/linux-user/signal.c b/linux-user/signal.c
index cefd2ff..f44f78e 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1205,14 +1205,14 @@  static const abi_ulong retcodes[4] = {
 
 #define __get_user_error(x,p,e) __get_user(x, p)
 
-static inline int valid_user_regs(CPUState *regs)
+static inline int valid_user_regs(CPUARMState *regs)
 {
     return 1;
 }
 
 static void
 setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
-		 CPUState *env, abi_ulong mask)
+                 CPUARMState *env, abi_ulong mask)
 {
 	__put_user(env->regs[0], &sc->arm_r0);
 	__put_user(env->regs[1], &sc->arm_r1);
@@ -1241,7 +1241,7 @@  setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
 }
 
 static inline abi_ulong
-get_sigframe(struct target_sigaction *ka, CPUState *regs, int framesize)
+get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize)
 {
 	unsigned long sp = regs->regs[13];
 
@@ -1257,7 +1257,7 @@  get_sigframe(struct target_sigaction *ka, CPUState *regs, int framesize)
 }
 
 static int
-setup_return(CPUState *env, struct target_sigaction *ka,
+setup_return(CPUARMState *env, struct target_sigaction *ka,
 	     abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr)
 {
 	abi_ulong handler = ka->_sa_handler;
@@ -1295,7 +1295,7 @@  setup_return(CPUState *env, struct target_sigaction *ka,
 	return 0;
 }
 
-static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUState *env)
+static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env)
 {
     int i;
     struct target_vfp_sigframe *vfpframe;
@@ -1312,7 +1312,8 @@  static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUState *env)
     return (abi_ulong*)(vfpframe+1);
 }
 
-static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, CPUState *env)
+static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace,
+                                           CPUARMState *env)
 {
     int i;
     struct target_iwmmxt_sigframe *iwmmxtframe;
@@ -1332,7 +1333,7 @@  static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, CPUState *env)
 }
 
 static void setup_sigframe_v2(struct target_ucontext_v2 *uc,
-                              target_sigset_t *set, CPUState *env)
+                              target_sigset_t *set, CPUARMState *env)
 {
     struct target_sigaltstack stack;
     int i;
@@ -1367,7 +1368,7 @@  static void setup_sigframe_v2(struct target_ucontext_v2 *uc,
 
 /* compare linux/arch/arm/kernel/signal.c:setup_frame() */
 static void setup_frame_v1(int usig, struct target_sigaction *ka,
-			   target_sigset_t *set, CPUState *regs)
+                           target_sigset_t *set, CPUARMState *regs)
 {
 	struct sigframe_v1 *frame;
 	abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
@@ -1391,7 +1392,7 @@  end:
 }
 
 static void setup_frame_v2(int usig, struct target_sigaction *ka,
-			   target_sigset_t *set, CPUState *regs)
+                           target_sigset_t *set, CPUARMState *regs)
 {
 	struct sigframe_v2 *frame;
 	abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
@@ -1408,7 +1409,7 @@  static void setup_frame_v2(int usig, struct target_sigaction *ka,
 }
 
 static void setup_frame(int usig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *regs)
+                        target_sigset_t *set, CPUARMState *regs)
 {
     if (get_osversion() >= 0x020612) {
         setup_frame_v2(usig, ka, set, regs);
@@ -1420,7 +1421,7 @@  static void setup_frame(int usig, struct target_sigaction *ka,
 /* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */
 static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,
                               target_siginfo_t *info,
-			      target_sigset_t *set, CPUState *env)
+                              target_sigset_t *set, CPUARMState *env)
 {
 	struct rt_sigframe_v1 *frame;
 	abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame));
@@ -1464,7 +1465,7 @@  end:
 
 static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
                               target_siginfo_t *info,
-                              target_sigset_t *set, CPUState *env)
+                              target_sigset_t *set, CPUARMState *env)
 {
 	struct rt_sigframe_v2 *frame;
 	abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame));
@@ -1490,7 +1491,7 @@  static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
 
 static void setup_rt_frame(int usig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUARMState *env)
 {
     if (get_osversion() >= 0x020612) {
         setup_rt_frame_v2(usig, ka, info, set, env);
@@ -1500,7 +1501,7 @@  static void setup_rt_frame(int usig, struct target_sigaction *ka,
 }
 
 static int
-restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
+restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc)
 {
 	int err = 0;
         uint32_t cpsr;
@@ -1531,7 +1532,7 @@  restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
 	return err;
 }
 
-static long do_sigreturn_v1(CPUState *env)
+static long do_sigreturn_v1(CPUARMState *env)
 {
         abi_ulong frame_addr;
 	struct sigframe_v1 *frame;
@@ -1578,7 +1579,7 @@  badframe:
 	return 0;
 }
 
-static abi_ulong *restore_sigframe_v2_vfp(CPUState *env, abi_ulong *regspace)
+static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace)
 {
     int i;
     abi_ulong magic, sz;
@@ -1608,7 +1609,8 @@  static abi_ulong *restore_sigframe_v2_vfp(CPUState *env, abi_ulong *regspace)
     return (abi_ulong*)(vfpframe + 1);
 }
 
-static abi_ulong *restore_sigframe_v2_iwmmxt(CPUState *env, abi_ulong *regspace)
+static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env,
+                                             abi_ulong *regspace)
 {
     int i;
     abi_ulong magic, sz;
@@ -1632,7 +1634,7 @@  static abi_ulong *restore_sigframe_v2_iwmmxt(CPUState *env, abi_ulong *regspace)
     return (abi_ulong*)(iwmmxtframe + 1);
 }
 
-static int do_sigframe_return_v2(CPUState *env, target_ulong frame_addr,
+static int do_sigframe_return_v2(CPUARMState *env, target_ulong frame_addr,
                                  struct target_ucontext_v2 *uc)
 {
     sigset_t host_set;
@@ -1671,7 +1673,7 @@  static int do_sigframe_return_v2(CPUState *env, target_ulong frame_addr,
     return 0;
 }
 
-static long do_sigreturn_v2(CPUState *env)
+static long do_sigreturn_v2(CPUARMState *env)
 {
         abi_ulong frame_addr;
 	struct sigframe_v2 *frame;
@@ -1700,7 +1702,7 @@  badframe:
 	return 0;
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUARMState *env)
 {
     if (get_osversion() >= 0x020612) {
         return do_sigreturn_v2(env);
@@ -1709,7 +1711,7 @@  long do_sigreturn(CPUState *env)
     }
 }
 
-static long do_rt_sigreturn_v1(CPUState *env)
+static long do_rt_sigreturn_v1(CPUARMState *env)
 {
         abi_ulong frame_addr;
 	struct rt_sigframe_v1 *frame;
@@ -1750,7 +1752,7 @@  badframe:
 	return 0;
 }
 
-static long do_rt_sigreturn_v2(CPUState *env)
+static long do_rt_sigreturn_v2(CPUARMState *env)
 {
         abi_ulong frame_addr;
 	struct rt_sigframe_v2 *frame;
@@ -1779,7 +1781,7 @@  badframe:
 	return 0;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUARMState *env)
 {
     if (get_osversion() >= 0x020612) {
         return do_rt_sigreturn_v2(env);
@@ -1888,7 +1890,8 @@  struct target_rt_signal_frame {
 #define UREG_SP        UREG_O6
 
 static inline abi_ulong get_sigframe(struct target_sigaction *sa, 
-                                     CPUState *env, unsigned long framesize)
+                                     CPUSPARCState *env,
+                                     unsigned long framesize)
 {
 	abi_ulong sp;
 
@@ -1904,7 +1907,7 @@  static inline abi_ulong get_sigframe(struct target_sigaction *sa,
 }
 
 static int
-setup___siginfo(__siginfo_t *si, CPUState *env, abi_ulong mask)
+setup___siginfo(__siginfo_t *si, CPUSPARCState *env, abi_ulong mask)
 {
 	int err = 0, i;
 
@@ -1925,7 +1928,7 @@  setup___siginfo(__siginfo_t *si, CPUState *env, abi_ulong mask)
 #if 0
 static int
 setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
-		 CPUState *env, unsigned long mask)
+                 CPUSPARCState *env, unsigned long mask)
 {
 	int err = 0;
 
@@ -1943,7 +1946,7 @@  setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
 #define NF_ALIGNEDSZ  (((sizeof(struct target_signal_frame) + 7) & (~7)))
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUSPARCState *env)
 {
         abi_ulong sf_addr;
 	struct target_signal_frame *sf;
@@ -2032,7 +2035,7 @@  sigsegv:
 	force_sig(TARGET_SIGSEGV);
 }
 static inline int
-restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
+restore_fpu_state(CPUSPARCState *env, qemu_siginfo_fpu_t *fpu)
 {
         int err;
 #if 0
@@ -2073,12 +2076,12 @@  restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu)
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUSPARCState *env)
 {
     fprintf(stderr, "setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUSPARCState *env)
 {
         abi_ulong sf_addr;
         struct target_signal_frame *sf;
@@ -2151,7 +2154,7 @@  segv_and_exit:
 	force_sig(TARGET_SIGSEGV);
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUSPARCState *env)
 {
     fprintf(stderr, "do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -2427,25 +2430,25 @@  void sparc64_get_context(CPUSPARCState *env)
 # warning signal handling not implemented
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUMIPSState *env)
 {
     fprintf(stderr, "setup_frame: not implemented\n");
 }
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUMIPSState *env)
 {
     fprintf(stderr, "setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUMIPSState *env)
 {
     fprintf(stderr, "do_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUMIPSState *env)
 {
     fprintf(stderr, "do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -2456,25 +2459,25 @@  long do_rt_sigreturn(CPUState *env)
 # warning signal handling not implemented
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUMIPSState *env)
 {
     fprintf(stderr, "setup_frame: not implemented\n");
 }
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUMIPSState *env)
 {
     fprintf(stderr, "setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUMIPSState *env)
 {
     fprintf(stderr, "do_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUMIPSState *env)
 {
     fprintf(stderr, "do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -2546,7 +2549,7 @@  static inline int install_sigtramp(unsigned int *tramp,   unsigned int syscall)
 }
 
 static inline int
-setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
+setup_sigcontext(CPUMIPSState *regs, struct target_sigcontext *sc)
 {
     int err = 0;
 
@@ -2621,7 +2624,7 @@  setup_sigcontext(CPUState *regs, struct target_sigcontext *sc)
 }
 
 static inline int
-restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
+restore_sigcontext(CPUMIPSState *regs, struct target_sigcontext *sc)
 {
     int err = 0;
 
@@ -2692,7 +2695,7 @@  restore_sigcontext(CPUState *regs, struct target_sigcontext *sc)
  * Determine which stack to use..
  */
 static inline abi_ulong
-get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
+get_sigframe(struct target_sigaction *ka, CPUMIPSState *regs, size_t frame_size)
 {
     unsigned long sp;
 
@@ -2716,7 +2719,7 @@  get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
 
 /* compare linux/arch/mips/kernel/signal.c:setup_frame() */
 static void setup_frame(int sig, struct target_sigaction * ka,
-                        target_sigset_t *set, CPUState *regs)
+                        target_sigset_t *set, CPUMIPSState *regs)
 {
     struct sigframe *frame;
     abi_ulong frame_addr;
@@ -2764,7 +2767,7 @@  give_sigsegv:
     return;
 }
 
-long do_sigreturn(CPUState *regs)
+long do_sigreturn(CPUMIPSState *regs)
 {
     struct sigframe *frame;
     abi_ulong frame_addr;
@@ -2815,7 +2818,7 @@  badframe:
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUMIPSState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr;
@@ -2873,7 +2876,7 @@  give_sigsegv:
     return;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUMIPSState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr;
@@ -2974,7 +2977,7 @@  static abi_ulong get_sigframe(struct target_sigaction *ka,
 }
 
 static int setup_sigcontext(struct target_sigcontext *sc,
-			    CPUState *regs, unsigned long mask)
+                            CPUSH4State *regs, unsigned long mask)
 {
     int err = 0;
     int i;
@@ -3005,7 +3008,7 @@  static int setup_sigcontext(struct target_sigcontext *sc,
     return err;
 }
 
-static int restore_sigcontext(CPUState *regs, struct target_sigcontext *sc,
+static int restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc,
                               target_ulong *r0_p)
 {
     unsigned int err = 0;
@@ -3037,7 +3040,7 @@  static int restore_sigcontext(CPUState *regs, struct target_sigcontext *sc,
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *regs)
+                        target_sigset_t *set, CPUSH4State *regs)
 {
     struct target_sigframe *frame;
     abi_ulong frame_addr;
@@ -3089,7 +3092,7 @@  give_sigsegv:
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *regs)
+                           target_sigset_t *set, CPUSH4State *regs)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr;
@@ -3150,7 +3153,7 @@  give_sigsegv:
     force_sig(TARGET_SIGSEGV);
 }
 
-long do_sigreturn(CPUState *regs)
+long do_sigreturn(CPUSH4State *regs)
 {
     struct target_sigframe *frame;
     abi_ulong frame_addr;
@@ -3190,7 +3193,7 @@  badframe:
     return 0;
 }
 
-long do_rt_sigreturn(CPUState *regs)
+long do_rt_sigreturn(CPUSH4State *regs)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr;
@@ -3257,7 +3260,7 @@  struct rt_signal_frame {
     uint32_t tramp[2];
 };
 
-static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
+static void setup_sigcontext(struct target_sigcontext *sc, CPUMBState *env)
 {
     __put_user(env->regs[0], &sc->regs.r0);
     __put_user(env->regs[1], &sc->regs.r1);
@@ -3294,7 +3297,7 @@  static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
     __put_user(env->sregs[SR_PC], &sc->regs.pc);
 }
 
-static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
+static void restore_sigcontext(struct target_sigcontext *sc, CPUMBState *env)
 {
     __get_user(env->regs[0], &sc->regs.r0);
     __get_user(env->regs[1], &sc->regs.r1);
@@ -3332,7 +3335,7 @@  static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
 }
 
 static abi_ulong get_sigframe(struct target_sigaction *ka,
-                              CPUState *env, int frame_size)
+                              CPUMBState *env, int frame_size)
 {
     abi_ulong sp = env->regs[1];
 
@@ -3343,7 +3346,7 @@  static abi_ulong get_sigframe(struct target_sigaction *ka,
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUMBState *env)
 {
     struct target_signal_frame *frame;
     abi_ulong frame_addr;
@@ -3409,12 +3412,12 @@  static void setup_frame(int sig, struct target_sigaction *ka,
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUMBState *env)
 {
     fprintf(stderr, "Microblaze setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUMBState *env)
 {
     struct target_signal_frame *frame;
     abi_ulong frame_addr;
@@ -3449,7 +3452,7 @@  long do_sigreturn(CPUState *env)
     force_sig(TARGET_SIGSEGV);
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUMBState *env)
 {
     fprintf(stderr, "Microblaze do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -3478,7 +3481,7 @@  struct rt_signal_frame {
         uint8_t retcode[8];       /* Trampoline code. */
 };
 
-static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
+static void setup_sigcontext(struct target_sigcontext *sc, CPUCRISState *env)
 {
 	__put_user(env->regs[0], &sc->regs.r0);
 	__put_user(env->regs[1], &sc->regs.r1);
@@ -3501,7 +3504,7 @@  static void setup_sigcontext(struct target_sigcontext *sc, CPUState *env)
 	__put_user(env->pc, &sc->regs.erp);
 }
 
-static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
+static void restore_sigcontext(struct target_sigcontext *sc, CPUCRISState *env)
 {
 	__get_user(env->regs[0], &sc->regs.r0);
 	__get_user(env->regs[1], &sc->regs.r1);
@@ -3524,7 +3527,7 @@  static void restore_sigcontext(struct target_sigcontext *sc, CPUState *env)
 	__get_user(env->pc, &sc->regs.erp);
 }
 
-static abi_ulong get_sigframe(CPUState *env, int framesize)
+static abi_ulong get_sigframe(CPUCRISState *env, int framesize)
 {
 	abi_ulong sp;
 	/* Align the stack downwards to 4.  */
@@ -3533,7 +3536,7 @@  static abi_ulong get_sigframe(CPUState *env, int framesize)
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUCRISState *env)
 {
 	struct target_signal_frame *frame;
 	abi_ulong frame_addr;
@@ -3584,12 +3587,12 @@  static void setup_frame(int sig, struct target_sigaction *ka,
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUCRISState *env)
 {
     fprintf(stderr, "CRIS setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUCRISState *env)
 {
 	struct target_signal_frame *frame;
 	abi_ulong frame_addr;
@@ -3620,7 +3623,7 @@  long do_sigreturn(CPUState *env)
 	force_sig(TARGET_SIGSEGV);
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUCRISState *env)
 {
     fprintf(stderr, "CRIS do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -3687,7 +3690,7 @@  typedef struct {
 } rt_sigframe;
 
 static inline abi_ulong
-get_sigframe(struct target_sigaction *ka, CPUState *env, size_t frame_size)
+get_sigframe(struct target_sigaction *ka, CPUS390XState *env, size_t frame_size)
 {
     abi_ulong sp;
 
@@ -3712,7 +3715,7 @@  get_sigframe(struct target_sigaction *ka, CPUState *env, size_t frame_size)
     return (sp - frame_size) & -8ul;
 }
 
-static void save_sigregs(CPUState *env, target_sigregs *sregs)
+static void save_sigregs(CPUS390XState *env, target_sigregs *sregs)
 {
     int i;
     //save_access_regs(current->thread.acrs); FIXME
@@ -3738,7 +3741,7 @@  static void save_sigregs(CPUState *env, target_sigregs *sregs)
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUS390XState *env)
 {
     sigframe *frame;
     abi_ulong frame_addr;
@@ -3805,7 +3808,7 @@  give_sigsegv:
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-                           target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUS390XState *env)
 {
     int i;
     rt_sigframe *frame;
@@ -3869,7 +3872,7 @@  give_sigsegv:
 }
 
 static int
-restore_sigregs(CPUState *env, target_sigregs *sc)
+restore_sigregs(CPUS390XState *env, target_sigregs *sc)
 {
     int err = 0;
     int i;
@@ -3895,7 +3898,7 @@  restore_sigregs(CPUState *env, target_sigregs *sc)
     return err;
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUS390XState *env)
 {
     sigframe *frame;
     abi_ulong frame_addr = env->regs[15];
@@ -3927,7 +3930,7 @@  badframe:
     return 0;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUS390XState *env)
 {
     rt_sigframe *frame;
     abi_ulong frame_addr = env->regs[15];
@@ -4107,7 +4110,7 @@  struct target_rt_sigframe {
 
 /* See arch/powerpc/kernel/signal.c.  */
 static target_ulong get_sigframe(struct target_sigaction *ka,
-                                 CPUState *env,
+                                 CPUPPCState *env,
                                  int frame_size)
 {
     target_ulong oldsp, newsp;
@@ -4125,7 +4128,7 @@  static target_ulong get_sigframe(struct target_sigaction *ka,
     return newsp;
 }
 
-static int save_user_regs(CPUState *env, struct target_mcontext *frame,
+static int save_user_regs(CPUPPCState *env, struct target_mcontext *frame,
                           int sigret)
 {
     target_ulong msr = env->msr;
@@ -4221,7 +4224,7 @@  static int save_user_regs(CPUState *env, struct target_mcontext *frame,
     return 0;
 }
 
-static int restore_user_regs(CPUState *env,
+static int restore_user_regs(CPUPPCState *env,
                              struct target_mcontext *frame, int sig)
 {
     target_ulong save_r2 = 0;
@@ -4320,7 +4323,7 @@  static int restore_user_regs(CPUState *env,
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-                        target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUPPCState *env)
 {
     struct target_sigframe *frame;
     struct target_sigcontext *sc;
@@ -4382,7 +4385,7 @@  sigsegv:
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-                           target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUPPCState *env)
 {
     struct target_rt_sigframe *rt_sf;
     struct target_mcontext *frame;
@@ -4450,7 +4453,7 @@  sigsegv:
 
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUPPCState *env)
 {
     struct target_sigcontext *sc = NULL;
     struct target_mcontext *sr = NULL;
@@ -4493,7 +4496,7 @@  sigsegv:
 }
 
 /* See arch/powerpc/kernel/signal_32.c.  */
-static int do_setcontext(struct target_ucontext *ucp, CPUState *env, int sig)
+static int do_setcontext(struct target_ucontext *ucp, CPUPPCState *env, int sig)
 {
     struct target_mcontext *mcp;
     target_ulong mcp_addr;
@@ -4528,7 +4531,7 @@  sigsegv:
 #endif
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUPPCState *env)
 {
     struct target_rt_sigframe *rt_sf = NULL;
     target_ulong rt_sf_addr;
@@ -4617,7 +4620,8 @@  struct target_rt_sigframe
 };
 
 static int
-setup_sigcontext(struct target_sigcontext *sc, CPUState *env, abi_ulong mask)
+setup_sigcontext(struct target_sigcontext *sc, CPUM68KState *env,
+                 abi_ulong mask)
 {
     int err = 0;
 
@@ -4634,7 +4638,7 @@  setup_sigcontext(struct target_sigcontext *sc, CPUState *env, abi_ulong mask)
 }
 
 static int
-restore_sigcontext(CPUState *env, struct target_sigcontext *sc, int *pd0)
+restore_sigcontext(CPUM68KState *env, struct target_sigcontext *sc, int *pd0)
 {
     int err = 0;
     int temp;
@@ -4656,7 +4660,8 @@  restore_sigcontext(CPUState *env, struct target_sigcontext *sc, int *pd0)
  * Determine which stack to use..
  */
 static inline abi_ulong
-get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
+get_sigframe(struct target_sigaction *ka, CPUM68KState *regs,
+             size_t frame_size)
 {
     unsigned long sp;
 
@@ -4671,7 +4676,7 @@  get_sigframe(struct target_sigaction *ka, CPUState *regs, size_t frame_size)
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUM68KState *env)
 {
     struct target_sigframe *frame;
     abi_ulong frame_addr;
@@ -4725,7 +4730,7 @@  give_sigsegv:
 }
 
 static inline int target_rt_setup_ucontext(struct target_ucontext *uc,
-                                           CPUState *env)
+                                           CPUM68KState *env)
 {
     target_greg_t *gregs = uc->tuc_mcontext.gregs;
     int err;
@@ -4753,7 +4758,7 @@  static inline int target_rt_setup_ucontext(struct target_ucontext *uc,
     return err;
 }
  
-static inline int target_rt_restore_ucontext(CPUState *env,
+static inline int target_rt_restore_ucontext(CPUM68KState *env,
                                              struct target_ucontext *uc,
                                              int *pd0)
 {
@@ -4795,7 +4800,7 @@  badframe:
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUM68KState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr;
@@ -4866,7 +4871,7 @@  give_sigsegv:
     force_sig(TARGET_SIGSEGV);
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUM68KState *env)
 {
     struct target_sigframe *frame;
     abi_ulong frame_addr = env->aregs[7] - 4;
@@ -4904,7 +4909,7 @@  badframe:
     return 0;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUM68KState *env)
 {
     struct target_rt_sigframe *frame;
     abi_ulong frame_addr = env->aregs[7] - 4;
@@ -4985,7 +4990,7 @@  struct target_rt_sigframe {
 #define INSN_LDI_R0             0x201f0000
 #define INSN_CALLSYS            0x00000083
 
-static int setup_sigcontext(struct target_sigcontext *sc, CPUState *env,
+static int setup_sigcontext(struct target_sigcontext *sc, CPUAlphaState *env,
                             abi_ulong frame_addr, target_sigset_t *set)
 {
     int i, err = 0;
@@ -5013,7 +5018,8 @@  static int setup_sigcontext(struct target_sigcontext *sc, CPUState *env,
     return err;
 }
 
-static int restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
+static int restore_sigcontext(CPUAlphaState *env,
+                              struct target_sigcontext *sc)
 {
     uint64_t fpcr;
     int i, err = 0;
@@ -5034,7 +5040,8 @@  static int restore_sigcontext(CPUState *env, struct target_sigcontext *sc)
 }
 
 static inline abi_ulong get_sigframe(struct target_sigaction *sa,
-                                     CPUState *env, unsigned long framesize)
+                                     CPUAlphaState *env,
+                                     unsigned long framesize)
 {
     abi_ulong sp = env->ir[IR_SP];
 
@@ -5046,7 +5053,7 @@  static inline abi_ulong get_sigframe(struct target_sigaction *sa,
 }
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-                        target_sigset_t *set, CPUState *env)
+                        target_sigset_t *set, CPUAlphaState *env)
 {
     abi_ulong frame_addr, r26;
     struct target_sigframe *frame;
@@ -5090,7 +5097,7 @@  static void setup_frame(int sig, struct target_sigaction *ka,
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+                           target_sigset_t *set, CPUAlphaState *env)
 {
     abi_ulong frame_addr, r26;
     struct target_rt_sigframe *frame;
@@ -5144,7 +5151,7 @@  static void setup_rt_frame(int sig, struct target_sigaction *ka,
     env->ir[IR_SP] = frame_addr;
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUAlphaState *env)
 {
     struct target_sigcontext *sc;
     abi_ulong sc_addr = env->ir[IR_A0];
@@ -5174,7 +5181,7 @@  long do_sigreturn(CPUState *env)
     force_sig(TARGET_SIGSEGV);
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUAlphaState *env)
 {
     abi_ulong frame_addr = env->ir[IR_A0];
     struct target_rt_sigframe *frame;