qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 01/23] bsd-user: initial code clean up


From: Stacey Son
Subject: [Qemu-devel] [PATCH 01/23] bsd-user: initial code clean up
Date: Sun, 23 Jun 2013 21:03:33 -0500

Add license headers, #ifndef's for header files, and fix various style problem
as reported by checkpatch.pl.

Signed-off-by: Stacey Son <address@hidden>
---
 bsd-user/bsd-mman.h              |    2 +-
 bsd-user/bsdload.c               |   21 ++++++-
 bsd-user/elfload.c               |  122 ++++++++++++++++++++++----------------
 bsd-user/errno_defs.h            |    8 ++-
 bsd-user/freebsd/strace.list     |   18 ++++++
 bsd-user/freebsd/syscall_nr.h    |   21 ++++++-
 bsd-user/i386/syscall.h          |   21 +++++++
 bsd-user/i386/target_signal.h    |   17 +++++
 bsd-user/main.c                  |   24 ++++----
 bsd-user/mmap.c                  |   24 ++++----
 bsd-user/netbsd/strace.list      |   18 ++++++
 bsd-user/netbsd/syscall_nr.h     |   24 +++++++-
 bsd-user/openbsd/strace.list     |   18 ++++++
 bsd-user/openbsd/syscall_nr.h    |   24 +++++++-
 bsd-user/qemu.h                  |   20 ++++++-
 bsd-user/sparc/syscall.h         |   22 +++++++
 bsd-user/sparc64/syscall.h       |   21 +++++++
 bsd-user/sparc64/target_signal.h |   23 ++++++-
 bsd-user/strace.c                |   17 +++++
 bsd-user/syscall.c               |   14 ++--
 bsd-user/syscall_defs.h          |    6 +-
 bsd-user/uaccess.c               |   20 ++++++-
 bsd-user/x86_64/syscall.h        |   22 +++++++
 bsd-user/x86_64/target_signal.h  |   23 ++++++-
 24 files changed, 442 insertions(+), 108 deletions(-)

