diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-16 21:08:06 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-16 21:08:06 +0000 |
commit | 5fafdf24ef2c090c164d4dc89684b3f379dbdd87 (patch) | |
tree | c0654ee63b6dac76d98b427e92ef16850a90c652 /linux-user | |
parent | bd494f4cbd4187dda8cc8f4739763f24a31a4c8b (diff) |
find -type f | xargs sed -i 's/[\t ]$//g' # on most files
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/alpha/syscall_nr.h | 4 | ||||
-rw-r--r-- | linux-user/elfload.c | 54 | ||||
-rw-r--r-- | linux-user/flat.h | 2 | ||||
-rw-r--r-- | linux-user/flatload.c | 24 | ||||
-rw-r--r-- | linux-user/linuxload.c | 4 | ||||
-rw-r--r-- | linux-user/m68k-sim.c | 2 | ||||
-rw-r--r-- | linux-user/main.c | 110 | ||||
-rw-r--r-- | linux-user/mmap.c | 48 | ||||
-rw-r--r-- | linux-user/ppc/syscall.h | 2 | ||||
-rw-r--r-- | linux-user/ppc64/syscall.h | 8 | ||||
-rw-r--r-- | linux-user/qemu.h | 10 | ||||
-rw-r--r-- | linux-user/sh4/termbits.h | 10 | ||||
-rw-r--r-- | linux-user/signal.c | 90 | ||||
-rw-r--r-- | linux-user/sparc/termbits.h | 2 | ||||
-rw-r--r-- | linux-user/sparc64/termbits.h | 2 | ||||
-rw-r--r-- | linux-user/syscall.c | 168 | ||||
-rw-r--r-- | linux-user/syscall_defs.h | 46 | ||||
-rw-r--r-- | linux-user/syscall_types.h | 12 | ||||
-rw-r--r-- | linux-user/vm86.c | 32 | ||||
-rw-r--r-- | linux-user/x86_64/syscall_nr.h | 2 |
20 files changed, 316 insertions, 316 deletions
diff --git a/linux-user/alpha/syscall_nr.h b/linux-user/alpha/syscall_nr.h index b39b6d8dfa..139a4cfcbc 100644 --- a/linux-user/alpha/syscall_nr.h +++ b/linux-user/alpha/syscall_nr.h @@ -161,7 +161,7 @@ #define TARGET_NR_osf_fstatfs 161 #define TARGET_NR_osf_asynch_daemon 163 /* not implemented */ -#define TARGET_NR_osf_getfh 164 /* not implemented */ +#define TARGET_NR_osf_getfh 164 /* not implemented */ #define TARGET_NR_osf_getdomainname 165 #define TARGET_NR_setdomainname 166 @@ -329,7 +329,7 @@ #define TARGET_NR_lremovexattr 392 #define TARGET_NR_fremovexattr 393 #define TARGET_NR_futex 394 -#define TARGET_NR_sched_setaffinity 395 +#define TARGET_NR_sched_setaffinity 395 #define TARGET_NR_sched_getaffinity 396 #define TARGET_NR_tuxcall 397 #define TARGET_NR_io_setup 398 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 2a7bd703c5..a3d8649bae 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -577,7 +577,7 @@ unsigned long setup_arg_pages(target_ulong p, struct linux_binprm * bprm, size = x86_stack_size; if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE) size = MAX_ARG_PAGES*TARGET_PAGE_SIZE; - error = target_mmap(0, + error = target_mmap(0, size + qemu_host_page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, @@ -637,7 +637,7 @@ static void padzero(unsigned long elf_bss, unsigned long last_bss) size must be known */ if (qemu_real_host_page_size < qemu_host_page_size) { unsigned long end_addr, end_addr1; - end_addr1 = (elf_bss + qemu_real_host_page_size - 1) & + end_addr1 = (elf_bss + qemu_real_host_page_size - 1) & ~(qemu_real_host_page_size - 1); end_addr = HOST_PAGE_ALIGN(elf_bss); if (end_addr1 < end_addr) { @@ -695,7 +695,7 @@ static unsigned long create_elf_tables(target_ulong p, int argc, int envc, size *= n; if (size & 15) sp -= 16 - (size & 15); - + #define NEW_AUX_ENT(id, val) do { \ sp -= n; tputl(sp, val); \ sp -= n; tputl(sp, id); \ @@ -718,7 +718,7 @@ static unsigned long create_elf_tables(target_ulong p, int argc, int envc, if (k_platform) NEW_AUX_ENT(AT_PLATFORM, u_platform); #ifdef ARCH_DLINFO - /* + /* * ARCH_DLINFO must come last so platform specific code can enforce * special alignment requirements on the AUXV if necessary (eg. PPC). */ @@ -743,7 +743,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, unsigned long last_bss, elf_bss; unsigned long error; int i; - + elf_bss = 0; last_bss = 0; error = 0; @@ -752,24 +752,24 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, bswap_ehdr(interp_elf_ex); #endif /* First of all, some simple consistency checks */ - if ((interp_elf_ex->e_type != ET_EXEC && - interp_elf_ex->e_type != ET_DYN) || + if ((interp_elf_ex->e_type != ET_EXEC && + interp_elf_ex->e_type != ET_DYN) || !elf_check_arch(interp_elf_ex->e_machine)) { return ~0UL; } - + /* Now read in all of the header information */ - + if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > TARGET_PAGE_SIZE) return ~0UL; - - elf_phdata = (struct elf_phdr *) + + elf_phdata = (struct elf_phdr *) malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); if (!elf_phdata) return ~0UL; - + /* * If the size of this structure has changed, then punt, since * we will be doing the wrong thing. @@ -802,7 +802,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, /* in order to avoid hardcoding the interpreter load address in qemu, we allocate a big enough memory zone */ error = target_mmap(0, INTERP_MAP_SIZE, - PROT_NONE, MAP_PRIVATE | MAP_ANON, + PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); @@ -833,7 +833,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, elf_type, interpreter_fd, eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr)); - + if (error == -1) { /* Real error */ close(interpreter_fd); @@ -860,7 +860,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, k = load_addr + eppnt->p_memsz + eppnt->p_vaddr; if (k > last_bss) last_bss = k; } - + /* Now use mmap to map the library into memory. */ close(interpreter_fd); @@ -932,7 +932,7 @@ static void load_symbols(struct elfhdr *hdr, int fd) s->disas_strtab = strings = malloc(strtab.sh_size); if (!s->disas_symtab || !s->disas_strtab) return; - + lseek(fd, symtab.sh_offset, SEEK_SET); if (read(fd, s->disas_symtab, symtab.sh_size) != symtab.sh_size) return; @@ -1019,7 +1019,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, retval = lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); if(retval > 0) { - retval = read(bprm->fd, (char *) elf_phdata, + retval = read(bprm->fd, (char *) elf_phdata, elf_ex.e_phentsize * elf_ex.e_phnum); } @@ -1078,7 +1078,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, if(retval < 0) { perror("load_elf_binary2"); exit(-1); - } + } /* If the program interpreter is one of these two, then assume an iBCS2 image. Otherwise assume @@ -1199,10 +1199,10 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, int elf_prot = 0; int elf_flags = 0; unsigned long error; - + if (elf_ppnt->p_type != PT_LOAD) continue; - + if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; @@ -1216,7 +1216,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, /* NOTE: for qemu, we do a big mmap to get enough space without hardcoding any address */ error = target_mmap(0, ET_DYN_MAP_SIZE, - PROT_NONE, MAP_PRIVATE | MAP_ANON, + PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); @@ -1224,14 +1224,14 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, } load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); } - + error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), (elf_ppnt->p_filesz + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), bprm->fd, - (elf_ppnt->p_offset - + (elf_ppnt->p_offset - TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); if (error == -1) { perror("mmap"); @@ -1242,7 +1242,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); #endif - + if (!load_addr_set) { load_addr_set = 1; load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; @@ -1254,14 +1254,14 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, } } k = elf_ppnt->p_vaddr; - if (k < start_code) + if (k < start_code) start_code = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; - if (k > elf_bss) + if (k > elf_bss) elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; - if (end_data < k) + if (end_data < k) end_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; if (k > elf_brk) elf_brk = k; diff --git a/linux-user/flat.h b/linux-user/flat.h index 6d52b1ffe9..1fdba514cd 100644 --- a/linux-user/flat.h +++ b/linux-user/flat.h @@ -38,7 +38,7 @@ struct flat_hdr { target_ulong reloc_start; /* Offset of relocation records from beginning of file */ target_ulong reloc_count; /* Number of relocation records */ - target_ulong flags; + target_ulong flags; target_ulong build_date; /* When the program/library was built */ target_ulong filler[5]; /* Reservered, set to zero */ }; diff --git a/linux-user/flatload.c b/linux-user/flatload.c index bf10d7968b..8e3bf73a6c 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -359,7 +359,7 @@ void old_reloc(struct lib_info *libinfo, uint32_t rl) "(address %p, currently %x) into segment %s\n", offset, ptr, (int)*ptr, segment[reloc_type]); #endif - + switch (reloc_type) { case OLD_FLAT_RELOC_TYPE_TEXT: *ptr += libinfo->start_code; @@ -376,7 +376,7 @@ void old_reloc(struct lib_info *libinfo, uint32_t rl) break; } DBG_FLT("Relocation became %x\n", (int)*ptr); -} +} /****************************************************************************/ @@ -416,7 +416,7 @@ static int load_flat_file(struct linux_binprm * bprm, rev, (int) FLAT_VERSION); return -ENOEXEC; } - + /* Don't allow old format executables to use shared libraries */ if (rev == OLD_FLAT_VERSION && id != 0) { fprintf(stderr, "BINFMT_FLAT: shared libraries are not available\n"); @@ -463,7 +463,7 @@ static int load_flat_file(struct linux_binprm * bprm, textpos = target_mmap(0, text_len, PROT_READ|PROT_EXEC, MAP_PRIVATE, bprm->fd, 0); - if (textpos == -1) { + if (textpos == -1) { fprintf(stderr, "Unable to mmap process text\n"); return -1; } @@ -484,7 +484,7 @@ static int load_flat_file(struct linux_binprm * bprm, fpos = ntohl(hdr->data_start); #ifdef CONFIG_BINFMT_ZFLAT if (flags & FLAT_FLAG_GZDATA) { - result = decompress_exec(bprm, fpos, (char *) datapos, + result = decompress_exec(bprm, fpos, (char *) datapos, data_len + (relocs * sizeof(target_ulong))) } else #endif @@ -581,7 +581,7 @@ static int load_flat_file(struct linux_binprm * bprm, libinfo[id].loaded = 1; libinfo[id].entry = (0x00ffffff & ntohl(hdr->entry)) + textpos; libinfo[id].build_date = ntohl(hdr->build_date); - + /* * We just load the allocations into some temporary memory to * help simplify all this mumbo jumbo @@ -662,7 +662,7 @@ static int load_flat_file(struct linux_binprm * bprm, old_reloc(&libinfo[0], relval); } } - + /* zero the BSS. */ memset((void*)(datapos + data_len), 0, bss_len); @@ -732,11 +732,11 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, stack_len += (bprm->argc + 1) * 4; /* the argv array */ stack_len += (bprm->envc + 1) * 4; /* the envp array */ - + res = load_flat_file(bprm, libinfo, 0, &stack_len); if (res > (unsigned long)-4096) return res; - + /* Update data segment pointers for all libraries */ for (i=0; i<MAX_SHARED_LIBS; i++) { if (libinfo[i].loaded) { @@ -767,7 +767,7 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, if ((sp + stack_len) & 15) sp -= 16 - ((sp + stack_len) & 15); sp = loader_build_argptr(bprm->envc, bprm->argc, sp, p, 1); - + /* Fake some return addresses to ensure the call chain will * initialise library in order for us. We are required to call * lib 1 first, then 2, ... and finally the main program (id 0). @@ -784,7 +784,7 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, } } #endif - + /* Stash our initial stack pointer into the mm structure */ info->start_code = libinfo[0].start_code; info->end_code = libinfo[0].start_code = libinfo[0].text_len; @@ -798,6 +798,6 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n", (int)info->entry, (int)info->start_stack); - + return 0; } diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 34fa10d7c1..8c29f80872 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -140,7 +140,7 @@ target_ulong loader_build_argptr(int envc, int argc, target_ulong sp, return sp; } -int loader_exec(const char * filename, char ** argv, char ** envp, +int loader_exec(const char * filename, char ** argv, char ** envp, struct target_pt_regs * regs, struct image_info *infop) { struct linux_binprm bprm; @@ -182,7 +182,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp, return -1; } } - + if(retval>=0) { /* success. Initialize important registers */ do_init_thread(regs, infop); diff --git a/linux-user/m68k-sim.c b/linux-user/m68k-sim.c index 667808e8c8..aab82dd7ec 100644 --- a/linux-user/m68k-sim.c +++ b/linux-user/m68k-sim.c @@ -1,6 +1,6 @@ /* * m68k simulator syscall interface - * + * * Copyright (c) 2005 CodeSourcery, LLC. Written by Paul Brook. * * This program is free software; you can redistribute it and/or modify diff --git a/linux-user/main.c b/linux-user/main.c index edcb68b8d4..e75bb8432e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1,6 +1,6 @@ /* * qemu user main - * + * * Copyright (c) 2003 Fabrice Bellard * * This program is free software; you can redistribute it and/or modify @@ -131,7 +131,7 @@ uint64_t cpu_get_tsc(CPUX86State *env) return cpu_get_real_ticks(); } -static void write_dt(void *ptr, unsigned long addr, unsigned long limit, +static void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags) { unsigned int e1, e2; @@ -144,7 +144,7 @@ static void write_dt(void *ptr, unsigned long addr, unsigned long limit, p[1] = tswapl(e2); } -static void set_gate(void *ptr, unsigned int type, unsigned int dpl, +static void set_gate(void *ptr, unsigned int type, unsigned int dpl, unsigned long addr, unsigned int sel) { unsigned int e1, e2; @@ -176,8 +176,8 @@ void cpu_loop(CPUX86State *env) switch(trapnr) { case 0x80: /* linux syscall */ - env->regs[R_EAX] = do_syscall(env, - env->regs[R_EAX], + env->regs[R_EAX] = do_syscall(env, + env->regs[R_EAX], env->regs[R_EBX], env->regs[R_ECX], env->regs[R_EDX], @@ -293,7 +293,7 @@ void cpu_loop(CPUX86State *env) break; default: pc = env->segs[R_CS].base + env->eip; - fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n", + fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n", (long)pc, trapnr); abort(); } @@ -331,7 +331,7 @@ void cpu_loop(CPUARMState *env) unsigned int n, insn; target_siginfo_t info; uint32_t addr; - + for(;;) { trapnr = cpu_arm_exec(env); switch(trapnr) { @@ -343,7 +343,7 @@ void cpu_loop(CPUARMState *env) /* we handle the FPU emulation here, as Linux */ /* we get the opcode */ opcode = tget32(env->regs[15]); - + if (EmulateAll(opcode, &ts->fpa, env) == 0) { info.si_signo = SIGILL; info.si_errno = 0; @@ -395,8 +395,8 @@ void cpu_loop(CPUARMState *env) n -= ARM_SYSCALL_BASE; env->eabi = 0; } - env->regs[0] = do_syscall(env, - n, + env->regs[0] = do_syscall(env, + n, env->regs[0], env->regs[1], env->regs[2], @@ -443,7 +443,7 @@ void cpu_loop(CPUARMState *env) break; default: error: - fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); cpu_dump_state(env, stderr, fprintf, 0); abort(); @@ -475,10 +475,10 @@ static inline void save_window_offset(CPUSPARCState *env, int cwp1) { unsigned int i; target_ulong sp_ptr; - + sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; #if defined(DEBUG_WIN) - printf("win_overflow: sp_ptr=0x%x save_cwp=%d\n", + printf("win_overflow: sp_ptr=0x%x save_cwp=%d\n", (int)sp_ptr, cwp1); #endif for(i = 0; i < 16; i++) { @@ -506,15 +506,15 @@ static void restore_window(CPUSPARCState *env) { unsigned int new_wim, i, cwp1; target_ulong sp_ptr; - + new_wim = ((env->wim << 1) | (env->wim >> (NWINDOWS - 1))) & ((1LL << NWINDOWS) - 1); - + /* restore the invalid window */ cwp1 = (env->cwp + 1) & (NWINDOWS - 1); sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; #if defined(DEBUG_WIN) - printf("win_underflow: sp_ptr=0x%x load_cwp=%d\n", + printf("win_underflow: sp_ptr=0x%x load_cwp=%d\n", (int)sp_ptr, cwp1); #endif for(i = 0; i < 16; i++) { @@ -555,20 +555,20 @@ void cpu_loop (CPUSPARCState *env) { int trapnr, ret; target_siginfo_t info; - + while (1) { trapnr = cpu_sparc_exec (env); - + switch (trapnr) { #ifndef TARGET_SPARC64 - case 0x88: + case 0x88: case 0x90: #else case 0x16d: #endif ret = do_syscall (env, env->gregs[1], - env->regwptr[0], env->regwptr[1], - env->regwptr[2], env->regwptr[3], + env->regwptr[0], env->regwptr[1], + env->regwptr[2], env->regwptr[3], env->regwptr[4], env->regwptr[5]); if ((unsigned int)ret >= (unsigned int)(-515)) { #ifdef TARGET_SPARC64 @@ -670,17 +670,17 @@ static inline uint64_t cpu_ppc_get_tb (CPUState *env) /* TO FIX */ return 0; } - + uint32_t cpu_ppc_load_tbl (CPUState *env) { return cpu_ppc_get_tb(env) & 0xFFFFFFFF; } - + uint32_t cpu_ppc_load_tbu (CPUState *env) { return cpu_ppc_get_tb(env) >> 32; } - + static void cpu_ppc_store_tb (CPUState *env, uint64_t value) { /* TO FIX */ @@ -690,7 +690,7 @@ void cpu_ppc_store_tbu (CPUState *env, uint32_t value) { cpu_ppc_store_tb(env, ((uint64_t)value << 32) | cpu_ppc_load_tbl(env)); } - + void cpu_ppc_store_tbl (CPUState *env, uint32_t value) { cpu_ppc_store_tb(env, ((uint64_t)cpu_ppc_load_tbl(env) << 32) | value); @@ -717,7 +717,7 @@ void cpu_loop(CPUPPCState *env) target_siginfo_t info; int trapnr; uint32_t ret; - + for(;;) { trapnr = cpu_ppc_exec(env); if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH && @@ -1026,7 +1026,7 @@ void cpu_loop(CPUPPCState *env) } break; default: - fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); if (loglevel) { fprintf(logfile, "qemu: unhandled CPU exception 0x%02x - " @@ -1437,7 +1437,7 @@ void cpu_loop(CPUMIPSState *env) break; default: // error: - fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); cpu_dump_state(env, stderr, fprintf, 0); abort(); @@ -1452,19 +1452,19 @@ void cpu_loop (CPUState *env) { int trapnr, ret; target_siginfo_t info; - + while (1) { trapnr = cpu_sh4_exec (env); - + switch (trapnr) { case 0x160: - ret = do_syscall(env, - env->gregs[3], - env->gregs[4], - env->gregs[5], - env->gregs[6], - env->gregs[7], - env->gregs[0], + ret = do_syscall(env, + env->gregs[3], + env->gregs[4], + env->gregs[5], + env->gregs[6], + env->gregs[7], + env->gregs[0], 0); env->gregs[0] = ret; env->pc += 2; @@ -1501,7 +1501,7 @@ void cpu_loop(CPUM68KState *env) unsigned int n; target_siginfo_t info; TaskState *ts = env->opaque; - + for(;;) { trapnr = cpu_m68k_exec(env); switch(trapnr) { @@ -1537,8 +1537,8 @@ void cpu_loop(CPUM68KState *env) ts->sim_syscalls = 0; n = env->dregs[0]; env->pc += 2; - env->dregs[0] = do_syscall(env, - n, + env->dregs[0] = do_syscall(env, + n, env->dregs[1], env->dregs[2], env->dregs[3], @@ -1575,7 +1575,7 @@ void cpu_loop(CPUM68KState *env) } break; default: - fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", + fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); cpu_dump_state(env, stderr, fprintf, 0); abort(); @@ -1590,10 +1590,10 @@ void cpu_loop (CPUState *env) { int trapnr; target_siginfo_t info; - + while (1) { trapnr = cpu_alpha_exec (env); - + switch (trapnr) { case EXCP_RESET: fprintf(stderr, "Reset requested. Exit\n"); @@ -1608,7 +1608,7 @@ void cpu_loop (CPUState *env) exit(1); break; case EXCP_HW_INTERRUPT: - fprintf(stderr, "External interrupt. Exit\n"); + fprintf(stderr, "External interrupt. Exit\n"); exit(1); break; case EXCP_DFAULT: @@ -1695,7 +1695,7 @@ void usage(void) "-d options activate log (logfile=%s)\n" "-p pagesize set the host page size to 'pagesize'\n", TARGET_ARCH, - interp_prefix, + interp_prefix, x86_stack_size, DEBUG_LOGFILE); _exit(1); @@ -1745,7 +1745,7 @@ int main(int argc, char **argv) if (optind >= argc) break; - + r = argv[optind++]; mask = cpu_str_to_log_mask(r); if (!mask) { @@ -1794,11 +1794,11 @@ int main(int argc, char **argv) } } else if (!strcmp(r, "drop-ld-preload")) { drop_ld_preload = 1; - } else + } else #ifdef USE_CODE_COPY if (!strcmp(r, "no-code-copy")) { code_copy_enabled = 0; - } else + } else #endif { usage(); @@ -1821,7 +1821,7 @@ int main(int argc, char **argv) qemu_host_page_size */ env = cpu_init(); global_env = env; - + wrk = environ; while (*(wrk++)) environ_count++; @@ -1844,12 +1844,12 @@ int main(int argc, char **argv) for (wrk = target_environ; *wrk; wrk++) { free(*wrk); } - + free(target_environ); if (loglevel) { page_dump(logfile); - + fprintf(logfile, "start_brk 0x%08lx\n" , info->start_brk); fprintf(logfile, "end_code 0x%08lx\n" , info->end_code); fprintf(logfile, "start_code 0x%08lx\n" , info->start_code); @@ -1870,7 +1870,7 @@ int main(int argc, char **argv) ts->used = 1; ts->info = info; env->user_mode_only = 1; - + #if defined(TARGET_I386) cpu_x86_set_cpl(env, 3); @@ -1883,7 +1883,7 @@ int main(int argc, char **argv) /* flags setup : we activate the IRQs by default as in user mode */ env->eflags |= IF_MASK; - + /* linux register setup */ #if defined(TARGET_X86_64) env->regs[R_EAX] = regs->rax; @@ -1936,10 +1936,10 @@ int main(int argc, char **argv) env->gdt.base = h2g(gdt_table); env->gdt.limit = sizeof(gdt_table) - 1; write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, - DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | + DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff, - DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | + DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT)); cpu_x86_load_seg(env, R_CS, __USER_CS); cpu_x86_load_seg(env, R_DS, __USER_DS); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index bfecb7a545..3eb930e7b0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1,6 +1,6 @@ /* * mmap support for qemu - * + * * Copyright (c) 2003 Fabrice Bellard * * This program is free software; you can redistribute it and/or modify @@ -52,7 +52,7 @@ int target_mprotect(target_ulong start, target_ulong len, int prot) return -EINVAL; if (len == 0) return 0; - + host_start = start & qemu_host_page_mask; host_end = HOST_PAGE_ALIGN(end); if (start > host_start) { @@ -77,13 +77,13 @@ int target_mprotect(target_ulong start, target_ulong len, int prot) for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { prot1 |= page_get_flags(addr); } - ret = mprotect(g2h(host_end - qemu_host_page_size), qemu_host_page_size, + ret = mprotect(g2h(host_end - qemu_host_page_size), qemu_host_page_size, prot1 & PAGE_BITS); if (ret != 0) return ret; host_end -= qemu_host_page_size; } - + /* handle the pages in the middle */ if (host_start < host_end) { ret = mprotect(g2h(host_start), host_end - host_start, prot); @@ -95,8 +95,8 @@ int target_mprotect(target_ulong start, target_ulong len, int prot) } /* map an incomplete host page */ -static int mmap_frag(target_ulong real_start, - target_ulong start, target_ulong end, +static int mmap_frag(target_ulong real_start, + target_ulong start, target_ulong end, int prot, int flags, int fd, target_ulong offset) { target_ulong real_end, ret, addr; @@ -112,10 +112,10 @@ static int mmap_frag(target_ulong real_start, if (addr < start || addr >= end) prot1 |= page_get_flags(addr); } - + if (prot1 == 0) { /* no page was there, so we allocate one */ - ret = (long)mmap(host_start, qemu_host_page_size, prot, + ret = (long)mmap(host_start, qemu_host_page_size, prot, flags | MAP_ANONYMOUS, -1, 0); if (ret == -1) return ret; @@ -134,10 +134,10 @@ static int mmap_frag(target_ulong real_start, /* adjust protection to be able to read */ if (!(prot1 & PROT_WRITE)) mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); - + /* read the corresponding file data */ pread(fd, g2h(start), end - start, offset); - + /* put final protection */ if (prot_new != (prot1 | PROT_WRITE)) mprotect(host_start, qemu_host_page_size, prot_new); @@ -151,7 +151,7 @@ static int mmap_frag(target_ulong real_start, } /* NOTE: all the constants are the HOST ones */ -long target_mmap(target_ulong start, target_ulong len, int prot, +long target_mmap(target_ulong start, target_ulong len, int prot, int flags, int fd, target_ulong offset) { target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; @@ -167,7 +167,7 @@ long target_mmap(target_ulong start, target_ulong len, int prot, #ifdef DEBUG_MMAP { printf("mmap: start=0x%lx len=0x%lx prot=%c%c%c flags=", - start, len, + start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); @@ -216,7 +216,7 @@ long target_mmap(target_ulong start, target_ulong len, int prot, /* ??? This needs fixing for remapping. */ abort(); host_len = HOST_PAGE_ALIGN(len) + qemu_host_page_size - TARGET_PAGE_SIZE; - real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, + real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; @@ -238,13 +238,13 @@ abort(); if (host_start == -1) return host_start; /* update start so that it points to the file position at 'offset' */ - if (!(flags & MAP_ANONYMOUS)) + if (!(flags & MAP_ANONYMOUS)) host_start += offset - host_offset; start = h2g(host_start); goto the_end1; } } - + if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; @@ -263,8 +263,8 @@ abort(); errno = EINVAL; return -1; } - retaddr = target_mmap(start, len, prot | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, + retaddr = target_mmap(start, len, prot | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) return retaddr; @@ -295,15 +295,15 @@ abort(); } /* handle the end of the mapping */ if (end < real_end) { - ret = mmap_frag(real_end - qemu_host_page_size, + ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, real_end, - prot, flags, fd, + prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) return ret; real_end -= qemu_host_page_size; } - + /* map the middle (easier) */ if (real_start < real_end) { unsigned long offset1; @@ -311,7 +311,7 @@ abort(); offset1 = 0; else offset1 = offset + real_start - start; - ret = (long)mmap(g2h(real_start), real_end - real_start, + ret = (long)mmap(g2h(real_start), real_end - real_start, prot, flags, fd, offset1); if (ret == -1) return ret; @@ -367,7 +367,7 @@ int target_munmap(target_ulong start, target_ulong len) if (prot != 0) real_end -= qemu_host_page_size; } - + /* unmap what we can */ if (real_start < real_end) { ret = munmap((void *)real_start, real_end - real_start); @@ -381,7 +381,7 @@ int target_munmap(target_ulong start, target_ulong len) /* XXX: currently, we only handle MAP_ANONYMOUS and not MAP_FIXED blocks which have been allocated starting on a host page */ -long target_mremap(target_ulong old_addr, target_ulong old_size, +long target_mremap(target_ulong old_addr, target_ulong old_size, target_ulong new_size, unsigned long flags, target_ulong new_addr) { @@ -410,7 +410,7 @@ int target_msync(target_ulong start, target_ulong len, int flags) return -EINVAL; if (end == start) return 0; - + start &= qemu_host_page_mask; return msync(g2h(start), end - start, flags); } diff --git a/linux-user/ppc/syscall.h b/linux-user/ppc/syscall.h index d150af44cb..bf6b21b2f6 100644 --- a/linux-user/ppc/syscall.h +++ b/linux-user/ppc/syscall.h @@ -1,6 +1,6 @@ /* * PPC emulation for qemu: syscall definitions. - * + * * Copyright (c) 2003 Jocelyn Mayer * * This library is free software; you can redistribute it and/or diff --git a/linux-user/ppc64/syscall.h b/linux-user/ppc64/syscall.h index eea8a7c9ab..6920616410 100644 --- a/linux-user/ppc64/syscall.h +++ b/linux-user/ppc64/syscall.h @@ -1,6 +1,6 @@ /* * PPC emulation for qemu: syscall definitions. - * + * * Copyright (c) 2003 Jocelyn Mayer * * This library is free software; you can redistribute it and/or @@ -55,8 +55,8 @@ struct target_revectored_struct { #define TARGET_SEMOP 1 #define TARGET_SEMGET 2 -#define TARGET_SEMCTL 3 -#define TARGET_MSGSND 11 +#define TARGET_SEMCTL 3 +#define TARGET_MSGSND 11 #define TARGET_MSGRCV 12 #define TARGET_MSGGET 13 #define TARGET_MSGCTL 14 @@ -73,7 +73,7 @@ struct target_msgbuf { struct target_ipc_kludge { unsigned int msgp; /* Really (struct msgbuf *) */ int msgtyp; -}; +}; struct target_ipc_perm { int key; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 076145e1af..011b41ea7e 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -97,7 +97,7 @@ extern const char *qemu_uname_release; #define MAX_ARG_PAGES 32 /* - * This structure is used to hold the arguments that are + * This structure is used to hold the arguments that are * used when loading binaries. */ struct linux_binprm { @@ -115,7 +115,7 @@ struct linux_binprm { void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); target_ulong loader_build_argptr(int envc, int argc, target_ulong sp, target_ulong stringp, int push_ptr); -int loader_exec(const char * filename, char ** argv, char ** envp, +int loader_exec(const char * filename, char ** argv, char ** envp, struct target_pt_regs * regs, struct image_info *infop); int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, @@ -128,7 +128,7 @@ void memcpy_to_target(target_ulong dest, const void *src, void target_set_brk(target_ulong new_brk); long do_brk(target_ulong new_brk); void syscall_init(void); -long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, +long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6); void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); extern CPUState *global_env; @@ -158,10 +158,10 @@ int do_vm86(CPUX86State *env, long subfunction, target_ulong v86_addr); /* mmap.c */ int target_mprotect(target_ulong start, target_ulong len, int prot); -long target_mmap(target_ulong start, target_ulong len, int prot, +long target_mmap(target_ulong start, target_ulong len, int prot, int flags, int fd, target_ulong offset); int target_munmap(target_ulong start, target_ulong len); -long target_mremap(target_ulong old_addr, target_ulong old_size, +long target_mremap(target_ulong old_addr, target_ulong old_size, target_ulong new_size, unsigned long flags, target_ulong new_addr); int target_msync(target_ulong start, target_ulong len, int flags); diff --git a/linux-user/sh4/termbits.h b/linux-user/sh4/termbits.h index 6dd5845bc9..2ff774f6ba 100644 --- a/linux-user/sh4/termbits.h +++ b/linux-user/sh4/termbits.h @@ -245,7 +245,7 @@ struct target_termios { ndbreak() */ #define TARGET_TIOCSBRK TARGET_IO('T', 39) /* 0x5427 */ /* BSD compatibility */ #define TARGET_TIOCCBRK TARGET_IO('T', 40) /* 0x5428 */ /* BSD compatibility */ -#define TARGET_TIOCGSID TARGET_IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session +#define TARGET_TIOCGSID TARGET_IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */ #define TARGET_TIOCGPTN TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-m ux device) */ @@ -263,12 +263,12 @@ ebugging only */ tus register */ /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ # define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ -#define TARGET_TIOCSERGETMULTI TARGET_IOR('T', 90, int) /* 0x545A +#define TARGET_TIOCSERGETMULTI TARGET_IOR('T', 90, int) /* 0x545A */ /* Get multiport config */ -#define TARGET_TIOCSERSETMULTI TARGET_IOW('T', 91, int) /* 0x545B +#define TARGET_TIOCSERSETMULTI TARGET_IOW('T', 91, int) /* 0x545B */ /* Set multiport config */ -#define TARGET_TIOCMIWAIT TARGET_IO('T', 92) /* 0x545C */ /* wait for a change on +#define TARGET_TIOCMIWAIT TARGET_IO('T', 92) /* 0x545C */ /* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT TARGET_IOR('T', 93, int) /* 0x545D */ /* read +#define TARGET_TIOCGICOUNT TARGET_IOR('T', 93, int) /* 0x545D */ /* read serial port inline interrupt counts */ diff --git a/linux-user/signal.c b/linux-user/signal.c index f73d50516f..73b6dadc99 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1,6 +1,6 @@ /* * Emulation of Linux signals - * + * * Copyright (c) 2003 Fabrice Bellard * * This program is free software; you can redistribute it and/or modify @@ -50,7 +50,7 @@ static struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */ static struct sigqueue *first_free; /* first free siginfo queue entry */ static int signal_pending; /* non zero if a signal may be pending */ -static void host_signal_handler(int host_signum, siginfo_t *info, +static void host_signal_handler(int host_signum, siginfo_t *info, void *puc); static uint8_t host_to_target_signal_table[65] = { @@ -102,17 +102,17 @@ static inline int target_to_host_signal(int sig) return target_to_host_signal_table[sig]; } -static void host_to_target_sigset_internal(target_sigset_t *d, +static void host_to_target_sigset_internal(target_sigset_t *d, const sigset_t *s) { int i; unsigned long sigmask; uint32_t target_sigmask; - + sigmask = ((unsigned long *)s)[0]; target_sigmask = 0; for(i = 0; i < 32; i++) { - if (sigmask & (1 << i)) + if (sigmask & (1 << i)) target_sigmask |= 1 << (host_to_target_signal(i + 1) - 1); } #if TARGET_LONG_BITS == 32 && HOST_LONG_BITS == 32 @@ -147,7 +147,7 @@ void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s) target_sigmask = s->sig[0]; sigmask = 0; for(i = 0; i < 32; i++) { - if (target_sigmask & (1 << i)) + if (target_sigmask & (1 << i)) sigmask |= 1 << (target_to_host_signal(i + 1) - 1); } #if TARGET_LONG_BITS == 32 && HOST_LONG_BITS == 32 @@ -171,8 +171,8 @@ void target_to_host_sigset(sigset_t *d, const target_sigset_t *s) s1.sig[i] = tswapl(s->sig[i]); target_to_host_sigset_internal(d, &s1); } - -void host_to_target_old_sigset(target_ulong *old_sigset, + +void host_to_target_old_sigset(target_ulong *old_sigset, const sigset_t *sigset) { target_sigset_t d; @@ -180,7 +180,7 @@ void host_to_target_old_sigset(target_ulong *old_sigset, *old_sigset = d.sig[0]; } -void target_to_host_old_sigset(sigset_t *sigset, +void target_to_host_old_sigset(sigset_t *sigset, const target_ulong *old_sigset) { target_sigset_t d; @@ -194,7 +194,7 @@ void target_to_host_old_sigset(sigset_t *sigset, /* siginfo conversion */ -static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, +static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, const siginfo_t *info) { int sig; @@ -202,7 +202,7 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, tinfo->si_signo = sig; tinfo->si_errno = 0; tinfo->si_code = 0; - if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || + if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) { /* should never come here, but who knows. The information for the target is irrelevant */ @@ -213,12 +213,12 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, tinfo->_sifields._rt._pid = info->si_pid; tinfo->_sifields._rt._uid = info->si_uid; /* XXX: potential problem if 64 bit */ - tinfo->_sifields._rt._sigval.sival_ptr = + tinfo->_sifields._rt._sigval.sival_ptr = (target_ulong)info->si_value.sival_ptr; } } -static void tswap_siginfo(target_siginfo_t *tinfo, +static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t *info) { int sig; @@ -226,16 +226,16 @@ static void tswap_siginfo(target_siginfo_t *tinfo, tinfo->si_signo = tswap32(sig); tinfo->si_errno = tswap32(info->si_errno); tinfo->si_code = tswap32(info->si_code); - if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || + if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) { - tinfo->_sifields._sigfault._addr = + tinfo->_sifields._sigfault._addr = tswapl(info->_sifields._sigfault._addr); } else if (sig == SIGIO) { tinfo->_sifields._sigpoll._fd = tswap32(info->_sifields._sigpoll._fd); } else if (sig >= TARGET_SIGRTMIN) { tinfo->_sifields._rt._pid = tswap32(info->_sifields._rt._pid); tinfo->_sifields._rt._uid = tswap32(info->_sifields._rt._uid); - tinfo->_sifields._rt._sigval.sival_ptr = + tinfo->_sifields._rt._sigval.sival_ptr = tswapl(info->_sifields._rt._sigval.sival_ptr); } } @@ -256,7 +256,7 @@ void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo) info->si_code = tswap32(tinfo->si_code); info->si_pid = tswap32(tinfo->_sifields._rt._pid); info->si_uid = tswap32(tinfo->_sifields._rt._uid); - info->si_value.sival_ptr = + info->si_value.sival_ptr = (void *)tswapl(tinfo->_sifields._rt._sigval.sival_ptr); } @@ -274,7 +274,7 @@ void signal_init(void) j = host_to_target_signal_table[i]; target_to_host_signal_table[j] = i; } - + /* set all host signal handlers. ALL signals are blocked during the handlers to serialize them. */ sigfillset(&act.sa_mask); @@ -283,11 +283,11 @@ void signal_init(void) for(i = 1; i < NSIG; i++) { sigaction(i, &act, NULL); } - + memset(sigact_table, 0, sizeof(sigact_table)); first_free = &sigqueue_table[0]; - for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) + for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) sigqueue_table[i].next = &sigqueue_table[i + 1]; sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL; } @@ -314,7 +314,7 @@ void __attribute((noreturn)) force_sig(int sig) { int host_sig; host_sig = target_to_host_signal(sig); - fprintf(stderr, "qemu: uncaught target signal %d (%s) - exiting\n", + fprintf(stderr, "qemu: uncaught target signal %d (%s) - exiting\n", sig, strsignal(host_sig)); #if 1 _exit(-host_sig); @@ -339,15 +339,15 @@ int queue_signal(int sig, target_siginfo_t *info) target_ulong handler; #if defined(DEBUG_SIGNAL) - fprintf(stderr, "queue_signal: sig=%d\n", + fprintf(stderr, "queue_signal: sig=%d\n", sig); #endif k = &sigact_table[sig - 1]; handler = k->sa._sa_handler; if (handler == TARGET_SIG_DFL) { /* default handler : ignore some signal. The other are fatal */ - if (sig != TARGET_SIGCHLD && - sig != TARGET_SIGURG && + if (sig != TARGET_SIGCHLD && + sig != TARGET_SIGURG && sig != TARGET_SIGWINCH) { force_sig(sig); } else { @@ -388,7 +388,7 @@ int queue_signal(int sig, target_siginfo_t *info) } } -static void host_signal_handler(int host_signum, siginfo_t *info, +static void host_signal_handler(int host_signum, siginfo_t *info, void *puc) { int sig; @@ -396,7 +396,7 @@ static void host_signal_handler(int host_signum, siginfo_t *info, /* the CPU emulator uses some host signals to detect exceptions, we we forward to it some signals */ - if (host_signum == SIGSEGV || host_signum == SIGBUS + if (host_signum == SIGSEGV || host_signum == SIGBUS #if defined(TARGET_I386) && defined(USE_CODE_COPY) || host_signum == SIGFPE #endif @@ -430,7 +430,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, return -EINVAL; k = &sigact_table[sig - 1]; #if defined(DEBUG_SIGNAL) - fprintf(stderr, "sigaction sig=%d act=0x%08x, oact=0x%08x\n", + fprintf(stderr, "sigaction sig=%d act=0x%08x, oact=0x%08x\n", sig, (int)act, (int)oact); #endif if (oact) { @@ -476,7 +476,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, #define offsetof(type, field) ((size_t) &((type *)0)->field) #endif -static inline int copy_siginfo_to_user(target_siginfo_t *tinfo, +static inline int copy_siginfo_to_user(target_siginfo_t *tinfo, const target_siginfo_t *info) { tswap_siginfo(tinfo, info); @@ -648,7 +648,7 @@ get_sigframe(struct emulated_sigaction *ka, CPUX86State *env, size_t frame_size) } /* This is the legacy signal stack switching. */ - else + else #endif if ((env->segs[R_SS].selector & 0xffff) != __USER_DS && !(ka->sa.sa_flags & TARGET_SA_RESTORER) && @@ -723,7 +723,7 @@ give_sigsegv: force_sig(TARGET_SIGSEGV /* , current */); } -static void setup_rt_frame(int sig, struct emulated_sigaction *ka, +static void setup_rt_frame(int sig, struct emulated_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUX86State *env) { @@ -817,7 +817,7 @@ restore_sigcontext(CPUX86State *env, struct target_sigcontext *sc, int *peax) cpu_x86_load_seg(env, R_CS, lduw(&sc->cs) | 3); cpu_x86_load_seg(env, R_SS, lduw(&sc->ss) | 3); - + { unsigned int tmpflags; tmpflags = ldl(&sc->eflags); @@ -865,7 +865,7 @@ long do_sigreturn(CPUX86State *env) target_to_host_sigset_internal(&set, &target_set); sigprocmask(SIG_SETMASK, &set, NULL); - + /* restore registers */ if (restore_sigcontext(env, &frame->sc, &eax)) goto badframe; @@ -889,7 +889,7 @@ long do_rt_sigreturn(CPUX86State *env) #endif target_to_host_sigset(&set, &frame->uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &set, NULL); - + if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax)) goto badframe; @@ -1127,7 +1127,7 @@ static void setup_frame(int usig, struct emulated_sigaction *ka, // return err; } -static void setup_rt_frame(int usig, struct emulated_sigaction *ka, +static void setup_rt_frame(int usig, struct emulated_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUState *env) { @@ -1547,7 +1547,7 @@ restore_fpu_state(CPUState *env, qemu_siginfo_fpu_t *fpu) } -static void setup_rt_frame(int sig, struct emulated_sigaction *ka, +static void setup_rt_frame(int sig, struct emulated_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUState *env) { @@ -1851,7 +1851,7 @@ get_sigframe(struct emulated_sigaction *ka, CPUState *regs, size_t frame_size) return g2h((sp - frame_size) & ~7); } -static void setup_frame(int sig, struct emulated_sigaction * ka, +static void setup_frame(int sig, struct emulated_sigaction * ka, target_sigset_t *set, CPUState *regs) { struct sigframe *frame; @@ -1894,7 +1894,7 @@ static void setup_frame(int sig, struct emulated_sigaction * ka, give_sigsegv: force_sig(TARGET_SIGSEGV/*, current*/); - return; + return; } long do_sigreturn(CPUState *regs) @@ -1933,7 +1933,7 @@ long do_sigreturn(CPUState *regs) :"r" (®s)); /* Unreached */ #endif - + regs->PC[regs->current_tc] = regs->CP0_EPC; /* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ @@ -1945,7 +1945,7 @@ badframe: return 0; } -static void setup_rt_frame(int sig, struct emulated_sigaction *ka, +static void setup_rt_frame(int sig, struct emulated_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUState *env) { @@ -1966,7 +1966,7 @@ static void setup_frame(int sig, struct emulated_sigaction *ka, fprintf(stderr, "setup_frame: not implemented\n"); } -static void setup_rt_frame(int sig, struct emulated_sigaction *ka, +static void setup_rt_frame(int sig, struct emulated_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUState *env) { @@ -1995,7 +1995,7 @@ void process_pending_signals(void *cpu_env) target_sigset_t target_old_set; struct emulated_sigaction *k; struct sigqueue *q; - + if (!signal_pending) return; @@ -2018,7 +2018,7 @@ void process_pending_signals(void *cpu_env) k->first = q->next; if (!k->first) k->pending = 0; - + sig = gdb_handlesig (cpu_env, sig); if (!sig) { fprintf (stderr, "Lost signal\n"); @@ -2028,8 +2028,8 @@ void process_pending_signals(void *cpu_env) handler = k->sa._sa_handler; if (handler == TARGET_SIG_DFL) { /* default handler : ignore some signal. The other are fatal */ - if (sig != TARGET_SIGCHLD && - sig != TARGET_SIGURG && + if (sig != TARGET_SIGCHLD && + sig != TARGET_SIGURG && sig != TARGET_SIGWINCH) { force_sig(sig); } @@ -2044,7 +2044,7 @@ void process_pending_signals(void *cpu_env) blocked during the handler */ if (!(k->sa.sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); - + /* block signals in the handler using Linux */ sigprocmask(SIG_BLOCK, &set, &old_set); /* save the previous blocked signal state to restore it at the diff --git a/linux-user/sparc/termbits.h b/linux-user/sparc/termbits.h index cad45b2925..3ec8e97c79 100644 --- a/linux-user/sparc/termbits.h +++ b/linux-user/sparc/termbits.h @@ -182,7 +182,7 @@ struct target_termios { #define TARGET_TCSETSW TARGET_IOW('T', 10, struct target_termios) #define TARGET_TCSETSF TARGET_IOW('T', 11, struct target_termios) -/* Note that all the ioctls that are not available in Linux have a +/* Note that all the ioctls that are not available in Linux have a * double underscore on the front to: a) avoid some programs to * thing we support some ioctls under Linux (autoconfiguration stuff) */ diff --git a/linux-user/sparc64/termbits.h b/linux-user/sparc64/termbits.h index cad45b2925..3ec8e97c79 100644 --- a/linux-user/sparc64/termbits.h +++ b/linux-user/sparc64/termbits.h @@ -182,7 +182,7 @@ struct target_termios { #define TARGET_TCSETSW TARGET_IOW('T', 10, struct target_termios) #define TARGET_TCSETSF TARGET_IOW('T', 11, struct target_termios) -/* Note that all the ioctls that are not available in Linux have a +/* Note that all the ioctls that are not available in Linux have a * double underscore on the front to: a) avoid some programs to * thing we support some ioctls under Linux (autoconfiguration stuff) */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cd956aa1ac..a924490772 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1,6 +1,6 @@ /* * Linux syscalls - * + * * Copyright (c) 2003 Fabrice Bellard * * This program is free software; you can redistribute it and/or modify @@ -339,7 +339,7 @@ long do_brk(target_ulong new_brk) return target_brk; if (new_brk < target_original_brk) return -ENOMEM; - + brk_page = HOST_PAGE_ALIGN(target_brk); /* If the new brk is less than this, set it and we're done... */ @@ -350,7 +350,7 @@ long do_brk(target_ulong new_brk) /* We need to allocate more memory after the brk... */ new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page + 1); - mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, + mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, 0, 0)); if (is_error(mapped_addr)) { @@ -361,7 +361,7 @@ long do_brk(target_ulong new_brk) } } -static inline fd_set *target_to_host_fds(fd_set *fds, +static inline fd_set *target_to_host_fds(fd_set *fds, target_long *target_fds, int n) { #if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN) @@ -383,7 +383,7 @@ static inline fd_set *target_to_host_fds(fd_set *fds, #endif } -static inline void host_to_target_fds(target_long *target_fds, +static inline void host_to_target_fds(target_long *target_fds, fd_set *fds, int n) { #if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN) @@ -472,8 +472,8 @@ static inline void host_to_target_timeval(target_ulong target_addr, } -static long do_select(long n, - target_ulong rfd_p, target_ulong wfd_p, +static long do_select(long n, + target_ulong rfd_p, target_ulong wfd_p, target_ulong efd_p, target_ulong target_tv) { fd_set rfds, wfds, efds; @@ -504,7 +504,7 @@ static long do_select(long n, target_efds = NULL; efds_ptr = NULL; } - + if (target_tv) { target_to_host_timeval(&tv, target_tv); tv_ptr = &tv; @@ -569,7 +569,7 @@ static inline void target_to_host_cmsg(struct msghdr *msgh, void *data = CMSG_DATA(cmsg); void *target_data = TARGET_CMSG_DATA(target_cmsg); - int len = tswapl(target_cmsg->cmsg_len) + int len = tswapl(target_cmsg->cmsg_len) - TARGET_CMSG_ALIGN(sizeof (struct target_cmsghdr)); space += CMSG_SPACE(len); @@ -646,17 +646,17 @@ static inline void host_to_target_cmsg(struct target_msghdr *target_msgh, msgh->msg_controllen = tswapl(space); } -static long do_setsockopt(int sockfd, int level, int optname, +static long do_setsockopt(int sockfd, int level, int optname, target_ulong optval, socklen_t optlen) { int val, ret; - + switch(level) { case SOL_TCP: /* TCP options all take an 'int' value. */ if (optlen < sizeof(uint32_t)) return -EINVAL; - + val = tget32(optval); ret = get_errno(setsockopt(sockfd, level, optname, &val, sizeof(val))); break; @@ -766,7 +766,7 @@ static long do_setsockopt(int sockfd, int level, int optname, return ret; } -static long do_getsockopt(int sockfd, int level, int optname, +static long do_getsockopt(int sockfd, int level, int optname, target_ulong optval, target_ulong optlen) { int len, lv, val, ret; @@ -916,7 +916,7 @@ static long do_bind(int sockfd, target_ulong target_addr, socklen_t addrlen) { void *addr = alloca(addrlen); - + target_to_host_sockaddr(addr, target_addr, addrlen); return get_errno(bind(sockfd, addr, addrlen)); } @@ -925,7 +925,7 @@ static long do_connect(int sockfd, target_ulong target_addr, socklen_t addrlen) { void *addr = alloca(addrlen); - + target_to_host_sockaddr(addr, target_addr, addrlen); return get_errno(connect(sockfd, addr, addrlen)); } @@ -953,14 +953,14 @@ static long do_sendrecvmsg(int fd, target_ulong target_msg, msg.msg_controllen = 2 * tswapl(msgp->msg_controllen); msg.msg_control = alloca(msg.msg_controllen); msg.msg_flags = tswap32(msgp->msg_flags); - + count = tswapl(msgp->msg_iovlen); vec = alloca(count * sizeof(struct iovec)); target_vec = tswapl(msgp->msg_iov); lock_iovec(vec, target_vec, count, send); msg.msg_iovlen = count; msg.msg_iov = vec; - + if (send) { target_to_host_cmsg(&msg, msgp); ret = get_errno(sendmsg(fd, &msg, flags)); @@ -1209,7 +1209,7 @@ static long do_socketcall(int num, target_ulong vptr) target_msg = tgetl(vptr + n); flags = tgetl(vptr + 2 * n); - ret = do_sendrecvmsg(fd, target_msg, flags, + ret = do_sendrecvmsg(fd, target_msg, flags, (num == SOCKOP_sendmsg)); } break; @@ -1634,7 +1634,7 @@ static long do_ipc(long call, long first, long second, long third, break; raddr = ret; /* find out the length of the shared memory segment */ - + ret = get_errno(shmctl(first, IPC_STAT, &shm_info)); if (is_error(ret)) { /* can't get length, bail out */ @@ -1908,51 +1908,51 @@ static void target_to_host_termios (void *dst, const void *src) { struct host_termios *host = dst; const struct target_termios *target = src; - - host->c_iflag = + + host->c_iflag = target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl); - host->c_oflag = + host->c_oflag = target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl); - host->c_cflag = + host->c_cflag = target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl); - host->c_lflag = + host->c_lflag = target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); host->c_line = target->c_line; - - host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; - host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; - host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; - host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; - host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; - host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; - host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; - host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; - host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; - host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; - host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; - host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; - host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; - host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; - host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; - host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; - host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; + + host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; + host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; + host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; + host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; + host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; + host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; + host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; + host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; + host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; + host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; + host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; + host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; + host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; + host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; + host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; + host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; + host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; } - + static void host_to_target_termios (void *dst, const void *src) { struct target_termios *target = dst; const struct host_termios *host = src; - target->c_iflag = + target->c_iflag = tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl)); - target->c_oflag = + target->c_oflag = tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl)); - target->c_cflag = + target->c_cflag = tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl)); - target->c_lflag = + target->c_lflag = tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); target->c_line = host->c_line; - + target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; @@ -2033,7 +2033,7 @@ static int read_ldt(target_ulong ptr, unsigned long bytecount) } /* XXX: add locking support */ -static int write_ldt(CPUX86State *env, +static int write_ldt(CPUX86State *env, target_ulong ptr, unsigned long bytecount, int oldmode) { struct target_modify_ldt_ldt_s ldt_info; @@ -2050,7 +2050,7 @@ static int write_ldt(CPUX86State *env, ldt_info.limit = tswap32(target_ldt_info->limit); ldt_info.flags = tswap32(target_ldt_info->flags); unlock_user_struct(target_ldt_info, ptr, 0); - + if (ldt_info.entry_number >= TARGET_LDT_ENTRIES) return -EINVAL; seg_32bit = ldt_info.flags & 1; @@ -2091,7 +2091,7 @@ static int write_ldt(CPUX86State *env, goto install; } } - + entry_1 = ((ldt_info.base_addr & 0x0000ffff) << 16) | (ldt_info.limit & 0x0ffff); entry_2 = (ldt_info.base_addr & 0xff000000) | @@ -2118,7 +2118,7 @@ install: int do_modify_ldt(CPUX86State *env, int func, target_ulong ptr, unsigned long bytecount) { int ret = -ENOSYS; - + switch (func) { case 0: ret = read_ldt(ptr, bytecount); @@ -2153,7 +2153,7 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp) TaskState *ts; uint8_t *new_stack; CPUState *new_env; - + if (flags & CLONE_VM) { ts = malloc(sizeof(TaskState) + NEW_STACK_SIZE); memset(ts, 0, sizeof(TaskState)); @@ -2195,7 +2195,7 @@ int do_fork(CPUState *env, unsigned int flags, unsigned long newsp) if (!newsp) newsp = env->gpr[1]; new_env->gpr[1] = newsp; - { + { int i; for (i = 7; i < 32; i++) new_env->gpr[i] = 0; @@ -2261,7 +2261,7 @@ static long do_fcntl(int fd, int cmd, target_ulong arg) unlock_user_struct(target_fl, arg, 1); } break; - + case TARGET_F_SETLK: case TARGET_F_SETLKW: lock_user_struct(target_fl, arg, 1); @@ -2273,7 +2273,7 @@ static long do_fcntl(int fd, int cmd, target_ulong arg) unlock_user_struct(target_fl, arg, 0); ret = fcntl(fd, cmd, &fl); break; - + case TARGET_F_GETLK64: lock_user_struct(target_fl64, arg, 1); fl64.l_type = tswap16(target_fl64->l_type) >> 1; @@ -2363,8 +2363,8 @@ void syscall_init(void) const argtype *arg_type; int size; -#define STRUCT(name, list...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); -#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def); +#define STRUCT(name, list...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); +#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def); #include "syscall_types.h" #undef STRUCT #undef STRUCT_SPECIAL @@ -2377,20 +2377,20 @@ void syscall_init(void) TARGET_IOC_SIZEMASK) { arg_type = ie->arg_type; if (arg_type[0] != TYPE_PTR) { - fprintf(stderr, "cannot patch size for ioctl 0x%x\n", + fprintf(stderr, "cannot patch size for ioctl 0x%x\n", ie->target_cmd); exit(1); } arg_type++; size = thunk_type_size(arg_type, 0); - ie->target_cmd = (ie->target_cmd & + ie->target_cmd = (ie->target_cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) | (size << TARGET_IOC_SIZESHIFT); } /* automatic consistency check if same arch */ #if defined(__i386__) && defined(TARGET_I386) if (ie->target_cmd != ie->host_cmd) { - fprintf(stderr, "ERROR: ioctl: target=0x%x host=0x%x\n", + fprintf(stderr, "ERROR: ioctl: target=0x%x host=0x%x\n", ie->target_cmd, ie->host_cmd); } #endif @@ -2459,14 +2459,14 @@ static inline void host_to_target_timespec(target_ulong target_addr, unlock_user_struct(target_ts, target_addr, 1); } -long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, +long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) { long ret; struct stat st; struct statfs stfs; void *p; - + #ifdef DEBUG gemu_log("syscall %d", num); #endif @@ -2978,7 +2978,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, { int how = arg1; sigset_t set, oldset, *set_ptr; - + if (arg2) { switch(how) { case TARGET_SIG_BLOCK: @@ -3015,7 +3015,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, { int how = arg1; sigset_t set, oldset, *set_ptr; - + if (arg2) { switch(how) { case TARGET_SIG_BLOCK: @@ -3096,7 +3096,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, sigset_t set; struct timespec uts, *puts; siginfo_t uinfo; - + p = lock_user(arg1, sizeof(target_sigset_t), 1); target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); @@ -3157,7 +3157,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, int resource = arg1; struct target_rlimit *target_rlim; struct rlimit rlim; - + ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { lock_user_struct(target_rlim, arg2, 0); @@ -3265,13 +3265,13 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, v5 = tswapl(v[4]); v6 = tswapl(v[5]); unlock_user(v, arg1, 0); - ret = get_errno(target_mmap(v1, v2, v3, + ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), v5, v6)); } #else - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), + ret = get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6)); #endif @@ -3284,8 +3284,8 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, #else #define MMAP_SHIFT TARGET_PAGE_BITS #endif - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), + ret = get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), arg5, arg6 << MMAP_SHIFT)); break; @@ -3355,7 +3355,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, convert_statfs: if (!is_error(ret)) { struct target_statfs *target_stfs; - + lock_user_struct(target_stfs, arg2, 0); /* ??? put_user is probably wrong. */ put_user(stfs.f_type, &target_stfs->f_type); @@ -3382,7 +3382,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, convert_statfs64: if (!is_error(ret)) { struct target_statfs64 *target_stfs; - + lock_user_struct(target_stfs, arg3, 0); /* ??? put_user is probably wrong. */ put_user(stfs.f_type, &target_stfs->f_type); @@ -3509,9 +3509,9 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, if (arg2) { pvalue = &value; - target_to_host_timeval(&pvalue->it_interval, + target_to_host_timeval(&pvalue->it_interval, arg2); - target_to_host_timeval(&pvalue->it_value, + target_to_host_timeval(&pvalue->it_value, arg2 + sizeof(struct target_timeval)); } else { pvalue = NULL; @@ -3528,7 +3528,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, case TARGET_NR_getitimer: { struct itimerval value; - + ret = get_errno(getitimer(arg1, &value)); if (!is_error(ret) && arg2) { host_to_target_timeval(arg2, @@ -3697,7 +3697,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, /* no need to transcode because we use the linux syscall */ { struct new_utsname * buf; - + lock_user_struct(buf, arg1, 0); ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { @@ -3784,7 +3784,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, dirp = malloc(count); if (!dirp) return -ENOMEM; - + ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct dirent *de; @@ -4232,8 +4232,8 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, break; #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: - ret = get_errno(setresuid(low2highuid(arg1), - low2highuid(arg2), + ret = get_errno(setresuid(low2highuid(arg1), + low2highuid(arg2), low2highuid(arg3))); break; #endif @@ -4252,8 +4252,8 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: - ret = get_errno(setresgid(low2highgid(arg1), - low2highgid(arg2), + ret = get_errno(setresgid(low2highgid(arg1), + low2highgid(arg2), low2highgid(arg3))); break; #endif @@ -4352,7 +4352,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, uint32_t *target_grouplist; gid_t *grouplist; int i; - + grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(arg2, gidsetsize * 4, 1); for(i = 0;i < gidsetsize; i++) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 31e1b32901..01f4563282 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -281,9 +281,9 @@ static inline void target_siginitset(target_sigset_t *d, target_ulong set) void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); -void host_to_target_old_sigset(target_ulong *old_sigset, +void host_to_target_old_sigset(target_ulong *old_sigset, const sigset_t *sigset); -void target_to_host_old_sigset(sigset_t *sigset, +void target_to_host_old_sigset(sigset_t *sigset, const target_ulong *old_sigset); struct target_sigaction; int do_sigaction(int sig, const struct target_sigaction *act, @@ -709,59 +709,59 @@ struct target_pollfd { #define TARGET_FIGETBSZ TARGET_IO(0x00,2) /* get the block size used for bmap */ /* cdrom commands */ -#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */ +#define TARGET_CDROMPAUSE 0x5301 /* Pause Audio Operation */ #define TARGET_CDROMRESUME 0x5302 /* Resume paused Audio Operation */ #define TARGET_CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ -#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index +#define TARGET_CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index (struct cdrom_ti) */ -#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header +#define TARGET_CDROMREADTOCHDR 0x5305 /* Read TOC header (struct cdrom_tochdr) */ -#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry +#define TARGET_CDROMREADTOCENTRY 0x5306 /* Read TOC entry (struct cdrom_tocentry) */ #define TARGET_CDROMSTOP 0x5307 /* Stop the cdrom drive */ #define TARGET_CDROMSTART 0x5308 /* Start the cdrom drive */ #define TARGET_CDROMEJECT 0x5309 /* Ejects the cdrom media */ -#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume +#define TARGET_CDROMVOLCTRL 0x530a /* Control output volume (struct cdrom_volctrl) */ -#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data +#define TARGET_CDROMSUBCHNL 0x530b /* Read subchannel data (struct cdrom_subchnl) */ -#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes) +#define TARGET_CDROMREADMODE2 0x530c /* Read TARGET_CDROM mode 2 data (2336 Bytes) (struct cdrom_read) */ #define TARGET_CDROMREADMODE1 0x530d /* Read TARGET_CDROM mode 1 data (2048 Bytes) (struct cdrom_read) */ #define TARGET_CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ #define TARGET_CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ -#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session - address of multi session disks +#define TARGET_CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session + address of multi session disks (struct cdrom_multisession) */ -#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" +#define TARGET_CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" if available (struct cdrom_mcn) */ -#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is depricated, +#define TARGET_CDROM_GET_UPC TARGET_CDROM_GET_MCN /* This one is depricated, but here anyway for compatability */ #define TARGET_CDROMRESET 0x5312 /* hard-reset the drive */ -#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting +#define TARGET_CDROMVOLREAD 0x5313 /* Get the drive's volume setting (struct cdrom_volctrl) */ #define TARGET_CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) (struct cdrom_read) */ -/* +/* * These ioctls are used only used in aztcd.c and optcd.c */ #define TARGET_CDROMREADCOOKED 0x5315 /* read data in cooked mode */ #define TARGET_CDROMSEEK 0x5316 /* seek msf address */ - + /* - * This ioctl is only used by the scsi-cd driver. + * This ioctl is only used by the scsi-cd driver. It is for playing audio in logical block addressing mode. */ #define TARGET_CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ -/* +/* * These ioctls are only used in optcd.c */ #define TARGET_CDROMREADALL 0x5318 /* read all 2646 bytes */ -/* - * These ioctls are (now) only in ide-cd.c for controlling +/* + * These ioctls are (now) only in ide-cd.c for controlling * drive spindown time. They should be implemented in the * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... @@ -770,7 +770,7 @@ struct target_pollfd { #define TARGET_CDROMGETSPINDOWN 0x531d #define TARGET_CDROMSETSPINDOWN 0x531e -/* +/* * These ioctls are implemented through the uniform CD-ROM driver * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM * drivers are eventually ported to the uniform CD-ROM driver interface. @@ -1285,7 +1285,7 @@ struct target_stat64 { unsigned int __pad0; target_ulong target_st_atime; - target_ulong target_st_atime_nsec; + target_ulong target_st_atime_nsec; target_ulong target_st_mtime; target_ulong target_st_mtime_nsec; target_ulong target_st_ctime; @@ -1347,7 +1347,7 @@ struct target_stat64 { target_ulong target_st_mtime_nsec; target_ulong target_st_ctime; - target_ulong target_st_ctime_nsec; + target_ulong target_st_ctime_nsec; unsigned long long st_ino; }; diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 308da48573..2fd00f1031 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -5,7 +5,7 @@ STRUCT(winsize, STRUCT(serial_multiport_struct, TYPE_INT, TYPE_INT, TYPE_CHAR, TYPE_CHAR, TYPE_INT, TYPE_CHAR, TYPE_CHAR, - TYPE_INT, TYPE_CHAR, TYPE_CHAR, TYPE_INT, TYPE_CHAR, TYPE_CHAR, TYPE_INT, + TYPE_INT, TYPE_CHAR, TYPE_CHAR, TYPE_INT, TYPE_CHAR, TYPE_CHAR, TYPE_INT, MK_ARRAY(TYPE_INT, 32)) STRUCT(serial_icounter_struct, @@ -15,12 +15,12 @@ STRUCT(sockaddr, TYPE_SHORT, MK_ARRAY(TYPE_CHAR, 14)) STRUCT(rtentry, - TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), - TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID, + TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), + TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID, TYPE_ULONG, TYPE_ULONG, TYPE_SHORT) STRUCT(ifmap, - TYPE_ULONG, TYPE_ULONG, TYPE_SHORT, TYPE_CHAR, TYPE_CHAR, TYPE_CHAR, + TYPE_ULONG, TYPE_ULONG, TYPE_SHORT, TYPE_CHAR, TYPE_CHAR, TYPE_CHAR, /* Spare 3 bytes */ TYPE_CHAR, TYPE_CHAR, TYPE_CHAR) @@ -28,7 +28,7 @@ STRUCT(ifmap, STRUCT(sockaddr_ifreq, MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_STRUCT(STRUCT_sockaddr)) - + STRUCT(short_ifreq, MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_SHORT) @@ -49,7 +49,7 @@ STRUCT(ifconf, TYPE_INT, TYPE_PTRVOID) STRUCT(arpreq, - MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), TYPE_INT, MK_STRUCT(STRUCT_sockaddr), + MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), TYPE_INT, MK_STRUCT(STRUCT_sockaddr), MK_ARRAY(TYPE_CHAR, 16)) STRUCT(arpreq_old, diff --git a/linux-user/vm86.c b/linux-user/vm86.c index b28eea60d4..be71c2cd47 100644 --- a/linux-user/vm86.c +++ b/linux-user/vm86.c @@ -1,6 +1,6 @@ /* * vm86 linux syscall support - * + * * Copyright (c) 2003 Fabrice Bellard * * This program is free software; you can redistribute it and/or modify @@ -85,7 +85,7 @@ void save_v86_state(CPUX86State *env) target_v86->regs.eflags = tswap32(env->eflags); unlock_user_struct(target_v86, ts->target_v86, 1); #ifdef DEBUG_VM86 - fprintf(logfile, "save_v86_state: eflags=%08x cs:ip=%04x:%04x\n", + fprintf(logfile, "save_v86_state: eflags=%08x cs:ip=%04x:%04x\n", env->eflags, env->segs[R_CS].selector, env->eip); #endif @@ -123,7 +123,7 @@ static inline void return_to_32bit(CPUX86State *env, int retval) static inline int set_IF(CPUX86State *env) { TaskState *ts = env->opaque; - + ts->v86flags |= VIF_MASK; if (ts->v86flags & VIP_MASK) { return_to_32bit(env, TARGET_VM86_STI); @@ -202,7 +202,7 @@ static void do_int(CPUX86State *env, int intno) goto cannot_handle; if (is_revectored(intno, &ts->vm86plus.int_revectored)) goto cannot_handle; - if (intno == 0x21 && is_revectored((env->regs[R_EAX] >> 8) & 0xff, + if (intno == 0x21 && is_revectored((env->regs[R_EAX] >> 8) & 0xff, &ts->vm86plus.int21_revectored)) goto cannot_handle; int_ptr = (uint32_t *)(intno << 2); @@ -210,7 +210,7 @@ static void do_int(CPUX86State *env, int intno) if ((segoffs >> 16) == TARGET_BIOSSEG) goto cannot_handle; #if defined(DEBUG_VM86) - fprintf(logfile, "VM86: emulating int 0x%x. CS:IP=%04x:%04x\n", + fprintf(logfile, "VM86: emulating int 0x%x. CS:IP=%04x:%04x\n", intno, segoffs >> 16, segoffs & 0xffff); #endif /* save old state */ @@ -264,7 +264,7 @@ void handle_vm86_fault(CPUX86State *env) csp = (uint8_t *)(env->segs[R_CS].selector << 4); ip = env->eip & 0xffff; pc = csp + ip; - + ssp = (uint8_t *)(env->segs[R_SS].selector << 4); sp = env->regs[R_ESP] & 0xffff; @@ -330,7 +330,7 @@ void handle_vm86_fault(CPUX86State *env) ADD16(ip, 1); env->eip = ip; if (ts->vm86plus.vm86plus.flags & TARGET_vm86dbg_active) { - if ( (ts->vm86plus.vm86plus.vm86dbg_intxxtab[intno >> 3] >> + if ( (ts->vm86plus.vm86plus.vm86dbg_intxxtab[intno >> 3] >> (intno &7)) & 1) { return_to_32bit(env, TARGET_VM86_INTx + (intno << 8)); return; @@ -362,12 +362,12 @@ void handle_vm86_fault(CPUX86State *env) return; } VM86_FAULT_RETURN; - + case 0xfa: /* cli */ env->eip = ip; clear_IF(env); VM86_FAULT_RETURN; - + case 0xfb: /* sti */ env->eip = ip; if (set_IF(env)) @@ -386,7 +386,7 @@ int do_vm86(CPUX86State *env, long subfunction, target_ulong vm86_addr) TaskState *ts = env->opaque; struct target_vm86plus_struct * target_v86; int ret; - + switch (subfunction) { case TARGET_VM86_REQUEST_IRQ: case TARGET_VM86_FREE_IRQ: @@ -427,7 +427,7 @@ int do_vm86(CPUX86State *env, long subfunction, target_ulong vm86_addr) lock_user_struct(target_v86, vm86_addr, 1); /* build vm86 CPU state */ ts->v86flags = tswap32(target_v86->regs.eflags); - env->eflags = (env->eflags & ~SAFE_MASK) | + env->eflags = (env->eflags & ~SAFE_MASK) | (tswap32(target_v86->regs.eflags) & SAFE_MASK) | VM_MASK; ts->vm86plus.cpu_type = tswapl(target_v86->cpu_type); @@ -462,17 +462,17 @@ int do_vm86(CPUX86State *env, long subfunction, target_ulong vm86_addr) cpu_x86_load_seg(env, R_GS, tswap16(target_v86->regs.gs)); ret = tswap32(target_v86->regs.eax); /* eax will be restored at the end of the syscall */ - memcpy(&ts->vm86plus.int_revectored, + memcpy(&ts->vm86plus.int_revectored, &target_v86->int_revectored, 32); - memcpy(&ts->vm86plus.int21_revectored, + memcpy(&ts->vm86plus.int21_revectored, &target_v86->int21_revectored, 32); ts->vm86plus.vm86plus.flags = tswapl(target_v86->vm86plus.flags); - memcpy(&ts->vm86plus.vm86plus.vm86dbg_intxxtab, + memcpy(&ts->vm86plus.vm86plus.vm86dbg_intxxtab, target_v86->vm86plus.vm86dbg_intxxtab, 32); unlock_user_struct(target_v86, vm86_addr, 0); - + #ifdef DEBUG_VM86 - fprintf(logfile, "do_vm86: cs:ip=%04x:%04x\n", + fprintf(logfile, "do_vm86: cs:ip=%04x:%04x\n", env->segs[R_CS].selector, env->eip); #endif /* now the virtual CPU is ready for vm86 execution ! */ diff --git a/linux-user/x86_64/syscall_nr.h b/linux-user/x86_64/syscall_nr.h index e1a8ca20bc..c58de2bc5d 100644 --- a/linux-user/x86_64/syscall_nr.h +++ b/linux-user/x86_64/syscall_nr.h @@ -181,7 +181,7 @@ #define TARGET_NR_nfsservctl 180 #define TARGET_NR_getpmsg 181 /* reserved for LiS/STREAMS */ #define TARGET_NR_putpmsg 182 /* reserved for LiS/STREAMS */ -#define TARGET_NR_afs_syscall 183 /* reserved for AFS */ +#define TARGET_NR_afs_syscall 183 /* reserved for AFS */ #define TARGET_NR_tuxcall 184 /* reserved for tux */ #define TARGET_NR_security 185 #define TARGET_NR_gettid 186 |