diff --git a/bsd-user/bsd-mman.h b/bsd-user/bsd-mman.h
index 910e8c1..2193ce7 100644
--- a/bsd-user/bsd-mman.h
+++ b/bsd-user/bsd-mman.h
@@ -1,4 +1,4 @@
-/*-
+/*--
  * Copyright (c) 1982, 1986, 1993
  *      The Regents of the University of California.  All rights reserved.
  *
diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index 2abc713..637a217 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -1,4 +1,19 @@
-/* Code for loading BSD executables.  Mostly linux kernel code.  */
+/*
+ *  Load BSD executables.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -34,7 +49,7 @@ static int in_group_p(gid_t g)
     gid_t       grouplist[TARGET_NGROUPS];
 
     ngroup = getgroups(TARGET_NGROUPS, grouplist);
-    for(i = 0; i < ngroup; i++) {
+    for (i = 0; i < ngroup; i++) {
         if(grouplist[i] == g) {
             return 1;
         }
@@ -46,7 +61,7 @@ static int count(char ** vec)
 {
     int         i;
 
-    for(i = 0; *vec; i++) {
+    for (i = 0; *vec; i++) {
         vec++;
     }
 
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 5e20510..007bcb1 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -1,4 +1,20 @@
-/* This is the Linux kernel elf-loading code, ported into user space */
+/*
+ *  ELF loading code
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -918,54 +934,57 @@ static abi_ulong load_elf_interp(struct elfhdr * 
interp_elf_ex,
         }
 
         eppnt = elf_phdata;
-        for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++)
-          if (eppnt->p_type == PT_LOAD) {
-            int elf_type = MAP_PRIVATE | MAP_DENYWRITE;
-            int elf_prot = 0;
-            abi_ulong vaddr = 0;
-            abi_ulong k;
-
-            if (eppnt->p_flags & PF_R) elf_prot =  PROT_READ;
-            if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE;
-            if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC;
-            if (interp_elf_ex->e_type == ET_EXEC || load_addr_set) {
-                elf_type |= MAP_FIXED;
-                vaddr = eppnt->p_vaddr;
-            }
-            error = target_mmap(load_addr+TARGET_ELF_PAGESTART(vaddr),
-                 eppnt->p_filesz + TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr),
-                 elf_prot,
-                 elf_type,
-                 interpreter_fd,
-                 eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr));
-
-            if (error == -1) {
-              /* Real error */
-              close(interpreter_fd);
-              free(elf_phdata);
-              return ~((abi_ulong)0UL);
-            }
-
-            if (!load_addr_set && interp_elf_ex->e_type == ET_DYN) {
-              load_addr = error;
-              load_addr_set = 1;
+        for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++)
+            if (eppnt->p_type == PT_LOAD) {
+                int elf_type = MAP_PRIVATE | MAP_DENYWRITE;
+                int elf_prot = 0;
+                abi_ulong vaddr = 0;
+                abi_ulong k;
+
+                if (eppnt->p_flags & PF_R) {
+                    elf_prot =  PROT_READ;
+                }
+                if (eppnt->p_flags & PF_W) {
+                    elf_prot |= PROT_WRITE;
+                }
+                if (eppnt->p_flags & PF_X) {
+                    elf_prot |= PROT_EXEC;
+                }
+                if (interp_elf_ex->e_type == ET_EXEC || load_addr_set) {
+                    elf_type |= MAP_FIXED;
+                    vaddr = eppnt->p_vaddr;
+                }
+                error = target_mmap(load_addr+TARGET_ELF_PAGESTART(vaddr),
+                        eppnt->p_filesz + 
TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr),
+                        elf_prot, elf_type, interpreter_fd, eppnt->p_offset -
+                        TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr));
+                if (error == -1) {
+                    /* Real error */
+                    close(interpreter_fd);
+                    free(elf_phdata);
+                    return ~((abi_ulong)0UL);
+                }
+                if (!load_addr_set && interp_elf_ex->e_type == ET_DYN) {
+                    load_addr = error;
+                    load_addr_set = 1;
+                }
+                /*
+                 * Find the end of the file  mapping for this phdr, and keep
+                 * track of the largest address we see for this.
+                 */
+                k = load_addr + eppnt->p_vaddr + eppnt->p_filesz;
+                if (k > elf_bss) {
+                    elf_bss = k;
+                }
+                /*
+                 * Do the same thing for the memory mapping - between
+                 * elf_bss and last_bss is the bss section.
+                 */
+                k = load_addr + eppnt->p_memsz + eppnt->p_vaddr;
+                if (k > last_bss) {
+                    last_bss = k;
+                }
             }
-
-            /*
-             * Find the end of the file  mapping for this phdr, and keep
-             * track of the largest address we see for this.
-             */
-            k = load_addr + eppnt->p_vaddr + eppnt->p_filesz;
-            if (k > elf_bss) elf_bss = k;
-
-            /*
-             * Do the same thing for the memory mapping - between
-             * elf_bss and last_bss is the bss section.
-             */
-            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);
@@ -977,7 +996,8 @@ static abi_ulong load_elf_interp(struct elfhdr * 
interp_elf_ex,
          * bss page.
          */
         padzero(elf_bss, last_bss);
-        elf_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1); /* 
What we have mapped so far */
+        /* What we have mapped so far */
+        elf_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1);
 
         /* Map the last of the bss segment */
         if (last_bss > elf_bss) {
@@ -1231,7 +1251,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct 
target_pt_regs * regs,
     end_data = 0;
     interp_ex.a_info = 0;
 
-    for(i=0;i < elf_ex.e_phnum; i++) {
+    for (i = 0; i < elf_ex.e_phnum; i++) {
         if (elf_ppnt->p_type == PT_INTERP) {
             if ( elf_interpreter != NULL )
             {
@@ -1401,7 +1421,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct 
target_pt_regs * regs,
      * address.
      */
 
-    for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) {
+    for (i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) {
         int elf_prot = 0;
         int elf_flags = 0;
         abi_ulong error;
diff --git a/bsd-user/errno_defs.h b/bsd-user/errno_defs.h
index 1efa502..fcf95d3 100644
--- a/bsd-user/errno_defs.h
+++ b/bsd-user/errno_defs.h
@@ -1,6 +1,3 @@
-/*      $OpenBSD: errno.h,v 1.20 2007/09/03 14:37:52 millert Exp $      */
-/*      $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc Exp $   */
-
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
  *      The Regents of the University of California.  All rights reserved.
@@ -37,6 +34,9 @@
  *      @(#)errno.h     8.5 (Berkeley) 1/21/94
  */
 
+#ifndef _ERRNO_DEFS_H_
+#define _ERRNO_DEFS_H_
+
 #define TARGET_EPERM            1               /* Operation not permitted */
 #define TARGET_ENOENT           2               /* No such file or directory */
 #define TARGET_ESRCH            3               /* No such process */
@@ -147,3 +147,5 @@
 #define TARGET_EIDRM            89              /* Identifier removed */
 #define TARGET_ENOMSG           90              /* No message of desired type 
*/
 #define TARGET_ELAST            90              /* Must be equal largest errno 
*/
+
+#endif /* !  _ERRNO_DEFS_H_ */
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 1edf412..3e793cb 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -1,3 +1,21 @@
+/*
+ *  FreeBSD strace list
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
 { TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
 { TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
index 36336ab..057f46c 100644
--- a/bsd-user/freebsd/syscall_nr.h
+++ b/bsd-user/freebsd/syscall_nr.h
@@ -1,9 +1,26 @@
 /*
- * System call numbers.
+ *  FreeBSD System call numbers.
  *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
  * $FreeBSD: src/sys/sys/syscall.h,v 1.224 2008/08/24 21:23:08 rwatson Exp $
  * created from FreeBSD: head/sys/kern/syscalls.master 182123 2008-08-24 
21:20:35Z rwatson
  */
+#ifndef _FREEBSD_SYSCALL_NR_H_
+#define _FREEBSD_SYSCALL_NR_H_
 
 #define TARGET_FREEBSD_NR_syscall     0
 #define TARGET_FREEBSD_NR_exit        1
@@ -371,3 +388,5 @@
 #define TARGET_FREEBSD_NR_symlinkat   502
 #define TARGET_FREEBSD_NR_unlinkat    503
 #define TARGET_FREEBSD_NR_posix_openpt        504
+
+#endif /* ! _FREEBSD_SYSCALL_NR_H_ */
diff --git a/bsd-user/i386/syscall.h b/bsd-user/i386/syscall.h
index 9b34c61..8028fc8 100644
--- a/bsd-user/i386/syscall.h
+++ b/bsd-user/i386/syscall.h
@@ -1,3 +1,23 @@
+/*
+ *  i386 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _I386_SYSCALL_H_
+#define _I386_SYSCALL_H_
+
 /* default linux values for the selectors */
 #define __USER_CS      (0x23)
 #define __USER_DS      (0x2B)
@@ -159,3 +179,4 @@ struct target_vm86plus_struct {
 
 #define UNAME_MACHINE "i386"
 
+#endif /* ! _I386_SYSCALL_H_ */
diff --git a/bsd-user/i386/target_signal.h b/bsd-user/i386/target_signal.h
index 2ef36d1..806e1e2 100644
--- a/bsd-user/i386/target_signal.h
+++ b/bsd-user/i386/target_signal.h
@@ -1,3 +1,20 @@
+/*
+ *  i386 dependent signal definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef TARGET_SIGNAL_H
 #define TARGET_SIGNAL_H
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 572f13a..572aa14 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -1,4 +1,4 @@
-/*
+/**
  *  qemu user main
  *
  *  Copyright (c) 2003-2008 Fabrice Bellard
@@ -174,9 +174,9 @@ void cpu_loop(CPUX86State *env)
     abi_ulong pc;
     //target_siginfo_t info;
 
-    for(;;) {
+    for (;;) {
         trapnr = cpu_x86_exec(env);
-        switch(trapnr) {
+        switch (trapnr) {
         case 0x80:
             /* syscall from int $0x80 */
             if (bsd_type == target_freebsd) {
@@ -378,8 +378,8 @@ void cpu_loop(CPUX86State *env)
 #endif
         default:
             pc = env->segs[R_CS].base + env->eip;
-            fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - 
aborting\n",
-                    (long)pc, trapnr);
+            fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - "
+                    "aborting\n", (long)pc, trapnr);
             abort();
         }
         process_pending_signals(env);
@@ -418,7 +418,7 @@ static inline void save_window_offset(CPUSPARCState *env, 
int cwp1)
     printf("win_overflow: sp_ptr=0x" TARGET_ABI_FMT_lx " save_cwp=%d\n",
            sp_ptr, cwp1);
 #endif
-    for(i = 0; i < 16; i++) {
+    for (i = 0; i < 16; i++) {
         /* FIXME - what to do if put_user() fails? */
         put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
         sp_ptr += sizeof(abi_ulong);
@@ -464,7 +464,7 @@ static void restore_window(CPUSPARCState *env)
     printf("win_underflow: sp_ptr=0x" TARGET_ABI_FMT_lx " load_cwp=%d\n",
            sp_ptr, cwp1);
 #endif
-    for(i = 0; i < 16; i++) {
+    for (i = 0; i < 16; i++) {
         /* FIXME - what to do if get_user() fails? */
         get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
         sp_ptr += sizeof(abi_ulong);
@@ -484,7 +484,7 @@ static void flush_windows(CPUSPARCState *env)
     int offset, cwp1;
 
     offset = 1;
-    for(;;) {
+    for (;;) {
         /* if restore would invoke restore_window(), then we can stop */
         cwp1 = cpu_cwp_inc(env, env->cwp + offset);
 #ifndef TARGET_SPARC64
@@ -765,7 +765,7 @@ int main(int argc, char **argv)
 #endif
 
     optind = 1;
-    for(;;) {
+    for (;;) {
         if (optind >= argc)
             break;
         r = argv[optind];
@@ -1122,10 +1122,12 @@ int main(int argc, char **argv)
         env->pc = regs->pc;
         env->npc = regs->npc;
         env->y = regs->y;
-        for(i = 0; i < 8; i++)
+        for (i = 0; i < 8; i++) {
             env->gregs[i] = regs->u_regs[i];
-        for(i = 0; i < 8; i++)
+        }
+        for (i = 0; i < 8; i++) {
             env->regwptr[i] = regs->u_regs[i + 8];
+        }
     }
 #else
 #error unsupported target CPU
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index aae8ea1..29e0427 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -1,4 +1,4 @@
-/*
+/**
  *  mmap support for qemu
  *
  *  Copyright (c) 2003 - 2008 Fabrice Bellard
@@ -164,11 +164,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int 
prot)
     if (start > host_start) {
         /* handle host page containing start */
         prot1 = prot;
-        for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
+        for (addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
             prot1 |= page_get_flags(addr);
         }
         if (host_end == host_start + qemu_host_page_size) {
-            for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
+            for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
                 prot1 |= page_get_flags(addr);
             }
             end = host_end;
@@ -180,7 +180,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int 
prot)
     }
     if (end < host_end) {
         prot1 = prot;
-        for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
+        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,
@@ -218,7 +218,7 @@ static int mmap_frag(abi_ulong real_start,
 
     /* get the protection of the target pages outside the mapping */
     prot1 = 0;
-    for(addr = real_start; addr < real_end; addr++) {
+    for (addr = real_start; addr < real_end; addr++) {
         if (addr < start || addr >= end)
             prot1 |= page_get_flags(addr);
     }
@@ -300,9 +300,9 @@ static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong 
size)
     if (addr == 0)
         addr = mmap_next_start;
     addr_start = addr;
-    for(;;) {
+    for (;;) {
         prot = 0;
-        for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
+        for (addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
             prot |= page_get_flags(addr1);
         }
         if (prot == 0)
@@ -337,7 +337,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int 
prot,
             printf("MAP_FIXED ");
         if (flags & MAP_ANON)
             printf("MAP_ANON ");
-        switch(flags & TARGET_BSD_MAP_FLAGMASK) {
+        switch (flags & TARGET_BSD_MAP_FLAGMASK) {
         case MAP_PRIVATE:
             printf("MAP_PRIVATE ");
             break;
@@ -396,7 +396,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int 
prot,
         end = start + len;
         real_end = HOST_PAGE_ALIGN(end);
 
-        for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
+        for (addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) {
             flg = page_get_flags(addr);
             if (flg & PAGE_RESERVED) {
                 errno = ENXIO;
@@ -508,11 +508,11 @@ int target_munmap(abi_ulong start, abi_ulong len)
     if (start > real_start) {
         /* handle host page containing start */
         prot = 0;
-        for(addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {
+        for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {
             prot |= page_get_flags(addr);
         }
         if (real_end == real_start + qemu_host_page_size) {
-            for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
+            for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
                 prot |= page_get_flags(addr);
             }
             end = real_end;
@@ -522,7 +522,7 @@ int target_munmap(abi_ulong start, abi_ulong len)
     }
     if (end < real_end) {
         prot = 0;
-        for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
+        for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {
             prot |= page_get_flags(addr);
         }
         if (prot != 0)
diff --git a/bsd-user/netbsd/strace.list b/bsd-user/netbsd/strace.list
index 5609d70..41233cd 100644
--- a/bsd-user/netbsd/strace.list
+++ b/bsd-user/netbsd/strace.list
@@ -1,3 +1,21 @@
+/*
+ *  NetBSD strace list
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
 { TARGET_NETBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
 { TARGET_NETBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
 { TARGET_NETBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL },
diff --git a/bsd-user/netbsd/syscall_nr.h b/bsd-user/netbsd/syscall_nr.h
index 2e9ab53..b598f18 100644
--- a/bsd-user/netbsd/syscall_nr.h
+++ b/bsd-user/netbsd/syscall_nr.h
@@ -1,8 +1,24 @@
-/* $NetBSD: syscall.h,v 1.215 2008/06/17 16:07:57 tsutsui Exp $ */
-
 /*
- * System call numbers.
+ *  NetBSD system call numbers
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
  *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _NETBSD_SYSCALL_NR_H_
+#define _NETBSD_SYSCALL_NR_H_
+
+/*
  * created from        NetBSD: syscalls.master,v 1.204 2008/06/17 16:05:23 
tsutsui Exp
  */
 
@@ -371,3 +387,5 @@
 #define TARGET_NETBSD_NR_pset_assign 414
 #define TARGET_NETBSD_NR__pset_bind  415
 #define TARGET_NETBSD_NR___posix_fadvise50   416
+
+#endif /* ! _NETBSD_SYSCALL_NR_H_ */
diff --git a/bsd-user/openbsd/strace.list b/bsd-user/openbsd/strace.list
index 1f0a331..6575013 100644
--- a/bsd-user/openbsd/strace.list
+++ b/bsd-user/openbsd/strace.list
@@ -1,3 +1,21 @@
+/*
+ *  OpenBSD strace list
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
 { TARGET_OPENBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL },
 { TARGET_OPENBSD_NR___semctl, "__semctl", NULL, NULL, NULL },
 { TARGET_OPENBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
diff --git a/bsd-user/openbsd/syscall_nr.h b/bsd-user/openbsd/syscall_nr.h
index dececfd..2f17f2f 100644
--- a/bsd-user/openbsd/syscall_nr.h
+++ b/bsd-user/openbsd/syscall_nr.h
@@ -1,8 +1,24 @@
-/*      $OpenBSD: syscall.h,v 1.101 2008/03/16 19:43:41 otto Exp $      */
-
 /*
- * System call numbers.
+ *  OpenBSD system call numbers
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _OPENBSD_SYSCALL_NR_H_
+#define _OPENBSD_SYSCALL_NR_H_
+/*
  * created from;        OpenBSD: syscalls.master,v 1.90 2008/03/16 19:42:57 
otto Exp
  */
 
@@ -223,3 +239,5 @@
  */
 #define TARGET_OPENBSD_SYSCALL_G2RFLAG 0x400   /* on success, return to %g2 
rather than npc */
 #define TARGET_OPENBSD_SYSCALL_G7RFLAG 0x800   /* use %g7 as above 
(deprecated) */
+
+#endif /* !_OPENBSD_SYSCALL_NR_H_ */
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index a826086..1e14660 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -1,3 +1,19 @@
+/*
+ *  qemu bsd user mode definition
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #ifndef QEMU_H
 #define QEMU_H
 
@@ -216,7 +232,7 @@ static inline int access_ok(int type, abi_ulong addr, 
abi_ulong size)
 #define __put_user(x, hptr)\
 ({\
     int size = sizeof(*hptr);\
-    switch(size) {\
+    switch (size) {\
     case 1:\
         *(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
         break;\
@@ -238,7 +254,7 @@ static inline int access_ok(int type, abi_ulong addr, 
abi_ulong size)
 #define __get_user(x, hptr) \
 ({\
     int size = sizeof(*hptr);\
-    switch(size) {\
+    switch (size) {\
     case 1:\
         x = (typeof(*hptr))*(uint8_t *)(hptr);\
         break;\
diff --git a/bsd-user/sparc/syscall.h b/bsd-user/sparc/syscall.h
index 5a9bb7e..804889a 100644
--- a/bsd-user/sparc/syscall.h
+++ b/bsd-user/sparc/syscall.h
@@ -1,3 +1,23 @@
+/*
+ *  sparc dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SPARC_SYSCALL_H_
+#define _SPARC_SYSCALL_H_
+
 struct target_pt_regs {
        abi_ulong psr;
        abi_ulong pc;
@@ -7,3 +27,5 @@ struct target_pt_regs {
 };
 
 #define UNAME_MACHINE "sun4"
+
+#endif /* ! _SPARC_SYSCALL_H_ */
diff --git a/bsd-user/sparc64/syscall.h b/bsd-user/sparc64/syscall.h
index 81a816d..9f3b97e 100644
--- a/bsd-user/sparc64/syscall.h
+++ b/bsd-user/sparc64/syscall.h
@@ -1,3 +1,22 @@
+/*
+ *  sparc64 dependent system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SPARC64_SYSCALL_H_
+#define _SPARC64_SYSCALL_H_
 struct target_pt_regs {
        abi_ulong u_regs[16];
        abi_ulong tstate;
@@ -8,3 +27,5 @@ struct target_pt_regs {
 };
 
 #define UNAME_MACHINE "sun4u"
+
+#endif /* !_SPARC64_SYSCALL_H_ */
diff --git a/bsd-user/sparc64/target_signal.h b/bsd-user/sparc64/target_signal.h
index 5b2abba..51e44bb 100644
--- a/bsd-user/sparc64/target_signal.h
+++ b/bsd-user/sparc64/target_signal.h
@@ -1,5 +1,22 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
+/*
+ *  sparc64 dependent signal definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SPARC64_TARGET_SIGNAL_H_
+#define _SPARC64_TARGET_SIGNAL_H_
 
 #include "cpu.h"
 
@@ -24,4 +41,4 @@ static inline abi_ulong get_sp_from_cpustate(CPUSPARCState 
*state)
     return state->regwptr[UREG_FP];
 }
 
-#endif /* TARGET_SIGNAL_H */
+#endif /* !_SPARC64_TARGET_SIGNAL_H_ */
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index d73bbca..7a28c96 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -1,3 +1,20 @@
+/*
+ *  System call tracing and debugging
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #include <stdio.h>
 #include <errno.h>
 #include <sys/select.h>
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index a4d1583..8e8107b 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -1,4 +1,4 @@
-/*
+/**
  *  BSD syscalls
  *
  *  Copyright (c) 2003 - 2008 Fabrice Bellard
@@ -103,7 +103,7 @@ static abi_long do_freebsd_sysarch(CPUX86State *env, int 
op, abi_ulong parms)
     abi_ulong val;
     int idx;
 
-    switch(op) {
+    switch (op) {
 #ifdef TARGET_ABI32
     case TARGET_FREEBSD_I386_SET_GSBASE:
     case TARGET_FREEBSD_I386_SET_FSBASE:
@@ -279,7 +279,7 @@ static abi_long lock_iovec(int type, struct iovec *vec, 
abi_ulong target_addr,
     target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct 
target_iovec), 1);
     if (!target_vec)
         return -TARGET_EFAULT;
-    for(i = 0;i < count; i++) {
+    for (i = 0; i < count; i++) {
         base = tswapl(target_vec[i].iov_base);
         vec[i].iov_len = tswapl(target_vec[i].iov_len);
         if (vec[i].iov_len != 0) {
@@ -305,7 +305,7 @@ static abi_long unlock_iovec(struct iovec *vec, abi_ulong 
target_addr,
     target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct 
target_iovec), 1);
     if (!target_vec)
         return -TARGET_EFAULT;
-    for(i = 0;i < count; i++) {
+    for (i = 0; i < count; i++) {
         if (target_vec[i].iov_base) {
             base = tswapl(target_vec[i].iov_base);
             unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0);
@@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, 
abi_long arg1,
     if(do_strace)
         print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
-    switch(num) {
+    switch (num) {
     case TARGET_FREEBSD_NR_exit:
 #ifdef TARGET_GPROF
         _mcleanup();
@@ -428,7 +428,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long 
arg1,
     if(do_strace)
         print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
-    switch(num) {
+    switch (num) {
     case TARGET_NETBSD_NR_exit:
 #ifdef TARGET_GPROF
         _mcleanup();
@@ -500,7 +500,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, 
abi_long arg1,
     if(do_strace)
         print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
 
-    switch(num) {
+    switch (num) {
     case TARGET_OPENBSD_NR_exit:
 #ifdef TARGET_GPROF
         _mcleanup();
diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index 207ddee..58dafd1 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -1,6 +1,3 @@
-/*      $OpenBSD: signal.h,v 1.19 2006/01/08 14:20:16 millert Exp $     */
-/*      $NetBSD: signal.h,v 1.21 1996/02/09 18:25:32 christos Exp $     */
-
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
  *      The Regents of the University of California.  All rights reserved.
@@ -36,6 +33,8 @@
  *
  *      @(#)signal.h    8.2 (Berkeley) 1/21/94
  */
+#ifndef _SYSCALL_DEFS_H_
+#define _SYSCALL_DEFS_H_
 
 #define TARGET_NSIG     32              /* counting 0; could be 33 (mask is 
1-32) */
 
@@ -112,3 +111,4 @@ struct target_iovec {
     abi_long iov_len;   /* Number of bytes */
 };
 
+#endif /* ! _SYSCALL_DEFS_H_ */
diff --git a/bsd-user/uaccess.c b/bsd-user/uaccess.c
index 677f19c..09ac88e 100644
--- a/bsd-user/uaccess.c
+++ b/bsd-user/uaccess.c
@@ -1,4 +1,20 @@
-/* User memory access */
+/*
+ *  User memory access
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 #include <stdio.h>
 #include <string.h>
 
@@ -46,7 +62,7 @@ abi_long target_strlen(abi_ulong guest_addr1)
     int max_len, len;
 
     guest_addr = guest_addr1;
-    for(;;) {
+    for (;;) {
         max_len = TARGET_PAGE_SIZE - (guest_addr & ~TARGET_PAGE_MASK);
         ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
         if (!ptr)
diff --git a/bsd-user/x86_64/syscall.h b/bsd-user/x86_64/syscall.h
index 630514a..fbaeacf 100644
--- a/bsd-user/x86_64/syscall.h
+++ b/bsd-user/x86_64/syscall.h
@@ -1,3 +1,23 @@
+/*
+ *  x86_64 system call definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _X86_64_SYSCALL_H_
+#define _X86_64_SYSCALL_H_
+
 #define __USER_CS      (0x33)
 #define __USER_DS      (0x2B)
 
@@ -114,3 +134,5 @@ struct target_msqid64_ds {
 #define TARGET_ARCH_SET_FS 0x1002
 #define TARGET_ARCH_GET_FS 0x1003
 #define TARGET_ARCH_GET_GS 0x1004
+
+#endif /* ! _X86_64_SYSCALL_H_ */
diff --git a/bsd-user/x86_64/target_signal.h b/bsd-user/x86_64/target_signal.h
index 659cd40..c33dbcc 100644
--- a/bsd-user/x86_64/target_signal.h
+++ b/bsd-user/x86_64/target_signal.h
@@ -1,5 +1,22 @@
-#ifndef TARGET_SIGNAL_H
-#define TARGET_SIGNAL_H
+/*
+ *  x86_64 signal definitions
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _X86_64_TARGET_SIGNAL_H_
+#define _X86_64_TARGET_SIGNAL_H_
 
 #include "cpu.h"
 
@@ -16,4 +33,4 @@ static inline abi_ulong get_sp_from_cpustate(CPUX86State 
*state)
     return state->regs[R_ESP];
 }
 
-#endif /* TARGET_SIGNAL_H */
+#endif /* !_X86_64_TARGET_SIGNAL_H_ */
-- 
1.7.8




reply via email to

[Prev in Thread] Current Thread [Next in Thread]