]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Arch-abstraction:
authorNicholas Nethercote <n.nethercote@gmail.com>
Sun, 31 Oct 2004 18:48:21 +0000 (18:48 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Sun, 31 Oct 2004 18:48:21 +0000 (18:48 +0000)
- Added include/x86-linux/ and include/linux/ subdirectories, with Makefile.am
  files.

- Overhauled the definitions of kernel types.  include/vg_kerneliface.h is now
  three files, include/linux/vki.h, include/x86-linux/vki_arch.h, and
  include/x86-linux/vki_arch_posixtypes.h.  These files separate the
  common/Linux and x86/Linux parts cleanly.  All code is copied verbatim from
  the relevant kernel headers, except that VKI_/vki_ prefixes are added as
  necessary to distinguish them from glibc types.  (This is done consistently,
  unlike previously when some types did not have the prefixes.)

  All code is clearly marked to show which particular header file it came from,
  and the Linux version used.  (I used 2.6.8.1, the most recent stable release,
  for all of them.)

  A few of the types changed;  this is because they changed between the older
  versions of Linux and the current 2.6.8.1.  I checked that all these changes
  were ok with respect to backwards compatibility for our purposes.

- vg_unsafe.h has been removed;  we are no longer including any kernel headers,
  as we have our own copies for everything.  This is because installed kernel
  headers are not reliable, and often cause compilation problems. (bug
  #92420 is a recent example)

- Removed some no-longer-needed header-presence tests from configure.in.

- Some code in the rest of Valgrind was changed to account for some slight
  changes in the names of our VKI_/vki_ kernel constants and types.

- Updated README_MISSING_SYSCALL_OR_IOCTL accordingly.

- Fixed off-by-one error with VKI_GDT_ENTRY_TLS_MAX (merged from stable branch)

The end result is that the kernel types situation should be much clearer, and
similar files can be created relatively easily for other architectures as
necessary.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2884

39 files changed:
Makefile.core-AM_CPPFLAGS.am
Makefile.tool-flags.am
README_MISSING_SYSCALL_OR_IOCTL
cachegrind/x86/cg_arch.c
configure.in
coregrind/Makefile.am
coregrind/core.h
coregrind/ume.c
coregrind/vg_execontext.c
coregrind/vg_libpthread.c
coregrind/vg_main.c
coregrind/vg_malloc2.c
coregrind/vg_memory.c
coregrind/vg_mylibc.c
coregrind/vg_proxylwp.c
coregrind/vg_scheduler.c
coregrind/vg_signals.c
coregrind/vg_symtab2.c
coregrind/vg_symtypes.c
coregrind/vg_syscalls.c
coregrind/vg_unsafe.h [deleted file]
coregrind/x86-linux/core_platform.h
coregrind/x86-linux/ldt.c
coregrind/x86/core_arch.h
coregrind/x86/libpthread.c
coregrind/x86/signal.c
coregrind/x86/state.c
include/Makefile.am
include/linux/Makefile.am [new file with mode: 0644]
include/linux/vki.h [new file with mode: 0644]
include/tool.h.base
include/vg_kerneliface.h [deleted file]
include/x86-linux/.cvsignore [new file with mode: 0644]
include/x86-linux/Makefile.am [new file with mode: 0644]
include/x86-linux/vki_arch.h [new file with mode: 0644]
include/x86-linux/vki_arch_posixtypes.h [new file with mode: 0644]
memcheck/docs/mc_techdocs.html
memcheck/mac_leakcheck.c
valgrind.spec.in

index 2632a678f45d3c00d0693fe8e8ff9d7c1d11bf47..e71c12058fa6702187fd925de15018ed466505b8 100644 (file)
@@ -2,7 +2,9 @@ add_includes = -I$(top_builddir)/coregrind -I$(top_srcdir)/coregrind \
                -I$(top_srcdir)/coregrind/$(VG_ARCH) \
                -I$(top_srcdir)/coregrind/$(VG_PLATFORM) \
                -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/include/$(VG_ARCH)
+               -I$(top_srcdir)/include/$(VG_ARCH) \
+               -I$(top_srcdir)/include/$(VG_OS) \
+               -I$(top_srcdir)/include/$(VG_PLATFORM)
 
 AM_CPPFLAGS = $(add_includes)
 AM_CCASFLAGS = $(add_includes) @ARCH_CORE_AM_CCASFLAGS@
index 776d9137945423588c28553a3d4009b44e6635b8..01b2a8e62d54b260229435127a23b49c13dc9d0c 100644 (file)
@@ -1,7 +1,9 @@
 ## Need $(top_builddir)/include because tool.h is built from tool.h.base;
 ## otherwise it will not work if builddir != srcdir.
 add_includes = -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/include/$(VG_ARCH)
+               -I$(top_srcdir)/include/$(VG_ARCH) \
+               -I$(top_srcdir)/include/$(VG_OS) \
+               -I$(top_srcdir)/include/$(VG_PLATFORM)
 
 AM_CPPFLAGS = $(add_includes)
 AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -g @ARCH_TOOL_AM_CFLAGS@
index ad919252ec9b1b760b954ff059ba2d37d3d3a1e7..de88a83e70ab234b4a8bdb9253465edafff2e349 100644 (file)
@@ -130,12 +130,10 @@ following:
     which has a similar behaviour to yours, and use it as a 
     starting point.
 
-    If you need structure definitions for your syscall, you can copy
-    structure definitions from the kernel headers into
-    include/vg_kerneliface.h, with the appropriate vki_* name
-    mangling.  Alternatively, you can #include headers for structure
-    definitions, put your #includes into vg_unsafe.h (copying
-    syscall-related things into vg_kerneliface.h is preferred though).
+    If you need structure definitions and/or constants for your syscall,
+    copy them from the kernel headers into include/vki.h and co., with
+    the appropriate vki_*/VKI_* name mangling.  Don't #include any
+    kernel headers.  And certainly don't #include any glibc headers.
 
     Test it.
 
index 29cc28380f603431a139cada8705ee01ce3fd38f..a070c978cbac1a5e287b04c81af9038cf16f6d8d 100644 (file)
@@ -258,16 +258,16 @@ Int get_caches_from_CPUID(cache_t* I1c, cache_t* D1c, cache_t* L2c)
 {
    Int  level, res, ret;
    Char vendor_id[13];
-   vki_ksigaction sigill_new, sigill_saved;
+   struct vki_sigaction sigill_new, sigill_saved;
 
    /* Install own SIGILL handler */
    sigill_new.ksa_handler  = cpuid_SIGILL_handler;
-   sigill_new.ksa_flags    = 0;
-   sigill_new.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sigill_new.ksa_mask );
+   sigill_new.sa_flags    = 0;
+   sigill_new.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sigill_new.sa_mask );
    sk_assert(res == 0);
 
-   res = VG_(ksigaction)( VKI_SIGILL, &sigill_new, &sigill_saved );
+   res = VG_(sigaction)( VKI_SIGILL, &sigill_new, &sigill_saved );
    sk_assert(res == 0);
 
    /* Trap for illegal instruction, in case it's a really old processor that
@@ -278,14 +278,14 @@ Int get_caches_from_CPUID(cache_t* I1c, cache_t* D1c, cache_t* L2c)
       vendor_id[12] = '\0';
 
       /* Restore old SIGILL handler */
-      res = VG_(ksigaction)( VKI_SIGILL, &sigill_saved, NULL );
+      res = VG_(sigaction)( VKI_SIGILL, &sigill_saved, NULL );
       sk_assert(res == 0);
 
    } else  {
       VG_(message)(Vg_DebugMsg, "CPUID instruction not supported");
 
       /* Restore old SIGILL handler */
-      res = VG_(ksigaction)( VKI_SIGILL, &sigill_saved, NULL );
+      res = VG_(sigaction)( VKI_SIGILL, &sigill_saved, NULL );
       sk_assert(res == 0);
       return -1;
    }
index 588f3759b1d3dfe61c1d2dcb2fc2edeea8cfb76d..2bcb4e02f5bd406518bd3751c001ca462c30785c 100644 (file)
@@ -241,19 +241,6 @@ if test "$vg_have_sched_priority" = yes; then
 AC_DEFINE([HAVE_SCHED_PRIORITY], 1, [pthread / sched_priority exists])
 fi
 
-AC_MSG_CHECKING([whether nfds_t is defined])
-AC_CACHE_VAL(vg_have_nfds_t,
-[
-AC_TRY_COMPILE([#include <sys/poll.h>],[
-nfds_t i=0;],
-vg_have_nfds_t=yes,
-vg_have_nfds_t=no)
-])
-AC_MSG_RESULT($vg_have_nfds_t)
-if test "$vg_have_nfds_t" = yes; then
-AC_DEFINE([HAVE_NFDS_T], 1, [nfds_t exists])
-fi
-
 # try to detect the XFree version
 # JRS 2002-06-17: this is completely bogus because it
 # detects the server version, whereas we need to know the 
@@ -336,21 +323,6 @@ EOF
 fi
 
 
-# check if the GNU as supports CFI directives
-AC_MSG_CHECKING([if gas accepts .cfi])
-AC_TRY_LINK(, [
-
-__asm__ __volatile__ (".cfi_startproc\n"
-                      ".cfi_adjust_cfa_offset 0x0\n"
-                      ".cfi_endproc\n");
-],
-[
-  AC_DEFINE_UNQUOTED([HAVE_GAS_CFI], 1, [Define if your GNU as supports .cfi])
-  AC_MSG_RESULT(yes)
-],
-  AC_MSG_RESULT(no)
-)
-
 # does this compiler support -mpreferred-stack-boundary=2 ?
 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary])
 
@@ -394,14 +366,7 @@ AM_CONDITIONAL(USE_PIE, test "$vg_cv_pie" = "yes")
 
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h sys/statfs.h sys/time.h sys/endian.h endian.h termios.h unistd.h utime.h linux/fb.h mqueue.h linux/compiler.h])
-
-AH_TEMPLATE([HAVE_LINUX_MII_H], [])
-AC_MSG_CHECKING([for linux/mii.h])
-AC_PREPROC_IFELSE([#include <linux/mii.h>],
-                   [AC_DEFINE([HAVE_LINUX_MII_H])
-                    AC_MSG_RESULT([yes])],
-                   [AC_MSG_RESULT([no])])
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h sys/statfs.h sys/time.h sys/endian.h endian.h termios.h unistd.h utime.h mqueue.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_UID_T
@@ -409,7 +374,6 @@ AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
 AC_CHECK_TYPES(__pthread_unwind_buf_t,,,[#include <pthread.h>])
-AC_CHECK_TYPES(u16,,,[#include <linux/mii.h>])
 
 # Checks for library functions.
 AC_FUNC_MEMCMP
@@ -429,6 +393,8 @@ AC_OUTPUT(
    include/valgrind.h 
    include/Makefile 
    include/x86/Makefile 
+   include/linux/Makefile 
+   include/x86-linux/Makefile 
    auxprogs/Makefile
    coregrind/Makefile 
    coregrind/demangle/Makefile 
index c70d39b41e63ac1ba3bee04c76a623f9c1a8cd67..0831070029507c2569db146437b57ea991ef8282 100644 (file)
@@ -26,8 +26,7 @@ noinst_HEADERS = \
        ume.h                   \
        vg_symtab2.h            \
        vg_symtypes.h           \
-       vg_toolint.h            \
-       vg_unsafe.h
+       vg_toolint.h
 
 EXTRA_DIST = \
        vg_libpthread.vs valgrind.vs \
index 71a681d86529b73fa0b07d48cb0b76119f006961..42af4c25642b94718ec028d735389271c3c31e6c 100644 (file)
 /* a - alignment - must be a power of 2 */
 #define ROUNDDN(p, a)  ((Addr)(p) & ~((a)-1))
 #define ROUNDUP(p, a)  ROUNDDN((p)+(a)-1, (a))
-#define PGROUNDDN(p)   ROUNDDN(p, VKI_BYTES_PER_PAGE)
-#define PGROUNDUP(p)   ROUNDUP(p, VKI_BYTES_PER_PAGE)
+#define PGROUNDDN(p)   ROUNDDN(p, VKI_PAGE_SIZE)
+#define PGROUNDUP(p)   ROUNDUP(p, VKI_PAGE_SIZE)
 
 /* ---------------------------------------------------------------------
    Environment variables
@@ -798,20 +798,20 @@ typedef
       LWP: it may have more signals blocked because of signal
       handling, or it may be different because of sigsuspend.
    */
-   vki_ksigset_t sig_mask;
+   vki_sigset_t sig_mask;
 
    /* Effective signal mask.  This is the mask which currently
       applies; it may be different from sig_mask while a signal
       handler is running.
     */
-   vki_ksigset_t eff_sig_mask;
+   vki_sigset_t eff_sig_mask;
 
    /* Signal queue.  This is used when the kernel doesn't route
       signals properly in order to remember the signal information
       while we are routing the signal.  It is a circular queue with
       insertions performed at the head and removals at the tail.
     */
-   vki_ksiginfo_t sigqueue[VG_N_SIGNALQUEUE];
+   vki_siginfo_t sigqueue[VG_N_SIGNALQUEUE];
    Int sigqueue_head;
    Int sigqueue_tail;
 
@@ -845,7 +845,7 @@ typedef
    Addr stack_highest_word;
 
    /* Alternate signal stack */
-   vki_kstack_t altstack;
+   vki_stack_t altstack;
 
    /* Architecture-specific thread state */
    arch_thread_t arch;
@@ -900,7 +900,7 @@ extern void VG_(scheduler_init) ( void );
 extern void VG_(pp_sched_status) ( void );
 
 // Longjmp back to the scheduler and thus enter the sighandler immediately.
-extern void VG_(resume_scheduler) ( Int sigNo, vki_ksiginfo_t *info );
+extern void VG_(resume_scheduler) ( Int sigNo, vki_siginfo_t *info );
 
 // Longjmp, ending the scheduler, when a fatal signal occurs in the client.
 extern void VG_(scheduler_handle_fatal_signal)( Int sigNo );
@@ -948,7 +948,7 @@ extern Int  VG_(sig_alloc_rtsig) ( Int high );
 
 extern void VG_(sigstartup_actions) ( void );
 
-extern void VG_(deliver_signal) ( ThreadId tid, const vki_ksiginfo_t *, Bool async );
+extern void VG_(deliver_signal) ( ThreadId tid, const vki_siginfo_t *, Bool async );
 extern void VG_(unblock_host_signal) ( Int sigNo );
 
 extern Bool VG_(is_sig_ign) ( Int sigNo );
@@ -961,11 +961,11 @@ extern void VG_(route_signals) ( void );
 extern void VG_(do__NR_sigaltstack)   ( ThreadId tid );
 extern void VG_(do__NR_sigaction)     ( ThreadId tid );
 extern void VG_(do__NR_sigprocmask)   ( ThreadId tid, Int how, 
-                                        vki_ksigset_t* set,
-                                        vki_ksigset_t* oldset );
+                                        vki_sigset_t* set,
+                                        vki_sigset_t* oldset );
 extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid, Int how, 
-                                               vki_ksigset_t* set,
-                                               vki_ksigset_t* oldset );
+                                               vki_sigset_t* set,
+                                               vki_sigset_t* oldset );
 
 /* Modify the current thread's state once we have detected it is
    returning from a signal handler. */
@@ -973,9 +973,9 @@ extern Bool VG_(signal_returns) ( ThreadId tid );
 
 /* Handy utilities to block/restore all host signals. */
 extern void VG_(block_all_host_signals) 
-                  ( /* OUT */ vki_ksigset_t* saved_mask );
+                  ( /* OUT */ vki_sigset_t* saved_mask );
 extern void VG_(restore_all_host_signals) 
-                  ( /* IN */ vki_ksigset_t* saved_mask );
+                  ( /* IN */ vki_sigset_t* saved_mask );
 
 extern void VG_(kill_self)(Int sigNo);
 
@@ -1228,8 +1228,8 @@ extern Addr VG_(shadow_end);
 extern Addr VG_(valgrind_base);        /* valgrind's address range */
 extern Addr VG_(valgrind_last); // Nb: last byte, rather than one past the end
 
-extern vki_rlimit VG_(client_rlimit_data); /* client's original rlimit data */
-extern vki_rlimit VG_(client_rlimit_stack); /* client's original rlimit stack */
+extern struct vki_rlimit VG_(client_rlimit_data); /* client's original rlimit data */
+extern struct vki_rlimit VG_(client_rlimit_stack); /* client's original rlimit stack */
 
 /* client executable file descriptor */
 extern Int  VG_(clexecfd);
@@ -1360,7 +1360,7 @@ extern void VG_(proxy_delete)   ( ThreadId tid, Bool force );
 extern void VG_(proxy_results)  ( void );
 extern void VG_(proxy_sendsig)  ( ThreadId tid, Int signo );
 extern void VG_(proxy_setsigmask)(ThreadId tid);
-extern void VG_(proxy_sigack)   ( ThreadId tid, const vki_ksigset_t *);
+extern void VG_(proxy_sigack)   ( ThreadId tid, const vki_sigset_t *);
 extern void VG_(proxy_abort_syscall) ( ThreadId tid );
 extern void VG_(proxy_waitsig)  ( void );
 extern void VG_(proxy_wait_sys)        (ThreadId tid, Bool restart);
@@ -1375,7 +1375,7 @@ void VG_(sanity_check_proxy)(void);
 /* Send a signal from a thread's proxy to the thread.  This longjmps
    back into the proxy's main loop, so it doesn't return. */
 __attribute__ ((__noreturn__))
-extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo, 
+extern void VG_(proxy_handlesig)( const vki_siginfo_t *siginfo, 
                                  Addr ip, Int sysnum );
 
 /* ---------------------------------------------------------------------
@@ -1515,21 +1515,21 @@ extern Int  VGA_(ptrace_setregs_from_BB)  ( Int pid );
 extern Int  VGA_(ptrace_setregs_from_tst) ( Int pid, arch_thread_t* arch );
 
 // Making coredumps
-extern void VGA_(fill_elfregs_from_BB)     ( struct user_regs_struct* regs );
-extern void VGA_(fill_elfregs_from_tst)    ( struct user_regs_struct* regs,
+extern void VGA_(fill_elfregs_from_BB)     ( struct vki_user_regs_struct* regs );
+extern void VGA_(fill_elfregs_from_tst)    ( struct vki_user_regs_struct* regs,
                                              const arch_thread_t* arch );
-extern void VGA_(fill_elffpregs_from_BB)   ( elf_fpregset_t* fpu );
-extern void VGA_(fill_elffpregs_from_tst)  ( elf_fpregset_t* fpu,
+extern void VGA_(fill_elffpregs_from_BB)   ( vki_elf_fpregset_t* fpu );
+extern void VGA_(fill_elffpregs_from_tst)  ( vki_elf_fpregset_t* fpu,
                                              const arch_thread_t* arch );
-extern void VGA_(fill_elffpxregs_from_BB)  ( elf_fpxregset_t* xfpu );
-extern void VGA_(fill_elffpxregs_from_tst) ( elf_fpxregset_t* xfpu,
+extern void VGA_(fill_elffpxregs_from_BB)  ( vki_elf_fpxregset_t* xfpu );
+extern void VGA_(fill_elffpxregs_from_tst) ( vki_elf_fpxregset_t* xfpu,
                                              const arch_thread_t* arch );
 
 // Signal stuff
 extern void VGA_(push_signal_frame) ( ThreadId tid, Addr sp_top_of_frame,
-                                      const vki_ksiginfo_t *siginfo,
+                                      const vki_siginfo_t *siginfo,
                                       void *handler, UInt flags,
-                                      const vki_ksigset_t *mask);
+                                      const vki_sigset_t *mask);
 extern Int  VGA_(pop_signal_frame)  ( ThreadId tid );
 
 // libpthread stuff
index b79a747a7046e3c375910b56b0f7e885c726b6d1..3ea44d0ffbcb294a7d177ffd3be4023dff9b8221 100644 (file)
@@ -252,9 +252,9 @@ ESZ(Addr) mapelf(struct elfinfo *e, ESZ(Addr) base)
             check_mmap(res, (char*)ROUNDUP(bss,align), bytes);
          }
 
-        bytes = bss & (VKI_BYTES_PER_PAGE - 1);
+        bytes = bss & (VKI_PAGE_SIZE - 1);
         if (bytes > 0) {
-           bytes = VKI_BYTES_PER_PAGE - bytes;
+           bytes = VKI_PAGE_SIZE - bytes;
            memset((char *)bss, 0, bytes);
         }
       }
@@ -281,7 +281,7 @@ static int load_ELF(char *hdr, int len, int fd, const char *name,
    ESZ(Addr) maxaddr = 0;      /* highest mapped address */
    ESZ(Addr) interp_addr = 0;  /* interpreter (ld.so) address */
    ESZ(Word) interp_size = 0;  /* interpreter size */
-   ESZ(Word) interp_align = VKI_BYTES_PER_PAGE;
+   ESZ(Word) interp_align = VKI_PAGE_SIZE;
    int i;
    void *entry;
    ESZ(Addr) ebase = 0;
@@ -537,7 +537,7 @@ static int do_exec_inner(const char *exe, struct exeinfo *info)
 {
    int fd;
    int err;
-   char buf[VKI_BYTES_PER_PAGE];
+   char buf[VKI_PAGE_SIZE];
    int bufsz;
    int i;
    int ret;
index 0c3d2913be6b11e175c35e3abc23803c38a403ad..e9e808798be65e3ea7ecb2837a9b4ebbb5007fec 100644 (file)
@@ -178,8 +178,7 @@ static UInt stack_snapshot2 ( Addr* ips, UInt n_ips, Addr ip, Addr fp,
    // JRS 2002-sep-17: hack, to round up fp_max to the end of the
    // current page, at least.  Dunno if it helps.
    // NJN 2002-sep-17: seems to -- stack traces look like 1.0.X again
-   fp_max = (fp_max_orig + VKI_BYTES_PER_PAGE - 1) 
-                & ~(VKI_BYTES_PER_PAGE - 1);
+   fp_max = (fp_max_orig + VKI_PAGE_SIZE - 1) & ~(VKI_PAGE_SIZE - 1);
    fp_max -= sizeof(Addr);
 
    /* Assertion broken before main() is reached in pthreaded programs;  the
index bf6d31ead4a7c3129c072445279dca4f4569bb53..bfaff070f89d898a4aadec2ae10b3b4cc5f59d7b 100644 (file)
@@ -410,7 +410,7 @@ int pthread_attr_init(pthread_attr_t *attr)
    vg_attr->__vg_detachstate = PTHREAD_CREATE_JOINABLE;
    /* Linuxthreads sets this field to the value __getpagesize(), so I
       guess the following is OK. */
-   vg_attr->__vg_guardsize = VKI_BYTES_PER_PAGE;
+   vg_attr->__vg_guardsize = VKI_PAGE_SIZE;
    /* No special stack yet. */
    vg_attr->__vg_stackaddr = 0;
    vg_attr->__vg_stacksize = VG_PTHREAD_STACK_SIZE;
@@ -1080,7 +1080,7 @@ pthread_create (pthread_t *__restrict __thredd,
    } else {
       si.base = (Addr)NULL;
       si.size = VG_PTHREAD_STACK_SIZE;
-      si.guardsize = VKI_BYTES_PER_PAGE;
+      si.guardsize = VKI_PAGE_SIZE;
    }
    
    VALGRIND_MAGIC_SEQUENCE(tid_child, VG_INVALID_THREADID /* default */,
index f2afc12f97421966a8c3ba58ecf44664f208ac45..cc1404fc45cc2e09472644c371f0d5ce900ff9b9 100644 (file)
@@ -106,8 +106,8 @@ Addr VG_(valgrind_base);     /* valgrind's address range */
 // the VG_(*_end) vars name the byte one past the end of the section.
 Addr VG_(valgrind_last);
 
-vki_rlimit VG_(client_rlimit_data);
-vki_rlimit VG_(client_rlimit_stack);
+struct vki_rlimit VG_(client_rlimit_data);
+struct vki_rlimit VG_(client_rlimit_stack);
 
 /* This is set early to indicate whether this CPU has the
    SSE/fxsave/fxrestor features.  */
@@ -239,7 +239,7 @@ void VG_(start_debugger) ( Int tid )
 
    if ((pid = fork()) == 0) {
       ptrace(PTRACE_TRACEME, 0, NULL, NULL);
-      VG_(kkill)(VG_(getpid)(), VKI_SIGSTOP);
+      VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
 
    } else if (pid > 0) {
       Int status;
@@ -301,7 +301,7 @@ void VG_(start_debugger) ( Int tid )
          }
       }
 
-      VG_(kkill)(pid, VKI_SIGKILL);
+      VG_(kill)(pid, VKI_SIGKILL);
       VG_(waitpid)(pid, &status, 0);
    }
 }
@@ -987,12 +987,12 @@ static Addr setup_client_stack(void* init_sp,
       sizeof(char **) +                        /* terminal NULL */
       auxsize +                                /* auxv */
       ROUNDUP(stringsize, sizeof(int)) +/* strings (aligned) */
-      VKI_BYTES_PER_PAGE;              /* page for trampoline code */
+      VKI_PAGE_SIZE;           /* page for trampoline code */
 
    // decide where stack goes!
    VG_(clstk_end) = VG_(client_end);
 
-   VG_(client_trampoline_code) = VG_(clstk_end) - VKI_BYTES_PER_PAGE;
+   VG_(client_trampoline_code) = VG_(clstk_end) - VKI_PAGE_SIZE;
 
    /* cl_esp is the client's stack pointer */
    cl_esp = VG_(clstk_end) - stacksize;
@@ -1680,9 +1680,9 @@ static void process_cmd_line_options( UInt* client_auxv, const char* toolname )
      config_error("Please use absolute paths in "
                   "./configure --prefix=... or --libdir=...");
 
-   for (auxp = client_auxv; auxp[0] != VKI_AT_NULL; auxp += 2) {
+   for (auxp = client_auxv; auxp[0] != AT_NULL; auxp += 2) {
       switch(auxp[0]) {
-      case VKI_AT_SYSINFO:
+      case AT_SYSINFO:
         auxp[1] = (Int)(VG_(client_trampoline_code) + VG_(tramp_syscall_offset));
         break;
       }
@@ -2551,7 +2551,7 @@ int main(int argc, char **argv)
    VgSchedReturnCode src;
    Int exitcode = 0;
    Int fatal_sigNo = -1;
-   vki_rlimit zero = { 0, 0 };
+   struct vki_rlimit zero = { 0, 0 };
    Int padfile;
    ThreadId last_run_tid = 0;    // Last thread the scheduler ran.
 
index a6d8832e784572a277a3c1632dd119014068d4e5..81e713372a780c9b0e567fa3fedd66e41b5a0fa4 100644 (file)
@@ -344,7 +344,7 @@ void arena_init ( ArenaId aid, Char* name, Int rz_szB, Int min_sblock_szB )
    Arena* a = arenaId_to_ArenaP(aid);
    
    vg_assert(rz_szB >= 0);
-   vg_assert((min_sblock_szB % VKI_BYTES_PER_PAGE) == 0);
+   vg_assert((min_sblock_szB % VKI_PAGE_SIZE) == 0);
    a->name      = name;
    a->clientmem = ( VG_AR_CLIENT == aid ? True : False );
 
@@ -455,7 +455,7 @@ Superblock* newSuperblock ( Arena* a, Int cszB )
    cszB += sizeof(Superblock);
 
    if (cszB < a->min_sblock_szB) cszB = a->min_sblock_szB;
-   while ((cszB % VKI_BYTES_PER_PAGE) > 0) cszB++;
+   while ((cszB % VKI_PAGE_SIZE) > 0) cszB++;
 
    if (!called_before) {
       // First time we're called -- use the special static bootstrap
index bd1e76f963ac2229c99eddaaaeb0f49a2e89f5d7..43915e18c535055c3a15f2ac69bfabd201577b55 100644 (file)
@@ -119,7 +119,7 @@ Segment *VG_(split_segment)(Addr a)
    Segment *ns;
    Int delta;
 
-   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((a & (VKI_PAGE_SIZE-1)) == 0);
 
    /* missed */
    if (s == NULL)
@@ -173,8 +173,8 @@ void VG_(unmap_range)(Addr addr, UInt len)
    end = addr+len;
 
    /* Everything must be page-aligned */
-   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
-   vg_assert((len  & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((addr & (VKI_PAGE_SIZE-1)) == 0);
+   vg_assert((len  & (VKI_PAGE_SIZE-1)) == 0);
 
    for(s = VG_(SkipList_Find)(&sk_segments, &addr); 
        s != NULL && s->addr < (addr+len); 
@@ -286,11 +286,11 @@ static void merge_segments(Addr a, UInt len)
    Segment *s;
    Segment *next;
 
-   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
-   vg_assert((len & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((a   & (VKI_PAGE_SIZE-1)) == 0);
+   vg_assert((len & (VKI_PAGE_SIZE-1)) == 0);
 
-   a -= VKI_BYTES_PER_PAGE;
-   len += VKI_BYTES_PER_PAGE;
+   a   -= VKI_PAGE_SIZE;
+   len += VKI_PAGE_SIZE;
 
    for(s = VG_(SkipList_Find)(&sk_segments, &a);
        s != NULL && s->addr < (a+len);) {
@@ -326,7 +326,7 @@ void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags,
                  addr, len, prot, flags, dev, ino, off, filename);
 
    /* Everything must be page-aligned */
-   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((addr & (VKI_PAGE_SIZE-1)) == 0);
    len = PGROUNDUP(len);
 
    /* First look to see what already exists around here */
@@ -392,7 +392,7 @@ void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags,
       if (off == 0                                                                     &&
          filename != NULL                                                              &&
          (prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == (VKI_PROT_READ|VKI_PROT_EXEC)       &&
-         len >= VKI_BYTES_PER_PAGE                                                     &&
+         len >= VKI_PAGE_SIZE                                                  &&
          s->symtab == NULL                                                             &&
          VG_(is_object_file)((void *)addr)) 
       {
@@ -431,7 +431,7 @@ void VG_(map_fd_segment)(Addr addr, UInt len, UInt prot, UInt flags,
    st.st_ino = 0;
 
    if (fd != -1 && (flags & SF_FILE)) {
-      vg_assert((off & (VKI_BYTES_PER_PAGE-1)) == 0);
+      vg_assert((off & (VKI_PAGE_SIZE-1)) == 0);
 
       if (VG_(fstat)(fd, &st) < 0)
         flags &= ~SF_FILE;
@@ -466,7 +466,7 @@ void VG_(mprotect_range)(Addr a, UInt len, UInt prot)
       VG_(printf)("mprotect_range(%p, %d, %x)\n", a, len, prot);
 
    /* Everything must be page-aligned */
-   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((a & (VKI_PAGE_SIZE-1)) == 0);
    len = PGROUNDUP(len);
 
    VG_(split_segment)(a);
@@ -499,15 +499,15 @@ Addr VG_(find_map_space)(Addr addr, UInt len, Bool for_client)
    else {
       /* leave space for redzone and still try to get the exact
         address asked for */
-      addr -= VKI_BYTES_PER_PAGE;
+      addr -= VKI_PAGE_SIZE;
    }
    ret = addr;
 
    /* Everything must be page-aligned */
-   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
+   vg_assert((addr & (VKI_PAGE_SIZE-1)) == 0);
    len = PGROUNDUP(len);
 
-   len += VKI_BYTES_PER_PAGE * 2; /* leave redzone gaps before and after mapping */
+   len += VKI_PAGE_SIZE * 2; /* leave redzone gaps before and after mapping */
 
    if (debug)
       VG_(printf)("find_map_space: ret starts as %p-%p client=%d\n",
@@ -539,7 +539,7 @@ Addr VG_(find_map_space)(Addr addr, UInt len, Bool for_client)
    if (((limit - len)+1) < ret)
       ret = 0;                 /* no space */
    else
-      ret += VKI_BYTES_PER_PAGE; /* skip leading redzone */
+      ret += VKI_PAGE_SIZE; /* skip leading redzone */
 
    if (debug)
       VG_(printf)("find_map_space(%p, %d, %d) -> %p\n",
@@ -719,16 +719,16 @@ Bool VG_(is_addressable)(Addr p, Int size)
 {
    volatile Char * volatile cp = (volatile Char *)p;
    volatile Bool ret;
-   vki_ksigaction sa, origsa;
-   vki_ksigset_t mask;
+   struct vki_sigaction sa, origsa;
+   vki_sigset_t mask;
 
    vg_assert(size > 0);
 
    sa.ksa_handler = segv_handler;
-   sa.ksa_flags = 0;
-   VG_(ksigfillset)(&sa.ksa_mask);
-   VG_(ksigaction)(VKI_SIGSEGV, &sa, &origsa);
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, NULL, &mask);
+   sa.sa_flags = 0;
+   VG_(sigfillset)(&sa.sa_mask);
+   VG_(sigaction)(VKI_SIGSEGV, &sa, &origsa);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, NULL, &mask);
 
    if (__builtin_setjmp(&segv_jmpbuf) == 0) {
       while(size--)
@@ -737,8 +737,8 @@ Bool VG_(is_addressable)(Addr p, Int size)
     } else
       ret = False;
 
-   VG_(ksigaction)(VKI_SIGSEGV, &origsa, NULL);
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
+   VG_(sigaction)(VKI_SIGSEGV, &origsa, NULL);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
 
    return ret;
 }
@@ -847,8 +847,8 @@ void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init)
         /* ask the tool to initialize each page */
         VG_TRACK( init_shadow_page, PGROUNDDN(p) );
         
-        p += VKI_BYTES_PER_PAGE;
-        sz -= VKI_BYTES_PER_PAGE;
+        p  += VKI_PAGE_SIZE;
+        sz -= VKI_PAGE_SIZE;
       }
 }
 
index b30330db3cf10d71ac15b904bfc9e016a6699c58..260afac7fbb76c753591a88098316517ec888397 100644 (file)
 /* sigemptyset, sigfullset, sigaddset and sigdelset return 0 on
    success and -1 on error.  
 */
-Int VG_(ksigfillset)( vki_ksigset_t* set )
+Int VG_(sigfillset)( vki_sigset_t* set )
 {
    Int i;
    if (set == NULL)
       return -1;
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      set->ws[i] = 0xFFFFFFFF;
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      set->sig[i] = 0xFFFFFFFF;
    return 0;
 }
 
-Int VG_(ksigemptyset)( vki_ksigset_t* set )
+Int VG_(sigemptyset)( vki_sigset_t* set )
 {
    Int i;
    if (set == NULL)
       return -1;
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      set->ws[i] = 0x0;
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      set->sig[i] = 0x0;
    return 0;
 }
 
-Bool VG_(kisemptysigset)( vki_ksigset_t* set )
+Bool VG_(isemptysigset)( vki_sigset_t* set )
 {
    Int i;
    vg_assert(set != NULL);
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      if (set->ws[i] != 0x0) return False;
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      if (set->sig[i] != 0x0) return False;
    return True;
 }
 
-Bool VG_(kisfullsigset)( vki_ksigset_t* set )
+Bool VG_(isfullsigset)( vki_sigset_t* set )
 {
    Int i;
    vg_assert(set != NULL);
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      if (set->ws[i] != (UInt)(~0x0)) return False;
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      if (set->sig[i] != (UInt)(~0x0)) return False;
    return True;
 }
 
 
-Int VG_(ksigaddset)( vki_ksigset_t* set, Int signum )
+Int VG_(sigaddset)( vki_sigset_t* set, Int signum )
 {
    if (set == NULL)
       return -1;
-   if (signum < 1 || signum > VKI_KNSIG)
+   if (signum < 1 || signum > _VKI_NSIG)
       return -1;
    signum--;
-   set->ws[signum / VKI_KNSIG_BPW] |= (1 << (signum % VKI_KNSIG_BPW));
+   set->sig[signum / _VKI_NSIG_BPW] |= (1 << (signum % _VKI_NSIG_BPW));
    return 0;
 }
 
-Int VG_(ksigdelset)( vki_ksigset_t* set, Int signum )
+Int VG_(sigdelset)( vki_sigset_t* set, Int signum )
 {
    if (set == NULL)
       return -1;
-   if (signum < 1 || signum > VKI_KNSIG)
+   if (signum < 1 || signum > _VKI_NSIG)
       return -1;
    signum--;
-   set->ws[signum / VKI_KNSIG_BPW] &= ~(1 << (signum % VKI_KNSIG_BPW));
+   set->sig[signum / _VKI_NSIG_BPW] &= ~(1 << (signum % _VKI_NSIG_BPW));
    return 0;
 }
 
-Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum )
+Int VG_(sigismember) ( vki_sigset_t* set, Int signum )
 {
    if (set == NULL)
       return 0;
-   if (signum < 1 || signum > VKI_KNSIG)
+   if (signum < 1 || signum > _VKI_NSIG)
       return 0;
    signum--;
-   if (1 & ((set->ws[signum / VKI_KNSIG_BPW]) >> (signum % VKI_KNSIG_BPW)))
+   if (1 & ((set->sig[signum / _VKI_NSIG_BPW]) >> (signum % _VKI_NSIG_BPW)))
       return 1;
    else
       return 0;
@@ -115,60 +115,60 @@ Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum )
 
 
 /* Add all signals in src to dst. */
-void VG_(ksigaddset_from_set)( vki_ksigset_t* dst, vki_ksigset_t* src )
+void VG_(sigaddset_from_set)( vki_sigset_t* dst, vki_sigset_t* src )
 {
    Int i;
    vg_assert(dst != NULL && src != NULL);
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      dst->ws[i] |= src->ws[i];
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      dst->sig[i] |= src->sig[i];
 }
 
 /* Remove all signals in src from dst. */
-void VG_(ksigdelset_from_set)( vki_ksigset_t* dst, vki_ksigset_t* src )
+void VG_(sigdelset_from_set)( vki_sigset_t* dst, vki_sigset_t* src )
 {
    Int i;
    vg_assert(dst != NULL && src != NULL);
-   for (i = 0; i < VKI_KNSIG_WORDS; i++)
-      dst->ws[i] &= ~(src->ws[i]);
+   for (i = 0; i < _VKI_NSIG_WORDS; i++)
+      dst->sig[i] &= ~(src->sig[i]);
 }
 
 
 /* The functions sigaction, sigprocmask, sigpending and sigsuspend
    return 0 on success and -1 on error.  
 */
-Int VG_(ksigprocmask)( Int how, 
-                       const vki_ksigset_t* set, 
-                       vki_ksigset_t* oldset)
+Int VG_(sigprocmask)( Int how, 
+                       const vki_sigset_t* set, 
+                       vki_sigset_t* oldset)
 {
    Int res 
       = VG_(do_syscall)(__NR_rt_sigprocmask, 
                        how, (UInt)set, (UInt)oldset, 
-                       VKI_KNSIG_WORDS * VKI_BYTES_PER_WORD);
+                       _VKI_NSIG_WORDS * sizeof(UWord));
    return VG_(is_kerror)(res) ? -1 : 0;
 }
 
 
-Int VG_(ksigaction) ( Int signum,  
-                      const vki_ksigaction* act,  
-                      vki_ksigaction* oldact)
+Int VG_(sigaction) ( Int signum,  
+                      const struct vki_sigaction* act,  
+                      struct vki_sigaction* oldact)
 {
    Int res
      = VG_(do_syscall)(__NR_rt_sigaction,
                       signum, (UInt)act, (UInt)oldact, 
-                      VKI_KNSIG_WORDS * VKI_BYTES_PER_WORD);
+                      _VKI_NSIG_WORDS * sizeof(UWord));
    /* VG_(printf)("res = %d\n",res); */
    return VG_(is_kerror)(res) ? -1 : 0;
 }
 
 
-Int VG_(ksigaltstack)( const vki_kstack_t* ss, vki_kstack_t* oss )
+Int VG_(sigaltstack)( const vki_stack_t* ss, vki_stack_t* oss )
 {
    Int res
      = VG_(do_syscall)(__NR_sigaltstack, (UInt)ss, (UInt)oss);
    return VG_(is_kerror)(res) ? -1 : 0;
 }
 
-Int VG_(ksigtimedwait)( const vki_ksigset_t *set, vki_ksiginfo_t *info, 
+Int VG_(sigtimedwait)( const vki_sigset_t *set, vki_siginfo_t *info, 
                        const struct vki_timespec *timeout )
 {
    Int res = VG_(do_syscall)(__NR_rt_sigtimedwait, set, info, timeout, sizeof(*set));
@@ -176,30 +176,30 @@ Int VG_(ksigtimedwait)( const vki_ksigset_t *set, vki_ksiginfo_t *info,
    return VG_(is_kerror)(res) ? -1 : res;
 }
  
-Int VG_(ksignal)(Int signum, void (*sighandler)(Int))
+Int VG_(signal)(Int signum, void (*sighandler)(Int))
 {
    Int res;
-   vki_ksigaction sa;
+   struct vki_sigaction sa;
    sa.ksa_handler = sighandler;
-   sa.ksa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
-   sa.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sa.ksa_mask );
+   sa.sa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
+   sa.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sa.sa_mask );
    vg_assert(res == 0);
    res = VG_(do_syscall)(__NR_rt_sigaction,
                         signum, (UInt)(&sa), (UInt)NULL,
-                        VKI_KNSIG_WORDS * VKI_BYTES_PER_WORD);
+                        _VKI_NSIG_WORDS * sizeof(UWord));
    return VG_(is_kerror)(res) ? -1 : 0;
 }
 
 
-Int VG_(kkill)( Int pid, Int signo )
+Int VG_(kill)( Int pid, Int signo )
 {
    Int res = VG_(do_syscall)(__NR_kill, pid, signo);
    return VG_(is_kerror)(res) ? -1 : 0;
 }
 
 
-Int VG_(ktkill)( Int tid, Int signo )
+Int VG_(tkill)( Int tid, Int signo )
 {
    Int ret = -VKI_ENOSYS;
 
@@ -218,7 +218,7 @@ Int VG_(ktkill)( Int tid, Int signo )
    return VG_(is_kerror)(ret) ? -1 : 0;
 }
 
-Int VG_(ksigpending) ( vki_ksigset_t* set )
+Int VG_(sigpending) ( vki_sigset_t* set )
 {
    Int res = VG_(do_syscall)(__NR_sigpending, (UInt)set);
    return VG_(is_kerror)(res) ? -1 : 0;
@@ -1810,46 +1810,6 @@ void VG_(ssort)( void* base, UInt nmemb, UInt size,
    This is all very Linux-kernel specific.
    ------------------------------------------------------------------ */
 
-/* Various needed constants from the kernel iface (2.4),
-   /usr/src/linux-2.4.9-31 */
-
-/* kernel, ./include/linux/net.h */
-#define SYS_SOCKET      1              /* sys_socket(2)        */
-#define SYS_CONNECT     3              /* sys_connect(2)       */
-#define SYS_GETSOCKNAME 6              /* sys_getsockname(2)   */
-#define SYS_GETPEERNAME 7              /* sys_getpeername(2)   */
-#define SYS_SEND        9              /* sys_send(2)          */
-#define SYS_GETSOCKOPT  15             /* sys_getsockopt(2)    */
-
-typedef UInt __u32;
-
-/* Internet address. */
-struct vki_in_addr {
-        __u32   s_addr;
-};
-
-/* kernel, include/linux/socket.h */
-#define AF_INET                2       /* Internet IP Protocol        */
-#define MSG_NOSIGNAL           0x4000  /* Do not generate SIGPIPE */
-
-/* kernel, ./include/asm-i386/socket.h */
-#define SOCK_STREAM 1                  /* stream (connection) socket  */
-
-/* kernel, /usr/src/linux-2.4.9-31/linux/include/in.h */
-/* Structure describing an Internet (IP) socket address. */
-#define __SOCK_SIZE__   16              /* sizeof(struct sockaddr)      */
-struct vki_sockaddr_in {
-  vki_sa_family_t       sin_family;     /* Address family               */
-  unsigned short int    sin_port;       /* Port number                  */
-  struct vki_in_addr    sin_addr;       /* Internet address             */
-
-  /* Pad to size of `struct sockaddr'. */
-  unsigned char         __pad[__SOCK_SIZE__ - sizeof(short int) -
-                        sizeof(unsigned short int) - 
-                        sizeof(struct vki_in_addr)];
-};
-
-
 static
 Int parse_inet_addr_and_port ( UChar* str, UInt* ip_addr, UShort* port );
 
@@ -1902,12 +1862,12 @@ Int VG_(connect_via_socket)( UChar* str )
                   (ip >> 8) & 0xFF, ip & 0xFF, 
                  (UInt)port );
 
-   servAddr.sin_family = AF_INET;
+   servAddr.sin_family = VKI_AF_INET;
    servAddr.sin_addr.s_addr = my_htonl(ip);
    servAddr.sin_port = my_htons(port);
 
    /* create socket */
-   sd = my_socket(AF_INET, SOCK_STREAM, 0 /* IPPROTO_IP ? */);
+   sd = my_socket(VKI_AF_INET, VKI_SOCK_STREAM, 0 /* IPPROTO_IP ? */);
    if (sd < 0) {
      /* this shouldn't happen ... nevertheless */
      return -2;
@@ -1978,7 +1938,7 @@ Int my_socket ( Int domain, Int type, Int protocol )
    args[0] = domain;
    args[1] = type;
    args[2] = protocol;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_SOCKET, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_SOCKET, (UInt)&args);
    if (VG_(is_kerror)(res)) 
       res = -1;
    return res;
@@ -1993,7 +1953,7 @@ Int my_connect ( Int sockfd, struct vki_sockaddr_in* serv_addr,
    args[0] = sockfd;
    args[1] = (UInt)serv_addr;
    args[2] = addrlen;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_CONNECT, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_CONNECT, (UInt)&args);
    if (VG_(is_kerror)(res)) 
       res = -1;
    return res;
@@ -2006,7 +1966,7 @@ Int VG_(write_socket)( Int sd, void *msg, Int count )
    /* Requests not to send SIGPIPE on errors on stream oriented
       sockets when the other end breaks the connection. The EPIPE
       error is still returned. */
-   Int flags = MSG_NOSIGNAL;
+   Int flags = VKI_MSG_NOSIGNAL;
 
    Int res;
    UInt args[4];
@@ -2014,7 +1974,7 @@ Int VG_(write_socket)( Int sd, void *msg, Int count )
    args[1] = (UInt)msg;
    args[2] = count;
    args[3] = flags;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_SEND, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_SEND, (UInt)&args);
    if (VG_(is_kerror)(res)) 
       res = -1;
    return res;
@@ -2027,7 +1987,7 @@ Int VG_(getsockname) ( Int sd, struct vki_sockaddr *name, Int *namelen)
    args[0] = sd;
    args[1] = (UInt)name;
    args[2] = (UInt)namelen;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_GETSOCKNAME, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_GETSOCKNAME, (UInt)&args);
    if(VG_(is_kerror)(res))
       res = -1;
    return res;
@@ -2040,7 +2000,7 @@ Int VG_(getpeername) ( Int sd, struct vki_sockaddr *name, Int *namelen)
    args[0] = sd;
    args[1] = (UInt)name;
    args[2] = (UInt)namelen;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_GETPEERNAME, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_GETPEERNAME, (UInt)&args);
    if(VG_(is_kerror)(res))
       res = -1;
    return res;
@@ -2056,7 +2016,7 @@ Int VG_(getsockopt) ( Int sd, Int level, Int optname, void *optval,
    args[2] = (UInt)optname;
    args[3] = (UInt)optval;
    args[4] = (UInt)optlen;
-   res = VG_(do_syscall)(__NR_socketcall, SYS_GETSOCKOPT, (UInt)&args);
+   res = VG_(do_syscall)(__NR_socketcall, VKI_SYS_GETSOCKOPT, (UInt)&args);
    if(VG_(is_kerror)(res))
       res = -1;
    return res;
index 8f7cb77d4b4b2b8fad480ba4956d18eec39a1484..bfd62153b3721e6cc4dcfe2ecaddad0c0155226d 100644 (file)
@@ -51,7 +51,7 @@ struct ProxyLWP {
    Int                 exitcode;       /* ProxyLWP exit code */
 
    Int                 topx, frommain; /* pipe fds */
-   vki_ksiginfo_t      siginfo;        /* received signal */
+   vki_siginfo_t       siginfo;        /* received signal */
    Bool                        terminating;    /* in the middle of exiting */
 
    /* State of proxy */
@@ -65,7 +65,7 @@ static void sys_wait_results(Bool block, ThreadId tid, enum RequestType reqtype,
 struct PX_Request {
    enum RequestType    request;
 
-   vki_ksigset_t       sigmask;        /* sigmask applied by SigACK */
+   vki_sigset_t                sigmask;        /* sigmask applied by SigACK */
 };
 
 /* All replies are multiplexed over a single pipe, so we need to disinguish them */
@@ -75,7 +75,7 @@ struct PX_Reply {
 
    union {
       Int              syscallno;      /* system call completed */
-      vki_ksiginfo_t   siginfo;        /* signal */
+      vki_siginfo_t    siginfo;        /* signal */
    } u;
 };
 
@@ -136,7 +136,7 @@ static const Char *px_name(enum RequestType r)
    }
 }
 
-#define PROXYLWP_OFFSET        (VKI_BYTES_PER_PAGE - sizeof(ProxyLWP))
+#define PROXYLWP_OFFSET        (VKI_PAGE_SIZE - sizeof(ProxyLWP))
 
 /* 
    Allocate a page for the ProxyLWP and its stack.
@@ -148,7 +148,7 @@ static const Char *px_name(enum RequestType r)
  */
 static ProxyLWP *LWP_alloc(void)
 {
-   UChar *p = VG_(get_memory_from_mmap)(VKI_BYTES_PER_PAGE, "alloc_LWP");
+   UChar *p = VG_(get_memory_from_mmap)(VKI_PAGE_SIZE, "alloc_LWP");
    ProxyLWP *ret;
    vg_assert(p == (UChar *)PGROUNDDN(p)); /* px must be page aligned */
 
@@ -168,7 +168,7 @@ static void LWP_free(ProxyLWP *px)
    px->magic = 0;
    vg_assert((p + PROXYLWP_OFFSET) == (UChar *)px);
 
-   VG_(munmap)(p, VKI_BYTES_PER_PAGE);
+   VG_(munmap)(p, VKI_PAGE_SIZE);
 }
 
 /* Get a particular ProxyLWP's LWP structure from its esp (relies on
@@ -282,7 +282,7 @@ void VG_(proxy_shutdown)(void)
    handler is being run with all signals blocked; the longjmp is
    there to make sure they stay masked until the application thread is
    ready to run its signal handler. */
-void VG_(proxy_handlesig)(const vki_ksiginfo_t *siginfo, Addr ip, Int sysnum)
+void VG_(proxy_handlesig)(const vki_siginfo_t *siginfo, Addr ip, Int sysnum)
 {
    UChar local;
    ProxyLWP *px = LWP_TSD(&local);
@@ -348,22 +348,22 @@ static Int proxylwp(void *v)
    ProxyLWP *px = (ProxyLWP *)v;
    Int frommain = px->frommain;
    ThreadState *tst = px->tst;
-   vki_ksigset_t allsig;
-   vki_ksigset_t appsigmask;   /* signal mask the client has asked for */
+   vki_sigset_t allsig;
+   vki_sigset_t appsigmask;    /* signal mask the client has asked for */
    Int ret = 1000;
-   static const vki_kstack_t ss = { .ss_flags = VKI_SS_DISABLE };
+   static const vki_stack_t ss = { .ss_flags = VKI_SS_DISABLE };
 
    /* Block everything until we're told otherwise (LWP should have
       been started with all signals blocked anyway) */
-   VG_(ksigfillset)(&allsig);
-   VG_(ksigdelset)(&allsig, VKI_SIGVGKILL);    /* but allow SIGVGKILL to interrupt */
+   VG_(sigfillset)(&allsig);
+   VG_(sigdelset)(&allsig, VKI_SIGVGKILL);     /* but allow SIGVGKILL to interrupt */
 
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
 
    appsigmask = allsig;
 
    /* no signal stack for us */
-   VG_(ksigaltstack)(&ss, NULL);
+   VG_(sigaltstack)(&ss, NULL);
 
    for(;;) {
       struct PX_Reply reply, sigreply;
@@ -516,7 +516,7 @@ static Int proxylwp(void *v)
 
         if (px->state == PXS_WaitReq) {
            /* allow signals when waiting for a normal request */
-           VG_(ksigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
+           VG_(sigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
         }
 
         /* ST:1 */
@@ -526,7 +526,7 @@ static Int proxylwp(void *v)
         /* ST:2 */
 
         /* process message with signals blocked */
-        VG_(ksigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
+        VG_(sigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
 
         if (res == 0) {
            ret = 0;
@@ -558,16 +558,16 @@ static Int proxylwp(void *v)
               want while running the handler. */
            vg_assert(px->state == PXS_SigACK);
            appsigmask = req.sigmask;
-           VG_(ksigdelset)(&appsigmask, VKI_SIGVGKILL);  /* but allow SIGVGKILL */
-           VG_(ksigdelset)(&appsigmask, VKI_SIGVGINT);   /*       and SIGVGINT to interrupt */
+           VG_(sigdelset)(&appsigmask, VKI_SIGVGKILL);  /* but allow SIGVGKILL */
+           VG_(sigdelset)(&appsigmask, VKI_SIGVGINT);   /*       and SIGVGINT to interrupt */
            px->state = PXS_WaitReq;
            reply.req = PX_BAD; /* don't reply */
            break;
            
         case PX_SetSigmask:
            appsigmask = req.sigmask;
-           VG_(ksigdelset)(&appsigmask, VKI_SIGVGKILL);  /* but allow SIGVGKILL */
-           VG_(ksigdelset)(&appsigmask, VKI_SIGVGINT);   /*       and SIGVGINT to interrupt */
+           VG_(sigdelset)(&appsigmask, VKI_SIGVGKILL);  /* but allow SIGVGKILL */
+           VG_(sigdelset)(&appsigmask, VKI_SIGVGINT);   /*       and SIGVGINT to interrupt */
 
            vg_assert(px->state == PXS_WaitReq || 
                      px->state == PXS_SigACK);
@@ -578,9 +578,9 @@ static Int proxylwp(void *v)
                  be delivered synchronously, so that some progress is
                  made before the we tell the client the mask has been
                  set..  Then reset the mask back to all blocked. */
-              VG_(ksigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
+              VG_(sigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
               /* ST:3 */
-              VG_(ksigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
+              VG_(sigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
            } else {
               /* Waiting for SigACK.  We want all signals blocked,
                  and when the SigACK arrives, it will give us the
@@ -616,7 +616,7 @@ static Int proxylwp(void *v)
               if (VG_(getpgrp)() != VG_(main_pgrp))
                  VG_(setpgid)(0, VG_(main_pgrp));
 
-              VG_(ksigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
+              VG_(sigprocmask)(VKI_SIG_SETMASK, &appsigmask, NULL);
 
               /* ST:4 */
               
@@ -625,7 +625,7 @@ static Int proxylwp(void *v)
 
               /* ST:5 */
 
-              VG_(ksigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
+              VG_(sigprocmask)(VKI_SIG_SETMASK, &allsig, NULL);
               /* whew - made it here without being interrupted */
               px->state = PXS_WaitReq;
 
@@ -705,9 +705,9 @@ void VG_(proxy_sendsig)(ThreadId tid, Int sig)
       /* SIGKILL and SIGSTOP always apply to all threads (need to
         route for route_signals case?) */
       if (sig == VKI_SIGKILL || sig == VKI_SIGSTOP)
-        VG_(kkill)(VG_(main_pid), sig);
+        VG_(kill)(VG_(main_pid), sig);
       else
-        VG_(ktkill)(lwp, sig);
+        VG_(tkill)(lwp, sig);
    }
 
    /* If a thread is sending a signal to itself and the signal isn't
@@ -716,7 +716,7 @@ void VG_(proxy_sendsig)(ThreadId tid, Int sig)
    if (sig != 0 && 
        !VG_(is_sig_ign)(sig) &&
        tid == VG_(get_current_or_recent_tid)() && 
-       !VG_(ksigismember)(&tst->eff_sig_mask, sig)) {
+       !VG_(sigismember)(&tst->eff_sig_mask, sig)) {
       /* If the LWP is actually blocked in a sigtimedwait, then it
         will eat the signal rather than make it pending and deliver
         it by the normal mechanism.  In this case, just wait for the
@@ -745,7 +745,7 @@ void VG_(proxy_abort_syscall)(ThreadId tid)
    lwp = proxy->lwp;
    
    if (lwp != 0)
-      VG_(ktkill)(lwp, VKI_SIGVGINT);
+      VG_(tkill)(lwp, VKI_SIGVGINT);
 
    sys_wait_results(True, tid, PX_RunSyscall, False);
 
@@ -838,7 +838,7 @@ static Bool proxy_wait(ProxyLWP *proxy, Bool block, Int *status)
         }
       }
    } else {
-      Int flags = VKI__WCLONE;
+      Int flags = __VKI_WCLONE;
       Int res;
 
       if (!block)
@@ -859,7 +859,7 @@ void VG_(proxy_create)(ThreadId tid)
    ThreadState *tst = VG_(get_ThreadState)(tid);
    ProxyLWP *proxy;
    Int p[2];
-   vki_ksigset_t mask;
+   vki_sigset_t mask;
    Int ret;
 
    vg_assert(tst->proxy == NULL);
@@ -928,7 +928,7 @@ void VG_(proxy_delete)(ThreadId tid, Bool force)
       /* wouldn't need to force it if it were already dead */
       vg_assert(tst->status != VgTs_Empty);
       //VG_(printf)("kill %d with SIGVGKILL\n", lwp);
-      VG_(ktkill)(lwp, VKI_SIGVGKILL);
+      VG_(tkill)(lwp, VKI_SIGVGKILL);
    } else
       vg_assert(tst->status == VgTs_Empty); /* just killed */
 
@@ -1125,7 +1125,7 @@ void VG_(proxy_setsigmask)(ThreadId tid)
    sys_wait_results(True, tid, PX_SetSigmask, True);
 }
 
-void VG_(proxy_sigack)(ThreadId tid, const vki_ksigset_t *mask)
+void VG_(proxy_sigack)(ThreadId tid, const vki_sigset_t *mask)
 {
    ThreadState *tst = VG_(get_ThreadState)(tid);
    ProxyLWP *proxy = tst->proxy;
index ec37dbf45844b28d3f185422b348b48b02ee3c9b..c3ffdac301f2cbe1f8fb5688096d0b32f9266796 100644 (file)
@@ -68,7 +68,7 @@ static Int     longjmpd_on_signal;
 /* If the current thread gets a syncronous unresumable signal, then
    its details are placed here by the signal handler, to be passed to
    the applications signal handler later on. */
-static vki_ksiginfo_t unresumable_siginfo;
+static vki_siginfo_t unresumable_siginfo;
 
 /* If != VG_INVALID_THREADID, this is the preferred tid to schedule */
 static ThreadId prefer_sched = VG_INVALID_THREADID;
@@ -303,12 +303,12 @@ static void save_thread_state ( ThreadId tid )
 }
 
 
-void VG_(resume_scheduler)(Int sigNo, vki_ksiginfo_t *info)
+void VG_(resume_scheduler)(Int sigNo, vki_siginfo_t *info)
 {
    if (scheduler_jmpbuf_valid) {
       /* Can't continue; must longjmp back to the scheduler and thus
          enter the sighandler immediately. */
-      VG_(memcpy)(&unresumable_siginfo, info, sizeof(vki_ksiginfo_t));
+      VG_(memcpy)(&unresumable_siginfo, info, sizeof(vki_siginfo_t));
    
       longjmpd_on_signal = sigNo;
       __builtin_longjmp(scheduler_jmpbuf,1);
@@ -371,8 +371,8 @@ void mostly_clear_thread_record ( ThreadId tid )
    VG_(threads)[tid].cancel_ty   = True; /* PTHREAD_CANCEL_DEFERRED */
    VG_(threads)[tid].cancel_pend = NULL; /* not pending */
    VG_(threads)[tid].custack_used = 0;
-   VG_(ksigemptyset)(&VG_(threads)[tid].sig_mask);
-   VG_(ksigfillset)(&VG_(threads)[tid].eff_sig_mask);
+   VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
+   VG_(sigfillset)(&VG_(threads)[tid].eff_sig_mask);
    VG_(threads)[tid].sigqueue_head = 0;
    VG_(threads)[tid].sigqueue_tail = 0;
    VG_(threads)[tid].specifics_ptr = NULL;
@@ -1795,7 +1795,7 @@ void do__apply_in_new_thread ( ThreadId parent_tid,
    /* Consider allocating the child a stack, if the one it already has
       is inadequate. */
    new_stk_szb = si->size + VG_AR_CLIENT_STACKBASE_REDZONE_SZB + si->guardsize;
-   new_stk_szb = (new_stk_szb + VKI_BYTES_PER_PAGE - 1) & ~VKI_BYTES_PER_PAGE;
+   new_stk_szb = (new_stk_szb + VKI_PAGE_SIZE - 1) & ~VKI_PAGE_SIZE;
     
    VG_(threads)[tid].stack_guard_size = si->guardsize;
 
@@ -1852,7 +1852,7 @@ void do__apply_in_new_thread ( ThreadId parent_tid,
 
    /* Start the thread with all signals blocked; it's up to the client
       code to set the right signal mask when it's ready. */
-   VG_(ksigfillset)(&VG_(threads)[tid].sig_mask);
+   VG_(sigfillset)(&VG_(threads)[tid].sig_mask);
 
    /* Now that the signal mask is set up, create a proxy LWP for this thread */
    VG_(proxy_create)(tid);
@@ -2650,8 +2650,8 @@ void do__get_key_destr_and_spec ( ThreadId tid,
 static
 void do_pthread_sigmask ( ThreadId tid,
                           Int vki_how,
-                          vki_ksigset_t* newmask, 
-                          vki_ksigset_t* oldmask )
+                          vki_sigset_t* newmask, 
+                          vki_sigset_t* oldmask )
 {
    Char msg_buf[100];
    if (VG_(clo_trace_pthread_level) >= 1) {
@@ -2666,15 +2666,15 @@ void do_pthread_sigmask ( ThreadId tid,
 
    if (newmask)
       VG_TRACK( pre_mem_read, Vg_CorePThread, tid, "pthread_sigmask: newmask",
-                              (Addr)newmask, sizeof(vki_ksigset_t));
+                              (Addr)newmask, sizeof(vki_sigset_t));
    if (oldmask)
       VG_TRACK( pre_mem_write, Vg_CorePThread, tid, "pthread_sigmask: oldmask",
-                               (Addr)oldmask, sizeof(vki_ksigset_t));
+                               (Addr)oldmask, sizeof(vki_sigset_t));
 
    VG_(do_pthread_sigmask_SCSS_upd) ( tid, vki_how, newmask, oldmask );
 
    if (oldmask)
-      VG_TRACK( post_mem_write, (Addr)oldmask, sizeof(vki_ksigset_t) );
+      VG_TRACK( post_mem_write, (Addr)oldmask, sizeof(vki_sigset_t) );
 
    /* Success. */
    SET_PTHREQ_RETVAL(tid, 0);
@@ -2712,7 +2712,7 @@ void do_pthread_kill ( ThreadId tid, /* me */
       return;
    }
 
-   if (sig < 1 || sig > VKI_KNSIG) {
+   if (sig < 1 || sig > _VKI_NSIG) {
       SET_PTHREQ_RETVAL(tid, VKI_EINVAL);
       return;
    }
@@ -3048,8 +3048,8 @@ void do_client_request ( ThreadId tid, UInt* arg )
       case VG_USERREQ__PTHREAD_SIGMASK:
          do_pthread_sigmask ( tid,
                               arg[1],
-                              (vki_ksigset_t*)(arg[2]),
-                              (vki_ksigset_t*)(arg[3]) );
+                              (vki_sigset_t*)(arg[2]),
+                              (vki_sigset_t*)(arg[3]) );
         break;
 
       case VG_USERREQ__PTHREAD_KILL:
index f79eeb1d1b2cb4d5cc3146c04d29f276313fe073..209f619a8da0d0321fc3c82d187355a000b79c56 100644 (file)
@@ -1,7 +1,6 @@
 
 /*--------------------------------------------------------------------*/
-/*--- Implementation of POSIX signals.                             ---*/
-/*---                                                 vg_signals.c ---*/
+/*--- Implementation of POSIX signals.                vg_signals.c ---*/
 /*--------------------------------------------------------------------*/
 
 /*
    Forwards decls.
    ------------------------------------------------------------------ */
 
-static void vg_sync_signalhandler  ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext * );
-static void vg_async_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext * );
-static void vg_babyeater          ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext * );
-static void proxy_sigvg_handler           ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext * );
+static void vg_sync_signalhandler  ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext * );
+static void vg_async_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext * );
+static void vg_babyeater          ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext * );
+static void proxy_sigvg_handler           ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext * );
 
 static Bool is_correct_sigmask(void);
 static const Char *signame(Int sigNo);
@@ -119,11 +118,11 @@ Bool VG_(do_signal_routing) = False;
    only used when we're doing signal routing, and this is a place to
    remember pending signals which we can't keep actually pending for
    some reason. */
-static vki_ksigset_t proc_pending; /* process-wide pending signals */
+static vki_sigset_t proc_pending; /* process-wide pending signals */
 
 /* Since we use a couple of RT signals, we need to handle allocating
    the rest for application use. */
-Int VG_(sig_rtmin) = VKI_SIGRTUSERMIN;
+Int VG_(sig_rtmin) = VKI_SIGVGRTUSERMIN;
 Int VG_(sig_rtmax) = VKI_SIGRTMAX;
 
 Int VG_(sig_alloc_rtsig)(Int high)
@@ -135,7 +134,7 @@ Int VG_(sig_alloc_rtsig)(Int high)
    else
       ret = high ? VG_(sig_rtmin)++ : VG_(sig_rtmax)--;
 
-   vg_assert(ret >= VKI_SIGRTUSERMIN);
+   vg_assert(ret >= VKI_SIGVGRTUSERMIN);
 
    return ret;
 }
@@ -145,9 +144,9 @@ Int VG_(sig_alloc_rtsig)(Int high)
    ------------------------------------------------------------------ */
 
 
-/* Base-ment of these arrays[VKI_KNSIG].
+/* Base-ment of these arrays[_VKI_NSIG].
 
-   Valid signal numbers are 1 .. VKI_KNSIG inclusive.
+   Valid signal numbers are 1 .. _VKI_NSIG inclusive.
    Rather than subtracting 1 for indexing these arrays, which
    is tedious and error-prone, they are simply dimensioned 1 larger,
    and entry [0] is not used. 
@@ -166,7 +165,7 @@ typedef
       void* scss_handler;  /* VKI_SIG_DFL or VKI_SIG_IGN or ptr to
                               client's handler */
       UInt  scss_flags;
-      vki_ksigset_t scss_mask;
+      vki_sigset_t scss_mask;
       void* scss_restorer; /* god knows; we ignore it. */
    }
    SCSS_Per_Signal;
@@ -174,7 +173,7 @@ typedef
 typedef 
    struct {
       /* per-signal info */
-      SCSS_Per_Signal scss_per_sig[1+VKI_KNSIG];
+      SCSS_Per_Signal scss_per_sig[1+_VKI_NSIG];
 
       /* Additional elements to SCSS not stored here:
          - for each thread, the thread's blocking mask
@@ -219,7 +218,7 @@ typedef
 
 typedef 
    struct {
-      SKSS_Per_Signal skss_per_sig[1+VKI_KNSIG];
+      SKSS_Per_Signal skss_per_sig[1+_VKI_NSIG];
    } 
    SKSS;
 
@@ -227,7 +226,7 @@ static SKSS vg_skss;
 
 Bool VG_(is_sig_ign)(Int sigNo)
 {
-   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
+   vg_assert(sigNo >= 1 && sigNo <= _VKI_NSIG);
 
    return vg_scss.scss_per_sig[sigNo].scss_handler == VKI_SIG_IGN;
 }
@@ -241,7 +240,7 @@ void pp_SKSS ( void )
 {
    Int sig;
    VG_(printf)("\n\nSKSS:\n");
-   for (sig = 1; sig <= VKI_KNSIG; sig++) {
+   for (sig = 1; sig <= _VKI_NSIG; sig++) {
       VG_(printf)("sig %d:  handler 0x%x,  flags 0x%x\n", sig,
                   vg_skss.skss_per_sig[sig].skss_handler,
                   vg_skss.skss_per_sig[sig].skss_flags );
@@ -268,7 +267,7 @@ void calculate_SKSS_from_SCSS ( SKSS* dst )
    UInt  scss_flags;
    UInt  skss_flags;
 
-   for (sig = 1; sig <= VKI_KNSIG; sig++) {
+   for (sig = 1; sig <= _VKI_NSIG; sig++) {
       void *skss_handler;
       void *scss_handler;
       
@@ -385,9 +384,9 @@ void calculate_SKSS_from_SCSS ( SKSS* dst )
 
 static void handle_SCSS_change ( Bool force_update )
 {
-   Int            res, sig;
-   SKSS           skss_old;
-   vki_ksigaction ksa, ksa_old;
+   Int  res, sig;
+   SKSS skss_old;
+   struct vki_sigaction ksa, ksa_old;
 
    vg_assert(is_correct_sigmask());
 
@@ -397,7 +396,7 @@ static void handle_SCSS_change ( Bool force_update )
 
    /* Compare the new SKSS entries vs the old ones, and update kernel
       where they differ. */
-   for (sig = 1; sig <= VKI_KNSIG; sig++) {
+   for (sig = 1; sig <= _VKI_NSIG; sig++) {
 
       /* Trying to do anything with SIGKILL is pointless; just ignore
          it. */
@@ -414,25 +413,25 @@ static void handle_SCSS_change ( Bool force_update )
       }
 
       ksa.ksa_handler = vg_skss.skss_per_sig[sig].skss_handler;
-      ksa.ksa_flags   = vg_skss.skss_per_sig[sig].skss_flags;
-      ksa.ksa_restorer = VG_(sigreturn);
+      ksa.sa_flags   = vg_skss.skss_per_sig[sig].skss_flags;
+      ksa.sa_restorer = VG_(sigreturn);
 
-      vg_assert(ksa.ksa_flags & VKI_SA_ONSTACK);
-      VG_(ksigfillset)( &ksa.ksa_mask );
-      VG_(ksigdelset)( &ksa.ksa_mask, VKI_SIGKILL );
-      VG_(ksigdelset)( &ksa.ksa_mask, VKI_SIGSTOP );
+      vg_assert(ksa.sa_flags & VKI_SA_ONSTACK);
+      VG_(sigfillset)( &ksa.sa_mask );
+      VG_(sigdelset)( &ksa.sa_mask, VKI_SIGKILL );
+      VG_(sigdelset)( &ksa.sa_mask, VKI_SIGSTOP );
 
       if (VG_(clo_trace_signals)) 
          VG_(message)(Vg_DebugMsg, 
             "setting ksig %d to: hdlr 0x%x, flags 0x%x, "
             "mask(63..0) 0x%x 0x%x",
             sig, ksa.ksa_handler,
-            ksa.ksa_flags,
-            ksa.ksa_mask.ws[1], 
-            ksa.ksa_mask.ws[0] 
+            ksa.sa_flags,
+            ksa.sa_mask.sig[1], 
+            ksa.sa_mask.sig[0] 
          );
 
-      res = VG_(ksigaction)( sig, &ksa, &ksa_old );
+      res = VG_(sigaction)( sig, &ksa, &ksa_old );
       vg_assert(res == 0);
 
       /* Since we got the old sigaction more or less for free, might
@@ -440,13 +439,13 @@ static void handle_SCSS_change ( Bool force_update )
       if (!force_update) {
          vg_assert(ksa_old.ksa_handler 
                    == skss_old.skss_per_sig[sig].skss_handler);
-         vg_assert(ksa_old.ksa_flags 
+         vg_assert(ksa_old.sa_flags 
                    == skss_old.skss_per_sig[sig].skss_flags);
-         vg_assert(ksa_old.ksa_restorer 
+         vg_assert(ksa_old.sa_restorer 
                    == VG_(sigreturn));
-         VG_(ksigaddset)( &ksa_old.ksa_mask, VKI_SIGKILL );
-         VG_(ksigaddset)( &ksa_old.ksa_mask, VKI_SIGSTOP );
-         vg_assert(VG_(kisfullsigset)( &ksa_old.ksa_mask ));
+         VG_(sigaddset)( &ksa_old.sa_mask, VKI_SIGKILL );
+         VG_(sigaddset)( &ksa_old.sa_mask, VKI_SIGSTOP );
+         vg_assert(VG_(isfullsigset)( &ksa_old.sa_mask ));
       }
    }
 }
@@ -479,13 +478,13 @@ static Int sas_ss_flags ( ThreadId tid, Addr m_SP )
 
 void VG_(do__NR_sigaltstack) ( ThreadId tid )
 {
-   vki_kstack_t* ss;
-   vki_kstack_t* oss;
-   Addr          m_SP;
+   vki_stack_t* ss;
+   vki_stack_t* oss;
+   Addr         m_SP;
 
    vg_assert(VG_(is_valid_tid)(tid));
-   ss    = (vki_kstack_t*)PLATFORM_SYSCALL_ARG1(VG_(threads)[tid].arch);
-   oss   = (vki_kstack_t*)PLATFORM_SYSCALL_ARG2(VG_(threads)[tid].arch);
+   ss    = (vki_stack_t*)PLATFORM_SYSCALL_ARG1(VG_(threads)[tid].arch);
+   oss   = (vki_stack_t*)PLATFORM_SYSCALL_ARG2(VG_(threads)[tid].arch);
    m_SP  = ARCH_STACK_PTR(VG_(threads)[tid].arch);
 
    if (VG_(clo_trace_signals))
@@ -530,30 +529,30 @@ void VG_(do__NR_sigaltstack) ( ThreadId tid )
 
 void VG_(do__NR_sigaction) ( ThreadId tid )
 {
-   Int              signo;
-   vki_ksigaction*  new_act;
-   vki_ksigaction*  old_act;
+   Int                    signo;
+   struct vki_sigaction*  new_act;
+   struct vki_sigaction*  old_act;
 
    vg_assert(is_correct_sigmask());
 
    vg_assert(VG_(is_valid_tid)(tid));
-   signo     =                  PLATFORM_SYSCALL_ARG1(VG_(threads)[tid].arch);
-   new_act   = (vki_ksigaction*)PLATFORM_SYSCALL_ARG2(VG_(threads)[tid].arch);
-   old_act   = (vki_ksigaction*)PLATFORM_SYSCALL_ARG3(VG_(threads)[tid].arch);
+   signo   =                        PLATFORM_SYSCALL_ARG1(VG_(threads)[tid].arch);
+   new_act = (struct vki_sigaction*)PLATFORM_SYSCALL_ARG2(VG_(threads)[tid].arch);
+   old_act = (struct vki_sigaction*)PLATFORM_SYSCALL_ARG3(VG_(threads)[tid].arch);
 
    if (VG_(clo_trace_signals))
       VG_(message)(Vg_DebugExtraMsg, 
          "__NR_sigaction: tid %d, sigNo %d, "
          "new 0x%x, old 0x%x, new flags 0x%x",
          tid, signo, (UInt)new_act, (UInt)old_act,
-         (UInt)(new_act ? new_act->ksa_flags : 0) );
+         (UInt)(new_act ? new_act->sa_flags : 0) );
 
    /* Rule out various error conditions.  The aim is to ensure that if
       when the call is passed to the kernel it will definitely
       succeed. */
 
    /* Reject out-of-range signal numbers. */
-   if (signo < 1 || signo > VKI_KNSIG) goto bad_signo;
+   if (signo < 1 || signo > _VKI_NSIG) goto bad_signo;
 
    /* don't let them use our signals */
    if ( (signo == VKI_SIGVGINT || signo == VKI_SIGVGKILL)
@@ -570,18 +569,18 @@ void VG_(do__NR_sigaction) ( ThreadId tid )
    /* If the client supplied non-NULL old_act, copy the relevant SCSS
       entry into it. */
    if (old_act) {
-      old_act->ksa_handler  = vg_scss.scss_per_sig[signo].scss_handler;
-      old_act->ksa_flags    = vg_scss.scss_per_sig[signo].scss_flags;
-      old_act->ksa_mask     = vg_scss.scss_per_sig[signo].scss_mask;
-      old_act->ksa_restorer = vg_scss.scss_per_sig[signo].scss_restorer;
+      old_act->ksa_handler = vg_scss.scss_per_sig[signo].scss_handler;
+      old_act->sa_flags    = vg_scss.scss_per_sig[signo].scss_flags;
+      old_act->sa_mask     = vg_scss.scss_per_sig[signo].scss_mask;
+      old_act->sa_restorer = vg_scss.scss_per_sig[signo].scss_restorer;
    }
 
    /* And now copy new SCSS entry from new_act. */
    if (new_act) {
       vg_scss.scss_per_sig[signo].scss_handler  = new_act->ksa_handler;
-      vg_scss.scss_per_sig[signo].scss_flags    = new_act->ksa_flags;
-      vg_scss.scss_per_sig[signo].scss_mask     = new_act->ksa_mask;
-      vg_scss.scss_per_sig[signo].scss_restorer = new_act->ksa_restorer;
+      vg_scss.scss_per_sig[signo].scss_flags    = new_act->sa_flags;
+      vg_scss.scss_per_sig[signo].scss_mask     = new_act->sa_mask;
+      vg_scss.scss_per_sig[signo].scss_restorer = new_act->sa_restorer;
    }
 
    /* All happy bunnies ... */
@@ -626,15 +625,15 @@ void VG_(do__NR_sigaction) ( ThreadId tid )
 
 static
 void do_sigprocmask_bitops ( Int vki_how, 
-                            vki_ksigset_t* orig_set,
-                            vki_ksigset_t* modifier )
+                            vki_sigset_t* orig_set,
+                            vki_sigset_t* modifier )
 {
    switch (vki_how) {
       case VKI_SIG_BLOCK: 
-         VG_(ksigaddset_from_set)( orig_set, modifier );
+         VG_(sigaddset_from_set)( orig_set, modifier );
          break;
       case VKI_SIG_UNBLOCK:
-         VG_(ksigdelset_from_set)( orig_set, modifier );
+         VG_(sigdelset_from_set)( orig_set, modifier );
          break;
       case VKI_SIG_SETMASK:
          *orig_set = *modifier;
@@ -655,8 +654,8 @@ void do_sigprocmask_bitops ( Int vki_how,
 static
 void do_setmask ( ThreadId tid,
                   Int how,
-                  vki_ksigset_t* newset,
-                 vki_ksigset_t* oldset )
+                  vki_sigset_t* newset,
+                 vki_sigset_t* oldset )
 {
    vg_assert(is_correct_sigmask());
 
@@ -667,7 +666,7 @@ void do_setmask ( ThreadId tid,
                   how==VKI_SIG_BLOCK ? "SIG_BLOCK" : (
                      how==VKI_SIG_UNBLOCK ? "SIG_UNBLOCK" : (
                         how==VKI_SIG_SETMASK ? "SIG_SETMASK" : "???")),
-                  newset, newset ? newset->ws[1] : 0, newset ? newset->ws[0] : 0
+                  newset, newset ? newset->sig[1] : 0, newset ? newset->sig[0] : 0
         );
 
    /* Just do this thread. */
@@ -677,12 +676,12 @@ void do_setmask ( ThreadId tid,
       if (VG_(clo_trace_signals))
              VG_(message)(Vg_DebugExtraMsg, 
                           "\toldset=%p %08x%08x",
-                          oldset, oldset->ws[1], oldset->ws[0]);
+                          oldset, oldset->sig[1], oldset->sig[0]);
    }
    if (newset) {
       do_sigprocmask_bitops (how, &VG_(threads)[tid].sig_mask, newset );
-      VG_(ksigdelset)(&VG_(threads)[tid].sig_mask, VKI_SIGKILL);
-      VG_(ksigdelset)(&VG_(threads)[tid].sig_mask, VKI_SIGSTOP);
+      VG_(sigdelset)(&VG_(threads)[tid].sig_mask, VKI_SIGKILL);
+      VG_(sigdelset)(&VG_(threads)[tid].sig_mask, VKI_SIGSTOP);
       VG_(proxy_setsigmask)(tid);
    }
 
@@ -692,8 +691,8 @@ void do_setmask ( ThreadId tid,
 
 void VG_(do__NR_sigprocmask) ( ThreadId tid,
                                Int how, 
-                               vki_ksigset_t* set,
-                               vki_ksigset_t* oldset )
+                               vki_sigset_t* set,
+                               vki_sigset_t* oldset )
 {
    switch(how) {
    case VKI_SIG_BLOCK:
@@ -721,8 +720,8 @@ void VG_(do__NR_sigprocmask) ( ThreadId tid,
 
 void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid,
                                         Int how, 
-                                        vki_ksigset_t* set,
-                                        vki_ksigset_t* oldset )
+                                        vki_sigset_t* set,
+                                        vki_sigset_t* oldset )
 {
    /* Assume that how has been validated by caller. */
    vg_assert(how == VKI_SIG_BLOCK || how == VKI_SIG_UNBLOCK 
@@ -742,21 +741,21 @@ void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid,
    ------------------------------------------------------------------ */
 
 /* Block all host signals, dumping the old mask in *saved_mask. */
-void VG_(block_all_host_signals) ( /* OUT */ vki_ksigset_t* saved_mask )
+void VG_(block_all_host_signals) ( /* OUT */ vki_sigset_t* saved_mask )
 {
    Int           ret;
-   vki_ksigset_t block_procmask;
-   VG_(ksigfillset)(&block_procmask);
-   ret = VG_(ksigprocmask)
+   vki_sigset_t block_procmask;
+   VG_(sigfillset)(&block_procmask);
+   ret = VG_(sigprocmask)
             (VKI_SIG_SETMASK, &block_procmask, saved_mask);
    vg_assert(ret == 0);
 }
 
 /* Restore the blocking mask using the supplied saved one. */
-void VG_(restore_all_host_signals) ( /* IN */ vki_ksigset_t* saved_mask )
+void VG_(restore_all_host_signals) ( /* IN */ vki_sigset_t* saved_mask )
 {
    Int ret;
-   ret = VG_(ksigprocmask)(VKI_SIG_SETMASK, saved_mask, NULL);
+   ret = VG_(sigprocmask)(VKI_SIG_SETMASK, saved_mask, NULL);
    vg_assert(ret == 0);
 }
 
@@ -764,34 +763,34 @@ void VG_(restore_all_host_signals) ( /* IN */ vki_ksigset_t* saved_mask )
    it is supposed to have blocked. */
 static Bool is_correct_sigmask(void)
 {
-   vki_ksigset_t mask;
+   vki_sigset_t mask;
    Bool ret = True;
 
    vg_assert(VG_(gettid)() == VG_(main_pid));
 
 #ifdef DEBUG_SIGNALS
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, NULL, &mask);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, NULL, &mask);
 
    /* unresumable signals */
    
-   ret = ret && !VG_(ksigismember)(&mask, VKI_SIGSEGV);
-   VG_(ksigaddset)(&mask, VKI_SIGSEGV);
+   ret = ret && !VG_(sigismember)(&mask, VKI_SIGSEGV);
+   VG_(sigaddset)(&mask, VKI_SIGSEGV);
 
-   ret = ret && !VG_(ksigismember)(&mask, VKI_SIGBUS);
-   VG_(ksigaddset)(&mask, VKI_SIGBUS);
+   ret = ret && !VG_(sigismember)(&mask, VKI_SIGBUS);
+   VG_(sigaddset)(&mask, VKI_SIGBUS);
 
-   ret = ret && !VG_(ksigismember)(&mask, VKI_SIGFPE);
-   VG_(ksigaddset)(&mask, VKI_SIGFPE);
+   ret = ret && !VG_(sigismember)(&mask, VKI_SIGFPE);
+   VG_(sigaddset)(&mask, VKI_SIGFPE);
 
-   ret = ret && !VG_(ksigismember)(&mask, VKI_SIGILL);
-   VG_(ksigaddset)(&mask, VKI_SIGILL);
+   ret = ret && !VG_(sigismember)(&mask, VKI_SIGILL);
+   VG_(sigaddset)(&mask, VKI_SIGILL);
 
    /* unblockable signals (doesn't really matter if these are
       already present) */
-   VG_(ksigaddset)(&mask, VKI_SIGSTOP);
-   VG_(ksigaddset)(&mask, VKI_SIGKILL);
+   VG_(sigaddset)(&mask, VKI_SIGSTOP);
+   VG_(sigaddset)(&mask, VKI_SIGKILL);
 
-   ret = ret && VG_(kisfullsigset)(&mask);
+   ret = ret && VG_(isfullsigset)(&mask);
 #endif /* DEBUG_SIGNALS */
 
    return ret;
@@ -802,15 +801,15 @@ static Bool is_correct_sigmask(void)
    LWPs. */
 static void set_main_sigmask(void)
 {
-   vki_ksigset_t mask;
+   vki_sigset_t mask;
 
-   VG_(ksigfillset)(&mask);
-   VG_(ksigdelset)(&mask, VKI_SIGSEGV);
-   VG_(ksigdelset)(&mask, VKI_SIGBUS);
-   VG_(ksigdelset)(&mask, VKI_SIGFPE);
-   VG_(ksigdelset)(&mask, VKI_SIGILL);
+   VG_(sigfillset)(&mask);
+   VG_(sigdelset)(&mask, VKI_SIGSEGV);
+   VG_(sigdelset)(&mask, VKI_SIGBUS);
+   VG_(sigdelset)(&mask, VKI_SIGFPE);
+   VG_(sigdelset)(&mask, VKI_SIGILL);
 
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, NULL);
 
    vg_assert(is_correct_sigmask());
 }
@@ -823,13 +822,13 @@ static void set_main_sigmask(void)
 /* Set up a stack frame (VgSigContext) for the client's signal
    handler. */
 static
-void vg_push_signal_frame ( ThreadId tid, const vki_ksiginfo_t *siginfo )
+void vg_push_signal_frame ( ThreadId tid, const vki_siginfo_t *siginfo )
 {
    Addr         esp_top_of_frame;
    ThreadState* tst;
    Int         sigNo = siginfo->si_signo;
 
-   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
+   vg_assert(sigNo >= 1 && sigNo <= _VKI_NSIG);
    vg_assert(VG_(is_valid_tid)(tid));
    tst = & VG_(threads)[tid];
 
@@ -896,7 +895,7 @@ Bool VG_(signal_returns) ( ThreadId tid )
       before the signal was delivered. */
    sigNo = vg_pop_signal_frame(tid);
 
-   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
+   vg_assert(sigNo >= 1 && sigNo <= _VKI_NSIG);
 
    /* Scheduler now can resume this thread, or perhaps some other.
       Tell the scheduler whether or not any syscall interrupted by
@@ -962,24 +961,24 @@ static const Char *signame(Int sigNo)
 /* Hit ourselves with a signal using the default handler */
 void VG_(kill_self)(Int sigNo)
 {
-   vki_ksigset_t       mask, origmask;
-   vki_ksigaction      sa, origsa;   
+   vki_sigset_t                mask, origmask;
+   struct vki_sigaction sa, origsa;   
 
    sa.ksa_handler = VKI_SIG_DFL;
-   sa.ksa_flags = 0;
-   sa.ksa_restorer = 0;
-   VG_(ksigemptyset)(&sa.ksa_mask);
+   sa.sa_flags = 0;
+   sa.sa_restorer = 0;
+   VG_(sigemptyset)(&sa.sa_mask);
       
-   VG_(ksigaction)(sigNo, &sa, &origsa);
+   VG_(sigaction)(sigNo, &sa, &origsa);
 
-   VG_(ksigfillset)(&mask);
-   VG_(ksigdelset)(&mask, sigNo);
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &mask, &origmask);
+   VG_(sigfillset)(&mask);
+   VG_(sigdelset)(&mask, sigNo);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, &origmask);
 
-   VG_(ktkill)(VG_(getpid)(), sigNo);
+   VG_(tkill)(VG_(getpid)(), sigNo);
 
-   VG_(ksigaction)(sigNo, &origsa, NULL);
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &origmask, NULL);
+   VG_(sigaction)(sigNo, &origsa, NULL);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &origmask, NULL);
 }
 
 /*
@@ -1051,7 +1050,7 @@ static void fill_phdr(Elf32_Phdr *phdr, const Segment *seg, UInt off, Bool write
    if (seg->prot & VKI_PROT_EXEC)
       phdr->p_flags |= PF_X;
 
-   phdr->p_align = VKI_BYTES_PER_PAGE;
+   phdr->p_align = VKI_PAGE_SIZE;
 }
 
 struct note {
@@ -1091,7 +1090,7 @@ static void write_note(Int fd, const struct note *n)
    VG_(write)(fd, &n->note, note_size(n));
 }
 
-static void fill_prpsinfo(const ThreadState *tst, struct elf_prpsinfo *prpsinfo)
+static void fill_prpsinfo(const ThreadState *tst, struct vki_elf_prpsinfo *prpsinfo)
 {
    Char *name;
 
@@ -1137,9 +1136,9 @@ static void fill_prpsinfo(const ThreadState *tst, struct elf_prpsinfo *prpsinfo)
    }
 }
 
-static void fill_prstatus(const ThreadState *tst, struct elf_prstatus *prs, const vki_ksiginfo_t *si)
+static void fill_prstatus(const ThreadState *tst, struct vki_elf_prstatus *prs, const vki_siginfo_t *si)
 {
-   struct user_regs_struct *regs;
+   struct vki_user_regs_struct *regs;
 
    VG_(memset)(prs, 0, sizeof(*prs));
 
@@ -1154,7 +1153,7 @@ static void fill_prstatus(const ThreadState *tst, struct elf_prstatus *prs, cons
    prs->pr_pgrp = VG_(main_pgrp);
    prs->pr_sid = VG_(main_pgrp);
    
-   regs = (struct user_regs_struct *)prs->pr_reg;
+   regs = (struct vki_user_regs_struct *)prs->pr_reg;
 
    vg_assert(sizeof(*regs) == sizeof(prs->pr_reg));
 
@@ -1165,7 +1164,7 @@ static void fill_prstatus(const ThreadState *tst, struct elf_prstatus *prs, cons
    }
 }
 
-static void fill_fpu(const ThreadState *tst, elf_fpregset_t *fpu)
+static void fill_fpu(const ThreadState *tst, vki_elf_fpregset_t *fpu)
 {
    if (VG_(is_running_thread)(tst->tid))
       VGA_(fill_elffpregs_from_BB)(fpu);
@@ -1173,7 +1172,7 @@ static void fill_fpu(const ThreadState *tst, elf_fpregset_t *fpu)
       VGA_(fill_elffpregs_from_tst)(fpu, &tst->arch);
 }
 
-static void fill_xfpu(const ThreadState *tst, elf_fpxregset_t *xfpu)
+static void fill_xfpu(const ThreadState *tst, vki_elf_fpxregset_t *xfpu)
 {
    if (VG_(is_running_thread)(tst->tid))
       VGA_(fill_elffpxregs_from_BB)(xfpu);
@@ -1181,7 +1180,7 @@ static void fill_xfpu(const ThreadState *tst, elf_fpxregset_t *xfpu)
       VGA_(fill_elffpxregs_from_tst)(xfpu, &tst->arch);
 }
 
-static void make_coredump(ThreadId tid, const vki_ksiginfo_t *si, UInt max_size)
+static void make_coredump(ThreadId tid, const vki_siginfo_t *si, UInt max_size)
 {
    Char buf[1000];
    Char *basename = "vgcore";
@@ -1196,8 +1195,8 @@ static void make_coredump(ThreadId tid, const vki_ksiginfo_t *si, UInt max_size)
    UInt off;
    struct note *notelist, *note;
    UInt notesz;
-   struct elf_prpsinfo prpsinfo;
-   struct elf_prstatus prstatus;
+   struct vki_elf_prpsinfo prpsinfo;
+   struct vki_elf_prstatus prstatus;
 
    if (VG_(clo_log_name) != NULL) {
       coreext = ".core";
@@ -1240,13 +1239,13 @@ static void make_coredump(ThreadId tid, const vki_ksiginfo_t *si, UInt max_size)
    phdrs = VG_(arena_malloc)(VG_AR_CORE, sizeof(*phdrs) * num_phdrs);
 
    for(i = 1; i < VG_N_THREADS; i++) {
-      elf_fpregset_t fpu;
+      vki_elf_fpregset_t fpu;
 
       if (VG_(threads)[i].status == VgTs_Empty)
         continue;
 
       if (VG_(have_ssestate)) {
-        elf_fpxregset_t xfpu;
+        vki_elf_fpxregset_t xfpu;
 
         fill_xfpu(&VG_(threads)[i], &xfpu);
         add_note(&notelist, "LINUX", NT_PRXFPREG, &xfpu, sizeof(xfpu));
@@ -1321,7 +1320,7 @@ static void make_coredump(ThreadId tid, const vki_ksiginfo_t *si, UInt max_size)
    If we're not being quiet, then print out some more detail about
    fatal signals (esp. core dumping signals).
  */
-static void vg_default_action(const vki_ksiginfo_t *info, ThreadId tid)
+static void vg_default_action(const vki_siginfo_t *info, ThreadId tid)
 {
    Int  sigNo     = info->si_signo;
    Bool terminate = False;
@@ -1465,7 +1464,7 @@ static void vg_default_action(const vki_ksiginfo_t *info, ThreadId tid)
 
 static void synth_fault_common(ThreadId tid, Addr addr, Int si_code)
 {
-   vki_ksiginfo_t info;
+   vki_siginfo_t info;
 
    vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
 
@@ -1496,10 +1495,10 @@ void VG_(synth_fault)(ThreadId tid)
    synth_fault_common(tid, 0, 0x80);
 }
 
-void VG_(deliver_signal) ( ThreadId tid, const vki_ksiginfo_t *info, Bool async )
+void VG_(deliver_signal) ( ThreadId tid, const vki_siginfo_t *info, Bool async )
 {
    Int                 sigNo = info->si_signo;
-   vki_ksigset_t       handlermask;
+   vki_sigset_t                handlermask;
    SCSS_Per_Signal     *handler = &vg_scss.scss_per_sig[sigNo];
    void                        *handler_fn;
    ThreadState         *tst = VG_(get_ThreadState)(tid);
@@ -1601,11 +1600,11 @@ void VG_(deliver_signal) ( ThreadId tid, const vki_ksiginfo_t *info, Bool async
       /* handler gets the union of the signal's mask and the thread's
         mask */
       handlermask = handler->scss_mask;
-      VG_(ksigaddset_from_set)(&handlermask, &VG_(threads)[tid].sig_mask);
+      VG_(sigaddset_from_set)(&handlermask, &VG_(threads)[tid].sig_mask);
 
       /* also mask this signal, unless they ask us not to */
       if (!(handler->scss_flags & VKI_SA_NOMASK))
-        VG_(ksigaddset)(&handlermask, sigNo);
+        VG_(sigaddset)(&handlermask, sigNo);
    }
 
    /* tell proxy we're about to start running the handler */
@@ -1620,7 +1619,7 @@ void VG_(deliver_signal) ( ThreadId tid, const vki_ksiginfo_t *info, Bool async
    client set the SA_NOCLDWAIT on their SIGCHLD handler.
  */
 static
-void vg_babyeater ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext *uc )
+void vg_babyeater ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext *uc )
 {
    Int status;
    Int pid;
@@ -1644,12 +1643,12 @@ void vg_babyeater ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext *uc )
    all signals for which this is the handler should be blocked there.
 */
 static 
-void vg_async_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext *uc )
+void vg_async_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext *uc )
 {
    if (VG_(gettid)() == VG_(main_pid)) {
       VG_(printf)("got signal %d in LWP %d (%d)\n",
                  sigNo, VG_(gettid)(), VG_(gettid)(), VG_(main_pid));
-      vg_assert(VG_(ksigismember)(&uc->uc_sigmask, sigNo));
+      vg_assert(VG_(sigismember)(&uc->uc_sigmask, sigNo));
    }
 
    vg_assert(VG_(gettid)() != VG_(main_pid));
@@ -1666,7 +1665,7 @@ void vg_async_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_uconte
    the sync signals.
 */
 static
-void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontext *uc )
+void vg_sync_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext *uc )
 {
    Int           dummy_local;
 
@@ -1702,7 +1701,7 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
    if (VG_(clo_trace_signals)) {
       VG_(message)(Vg_DebugMsg, "signal %d arrived ... si_code=%d", sigNo, info->si_code );
    }
-   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
+   vg_assert(sigNo >= 1 && sigNo <= _VKI_NSIG);
 
    /* Sanity check.  Ensure we're really running on the signal stack
       we asked for. */
@@ -1789,7 +1788,7 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
         static Int recursion = 0;
 
         if (recursion++ == 0) {
-           VG_(init_shadow_range)(PGROUNDDN(fault), VKI_BYTES_PER_PAGE, True);
+           VG_(init_shadow_range)(PGROUNDDN(fault), VKI_PAGE_SIZE, True);
            recursion--;
            return;
         } else {
@@ -1824,7 +1823,7 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
       */
       VG_(message)(Vg_DebugMsg, 
                   "adding signal %d to pending set", sigNo);
-      VG_(ksigaddset)(&proc_pending, sigNo);
+      VG_(sigaddset)(&proc_pending, sigNo);
    } else {
       /* 
         A bad signal came from the kernel (indicating an instruction
@@ -1869,7 +1868,7 @@ void vg_sync_signalhandler ( Int sigNo, vki_ksiginfo_t *info, struct vki_ucontex
    poke the LWP to make it fall out of whatever syscall it is in.
    Used for thread termination and cancellation.
  */
-static void proxy_sigvg_handler(int signo, vki_ksiginfo_t *si, struct vki_ucontext *uc)
+static void proxy_sigvg_handler(int signo, vki_siginfo_t *si, struct vki_ucontext *uc)
 {
    vg_assert(signo == VKI_SIGVGINT || signo == VKI_SIGVGKILL);
    vg_assert(si->si_signo == signo);
@@ -1900,14 +1899,14 @@ void VG_(unblock_host_signal) ( Int sigNo )
 
 
 static __attribute((unused))
-void pp_vg_ksigaction ( vki_ksigaction* sa )
+void pp_vg_ksigaction ( struct vki_sigaction* sa )
 {
    Int i;
    VG_(printf)("vg_ksigaction: handler %p, flags 0x%x, restorer %p\n", 
-               sa->ksa_handler, (UInt)sa->ksa_flags, sa->ksa_restorer);
+               sa->ksa_handler, (UInt)sa->sa_flags, sa->sa_restorer);
    VG_(printf)("vg_ksigaction: { ");
-   for (i = 1; i <= VKI_KNSIG; i++)
-      if (VG_(ksigismember(&(sa->ksa_mask),i)))
+   for (i = 1; i <= _VKI_NSIG; i++)
+      if (VG_(sigismember(&(sa->sa_mask),i)))
          VG_(printf)("%d ", i);
    VG_(printf)("}\n");
 }
@@ -1920,9 +1919,9 @@ void VG_(route_signals)(void)
 {
    static const struct vki_timespec zero = { 0, 0 };
    static ThreadId start_tid = 1;      /* tid to start scanning from */
-   vki_ksigset_t set;
-   vki_ksiginfo_t siset[VKI_KNSIG];
-   vki_ksiginfo_t si;
+   vki_sigset_t set;
+   vki_siginfo_t siset[_VKI_NSIG];
+   vki_siginfo_t si;
    Int sigNo;
 
    vg_assert(VG_(gettid)() == VG_(main_pid));
@@ -1937,19 +1936,19 @@ void VG_(route_signals)(void)
    VG_(block_all_host_signals) ( &set );
 
    /* grab any pending signals and add them to the pending signal set */
-   while(VG_(ksigtimedwait)(&set, &si, &zero) > 0) {
-      VG_(ksigaddset)(&proc_pending, si.si_signo);
+   while(VG_(sigtimedwait)(&set, &si, &zero) > 0) {
+      VG_(sigaddset)(&proc_pending, si.si_signo);
       siset[si.si_signo] = si;
    }
 
    /* transfer signals from the process pending set to a particular
       thread which has it unblocked */
-   for(sigNo = 0; sigNo < VKI_KNSIG; sigNo++) {
+   for(sigNo = 0; sigNo < _VKI_NSIG; sigNo++) {
       ThreadId tid;
       ThreadId end_tid;
       Int target = -1;
       
-      if (!VG_(ksigismember)(&proc_pending, sigNo))
+      if (!VG_(sigismember)(&proc_pending, sigNo))
         continue;
 
       end_tid = start_tid - 1;
@@ -1965,7 +1964,7 @@ void VG_(route_signals)(void)
         if (tst->status == VgTs_Empty)
            continue;
 
-        if (!VG_(ksigismember)(&tst->sig_mask, sigNo)) {
+        if (!VG_(sigismember)(&tst->sig_mask, sigNo)) {
            vg_assert(tst->proxy != NULL);
            target = tid;
            start_tid = tid;
@@ -1983,7 +1982,7 @@ void VG_(route_signals)(void)
          tst->sigqueue_head = (tst->sigqueue_head + 1) % VG_N_SIGNALQUEUE;
          vg_assert(tst->sigqueue_head != tst->sigqueue_tail);
         VG_(proxy_sendsig)(target, sigNo);
-        VG_(ksigdelset)(&proc_pending, sigNo);
+        VG_(sigdelset)(&proc_pending, sigNo);
       }
    }
 
@@ -1998,9 +1997,9 @@ void VG_(route_signals)(void)
 void VG_(sigstartup_actions) ( void )
 {
    Int i, ret;
-   vki_ksigset_t  saved_procmask;
-   vki_kstack_t   altstack_info;
-   vki_ksigaction sa;
+   vki_sigset_t saved_procmask;
+   vki_stack_t  altstack_info;
+   struct vki_sigaction sa;
 
    /* VG_(printf)("SIGSTARTUP\n"); */
    /* Block all signals.  saved_procmask remembers the previous mask,
@@ -2009,17 +2008,17 @@ void VG_(sigstartup_actions) ( void )
    VG_(block_all_host_signals)( &saved_procmask );
 
    /* clear process-wide pending signal set */
-   VG_(ksigemptyset)(&proc_pending);
+   VG_(sigemptyset)(&proc_pending);
 
    /* Set the signal mask which the scheduler LWP should maintain from
       now on. */
    set_main_sigmask();
 
    /* Copy per-signal settings to SCSS. */
-   for (i = 1; i <= VKI_KNSIG; i++) {
+   for (i = 1; i <= _VKI_NSIG; i++) {
 
       /* Get the old host action */
-      ret = VG_(ksigaction)(i, NULL, &sa);
+      ret = VG_(sigaction)(i, NULL, &sa);
       vg_assert(ret == 0);
 
       if (VG_(clo_trace_signals))
@@ -2027,18 +2026,18 @@ void VG_(sigstartup_actions) ( void )
                      (Addr)(sa.ksa_handler), i );
 
       vg_scss.scss_per_sig[i].scss_handler  = sa.ksa_handler;
-      vg_scss.scss_per_sig[i].scss_flags    = sa.ksa_flags;
-      vg_scss.scss_per_sig[i].scss_mask     = sa.ksa_mask;
-      vg_scss.scss_per_sig[i].scss_restorer = sa.ksa_restorer;
+      vg_scss.scss_per_sig[i].scss_flags    = sa.sa_flags;
+      vg_scss.scss_per_sig[i].scss_mask     = sa.sa_mask;
+      vg_scss.scss_per_sig[i].scss_restorer = sa.sa_restorer;
    }
 
    /* Our private internal signals are treated as ignored */
    vg_scss.scss_per_sig[VKI_SIGVGINT].scss_handler = VKI_SIG_IGN;
    vg_scss.scss_per_sig[VKI_SIGVGINT].scss_flags = VKI_SA_SIGINFO;
-   VG_(ksigfillset)(&vg_scss.scss_per_sig[VKI_SIGVGINT].scss_mask);
+   VG_(sigfillset)(&vg_scss.scss_per_sig[VKI_SIGVGINT].scss_mask);
    vg_scss.scss_per_sig[VKI_SIGVGKILL].scss_handler = VKI_SIG_IGN;
    vg_scss.scss_per_sig[VKI_SIGVGKILL].scss_flags = VKI_SA_SIGINFO;
-   VG_(ksigfillset)(&vg_scss.scss_per_sig[VKI_SIGVGKILL].scss_mask);
+   VG_(sigfillset)(&vg_scss.scss_per_sig[VKI_SIGVGKILL].scss_mask);
 
    /* Copy the process' signal mask into the root thread. */
    vg_assert(VG_(threads)[1].status == VgTs_Runnable);
@@ -2049,7 +2048,7 @@ void VG_(sigstartup_actions) ( void )
    altstack_info.ss_sp = &(sigstack[0]);
    altstack_info.ss_size = VG_SIGSTACK_SIZE_W * sizeof(UInt);
    altstack_info.ss_flags = 0;
-   ret = VG_(ksigaltstack)(&altstack_info, NULL);
+   ret = VG_(sigaltstack)(&altstack_info, NULL);
    if (ret != 0) {
       VG_(core_panic)(
          "vg_sigstartup_actions: couldn't install alternative sigstack");
@@ -2060,7 +2059,7 @@ void VG_(sigstartup_actions) ( void )
    }
 
    /* DEBUGGING HACK */
-   /* VG_(ksignal)(VKI_SIGUSR1, &VG_(oursignalhandler)); */
+   /* VG_(signal)(VKI_SIGUSR1, &VG_(oursignalhandler)); */
 
    /* Calculate SKSS and apply it.  This also sets the initial kernel
       mask we need to run with. */
index 87f21c5f752e1839291362480f6ef00855652635..4ad0edf410b8263fa341a05732e88c4f4e2943fa 100644 (file)
@@ -1297,8 +1297,8 @@ Bool vg_read_lib_symbols ( SegInfo* si )
               si->bss_size = 0;
         }
 
-        mapped = mapped & ~(VKI_BYTES_PER_PAGE-1);
-        mapped_end = (mapped_end + VKI_BYTES_PER_PAGE - 1) & ~(VKI_BYTES_PER_PAGE-1);
+        mapped = mapped & ~(VKI_PAGE_SIZE-1);
+        mapped_end = (mapped_end + VKI_PAGE_SIZE - 1) & ~(VKI_PAGE_SIZE-1);
 
         if (VG_(needs).data_syms &&
             (mapped >= si->start && mapped <= (si->start+si->size)) &&
index 52643ecd02074cd6f58df875cb4b0f931acca64a..56d9d7b48ac64c4511394ef74dbc10f549270a42 100644 (file)
@@ -522,9 +522,9 @@ static ShadowChunk *findchunk(Addr a)
 }
 #endif
 
-static vki_ksigaction sigbus_saved;
-static vki_ksigaction sigsegv_saved;
-static vki_ksigset_t  blockmask_saved;
+static struct vki_sigaction sigbus_saved;
+static struct vki_sigaction sigsegv_saved;
+static vki_sigset_t  blockmask_saved;
 static jmp_buf valid_addr_jmpbuf;
 
 static void valid_addr_handler(int sig)
@@ -538,39 +538,39 @@ static void valid_addr_handler(int sig)
 static void setup_signals(void)
 {
    Int res;
-   vki_ksigaction sigbus_new;
-   vki_ksigaction sigsegv_new;
-   vki_ksigset_t  unblockmask_new;
+   struct vki_sigaction sigbus_new;
+   struct vki_sigaction sigsegv_new;
+   vki_sigset_t         unblockmask_new;
 
    /* Temporarily install a new sigsegv and sigbus handler, and make
       sure SIGBUS, SIGSEGV and SIGTERM are unblocked.  (Perhaps the
       first two can never be blocked anyway?)  */
 
    sigbus_new.ksa_handler = valid_addr_handler;
-   sigbus_new.ksa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
-   sigbus_new.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sigbus_new.ksa_mask );
+   sigbus_new.sa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
+   sigbus_new.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sigbus_new.sa_mask );
    vg_assert(res == 0);
 
    sigsegv_new.ksa_handler = valid_addr_handler;
-   sigsegv_new.ksa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
-   sigsegv_new.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sigsegv_new.ksa_mask );
+   sigsegv_new.sa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
+   sigsegv_new.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sigsegv_new.sa_mask );
    vg_assert(res == 0+0);
 
-   res =  VG_(ksigemptyset)( &unblockmask_new );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGBUS );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGSEGV );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGTERM );
+   res =  VG_(sigemptyset)( &unblockmask_new );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGBUS );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGSEGV );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGTERM );
    vg_assert(res == 0+0+0);
 
-   res = VG_(ksigaction)( VKI_SIGBUS, &sigbus_new, &sigbus_saved );
+   res = VG_(sigaction)( VKI_SIGBUS, &sigbus_new, &sigbus_saved );
    vg_assert(res == 0+0+0+0);
 
-   res = VG_(ksigaction)( VKI_SIGSEGV, &sigsegv_new, &sigsegv_saved );
+   res = VG_(sigaction)( VKI_SIGSEGV, &sigsegv_new, &sigsegv_saved );
    vg_assert(res == 0+0+0+0+0);
 
-   res = VG_(ksigprocmask)( VKI_SIG_UNBLOCK, &unblockmask_new, &blockmask_saved );
+   res = VG_(sigprocmask)( VKI_SIG_UNBLOCK, &unblockmask_new, &blockmask_saved );
    vg_assert(res == 0+0+0+0+0+0);
 }
 
@@ -579,13 +579,13 @@ static void restore_signals(void)
    Int res;
 
    /* Restore signal state to whatever it was before. */
-   res = VG_(ksigaction)( VKI_SIGBUS, &sigbus_saved, NULL );
+   res = VG_(sigaction)( VKI_SIGBUS, &sigbus_saved, NULL );
    vg_assert(res == 0 +0);
 
-   res = VG_(ksigaction)( VKI_SIGSEGV, &sigsegv_saved, NULL );
+   res = VG_(sigaction)( VKI_SIGSEGV, &sigsegv_saved, NULL );
    vg_assert(res == 0 +0 +0);
 
-   res = VG_(ksigprocmask)( VKI_SIG_SETMASK, &blockmask_saved, NULL );
+   res = VG_(sigprocmask)( VKI_SIG_SETMASK, &blockmask_saved, NULL );
    vg_assert(res == 0 +0 +0 +0);
 }
 
@@ -598,7 +598,7 @@ static Bool is_valid_addr(Addr a)
    static const Bool debug = False;
    volatile Bool ret = False;
 
-   if ((a > VKI_BYTES_PER_PAGE) &&
+   if ((a > VKI_PAGE_SIZE) &&
        !test_visited(a, &faulted)) {
       if (!LAZYSIG)
         setup_signals();
index 25fbe37c0d228fa9d221f19c0e4464f100b83a75..81151d3e65ceb6a749fd60e463d79c6a485f4010 100644 (file)
 
 #include "core.h"
 
-/* vg_unsafe.h should NOT be included into any file except this
-   one. */
-#include "vg_unsafe.h"
-
-
 /* All system calls are channelled through here, doing two things:
 
    * notify the tool of the memory events (reads, writes) happening
@@ -395,12 +390,12 @@ static int fd_count = 0;
 
 Char *VG_(resolve_filename)(Int fd)
 {
-   char tmp[28], buf[PATH_MAX];
+   char tmp[28], buf[VKI_PATH_MAX];
 
    VG_(sprintf)(tmp, "/proc/self/fd/%d", fd);
-   VG_(memset)(buf, 0, PATH_MAX);
+   VG_(memset)(buf, 0, VKI_PATH_MAX);
 
-   if(VG_(readlink)(tmp, buf, PATH_MAX) == -1)
+   if(VG_(readlink)(tmp, buf, VKI_PATH_MAX) == -1)
       return NULL;
 
    return ((buf[0] == '/') ? VG_(arena_strdup)(VG_AR_CORE, buf) : NULL);
@@ -477,9 +472,9 @@ void record_fd_open(Int tid, Int fd, char *pathname)
 }
 
 static
-Char *unix2name(struct sockaddr_un *sa, UInt len, Char *name)
+Char *unix2name(struct vki_sockaddr_un *sa, UInt len, Char *name)
 {
-   if(sa == NULL || len == 0 || sa->sun_path[0] == '\0') {
+   if (sa == NULL || len == 0 || sa->sun_path[0] == '\0') {
       VG_(sprintf)(name, "<unknown>");
    } else {
       VG_(sprintf)(name, "%s", sa->sun_path);
@@ -489,9 +484,9 @@ Char *unix2name(struct sockaddr_un *sa, UInt len, Char *name)
 }
 
 static
-Char *inet2name(struct sockaddr_in *sa, UInt len, Char *name)
+Char *inet2name(struct vki_sockaddr_in *sa, UInt len, Char *name)
 {
-   if(sa == NULL || len == 0) {
+   if (sa == NULL || len == 0) {
       VG_(sprintf)(name, "<unknown>");
    } else {
       UInt addr = sa->sin_addr.s_addr;
@@ -502,7 +497,7 @@ Char *inet2name(struct sockaddr_in *sa, UInt len, Char *name)
          VG_(sprintf)(name, "%u.%u.%u.%u:%u",
                       addr & 0xFF, (addr>>8) & 0xFF,
                       (addr>>16) & 0xFF, (addr>>24) & 0xFF,
-                      ntohs(sa->sin_port));
+                      vki_ntohs(sa->sin_port));
       }
    }
 
@@ -518,22 +513,22 @@ static void
 getsockdetails(int fd)
 {
    union u {
-      struct sockaddr a;
-      struct sockaddr_in in;
-      struct sockaddr_un un;
+      struct vki_sockaddr a;
+      struct vki_sockaddr_in in;
+      struct vki_sockaddr_un un;
    } laddr;
-   socklen_t llen;
+   UInt llen;
 
    llen = sizeof(laddr);
    VG_(memset)(&laddr, 0, llen);
 
    if(VG_(getsockname)(fd, (struct vki_sockaddr *)&(laddr.a), &llen) != -1) {
       switch(laddr.a.sa_family) {
-      case AF_INET: {
+      case VKI_AF_INET: {
          static char lname[32];
          static char pname[32];
-         struct sockaddr_in paddr;
-         socklen_t plen = sizeof(struct sockaddr_in);
+         struct vki_sockaddr_in paddr;
+         UInt plen = sizeof(struct vki_sockaddr_in);
 
          if(VG_(getpeername)(fd, (struct vki_sockaddr *)&paddr, &plen) != -1) {
             VG_(message)(Vg_UserMsg, "Open AF_INET socket %d: %s <-> %s", fd,
@@ -545,7 +540,7 @@ getsockdetails(int fd)
          }
          return;
          }
-      case AF_UNIX: {
+      case VKI_AF_UNIX: {
          static char lname[256];
          VG_(message)(Vg_UserMsg, "Open AF_UNIX socket %d: %s", fd,
                       unix2name(&(laddr.un), llen, lname));
@@ -575,9 +570,9 @@ void VG_(show_open_fds) ()
                       i->pathname);
       } else {
          int val;
-         socklen_t len = sizeof(val);
+         UInt len = sizeof(val);
 
-         if(VG_(getsockopt)(i->fd, SOL_SOCKET, SO_TYPE, &val, &len) == -1) {
+         if (VG_(getsockopt)(i->fd, VKI_SOL_SOCKET, VKI_SO_TYPE, &val, &len) == -1) {
             VG_(message)(Vg_UserMsg, "Open file descriptor %d:", i->fd);
          } else {
             getsockdetails(i->fd);
@@ -660,8 +655,8 @@ out:
 static
 UInt get_shm_size ( Int shmid )
 {
-   struct shmid_ds buf;
-   long __res = VG_(do_syscall)(__NR_ipc, 24 /* IPCOP_shmctl */, shmid, IPC_STAT, 0, &buf);
+   struct vki_shmid_ds buf;
+   long __res = VG_(do_syscall)(__NR_ipc, 24 /* IPCOP_shmctl */, shmid, VKI_IPC_STAT, 0, &buf);
     if ( VG_(is_kerror) ( __res ) )
        return 0;
  
@@ -671,13 +666,13 @@ UInt get_shm_size ( Int shmid )
 static
 UInt get_sem_count( Int semid )
 {
-  struct semid_ds buf;
-  union semun arg;
+  struct vki_semid_ds buf;
+  union vki_semun arg;
   long res;
 
   arg.buf = &buf;
   
-  res = VG_(do_syscall)(__NR_ipc, 3 /* IPCOP_semctl */, semid, 0, IPC_STAT, &arg);
+  res = VG_(do_syscall)(__NR_ipc, 3 /* IPCOP_semctl */, semid, 0, VKI_IPC_STAT, &arg);
   if ( VG_(is_kerror)(res) )
     return 0;
 
@@ -723,14 +718,14 @@ void post_mem_write_recvmsg ( ThreadId tid,
 static
 void msghdr_foreachfield ( 
         ThreadId tid, 
-        struct msghdr *msg, 
+        struct vki_msghdr *msg, 
         void (*foreach_func)( ThreadId, Char *, UInt, UInt ) 
      )
 {
    if ( !msg )
       return;
 
-   foreach_func ( tid, "(msg)", (Addr)msg, sizeof( struct msghdr ) );
+   foreach_func ( tid, "(msg)", (Addr)msg, sizeof( struct vki_msghdr ) );
 
    if ( msg->msg_name )
       foreach_func ( tid, 
@@ -738,12 +733,12 @@ void msghdr_foreachfield (
                      (Addr)msg->msg_name, msg->msg_namelen );
 
    if ( msg->msg_iov ) {
-      struct iovec *iov = msg->msg_iov;
+      struct vki_iovec *iov = msg->msg_iov;
       UInt i;
 
       foreach_func ( tid, 
                      "(msg.msg_iov)", 
-                     (Addr)iov, msg->msg_iovlen * sizeof( struct iovec ) );
+                     (Addr)iov, msg->msg_iovlen * sizeof( struct vki_iovec ) );
 
       for ( i = 0; i < msg->msg_iovlen; ++i, ++iov )
          foreach_func ( tid, 
@@ -757,15 +752,15 @@ void msghdr_foreachfield (
                      (Addr)msg->msg_control, msg->msg_controllen );
 }
 
-void check_cmsg_for_fds(Int tid, struct msghdr *msg)
+void check_cmsg_for_fds(Int tid, struct vki_msghdr *msg)
 {
-   struct cmsghdr *cm = CMSG_FIRSTHDR(msg);
+   struct vki_cmsghdr *cm = VKI_CMSG_FIRSTHDR(msg);
 
    while (cm) {
-      if (cm->cmsg_level == SOL_SOCKET &&
-          cm->cmsg_type == SCM_RIGHTS ) {
-         int *fds = (int *) CMSG_DATA(cm);
-         int fdc = (cm->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)))
+      if (cm->cmsg_level == VKI_SOL_SOCKET &&
+          cm->cmsg_type == VKI_SCM_RIGHTS ) {
+         int *fds = (int *) VKI_CMSG_DATA(cm);
+         int fdc = (cm->cmsg_len - VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr)))
                          / sizeof(int);
          int i;
 
@@ -776,14 +771,14 @@ void check_cmsg_for_fds(Int tid, struct msghdr *msg)
                record_fd_open (tid, fds[i], VG_(resolve_filename)(fds[i]));
       }
 
-      cm = CMSG_NXTHDR(msg, cm);
+      cm = VKI_CMSG_NXTHDR(msg, cm);
    }
 }
 
 static
 void pre_mem_read_sockaddr ( ThreadId tid,
                             Char *description,
-                            struct sockaddr *sa, UInt salen )
+                            struct vki_sockaddr *sa, UInt salen )
 {
    Char *outmsg;
 
@@ -791,50 +786,48 @@ void pre_mem_read_sockaddr ( ThreadId tid,
    if ( sa == NULL || salen == 0 ) return;
 
    outmsg = VG_(arena_malloc) ( VG_AR_TRANSIENT,
-                                strlen( description ) + 30 );
+                                VG_(strlen)( description ) + 30 );
 
    VG_(sprintf) ( outmsg, description, ".sa_family" );
    SYSCALL_TRACK( pre_mem_read, tid, outmsg, 
-                  (Addr) &sa->sa_family, sizeof (sa_family_t));
+                  (Addr) &sa->sa_family, sizeof(vki_sa_family_t));
 
    switch (sa->sa_family) {
                   
-      case AF_UNIX:
+      case VKI_AF_UNIX:
          VG_(sprintf) ( outmsg, description, ".sun_path" );
          SYSCALL_TRACK( pre_mem_read_asciiz, tid, outmsg,
-            (Addr) ((struct sockaddr_un *) sa)->sun_path);
+            (Addr) ((struct vki_sockaddr_un *) sa)->sun_path);
          break;
                      
-      case AF_INET:
+      case VKI_AF_INET:
          VG_(sprintf) ( outmsg, description, ".sin_port" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in *) sa)->sin_port,
-            sizeof (((struct sockaddr_in *) sa)->sin_port));
+            (Addr) &((struct vki_sockaddr_in *) sa)->sin_port,
+            sizeof (((struct vki_sockaddr_in *) sa)->sin_port));
          VG_(sprintf) ( outmsg, description, ".sin_addr" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in *) sa)->sin_addr,
-            sizeof (struct in_addr));
+            (Addr) &((struct vki_sockaddr_in *) sa)->sin_addr,
+            sizeof (struct vki_in_addr));
          break;
                            
-      case AF_INET6:
+      case VKI_AF_INET6:
          VG_(sprintf) ( outmsg, description, ".sin6_port" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in6 *) sa)->sin6_port,
-            sizeof (((struct sockaddr_in6 *) sa)->sin6_port));
+            (Addr) &((struct vki_sockaddr_in6 *) sa)->sin6_port,
+            sizeof (((struct vki_sockaddr_in6 *) sa)->sin6_port));
          VG_(sprintf) ( outmsg, description, ".sin6_flowinfo" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in6 *) sa)->sin6_flowinfo,
-            sizeof (uint32_t));
+            (Addr) &((struct vki_sockaddr_in6 *) sa)->sin6_flowinfo,
+            sizeof (__vki_u32));
          VG_(sprintf) ( outmsg, description, ".sin6_addr" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in6 *) sa)->sin6_addr,
-            sizeof (struct in6_addr));
-#        ifndef GLIBC_2_1
+            (Addr) &((struct vki_sockaddr_in6 *) sa)->sin6_addr,
+            sizeof (struct vki_in6_addr));
          VG_(sprintf) ( outmsg, description, ".sin6_scope_id" );
          SYSCALL_TRACK( pre_mem_read, tid, outmsg,
-            (Addr) &((struct sockaddr_in6 *) sa)->sin6_scope_id,
-                       sizeof (uint32_t));
-#        endif
+            (Addr) &((struct vki_sockaddr_in6 *) sa)->sin6_scope_id,
+                       sizeof (__vki_u32));
          break;
                
       default:
@@ -1038,15 +1031,15 @@ PRE(ptrace)
    switch (arg1) {
    case 12:   /* PTRACE_GETREGS */
       SYSCALL_TRACK( pre_mem_write, tid, "ptrace(getregs)", arg4, 
-                    sizeof (struct user_regs_struct));
+                    sizeof (struct vki_user_regs_struct));
       break;
    case 14:   /* PTRACE_GETFPREGS */
       SYSCALL_TRACK( pre_mem_write, tid, "ptrace(getfpregs)", arg4, 
-                    sizeof (struct user_i387_struct));
+                    sizeof (struct vki_user_i387_struct));
       break;
    case 18:   /* PTRACE_GETFPXREGS */
       SYSCALL_TRACK( pre_mem_write, tid, "ptrace(getfpxregs)", arg4, 
-                     sizeof(struct user_fxsr_struct) );
+                     sizeof(struct vki_user_fxsr_struct) );
       break;
    case 1: case 2: case 3:    /* PTRACE_PEEK{TEXT,DATA,USER} */
       SYSCALL_TRACK( pre_mem_write, tid, "ptrace(peek)", arg4, 
@@ -1054,15 +1047,15 @@ PRE(ptrace)
       break;
    case 13:   /* PTRACE_SETREGS */
       SYSCALL_TRACK( pre_mem_read, tid, "ptrace(setregs)", arg4, 
-                    sizeof (struct user_regs_struct));
+                    sizeof (struct vki_user_regs_struct));
       break;
    case 15:   /* PTRACE_SETFPREGS */
       SYSCALL_TRACK( pre_mem_read, tid, "ptrace(setfpregs)", arg4, 
-                    sizeof (struct user_i387_struct));
+                    sizeof (struct vki_user_i387_struct));
       break;
    case 19:   /* PTRACE_SETFPXREGS */
       SYSCALL_TRACK( pre_mem_read, tid, "ptrace(setfpxregs)", arg4, 
-                     sizeof(struct user_fxsr_struct) );
+                     sizeof(struct vki_user_fxsr_struct) );
       break;
    default:
       break;
@@ -1074,15 +1067,15 @@ POST(ptrace)
    switch (arg1) {
    case 12:  /* PTRACE_GETREGS */
       VG_TRACK( post_mem_write, arg4, 
-               sizeof (struct user_regs_struct));
+               sizeof (struct vki_user_regs_struct));
       break;
    case 14:  /* PTRACE_GETFPREGS */
       VG_TRACK( post_mem_write, arg4, 
-               sizeof (struct user_i387_struct));
+               sizeof (struct vki_user_i387_struct));
       break;
    case 18:  /* PTRACE_GETFPXREGS */
       VG_TRACK( post_mem_write, arg4, 
-                sizeof(struct user_fxsr_struct) );
+                sizeof(struct vki_user_fxsr_struct) );
       break;
    case 1: case 2: case 3:    /* PTRACE_PEEK{TEXT,DATA,USER} */
       VG_TRACK( post_mem_write, arg4, sizeof (long));
@@ -1122,7 +1115,7 @@ PRE(modify_ldt)
       /* write the LDT with the entry pointed at by ptr */
       SYSCALL_TRACK( pre_mem_read, tid, 
                     "modify_ldt(ptr)(func=1 or 0x11)", arg2, 
-                    sizeof(struct vki_modify_ldt_ldt_s) );
+                    sizeof(vki_modify_ldt_t) );
    }
    /* "do" the syscall ourselves; the kernel never sees it */
    res = VG_(sys_modify_ldt)( tid, arg1, (void*)arg2, arg3 );
@@ -1138,7 +1131,7 @@ PRE(set_thread_area)
 
    SYSCALL_TRACK( pre_mem_read, tid, 
                  "set_thread_area(ptr)", arg1, 
-                 sizeof(struct vki_modify_ldt_ldt_s) );
+                 sizeof(vki_modify_ldt_t) );
 
    /* "do" the syscall ourselves; the kernel never sees it */
    set_result( VG_(sys_set_thread_area)( tid, (void *)arg1 ) );
@@ -1149,13 +1142,13 @@ PRE(get_thread_area)
    MAYBE_PRINTF("get_thread_area ( %p )\n", arg1);
    SYSCALL_TRACK( pre_mem_write, tid, 
                  "get_thread_area(ptr)", arg1, 
-                 sizeof(struct vki_modify_ldt_ldt_s) );
+                 sizeof(vki_modify_ldt_t) );
 
    /* "do" the syscall ourselves; the kernel never sees it */
    set_result( VG_(sys_get_thread_area)( tid, (void *)arg1 ) );
 
    if (!VG_(is_kerror)(res)) {
-      VG_TRACK( post_mem_write, arg1, sizeof(struct vki_modify_ldt_ldt_s) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_modify_ldt_t) );
    }
 }
 
@@ -1318,10 +1311,10 @@ PRE(msync)
    SYSCALL_TRACK( pre_mem_read, tid, "msync(start)", arg1, arg2 );
 }
 
-struct getpmsg_strbuf {
+struct pmsg_strbuf {
    int     maxlen;         /* no. of bytes in buffer */
    int     len;            /* no. of bytes returned */
-   caddr_t buf;            /* pointer to data */
+   vki_caddr_t buf;        /* pointer to data */
 };
 
 PRE(getpmsg)
@@ -1329,12 +1322,12 @@ PRE(getpmsg)
    /* LiS getpmsg from http://www.gcom.com/home/linux/lis/ */
    /* int getpmsg(int fd, struct strbuf *ctrl, struct strbuf *data, 
       int *bandp, int *flagsp); */
-   struct getpmsg_strbuf *ctrl;
-   struct getpmsg_strbuf *data;
+   struct pmsg_strbuf *ctrl;
+   struct pmsg_strbuf *data;
    MAYBE_PRINTF("getpmsg ( %d, %p, %p, %p, %p )\n",
                arg1,arg2,arg3,arg4,arg5);
-   ctrl = (struct getpmsg_strbuf *)arg2;
-   data = (struct getpmsg_strbuf *)arg3;
+   ctrl = (struct pmsg_strbuf *)arg2;
+   data = (struct pmsg_strbuf *)arg3;
    if (ctrl && ctrl->maxlen > 0)
       SYSCALL_TRACK( pre_mem_write,tid, "getpmsg(ctrl)", 
                     (Addr)ctrl->buf, ctrl->maxlen);
@@ -1351,11 +1344,11 @@ PRE(getpmsg)
 
 POST(getpmsg)
 {
-   struct getpmsg_strbuf *ctrl;
-   struct getpmsg_strbuf *data;
+   struct pmsg_strbuf *ctrl;
+   struct pmsg_strbuf *data;
 
-   ctrl = (struct getpmsg_strbuf *)arg2;
-   data = (struct getpmsg_strbuf *)arg3;
+   ctrl = (struct pmsg_strbuf *)arg2;
+   data = (struct pmsg_strbuf *)arg3;
    if (res == 0 && ctrl && ctrl->len > 0) {
       VG_TRACK( post_mem_write, (Addr)ctrl->buf, ctrl->len);
    }
@@ -1369,17 +1362,12 @@ PRE(putpmsg)
    /* LiS putpmsg from http://www.gcom.com/home/linux/lis/ */
    /* int putpmsg(int fd, struct strbuf *ctrl, struct strbuf *data, 
       int band, int flags); */
-   struct strbuf {
-      int     maxlen;         /* no. of bytes in buffer */
-      int     len;            /* no. of bytes returned */
-      caddr_t buf;            /* pointer to data */
-   };
-   struct strbuf *ctrl;
-   struct strbuf *data;
+   struct pmsg_strbuf *ctrl;
+   struct pmsg_strbuf *data;
    MAYBE_PRINTF("putpmsg ( %d, %p, %p, %d, %d )\n",
                arg1,arg2,arg3,arg4,arg5);
-   ctrl = (struct strbuf *)arg2;
-   data = (struct strbuf *)arg3;
+   ctrl = (struct pmsg_strbuf *)arg2;
+   data = (struct pmsg_strbuf *)arg3;
    if (ctrl && ctrl->len > 0)
       SYSCALL_TRACK( pre_mem_read,tid, "putpmsg(ctrl)",
                     (Addr)ctrl->buf, ctrl->len);
@@ -1393,13 +1381,13 @@ PRE(getitimer)
    /* int getitimer(int which, struct itimerval *value); */
    MAYBE_PRINTF("getitimer ( %d, %p )\n", arg1, arg2);
    SYSCALL_TRACK( pre_mem_write, tid, "getitimer(timer)", arg2, 
-                 sizeof(struct itimerval) );
+                 sizeof(struct vki_itimerval) );
 }
 
 POST(getitimer)
 {
    if (arg2 != (Addr)NULL) {
-      VG_TRACK( post_mem_write,arg2, sizeof(struct itimerval));
+      VG_TRACK( post_mem_write,arg2, sizeof(struct vki_itimerval));
    }
 }
 
@@ -1481,12 +1469,12 @@ PRE(_sysctl)
    /* int _sysctl(struct __sysctl_args *args); */
    MAYBE_PRINTF("_sysctl ( %p )\n", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "_sysctl(args)", arg1, 
-                 sizeof(struct __sysctl_args) );
+                 sizeof(struct __vki_sysctl_args) );
 }
 
 POST(_sysctl)
 {
-   VG_TRACK( post_mem_write, arg1, sizeof(struct __sysctl_args) );
+   VG_TRACK( post_mem_write, arg1, sizeof(struct __vki_sysctl_args) );
 
 }
 
@@ -1504,7 +1492,7 @@ PRE(sched_setscheduler)
    if (arg3 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid,
                     "sched_setscheduler(struct sched_param *p)", 
-                    arg3, sizeof(struct sched_param));
+                    arg3, sizeof(struct vki_sched_param));
 }
 
 PRE(mlock)
@@ -1586,12 +1574,12 @@ PRE(sendfile)
    MAYBE_PRINTF("sendfile ( %d, %d, %p, %d )\n",arg1,arg2,arg3,arg4);
    if (arg3 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "sendfile(offset)",
-                    arg3, sizeof(off_t) );
+                    arg3, sizeof(vki_off_t) );
 }
 
 POST(sendfile)
 {
-   VG_TRACK( post_mem_write, arg3, sizeof( off_t ) );
+   VG_TRACK( post_mem_write, arg3, sizeof( vki_off_t ) );
 }
 
 PRE(sendfile64)
@@ -1601,13 +1589,13 @@ PRE(sendfile64)
    MAYBE_PRINTF("sendfile64 ( %d, %d, %p, %d )\n",arg1,arg2,arg3,arg4);
    if (arg3 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "sendfile64(offset)",
-                    arg3, sizeof(loff_t) );
+                    arg3, sizeof(vki_loff_t) );
 }
 
 POST(sendfile64)
 {
    if (arg3 != (UInt)NULL ) {
-      VG_TRACK( post_mem_write, arg3, sizeof(loff_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_loff_t) );
    }
 }
 
@@ -1707,23 +1695,23 @@ PRE(capget)
    /* int capget(cap_user_header_t header, cap_user_data_t data); */
    MAYBE_PRINTF("capget ( %p, %p )\n", arg1, arg2 );
    SYSCALL_TRACK( pre_mem_read, tid, "capget(header)", arg1, 
-                 sizeof(vki_cap_user_header_t) );
+                  sizeof(struct __vki_user_cap_header_struct) );
    SYSCALL_TRACK( pre_mem_write, tid, "capget(data)", arg2, 
-                 sizeof( vki_cap_user_data_t) );
+                  sizeof(struct __vki_user_cap_data_struct) );
 }
 
 POST(capget)
 {
    if (arg2 != (Addr)NULL)
-      VG_TRACK( post_mem_write, arg2, sizeof( vki_cap_user_data_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(struct __vki_user_cap_data_struct) );
 }
 
 PRE(capset)
 {
    SYSCALL_TRACK( pre_mem_read, tid, "capset(header)", 
-                 arg1, sizeof(vki_cap_user_header_t) );
+                  arg1, sizeof(struct __vki_user_cap_header_struct) );
    SYSCALL_TRACK( pre_mem_read, tid, "capset(data)", 
-                 arg2, sizeof( vki_cap_user_data_t) );
+                  arg2, sizeof(struct __vki_user_cap_data_struct) );
 }
 
 // Pre_read a char** argument.
@@ -1824,15 +1812,15 @@ PRE(execve)
       well.
    */
    {
-      vki_ksigset_t allsigs;
-      vki_ksiginfo_t info;
+      vki_sigset_t allsigs;
+      vki_siginfo_t info;
       static const struct vki_timespec zero = { 0, 0 };
     
-      VG_(ksigfillset)(&allsigs);
-      while(VG_(ksigtimedwait)(&allsigs, &info, &zero) > 0)
+      VG_(sigfillset)(&allsigs);
+      while(VG_(sigtimedwait)(&allsigs, &info, &zero) > 0)
         ;
 
-      VG_(ksigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
+      VG_(sigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
    }
 
    /* restore the DATA rlimit for the child */
@@ -2043,26 +2031,26 @@ PRE(fstat)
 {
    /* int fstat(int filedes, struct stat *buf); */
    MAYBE_PRINTF("fstat ( %d, %p )\n",arg1,arg2);
-   SYSCALL_TRACK( pre_mem_write, tid, "fstat", arg2, sizeof(struct stat) );
+   SYSCALL_TRACK( pre_mem_write, tid, "fstat", arg2, sizeof(struct vki_stat) );
 }
 
 POST(fstat)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct stat) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat) );
 }
 
-static vki_ksigset_t fork_saved_mask;
+static vki_sigset_t fork_saved_mask;
 
 PRE(fork)
 {
-   vki_ksigset_t mask;
+   vki_sigset_t mask;
 
    vg_assert(VG_(gettid)() == VG_(main_pid));
 
    /* Block all signals during fork, so that we can fix things up in
       the child without being interrupted. */
-   VG_(ksigfillset)(&mask);
-   VG_(ksigprocmask)(VKI_SIG_SETMASK, &mask, &fork_saved_mask);
+   VG_(sigfillset)(&mask);
+   VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, &fork_saved_mask);
 
    /* pid_t fork(void); */
    MAYBE_PRINTF("fork ()\n");
@@ -2083,14 +2071,14 @@ POST(fork)
         We should move this TID to 1 in the child. */
 
       /* restore signal mask */
-      VG_(ksigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
+      VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
    } else {
       MAYBE_PRINTF("   fork: process %d created child %d\n", VG_(main_pid), res);
 
       do_atfork_parent(tid);
 
       /* restore signal mask */
-      VG_(ksigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
+      VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
    }
 }
 
@@ -2167,13 +2155,13 @@ PRE(getgroups)
    MAYBE_PRINTF("getgroups ( %d, %p )\n", arg1, arg2);
    if (arg1 > 0)
       SYSCALL_TRACK( pre_mem_write, tid, "getgroups(list)", arg2, 
-                    arg1 * sizeof(gid_t) );
+                    arg1 * sizeof(vki_gid_t) );
 }
 
 POST(getgroups)
 {
    if (arg1 > 0 && res > 0)
-      VG_TRACK( post_mem_write, arg2, res * sizeof(gid_t) );
+      VG_TRACK( post_mem_write, arg2, res * sizeof(vki_gid_t) );
 }
 
 PREALIAS(getgroups32, getgroups);
@@ -2259,19 +2247,19 @@ PRE(getresgid)
    /* int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); */
    MAYBE_PRINTF("getresgid ( %p, %p, %p )\n", arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid(rgid)", 
-                 arg1, sizeof(gid_t) );
+                 arg1, sizeof(vki_gid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid(egid)", 
-                 arg2, sizeof(gid_t) );
+                 arg2, sizeof(vki_gid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid(sgid)", 
-                 arg3, sizeof(gid_t) );
+                 arg3, sizeof(vki_gid_t) );
 }
 
 POST(getresgid)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg1, sizeof(gid_t) );
-      VG_TRACK( post_mem_write, arg2, sizeof(gid_t) );
-      VG_TRACK( post_mem_write, arg3, sizeof(gid_t) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_gid_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_gid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_gid_t) );
    }
 }
 
@@ -2280,19 +2268,19 @@ PRE(getresgid32)
    /* int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); */
    MAYBE_PRINTF("getresgid32 ( %p, %p, %p )\n", arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid32(rgid)", 
-                 arg1, sizeof(gid_t) );
+                 arg1, sizeof(vki_gid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid32(egid)", 
-                 arg2, sizeof(gid_t) );
+                 arg2, sizeof(vki_gid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresgid32(sgid)", 
-                 arg3, sizeof(gid_t) );
+                 arg3, sizeof(vki_gid_t) );
 }
 
 POST(getresgid32)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg1, sizeof(gid_t) );
-      VG_TRACK( post_mem_write, arg2, sizeof(gid_t) );
-      VG_TRACK( post_mem_write, arg3, sizeof(gid_t) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_gid_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_gid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_gid_t) );
    }
 }
 
@@ -2301,19 +2289,19 @@ PRE(getresuid)
    /* int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); */
    MAYBE_PRINTF("getresuid ( %p, %p, %p )\n", arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid(ruid)", 
-                 arg1, sizeof(uid_t) );
+                 arg1, sizeof(vki_uid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid(euid)", 
-                 arg2, sizeof(uid_t) );
+                 arg2, sizeof(vki_uid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid(suid)", 
-                 arg3, sizeof(uid_t) );
+                 arg3, sizeof(vki_uid_t) );
 }
 
 POST(getresuid)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg1, sizeof(uid_t) );
-      VG_TRACK( post_mem_write, arg2, sizeof(uid_t) );
-      VG_TRACK( post_mem_write, arg3, sizeof(uid_t) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_uid_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_uid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_uid_t) );
    }
 }
 
@@ -2322,19 +2310,19 @@ PRE(getresuid32)
    /* int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); */
    MAYBE_PRINTF("getresuid32 ( %p, %p, %p )\n", arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid32(ruid)", 
-                 arg1, sizeof(uid_t) );
+                 arg1, sizeof(vki_uid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid32(euid)", 
-                 arg2, sizeof(uid_t) );
+                 arg2, sizeof(vki_uid_t) );
    SYSCALL_TRACK( pre_mem_write, tid, "getresuid32(suid)", 
-                 arg3, sizeof(uid_t) );
+                 arg3, sizeof(vki_uid_t) );
 }
 
 POST(getresuid32)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg1, sizeof(uid_t) );
-      VG_TRACK( post_mem_write, arg2, sizeof(uid_t) );
-      VG_TRACK( post_mem_write, arg3, sizeof(uid_t) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_uid_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_uid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_uid_t) );
    }
 }
 
@@ -2352,16 +2340,16 @@ POST(getrlimit)
 
     switch(arg1) {
     case VKI_RLIMIT_NOFILE:
-       ((vki_rlimit *)arg2)->rlim_cur = VG_(fd_soft_limit);
-       ((vki_rlimit *)arg2)->rlim_max = VG_(fd_hard_limit);
+       ((struct vki_rlimit *)arg2)->rlim_cur = VG_(fd_soft_limit);
+       ((struct vki_rlimit *)arg2)->rlim_max = VG_(fd_hard_limit);
        break;
 
     case VKI_RLIMIT_DATA:
-       *((vki_rlimit *)arg2) = VG_(client_rlimit_data);
+       *((struct vki_rlimit *)arg2) = VG_(client_rlimit_data);
        break;
 
     case VKI_RLIMIT_STACK:
-       *((vki_rlimit *)arg2) = VG_(client_rlimit_stack);
+       *((struct vki_rlimit *)arg2) = VG_(client_rlimit_stack);
        break;
     }
 }
@@ -2374,13 +2362,13 @@ PRE(getrusage)
    /* int getrusage (int who, struct rusage *usage); */
    MAYBE_PRINTF("getrusage ( %d, %p )\n", arg1,arg2);
    SYSCALL_TRACK( pre_mem_write, tid, "getrusage(usage)", arg2, 
-                 sizeof(struct rusage) );
+                 sizeof(struct vki_rusage) );
 }
 
 POST(getrusage)
 {
    if (res == 0)
-      VG_TRACK( post_mem_write,arg2, sizeof(struct rusage) );
+      VG_TRACK( post_mem_write,arg2, sizeof(struct vki_rusage) );
 }
 
 PRE(gettimeofday)
@@ -2388,18 +2376,18 @@ PRE(gettimeofday)
    /* int gettimeofday(struct timeval *tv, struct timezone *tz); */
    MAYBE_PRINTF("gettimeofday ( %p, %p )\n",arg1,arg2);
    SYSCALL_TRACK( pre_mem_write, tid, "gettimeofday(tv)", arg1, 
-                 sizeof(struct timeval) );
+                 sizeof(struct vki_timeval) );
    if (arg2 != 0)
       SYSCALL_TRACK( pre_mem_write, tid, "gettimeofday(tz)", arg2, 
-                    sizeof(struct timezone) );
+                    sizeof(struct vki_timezone) );
 }
 
 POST(gettimeofday)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg1, sizeof(struct timeval) );
+      VG_TRACK( post_mem_write, arg1, sizeof(struct vki_timeval) );
       if (arg2 != 0)
-        VG_TRACK( post_mem_write, arg2, sizeof(struct timezone) );
+        VG_TRACK( post_mem_write, arg2, sizeof(struct vki_timezone) );
    }
 }
 
@@ -2422,39 +2410,39 @@ PRE(ipc)
    switch (arg1 /* call */) {
    case 1: /* IPCOP_semop */
       SYSCALL_TRACK( pre_mem_read, tid, "semop(sops)", arg5, 
-                    arg3 * sizeof(struct sembuf) );
+                    arg3 * sizeof(struct vki_sembuf) );
       tst->sys_flags |= MayBlock;
       break;
    case 2: /* IPCOP_semget */
       break;
    case 3: /* IPCOP_semctl */
    {
-      union semun *arg = (union semun *)arg5;
+      union vki_semun *arg = (union vki_semun *)arg5;
       switch (arg4 /* cmd */) {
-      case IPC_INFO:
-      case SEM_INFO:
+      case VKI_IPC_INFO:
+      case VKI_SEM_INFO:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->__buf, "semctl(IPC_INFO, arg)" );
         SYSCALL_TRACK( pre_mem_write, tid, "semctl(IPC_INFO, arg->buf)", buf, 
-                       sizeof(struct seminfo) );
+                       sizeof(struct vki_seminfo) );
         break;
       }
-      case IPC_STAT:
-      case SEM_STAT:
+      case VKI_IPC_STAT:
+      case VKI_SEM_STAT:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(IPC_STAT, arg)" );
         SYSCALL_TRACK( pre_mem_write, tid, "semctl(IPC_STAT, arg->buf)", buf, 
-                       sizeof(struct semid_ds) );
+                       sizeof(struct vki_semid_ds) );
         break;
       }
-      case IPC_SET:
+      case VKI_IPC_SET:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(IPC_SET, arg)" );
         SYSCALL_TRACK( pre_mem_read, tid, "semctl(IPC_SET, arg->buf)", buf, 
-                       sizeof(struct semid_ds) );
+                       sizeof(struct vki_semid_ds) );
         break;
       }
-      case GETALL:
+      case VKI_GETALL:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(IPC_GETALL, arg)" );
          UInt nsems = get_sem_count( arg2 );
@@ -2462,7 +2450,7 @@ PRE(ipc)
                        sizeof(short) * nsems );
         break;
       }
-      case SETALL:
+      case VKI_SETALL:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(IPC_SETALL, arg)" );
          UInt nsems = get_sem_count( arg2 );
@@ -2470,37 +2458,36 @@ PRE(ipc)
                        sizeof(short) * nsems );
         break;
       }
-      case SETVAL:
+      case VKI_SETVAL:
       {
         SYSCALL_TRACK( pre_mem_read, tid, "semctl(IPC_SETVAL, arg->array)",
                         (Addr)&arg->val, sizeof(arg->val) );
         break;
       }
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
-      case SEM_INFO|IPC_64:
+      case VKI_IPC_INFO|VKI_IPC_64:
+      case VKI_SEM_INFO|VKI_IPC_64:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->__buf, "semctl(IPC_INFO, arg)" );
         SYSCALL_TRACK( pre_mem_write, tid, "semctl(IPC_INFO, arg->buf)", buf, 
-                       sizeof(struct seminfo) );
+                       sizeof(struct vki_seminfo) );
         break;
       }
-      case IPC_STAT|IPC_64:
-      case SEM_STAT|IPC_64:
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_SEM_STAT|VKI_IPC_64:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(IPC_STAT, arg)" );
         SYSCALL_TRACK( pre_mem_write, tid, "semctl(IPC_STAT, arg->buf)", buf, 
-                       sizeof(struct semid64_ds) );
+                       sizeof(struct vki_semid64_ds) );
         break;
       }
-      case IPC_SET|IPC_64:
+      case VKI_IPC_SET|VKI_IPC_64:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(IPC_SET, arg)" );
         SYSCALL_TRACK( pre_mem_read, tid, "semctl(IPC_SET, arg->buf)", buf, 
-                       sizeof(struct semid64_ds) );
+                       sizeof(struct vki_semid64_ds) );
         break;
       }
-      case GETALL|IPC_64:
+      case VKI_GETALL|VKI_IPC_64:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(IPC_GETALL, arg)" );
          UInt nsems = get_sem_count( arg2 );
@@ -2508,7 +2495,7 @@ PRE(ipc)
                        sizeof(short) * nsems );
         break;
       }
-      case SETALL|IPC_64:
+      case VKI_SETALL|VKI_IPC_64:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(IPC_SETALL, arg)" );
          UInt nsems = get_sem_count( arg2 );
@@ -2516,13 +2503,12 @@ PRE(ipc)
                        sizeof(short) * nsems );
         break;
       }
-      case SETVAL|IPC_64:
+      case VKI_SETVAL|VKI_IPC_64:
       {
         SYSCALL_TRACK( pre_mem_read, tid, "semctl(IPC_SETVAL, arg->array)",
                         (Addr)&arg->val, sizeof(arg->val) );
         break;
       }
-#                    endif
       default:
         break;
       }
@@ -2530,15 +2516,15 @@ PRE(ipc)
    }
    case 4: /* IPCOP_semtimedop */
       SYSCALL_TRACK( pre_mem_read, tid, "semtimedop(sops)", arg5, 
-                    arg3 * sizeof(struct sembuf) );
+                    arg3 * sizeof(struct vki_sembuf) );
       if (arg6 != (UInt)NULL)
          SYSCALL_TRACK( pre_mem_read, tid, "semtimedop(timeout)", arg6, 
-                        sizeof(struct timespec) );
+                        sizeof(struct vki_timespec) );
       tst->sys_flags |= MayBlock;
       break;
    case 11: /* IPCOP_msgsnd */
    {
-      struct msgbuf *msgp = (struct msgbuf *)arg5;
+      struct vki_msgbuf *msgp = (struct vki_msgbuf *)arg5;
       Int msgsz = arg3;
 
       SYSCALL_TRACK( pre_mem_read, tid, "msgsnd(msgp->mtype)", 
@@ -2552,11 +2538,11 @@ PRE(ipc)
    }
    case 12: /* IPCOP_msgrcv */
    {
-      struct msgbuf *msgp;
+      struct vki_msgbuf *msgp;
       Int msgsz = arg3;
  
-      msgp = (struct msgbuf *)deref_Addr( tid,
-                                         (Addr) (&((struct ipc_kludge *)arg5)->msgp),
+      msgp = (struct vki_msgbuf *)deref_Addr( tid,
+                                         (Addr) (&((struct vki_ipc_kludge *)arg5)->msgp),
                                          "msgrcv(msgp)" );
 
       SYSCALL_TRACK( pre_mem_write, tid, "msgrcv(msgp->mtype)", 
@@ -2573,36 +2559,34 @@ PRE(ipc)
    case 14: /* IPCOP_msgctl */
    {
       switch (arg3 /* cmd */) {
-      case IPC_INFO:
-      case MSG_INFO:
+      case VKI_IPC_INFO:
+      case VKI_MSG_INFO:
         SYSCALL_TRACK( pre_mem_write, tid, "msgctl(IPC_INFO, buf)", arg5, 
-                       sizeof(struct msginfo) );
+                       sizeof(struct vki_msginfo) );
         break;
-      case IPC_STAT:
-      case MSG_STAT:
+      case VKI_IPC_STAT:
+      case VKI_MSG_STAT:
         SYSCALL_TRACK( pre_mem_write, tid, "msgctl(IPC_STAT, buf)", arg5, 
-                       sizeof(struct msqid_ds) );
+                       sizeof(struct vki_msqid_ds) );
         break;
-      case IPC_SET:
+      case VKI_IPC_SET:
         SYSCALL_TRACK( pre_mem_read, tid, "msgctl(IPC_SET, buf)", arg5, 
-                       sizeof(struct msqid_ds) );
+                       sizeof(struct vki_msqid_ds) );
         break;
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
-      case MSG_INFO|IPC_64:
+      case VKI_IPC_INFO|VKI_IPC_64:
+      case VKI_MSG_INFO|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_write, tid, "msgctl(IPC_INFO, buf)", arg5, 
-                       sizeof(struct msginfo) );
+                       sizeof(struct vki_msginfo) );
         break;
-      case IPC_STAT|IPC_64:
-      case MSG_STAT|IPC_64:
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_MSG_STAT|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_write, tid, "msgctl(IPC_STAT, buf)", arg5, 
-                       sizeof(struct msqid64_ds) );
+                       sizeof(struct vki_msqid64_ds) );
         break;
-      case IPC_SET|IPC_64:
+      case VKI_IPC_SET|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_read, tid, "msgctl(IPC_SET, buf)", arg5, 
-                       sizeof(struct msqid64_ds) );
+                       sizeof(struct vki_msqid64_ds) );
         break;
-#                    endif
       default:
         break;
       }
@@ -2630,42 +2614,40 @@ PRE(ipc)
    case 24: /* IPCOP_shmctl */
    {
       switch (arg3 /* cmd */) {
-      case IPC_INFO:
+      case VKI_IPC_INFO:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(IPC_INFO, buf)", arg5, 
-                       sizeof(struct shminfo) );
+                       sizeof(struct vki_shminfo) );
         break;
-      case SHM_INFO:
+      case VKI_SHM_INFO:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(SHM_INFO, buf)", arg5, 
-                       sizeof(struct shm_info) );
+                       sizeof(struct vki_shm_info) );
         break;
-      case IPC_STAT:
-      case SHM_STAT:
+      case VKI_IPC_STAT:
+      case VKI_SHM_STAT:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(IPC_STAT, buf)", arg5, 
-                       sizeof(struct shmid_ds) );
+                       sizeof(struct vki_shmid_ds) );
         break;
-      case IPC_SET:
+      case VKI_IPC_SET:
         SYSCALL_TRACK( pre_mem_read, tid, "shmctl(IPC_SET, buf)", arg5, 
-                       sizeof(struct shmid_ds) );
+                       sizeof(struct vki_shmid_ds) );
         break;
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
+      case VKI_IPC_INFO|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(IPC_INFO, buf)", arg5, 
-                       sizeof(struct shminfo64) );
+                       sizeof(struct vki_shminfo64) );
         break;
-      case SHM_INFO|IPC_64:
+      case VKI_SHM_INFO|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(SHM_INFO, buf)", arg5, 
-                       sizeof(struct shm_info) );
+                       sizeof(struct vki_shm_info) );
         break;
-      case IPC_STAT|IPC_64:
-      case SHM_STAT|IPC_64:
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_SHM_STAT|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_write, tid, "shmctl(IPC_STAT, buf)", arg5, 
-                       sizeof(struct shmid64_ds) );
+                       sizeof(struct vki_shmid64_ds) );
         break;
-      case IPC_SET|IPC_64:
+      case VKI_IPC_SET|VKI_IPC_64:
         SYSCALL_TRACK( pre_mem_read, tid, "shmctl(IPC_SET, buf)", arg5, 
-                       sizeof(struct shmid_ds) );
+                       sizeof(struct vki_shmid_ds) );
         break;
-#                    endif
       default:
         break;
       }
@@ -2688,52 +2670,50 @@ POST(ipc)
       break;
    case 3: /* IPCOP_semctl */
    {
-      union semun *arg = (union semun *)arg5;
+      union vki_semun *arg = (union vki_semun *)arg5;
       switch (arg4 /* cmd */) {
-      case IPC_INFO:
-      case SEM_INFO:
+      case VKI_IPC_INFO:
+      case VKI_SEM_INFO:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->__buf, "semctl(arg)" );
-        VG_TRACK( post_mem_write, buf, sizeof(struct seminfo) );
+        VG_TRACK( post_mem_write, buf, sizeof(struct vki_seminfo) );
         break;
       }
-      case IPC_STAT:
-      case SEM_STAT:
+      case VKI_IPC_STAT:
+      case VKI_SEM_STAT:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(arg)" );
-        VG_TRACK( post_mem_write, buf, sizeof(struct semid_ds) );
+        VG_TRACK( post_mem_write, buf, sizeof(struct vki_semid_ds) );
         break;
       }
-      case GETALL:
+      case VKI_GETALL:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(arg)" );
          UInt nsems = get_sem_count( arg2 );
         VG_TRACK( post_mem_write, array, sizeof(short) * nsems );
         break;
       }
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
-      case SEM_INFO|IPC_64:
+      case VKI_IPC_INFO|VKI_IPC_64:
+      case VKI_SEM_INFO|VKI_IPC_64:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->__buf, "semctl(arg)" );
-        VG_TRACK( post_mem_write, buf, sizeof(struct seminfo) );
+        VG_TRACK( post_mem_write, buf, sizeof(struct vki_seminfo) );
         break;
       }
-      case IPC_STAT|IPC_64:
-      case SEM_STAT|IPC_64:
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_SEM_STAT|VKI_IPC_64:
       {
          Addr buf = deref_Addr( tid, (Addr)&arg->buf, "semctl(arg)" );
-        VG_TRACK( post_mem_write, buf, sizeof(struct semid64_ds) );
+        VG_TRACK( post_mem_write, buf, sizeof(struct vki_semid64_ds) );
         break;
       }
-      case GETALL|IPC_64:
+      case VKI_GETALL|VKI_IPC_64:
       {
          Addr array = deref_Addr( tid, (Addr)&arg->array, "semctl(arg)" );
          UInt nsems = get_sem_count( arg2 );
         VG_TRACK( post_mem_write, array, sizeof(short) * nsems );
         break;
       }
-#                    endif
       default:
         break;
       }
@@ -2745,10 +2725,10 @@ POST(ipc)
       break;
    case 12: /* IPCOP_msgrcv */
    {
-      struct msgbuf *msgp;
+      struct vki_msgbuf *msgp;
  
-      msgp = (struct msgbuf *)deref_Addr( tid,
-                                         (Addr) (&((struct ipc_kludge *)arg5)->msgp),
+      msgp = (struct vki_msgbuf *)deref_Addr( tid,
+                                         (Addr) (&((struct vki_ipc_kludge *)arg5)->msgp),
                                          "msgrcv(msgp)" );
       if ( res > 0 ) {
         VG_TRACK( post_mem_write, (Addr)&msgp->mtype, 
@@ -2762,28 +2742,26 @@ POST(ipc)
    case 14: /* IPCOP_msgctl */
    {
       switch (arg3 /* cmd */) {
-      case IPC_INFO:
-      case MSG_INFO:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct msginfo) );
+      case VKI_IPC_INFO:
+      case VKI_MSG_INFO:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_msginfo) );
         break;
-      case IPC_STAT:
-      case MSG_STAT:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct msqid_ds) );
+      case VKI_IPC_STAT:
+      case VKI_MSG_STAT:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_msqid_ds) );
         break;
-      case IPC_SET:
+      case VKI_IPC_SET:
         break;
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
-      case MSG_INFO|IPC_64:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct msginfo) );
+      case VKI_IPC_INFO|VKI_IPC_64:
+      case VKI_MSG_INFO|VKI_IPC_64:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_msginfo) );
         break;
-      case IPC_STAT|IPC_64:
-      case MSG_STAT|IPC_64:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct msqid64_ds) );
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_MSG_STAT|VKI_IPC_64:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_msqid64_ds) );
         break;
-      case IPC_SET|IPC_64:
+      case VKI_IPC_SET|VKI_IPC_64:
         break;
-#                    endif
       default:
         break;
       }
@@ -2831,28 +2809,26 @@ POST(ipc)
    case 24: /* IPCOP_shmctl */
    {
       switch (arg3 /* cmd */) {
-      case IPC_INFO:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shminfo) );
+      case VKI_IPC_INFO:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shminfo) );
         break;
-      case SHM_INFO:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shm_info) );
+      case VKI_SHM_INFO:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shm_info) );
         break;
-      case IPC_STAT:
-      case SHM_STAT:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shmid_ds) );
+      case VKI_IPC_STAT:
+      case VKI_SHM_STAT:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shmid_ds) );
         break;
-#                    if defined(IPC_64)
-      case IPC_INFO|IPC_64:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shminfo64) );
+      case VKI_IPC_INFO|VKI_IPC_64:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shminfo64) );
         break;
-      case SHM_INFO|IPC_64:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shm_info) );
+      case VKI_SHM_INFO|VKI_IPC_64:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shm_info) );
         break;
-      case IPC_STAT|IPC_64:
-      case SHM_STAT|IPC_64:
-        VG_TRACK( post_mem_write, arg5, sizeof(struct shmid64_ds) );
+      case VKI_IPC_STAT|VKI_IPC_64:
+      case VKI_SHM_STAT|VKI_IPC_64:
+        VG_TRACK( post_mem_write, arg5, sizeof(struct vki_shmid64_ds) );
         break;
-#                    endif
       default:
         break;
       }
@@ -2881,53 +2857,53 @@ PRE(ioctl)
    */
    MAYBE_PRINTF("ioctl ( %d, 0x%x, %p )\n",arg1,arg2,arg3);
    switch (arg2 /* request */) {
-   case TCSETS:
-   case TCSETSW:
-   case TCSETSF:
+   case VKI_TCSETS:
+   case VKI_TCSETSW:
+   case VKI_TCSETSF:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TCSET{S,SW,SF})", arg3, 
                     VKI_SIZEOF_STRUCT_TERMIOS );
       break; 
-   case TCGETS:
+   case VKI_TCGETS:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TCGETS)", arg3, 
                     VKI_SIZEOF_STRUCT_TERMIOS );
       break;
-   case TCSETA:
-   case TCSETAW:
-   case TCSETAF:
+   case VKI_TCSETA:
+   case VKI_TCSETAW:
+   case VKI_TCSETAF:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TCSET{A,AW,AF})", arg3,
-                    VKI_SIZEOF_STRUCT_TERMIO );
+                    sizeof(struct vki_termio) );
       break;
-   case TCGETA:
+   case VKI_TCGETA:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TCGETA)", arg3,
-                    VKI_SIZEOF_STRUCT_TERMIO );
+                    sizeof(struct vki_termio) );
       break;
-   case TCSBRK:
-   case TCXONC:
-   case TCSBRKP:
-   case TCFLSH:
+   case VKI_TCSBRK:
+   case VKI_TCXONC:
+   case VKI_TCSBRKP:
+   case VKI_TCFLSH:
       /* These just take an int by value */
       break;
-   case TIOCGWINSZ:
+   case VKI_TIOCGWINSZ:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TIOCGWINSZ)", arg3, 
-                    sizeof(struct winsize) );
+                    sizeof(struct vki_winsize) );
       break;
-   case TIOCSWINSZ:
+   case VKI_TIOCSWINSZ:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCSWINSZ)", arg3, 
-                    sizeof(struct winsize) );
+                    sizeof(struct vki_winsize) );
       break;
-   case TIOCMBIS:
+   case VKI_TIOCMBIS:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCMBIS)", arg3,
                      sizeof(unsigned int) );
       break;
-   case TIOCMBIC:
+   case VKI_TIOCMBIC:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCMBIC)", arg3,
                      sizeof(unsigned int) );
       break;
-   case TIOCMSET:
+   case VKI_TIOCMSET:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCMSET)", arg3,
                      sizeof(unsigned int) );
       break;
-   case TIOCLINUX:
+   case VKI_TIOCLINUX:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCLINUX)", arg3, 
                     sizeof(char *) );
       if (*(char *)arg3 == 11) {
@@ -2935,89 +2911,81 @@ PRE(ioctl)
                        arg3, 2 * sizeof(char *) );
       }
       break;
-   case TIOCGPGRP:
+   case VKI_TIOCGPGRP:
       /* Get process group ID for foreground processing group. */
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TIOCGPGRP)", arg3,
-                    sizeof(pid_t) );
+                    sizeof(vki_pid_t) );
       break;
-   case TIOCSPGRP:
+   case VKI_TIOCSPGRP:
       /* Set a process group ID? */
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TIOCGPGRP)", arg3,
-                    sizeof(pid_t) );
+                    sizeof(vki_pid_t) );
       break;
-   case TIOCGPTN: /* Get Pty Number (of pty-mux device) */
+   case VKI_TIOCGPTN: /* Get Pty Number (of pty-mux device) */
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(TIOCGPTN)", 
                     arg3, sizeof(int) );
       break;
-   case TIOCSCTTY:
+   case VKI_TIOCSCTTY:
       /* Just takes an int value.  */
       break;
-   case TIOCSPTLCK: /* Lock/unlock Pty */
+   case VKI_TIOCSPTLCK: /* Lock/unlock Pty */
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(TIOCSPTLCK)", 
                     arg3, sizeof(int) );
       break;
-   case FIONBIO:
+   case VKI_FIONBIO:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(FIONBIO)", 
                     arg3, sizeof(int) );
       break;
-   case FIOASYNC:
+   case VKI_FIOASYNC:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(FIOASYNC)", 
                     arg3, sizeof(int) );
       break;
-   case FIONREAD:                /* identical to SIOCINQ */
+   case VKI_FIONREAD:                /* identical to SIOCINQ */
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(FIONREAD)", 
                     arg3, sizeof(int) );
       break;
 
-      /* If you get compilation problems here, change the #if
-        1 to #if 0 and get rid of <scsi/sg.h> in
-        vg_unsafe.h. */
-#       if 1
-   case SG_SET_COMMAND_Q:
+   case VKI_SG_SET_COMMAND_Q:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SG_SET_COMMAND_Q)", 
                     arg3, sizeof(int) );
       break;
-#           if defined(SG_IO)
-   case SG_IO:
+   case VKI_SG_IO:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SG_IO)", arg3, 
-                    sizeof(struct sg_io_hdr) );
+                    sizeof(vki_sg_io_hdr_t) );
       break;
-#           endif /* SG_IO */
-   case SG_GET_SCSI_ID:
-      /* Note: sometimes sg_scsi_id is called sg_scsi_id_t */
+   case VKI_SG_GET_SCSI_ID:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SG_GET_SCSI_ID)", arg3, 
-                    sizeof(struct sg_scsi_id) );
+                    sizeof(vki_sg_scsi_id_t) );
       break;
-   case SG_SET_RESERVED_SIZE:
+   case VKI_SG_SET_RESERVED_SIZE:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SG_SET_RESERVED_SIZE)", 
                     arg3, sizeof(int) );
       break;
-   case SG_SET_TIMEOUT:
+   case VKI_SG_SET_TIMEOUT:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SG_SET_TIMEOUT)", arg3, 
                     sizeof(int) );
       break;
-   case SG_GET_RESERVED_SIZE:
+   case VKI_SG_GET_RESERVED_SIZE:
       SYSCALL_TRACK( pre_mem_write, tid, 
                     "ioctl(SG_GET_RESERVED_SIZE)", arg3, 
                     sizeof(int) );
       break;
-   case SG_GET_TIMEOUT:
+   case VKI_SG_GET_TIMEOUT:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SG_GET_TIMEOUT)", arg3, 
                     sizeof(int) );
       break;
-   case SG_GET_VERSION_NUM:
+   case VKI_SG_GET_VERSION_NUM:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SG_GET_VERSION_NUM)", 
                     arg3, sizeof(int) );
       break;
-   case SG_EMULATED_HOST: /* 0x2203 */
+   case VKI_SG_EMULATED_HOST: /* 0x2203 */
       SYSCALL_TRACK( pre_mem_write, tid,  "ioctl(SG_EMULATED_HOST)",
                     arg3, sizeof(int) );
       break;
-   case SG_GET_SG_TABLESIZE: /* 0x227f */
+   case VKI_SG_GET_SG_TABLESIZE: /* 0x227f */
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SG_GET_SG_TABLESIZE)",
                     arg3, sizeof(int) );
       break;
-#       endif
 
    case VKI_IIOCGETCPS:
       /* In early 2.4 kernels, ISDN_MAX_CHANNELS was only defined
@@ -3031,107 +2999,105 @@ PRE(ioctl)
       break;
    case VKI_IIOCNETGPN:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(IIOCNETGPN)",
-                    (Addr)&((isdn_net_ioctl_phone *)arg3)->name,
-                    sizeof(((isdn_net_ioctl_phone *)arg3)->name) );
+                    (Addr)&((vki_isdn_net_ioctl_phone *)arg3)->name,
+                    sizeof(((vki_isdn_net_ioctl_phone *)arg3)->name) );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(IIOCNETGPN)", arg3,
-                    sizeof(isdn_net_ioctl_phone) );
+                    sizeof(vki_isdn_net_ioctl_phone) );
       break;
 
       /* These all use struct ifreq AFAIK */
-   case SIOCGIFINDEX:        /* get iface index              */
+   case VKI_SIOCGIFINDEX:        /* get iface index              */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFINDEX)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFINDEX)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFFLAGS:        /* get flags                    */
+   case VKI_SIOCGIFFLAGS:        /* get flags                    */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFFLAGS)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFFLAGS)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFHWADDR:       /* Get hardware address         */
+   case VKI_SIOCGIFHWADDR:       /* Get hardware address         */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFHWADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFHWADDR)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFMTU:          /* get MTU size                 */
+   case VKI_SIOCGIFMTU:          /* get MTU size                 */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFMTU)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFMTU)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFADDR:         /* get PA address               */
+   case VKI_SIOCGIFADDR:         /* get PA address               */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFADDR)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFNETMASK:      /* get network PA mask          */
+   case VKI_SIOCGIFNETMASK:      /* get network PA mask          */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFNETMASK)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFNETMASK)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFMETRIC:       /* get metric                   */
+   case VKI_SIOCGIFMETRIC:       /* get metric                   */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFMETRIC)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFMETRIC)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFMAP:          /* Get device parameters        */
+   case VKI_SIOCGIFMAP:          /* Get device parameters        */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFMAP)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFMAP)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFTXQLEN:       /* Get the tx queue length      */
+   case VKI_SIOCGIFTXQLEN:       /* Get the tx queue length      */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFTXQLEN)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFTXQLEN)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFDSTADDR:      /* get remote PA address        */
+   case VKI_SIOCGIFDSTADDR:      /* get remote PA address        */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFDSTADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFDSTADDR)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFBRDADDR:      /* get broadcast PA address     */
+   case VKI_SIOCGIFBRDADDR:      /* get broadcast PA address     */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFBRDADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFBRDADDR)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGIFNAME:         /* get iface name               */
+   case VKI_SIOCGIFNAME:         /* get iface name               */
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCGIFNAME)",
-                     (Addr)((struct ifreq *)arg3)->ifr_ifindex,
-                     sizeof(((struct ifreq *)arg3)->ifr_ifindex) );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_ifindex,
+                     sizeof(((struct vki_ifreq *)arg3)->vki_ifr_ifindex) );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFNAME)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-#ifdef HAVE_LINUX_MII_H
-   case SIOCGMIIPHY:         /* get hardware entry           */
+   case VKI_SIOCGMIIPHY:         /* get hardware entry           */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFMIIPHY)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFMIIPHY)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-   case SIOCGMIIREG:         /* get hardware entry registers */
+   case VKI_SIOCGMIIREG:         /* get hardware entry registers */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCGIFMIIREG)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCGIFMIIREG)",
-                     (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id,
-                     sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id) );
+                     (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id,
+                     sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id) );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCGIFMIIREG)",
-                     (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->reg_num,
-                     sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->reg_num) );
+                     (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->reg_num,
+                     sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->reg_num) );
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGIFMIIREG)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
-#endif
-   case SIOCGIFCONF:         /* get iface list               */
+   case VKI_SIOCGIFCONF:         /* get iface list               */
       /* WAS:
         SYSCALL_TRACK( pre_mem_write,"ioctl(SIOCGIFCONF)", arg3, 
         sizeof(struct ifconf));
@@ -3140,172 +3106,170 @@ PRE(ioctl)
         VG_TRACK( post_mem_write,arg3, sizeof(struct ifconf));
       */
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(SIOCGIFCONF)", arg3, 
-                    sizeof(struct ifconf));
+                    sizeof(struct vki_ifconf));
       if ( arg3 ) {
         // TODO len must be readable and writable
         // buf pointer only needs to be readable
-        struct ifconf *ifc = (struct ifconf *) arg3;
+        struct vki_ifconf *ifc = (struct vki_ifconf *) arg3;
         SYSCALL_TRACK( pre_mem_write,tid, "ioctl(SIOCGIFCONF).ifc_buf",
-                       (Addr)(ifc->ifc_buf), (UInt)(ifc->ifc_len) );
+                       (Addr)(ifc->vki_ifc_buf), (UInt)(ifc->ifc_len) );
       }
       break;
-   case SIOCGSTAMP:
+   case VKI_SIOCGSTAMP:
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(SIOCGSTAMP)", arg3, 
-                    sizeof(struct timeval));
+                    sizeof(struct vki_timeval));
       break;
       /* SIOCOUTQ is an ioctl that, when called on a socket, returns
         the number of bytes currently in that socket's send buffer.
         It writes this value as an int to the memory location
         indicated by the third argument of ioctl(2). */
-   case SIOCOUTQ:
+   case VKI_SIOCOUTQ:
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(SIOCOUTQ)", arg3, 
                     sizeof(int));
       break;
-   case SIOCGRARP:           /* get RARP table entry         */
-   case SIOCGARP:            /* get ARP table entry          */
+   case VKI_SIOCGRARP:           /* get RARP table entry         */
+   case VKI_SIOCGARP:            /* get ARP table entry          */
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(SIOCGARP)", arg3, 
-                    sizeof(struct arpreq));
+                    sizeof(struct vki_arpreq));
       break;
                     
-   case SIOCSIFFLAGS:        /* set flags                    */
+   case VKI_SIOCSIFFLAGS:        /* set flags                    */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFFLAGS)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFFLAGS)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_flags,
-                     sizeof(((struct ifreq *)arg3)->ifr_flags) );
+                     (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_flags,
+                     sizeof(((struct vki_ifreq *)arg3)->vki_ifr_flags) );
       break;
-   case SIOCSIFMAP:          /* Set device parameters        */
+   case VKI_SIOCSIFMAP:          /* Set device parameters        */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFMAP)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFMAP)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_map,
-                     sizeof(((struct ifreq *)arg3)->ifr_map) );
+                     (Addr)&((struct vki_ifreq *)arg3)->ifr_map,
+                     sizeof(((struct vki_ifreq *)arg3)->ifr_map) );
       break;
-   case SIOCSIFTXQLEN:       /* Set the tx queue length      */
+   case VKI_SIOCSIFTXQLEN:       /* Set the tx queue length      */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFTXQLEN)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFTXQLEN)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_qlen,
-                     sizeof(((struct ifreq *)arg3)->ifr_qlen) );
+                     (Addr)&((struct vki_ifreq *)arg3)->ifr_qlen,
+                     sizeof(((struct vki_ifreq *)arg3)->ifr_qlen) );
       break;
-   case SIOCSIFADDR:         /* set PA address               */
-   case SIOCSIFDSTADDR:      /* set remote PA address        */
-   case SIOCSIFBRDADDR:      /* set broadcast PA address     */
-   case SIOCSIFNETMASK:      /* set network PA mask          */
+   case VKI_SIOCSIFADDR:         /* set PA address               */
+   case VKI_SIOCSIFDSTADDR:      /* set remote PA address        */
+   case VKI_SIOCSIFBRDADDR:      /* set broadcast PA address     */
+   case VKI_SIOCSIFNETMASK:      /* set network PA mask          */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIF*ADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIF*ADDR)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_addr,
-                     sizeof(((struct ifreq *)arg3)->ifr_addr) );
+                     (Addr)&((struct vki_ifreq *)arg3)->ifr_addr,
+                     sizeof(((struct vki_ifreq *)arg3)->ifr_addr) );
       break;
-   case SIOCSIFMETRIC:       /* set metric                   */
+   case VKI_SIOCSIFMETRIC:       /* set metric                   */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFMETRIC)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFMETRIC)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_metric,
-                     sizeof(((struct ifreq *)arg3)->ifr_metric) );
+                     (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_metric,
+                     sizeof(((struct vki_ifreq *)arg3)->vki_ifr_metric) );
       break;
-   case SIOCSIFMTU:          /* set MTU size                 */
+   case VKI_SIOCSIFMTU:          /* set MTU size                 */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFMTU)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFMTU)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_mtu,
-                     sizeof(((struct ifreq *)arg3)->ifr_mtu) );
+                     (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_mtu,
+                     sizeof(((struct vki_ifreq *)arg3)->vki_ifr_mtu) );
       break;
-   case SIOCSIFHWADDR:       /* set hardware address         */
+   case VKI_SIOCSIFHWADDR:       /* set hardware address         */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSIFHWADDR)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSIFHWADDR)",
-                     (Addr)&((struct ifreq *)arg3)->ifr_hwaddr,
-                     sizeof(((struct ifreq *)arg3)->ifr_hwaddr) );
+                     (Addr)&((struct vki_ifreq *)arg3)->ifr_hwaddr,
+                     sizeof(((struct vki_ifreq *)arg3)->ifr_hwaddr) );
       break;
-#ifdef HAVE_LINUX_MII_H
-   case SIOCSMIIREG:         /* set hardware entry registers */
+   case VKI_SIOCSMIIREG:         /* set hardware entry registers */
       SYSCALL_TRACK( pre_mem_read_asciiz, tid, "ioctl(SIOCSMIIREG)",
-                     (Addr)((struct ifreq *)arg3)->ifr_name );
+                     (Addr)((struct vki_ifreq *)arg3)->vki_ifr_name );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSMIIREG)",
-                     (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id,
-                     sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id) );
+                     (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id,
+                     sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id) );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSMIIREG)",
-                     (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->reg_num,
-                     sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->reg_num) );
+                     (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->reg_num,
+                     sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->reg_num) );
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSMIIREG)",
-                     (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->val_in,
-                     sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->val_in) );
+                     (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->val_in,
+                     sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->val_in) );
       break;
-#endif
       /* Routing table calls.  */
-   case SIOCADDRT:           /* add routing table entry      */
-   case SIOCDELRT:           /* delete routing table entry   */
+   case VKI_SIOCADDRT:           /* add routing table entry      */
+   case VKI_SIOCDELRT:           /* delete routing table entry   */
       SYSCALL_TRACK( pre_mem_read,tid,"ioctl(SIOCADDRT/DELRT)", arg3, 
-                    sizeof(struct rtentry));
+                    sizeof(struct vki_rtentry));
       break;
 
       /* RARP cache control calls. */
-   case SIOCDRARP:           /* delete RARP table entry      */
-   case SIOCSRARP:           /* set RARP table entry         */
+   case VKI_SIOCDRARP:           /* delete RARP table entry      */
+   case VKI_SIOCSRARP:           /* set RARP table entry         */
       /* ARP cache control calls. */
-   case SIOCSARP:            /* set ARP table entry          */
-   case SIOCDARP:            /* delete ARP table entry       */
+   case VKI_SIOCSARP:            /* set ARP table entry          */
+   case VKI_SIOCDARP:            /* delete ARP table entry       */
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(SIOCSIFFLAGS)", arg3, 
-                    sizeof(struct ifreq));
+                    sizeof(struct vki_ifreq));
       break;
 
-   case SIOCGPGRP:
+   case VKI_SIOCGPGRP:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(SIOCGPGRP)", arg3, 
                     sizeof(int) );
       break;
-   case SIOCSPGRP:
+   case VKI_SIOCSPGRP:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(SIOCSPGRP)", arg3, 
                     sizeof(int) );
       tst->sys_flags &= ~MayBlock;
       break;
 
       /* linux/soundcard interface (OSS) */
-   case SNDCTL_SEQ_GETOUTCOUNT:
-   case SNDCTL_SEQ_GETINCOUNT:
-   case SNDCTL_SEQ_PERCMODE:
-   case SNDCTL_SEQ_TESTMIDI:
-   case SNDCTL_SEQ_RESETSAMPLES:
-   case SNDCTL_SEQ_NRSYNTHS:
-   case SNDCTL_SEQ_NRMIDIS:
-   case SNDCTL_SEQ_GETTIME:
-   case SNDCTL_DSP_GETFMTS:
-   case SNDCTL_DSP_GETTRIGGER:
-   case SNDCTL_DSP_GETODELAY:
+   case VKI_SNDCTL_SEQ_GETOUTCOUNT:
+   case VKI_SNDCTL_SEQ_GETINCOUNT:
+   case VKI_SNDCTL_SEQ_PERCMODE:
+   case VKI_SNDCTL_SEQ_TESTMIDI:
+   case VKI_SNDCTL_SEQ_RESETSAMPLES:
+   case VKI_SNDCTL_SEQ_NRSYNTHS:
+   case VKI_SNDCTL_SEQ_NRMIDIS:
+   case VKI_SNDCTL_SEQ_GETTIME:
+   case VKI_SNDCTL_DSP_GETFMTS:
+   case VKI_SNDCTL_DSP_GETTRIGGER:
+   case VKI_SNDCTL_DSP_GETODELAY:
 #           if defined(SNDCTL_DSP_GETSPDIF)
-   case SNDCTL_DSP_GETSPDIF:
+   case VKI_SNDCTL_DSP_GETSPDIF:
 #           endif
-   case SNDCTL_DSP_GETCAPS:
-   case SOUND_PCM_READ_RATE:
-   case SOUND_PCM_READ_CHANNELS:
-   case SOUND_PCM_READ_BITS:
-   case (SOUND_PCM_READ_BITS|0x40000000): /* what the fuck ? */
-   case SOUND_PCM_READ_FILTER:
+   case VKI_SNDCTL_DSP_GETCAPS:
+   case VKI_SOUND_PCM_READ_RATE:
+   case VKI_SOUND_PCM_READ_CHANNELS:
+   case VKI_SOUND_PCM_READ_BITS:
+   case (VKI_SOUND_PCM_READ_BITS|0x40000000): /* what the fuck ? */
+   case VKI_SOUND_PCM_READ_FILTER:
       SYSCALL_TRACK( pre_mem_write,tid,
                     "ioctl(SNDCTL_XXX|SOUND_XXX (SIOR, int))", 
                     arg3,
                     sizeof(int));
       break;
-   case SNDCTL_SEQ_CTRLRATE:
-   case SNDCTL_DSP_SPEED:
-   case SNDCTL_DSP_STEREO:
-   case SNDCTL_DSP_GETBLKSIZE: 
-   case SNDCTL_DSP_CHANNELS:
-   case SOUND_PCM_WRITE_FILTER:
-   case SNDCTL_DSP_SUBDIVIDE:
-   case SNDCTL_DSP_SETFRAGMENT:
+   case VKI_SNDCTL_SEQ_CTRLRATE:
+   case VKI_SNDCTL_DSP_SPEED:
+   case VKI_SNDCTL_DSP_STEREO:
+   case VKI_SNDCTL_DSP_GETBLKSIZE: 
+   case VKI_SNDCTL_DSP_CHANNELS:
+   case VKI_SOUND_PCM_WRITE_FILTER:
+   case VKI_SNDCTL_DSP_SUBDIVIDE:
+   case VKI_SNDCTL_DSP_SETFRAGMENT:
 #           if defined(SNDCTL_DSP_GETCHANNELMASK)
-   case SNDCTL_DSP_GETCHANNELMASK:
+   case VKI_SNDCTL_DSP_GETCHANNELMASK:
 #           endif
 #           if defined(SNDCTL_DSP_BIND_CHANNEL)
-   case SNDCTL_DSP_BIND_CHANNEL:
+   case VKI_SNDCTL_DSP_BIND_CHANNEL:
 #           endif
-   case SNDCTL_TMR_TIMEBASE:
-   case SNDCTL_TMR_TEMPO:
-   case SNDCTL_TMR_SOURCE:
-   case SNDCTL_MIDI_PRETIME:
-   case SNDCTL_MIDI_MPUMODE:
+   case VKI_SNDCTL_TMR_TIMEBASE:
+   case VKI_SNDCTL_TMR_TEMPO:
+   case VKI_SNDCTL_TMR_SOURCE:
+   case VKI_SNDCTL_MIDI_PRETIME:
+   case VKI_SNDCTL_MIDI_MPUMODE:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(SNDCTL_XXX|SOUND_XXX "
                     "(SIOWR, int))", 
                     arg3, sizeof(int));
@@ -3313,50 +3277,48 @@ PRE(ioctl)
                     "(SIOWR, int))", 
                     arg3, sizeof(int));
       break;
-   case SNDCTL_DSP_GETOSPACE:
-   case SNDCTL_DSP_GETISPACE:
+   case VKI_SNDCTL_DSP_GETOSPACE:
+   case VKI_SNDCTL_DSP_GETISPACE:
       SYSCALL_TRACK( pre_mem_write,tid, 
                     "ioctl(SNDCTL_XXX|SOUND_XXX "
                     "(SIOR, audio_buf_info))", arg3,
-                    sizeof(audio_buf_info));
+                    sizeof(vki_audio_buf_info));
       break;
-   case SNDCTL_DSP_SETTRIGGER:
+   case VKI_SNDCTL_DSP_SETTRIGGER:
       SYSCALL_TRACK( pre_mem_read,tid, 
                     "ioctl(SNDCTL_XXX|SOUND_XXX (SIOW, int))", 
                     arg3, sizeof(int));
       break;
 
-   case SNDCTL_DSP_POST:
-   case SNDCTL_DSP_RESET:
-   case SNDCTL_DSP_SYNC:
-   case SNDCTL_DSP_SETSYNCRO:
-   case SNDCTL_DSP_SETDUPLEX:
+   case VKI_SNDCTL_DSP_POST:
+   case VKI_SNDCTL_DSP_RESET:
+   case VKI_SNDCTL_DSP_SYNC:
+   case VKI_SNDCTL_DSP_SETSYNCRO:
+   case VKI_SNDCTL_DSP_SETDUPLEX:
       break;
 
       /* Real Time Clock (/dev/rtc) ioctls */
-#           ifndef GLIBC_2_1
-   case RTC_UIE_ON:
-   case RTC_UIE_OFF:
-   case RTC_AIE_ON:
-   case RTC_AIE_OFF:
-   case RTC_PIE_ON:
-   case RTC_PIE_OFF:
-   case RTC_IRQP_SET:
-      break;
-   case RTC_RD_TIME:
-   case RTC_ALM_READ:
+   case VKI_RTC_UIE_ON:
+   case VKI_RTC_UIE_OFF:
+   case VKI_RTC_AIE_ON:
+   case VKI_RTC_AIE_OFF:
+   case VKI_RTC_PIE_ON:
+   case VKI_RTC_PIE_OFF:
+   case VKI_RTC_IRQP_SET:
+      break;
+   case VKI_RTC_RD_TIME:
+   case VKI_RTC_ALM_READ:
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(RTC_RD_TIME/ALM_READ)", 
-                    arg3, sizeof(struct rtc_time));
+                    arg3, sizeof(struct vki_rtc_time));
       break;
-   case RTC_ALM_SET:
+   case VKI_RTC_ALM_SET:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(RTC_ALM_SET)", arg3,
-                    sizeof(struct rtc_time));
+                    sizeof(struct vki_rtc_time));
       break;
-   case RTC_IRQP_READ:
+   case VKI_RTC_IRQP_READ:
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(RTC_IRQP_READ)", arg3,
                     sizeof(unsigned long));
       break;
-#           endif /* GLIBC_2_1 */
 
 #           ifdef BLKGETSIZE
    case BLKGETSIZE:
@@ -3366,192 +3328,180 @@ PRE(ioctl)
 #           endif /* BLKGETSIZE */
 
       /* Hard disks */
-   case HDIO_GET_IDENTITY: /* 0x030d */
+   case VKI_HDIO_GET_IDENTITY: /* 0x030d */
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(HDIO_GET_IDENTITY)", arg3,
-                     sizeof(struct hd_driveid) );
+                     VKI_SIZEOF_STRUCT_HD_DRIVEID );
       break;
 
       /* CD ROM stuff (??)  */
-   case CDROM_GET_MCN:
+   case VKI_CDROM_GET_MCN:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(CDROM_GET_MCN)", arg3,
-                    sizeof(struct cdrom_mcn) );
+                    sizeof(struct vki_cdrom_mcn) );
       break;
-   case CDROM_SEND_PACKET:
+   case VKI_CDROM_SEND_PACKET:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(CDROM_SEND_PACKET)", arg3,
-                    sizeof(struct cdrom_generic_command));
+                    sizeof(struct vki_cdrom_generic_command));
       break;
-   case CDROMSUBCHNL:
+   case VKI_CDROMSUBCHNL:
       SYSCALL_TRACK( pre_mem_read,tid, 
                     "ioctl(CDROMSUBCHNL (cdsc_format, char))",
-                    (int) &(((struct cdrom_subchnl *) arg3)->cdsc_format), 
-                    sizeof(((struct cdrom_subchnl *) arg3)->cdsc_format));
+                    (int) &(((struct vki_cdrom_subchnl *) arg3)->cdsc_format), 
+                    sizeof(((struct vki_cdrom_subchnl *) arg3)->cdsc_format));
       SYSCALL_TRACK( pre_mem_write,tid, 
                     "ioctl(CDROMSUBCHNL)", arg3, 
-                    sizeof(struct cdrom_subchnl));
+                    sizeof(struct vki_cdrom_subchnl));
       break;
-   case CDROMREADMODE2:
+   case VKI_CDROMREADMODE2:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(CDROMREADMODE2)", arg3,
-                     CD_FRAMESIZE_RAW0 );
+                     VKI_CD_FRAMESIZE_RAW0 );
       break;
-   case CDROMREADTOCHDR:
+   case VKI_CDROMREADTOCHDR:
       SYSCALL_TRACK( pre_mem_write,tid, 
                     "ioctl(CDROMREADTOCHDR)", arg3, 
-                    sizeof(struct cdrom_tochdr));
+                    sizeof(struct vki_cdrom_tochdr));
       break;
-   case CDROMREADTOCENTRY:
+   case VKI_CDROMREADTOCENTRY:
       SYSCALL_TRACK( pre_mem_read,tid, 
                     "ioctl(CDROMREADTOCENTRY (cdte_format, char))",
-                    (int) &(((struct cdrom_tocentry *) arg3)->cdte_format), 
-                    sizeof(((struct cdrom_tocentry *) arg3)->cdte_format));
+                    (int) &(((struct vki_cdrom_tocentry *) arg3)->cdte_format), 
+                    sizeof(((struct vki_cdrom_tocentry *) arg3)->cdte_format));
       SYSCALL_TRACK( pre_mem_read,tid, 
                     "ioctl(CDROMREADTOCENTRY (cdte_track, char))",
-                    (int) &(((struct cdrom_tocentry *) arg3)->cdte_track), 
-                    sizeof(((struct cdrom_tocentry *) arg3)->cdte_track));
+                    (int) &(((struct vki_cdrom_tocentry *) arg3)->cdte_track), 
+                    sizeof(((struct vki_cdrom_tocentry *) arg3)->cdte_track));
       SYSCALL_TRACK( pre_mem_write,tid, 
                     "ioctl(CDROMREADTOCENTRY)", arg3, 
-                    sizeof(struct cdrom_tocentry));
+                    sizeof(struct vki_cdrom_tocentry));
       break;
-   case CDROMMULTISESSION: /* 0x5310 */
+   case VKI_CDROMMULTISESSION: /* 0x5310 */
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(CDROMMULTISESSION)", arg3,
-                    sizeof(struct cdrom_multisession));
+                    sizeof(struct vki_cdrom_multisession));
       break;
-   case CDROMVOLREAD: /* 0x5313 */
+   case VKI_CDROMVOLREAD: /* 0x5313 */
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(CDROMVOLREAD)", arg3,
-                    sizeof(struct cdrom_volctrl));
+                    sizeof(struct vki_cdrom_volctrl));
       break;
-   case CDROMREADAUDIO: /* 0x530e */
+   case VKI_CDROMREADAUDIO: /* 0x530e */
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(CDROMREADAUDIO)", arg3,
-                    sizeof (struct cdrom_read_audio));
+                    sizeof (struct vki_cdrom_read_audio));
       if ( arg3 ) {
          /* ToDo: don't do any of the following if the structure is invalid */
-         struct cdrom_read_audio *cra = (struct cdrom_read_audio *) arg3;
+         struct vki_cdrom_read_audio *cra = (struct vki_cdrom_read_audio *) arg3;
         SYSCALL_TRACK( pre_mem_write, tid, "ioctl(CDROMREADAUDIO).buf",
                        (Addr)(cra->buf),
-                        (UInt)(cra->nframes * CD_FRAMESIZE_RAW));
+                        (UInt)(cra->nframes * VKI_CD_FRAMESIZE_RAW));
       }
       break;      
-   case CDROMPLAYMSF:
+   case VKI_CDROMPLAYMSF:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(CDROMPLAYMSF)", arg3, 
-                    sizeof(struct cdrom_msf));
+                    sizeof(struct vki_cdrom_msf));
       break;
       /* The following two are probably bogus (should check args
         for readability).  JRS 20021117 */
-   case CDROM_DRIVE_STATUS: /* 0x5326 */
-   case CDROM_CLEAR_OPTIONS: /* 0x5321 */
+   case VKI_CDROM_DRIVE_STATUS: /* 0x5326 */
+   case VKI_CDROM_CLEAR_OPTIONS: /* 0x5321 */
       break;
 
-   case FIGETBSZ:
+   case VKI_FIGETBSZ:
       SYSCALL_TRACK( pre_mem_write,tid, "ioctl(FIGETBSZ)", arg3,
                      sizeof(unsigned long));
       break;
-   case FIBMAP:
+   case VKI_FIBMAP:
       SYSCALL_TRACK( pre_mem_read,tid, "ioctl(FIBMAP)", arg3,
                      sizeof(unsigned long));
       break;
 
-#ifdef HAVE_LINUX_FB_H
-   case FBIOGET_VSCREENINFO: /* 0x4600 */
+   case VKI_FBIOGET_VSCREENINFO: /* 0x4600 */
       SYSCALL_TRACK( pre_mem_write,tid,
                      "ioctl(FBIOGET_VSCREENINFO)", arg3,
-                     sizeof(struct fb_var_screeninfo));
+                     sizeof(struct vki_fb_var_screeninfo));
       break;
-   case FBIOGET_FSCREENINFO: /* 0x4602 */
+   case VKI_FBIOGET_FSCREENINFO: /* 0x4602 */
       SYSCALL_TRACK( pre_mem_write,tid,
                      "ioctl(FBIOGET_FSCREENINFO)", arg3,
-                     sizeof(struct fb_fix_screeninfo));
+                     sizeof(struct vki_fb_fix_screeninfo));
       break;
-#endif
 
-   case PPCLAIM:
-   case PPEXCL:
-   case PPYIELD:
-   case PPRELEASE:
+   case VKI_PPCLAIM:
+   case VKI_PPEXCL:
+   case VKI_PPYIELD:
+   case VKI_PPRELEASE:
       break;
-   case PPSETMODE:
+   case VKI_PPSETMODE:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPSETMODE)", arg3,
                      sizeof(int) );
       break;
-#ifdef PPGETMODE
-   case PPGETMODE:
+   case VKI_PPGETMODE:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPGETMODE)", arg3,
                      sizeof(int) );
       break;
-#endif
-   case PPSETPHASE:
+   case VKI_PPSETPHASE:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPSETPHASE)", arg3,
                      sizeof(int) );
       break;
-#ifdef PPGETPHASE
-   case PPGETPHASE:
+   case VKI_PPGETPHASE:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPGETPHASE)", arg3,
                      sizeof(int) );
       break;
-#endif
-#ifdef PPGETMODES
-   case PPGETMODES:
+   case VKI_PPGETMODES:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPGETMODES)", arg3,
                      sizeof(unsigned int) );
       break;
-#endif
-#ifdef PPSETFLAGS
-   case PPSETFLAGS:
+   case VKI_PPSETFLAGS:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPSETFLAGS)", arg3,
                      sizeof(int) );
       break;
-#endif
-#ifdef PPGETFLAGS
-   case PPGETFLAGS:
+   case VKI_PPGETFLAGS:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPGETFLAGS)", arg3,
                      sizeof(int) );
       break;
-#endif
-   case PPRSTATUS:
+   case VKI_PPRSTATUS:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPRSTATUS)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPRDATA:
+   case VKI_PPRDATA:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPRDATA)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPRCONTROL:
+   case VKI_PPRCONTROL:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPRCONTROL)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPWDATA:
+   case VKI_PPWDATA:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPWDATA)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPWCONTROL:
+   case VKI_PPWCONTROL:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPWCONTROL)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPFCONTROL:
+   case VKI_PPFCONTROL:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPFCONTROL)", arg3,
                      2 * sizeof(unsigned char) );
       break;
-   case PPDATADIR:
+   case VKI_PPDATADIR:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPDATADIR)", arg3,
                      sizeof(int) );
       break;
-   case PPNEGOT:
+   case VKI_PPNEGOT:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPNEGOT)", arg3,
                      sizeof(int) );
       break;
-   case PPWCTLONIRQ:
+   case VKI_PPWCTLONIRQ:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPWCTLONIRQ)", arg3,
                      sizeof(unsigned char) );
       break;
-   case PPCLRIRQ:
+   case VKI_PPCLRIRQ:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPCLRIRQ)", arg3,
                      sizeof(int) );
       break;
-   case PPSETTIME:
+   case VKI_PPSETTIME:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(PPSETTIME)", arg3,
-                     sizeof(struct timeval) );
+                     sizeof(struct vki_timeval) );
       break;
-   case PPGETTIME:
+   case VKI_PPGETTIME:
       SYSCALL_TRACK( pre_mem_write, tid, "ioctl(PPGETTIME)", arg3,
-                     sizeof(struct timeval) );
+                     sizeof(struct vki_timeval) );
       break;
 
       /* We don't have any specific information on it, so
@@ -3563,8 +3513,8 @@ PRE(ioctl)
         writes a value to the ioctl value passed from the user
         space and the other way around with _IOC_WRITE. */
    default: {
-      UInt dir  = _IOC_DIR(arg2);
-      UInt size = _IOC_SIZE(arg2);
+      UInt dir  = _VKI_IOC_DIR(arg2);
+      UInt size = _VKI_IOC_SIZE(arg2);
       if (VG_(strstr)(VG_(clo_weird_hacks), "lax-ioctls") != NULL) {
         /* 
          * Be very lax about ioctl handling; the only
@@ -3574,7 +3524,7 @@ PRE(ioctl)
          * drivers with a large number of strange ioctl
          * commands becomes very tiresome.
          */
-      } else if (/* size == 0 || */ dir == _IOC_NONE) {
+      } else if (/* size == 0 || */ dir == _VKI_IOC_NONE) {
         static Int moans = 3;
         if (moans > 0) {
            moans--;
@@ -3590,10 +3540,10 @@ PRE(ioctl)
                         "guidance on writing a proper wrapper." );
         }
       } else {
-        if ((dir & _IOC_WRITE) && size > 0)
+        if ((dir & _VKI_IOC_WRITE) && size > 0)
            SYSCALL_TRACK( pre_mem_read,tid, "ioctl(generic)", 
                           arg3, size);
-        if ((dir & _IOC_READ) && size > 0)
+        if ((dir & _VKI_IOC_READ) && size > 0)
            SYSCALL_TRACK( pre_mem_write,tid, "ioctl(generic)", 
                           arg3, size);
       }
@@ -3616,92 +3566,85 @@ POST(ioctl)
    */
    MAYBE_PRINTF("ioctl ( %d, 0x%x, %p )\n",arg1,arg2,arg3);
    switch (arg2 /* request */) {
-   case TCSETS:
-   case TCSETSW:
-   case TCSETSF:
+   case VKI_TCSETS:
+   case VKI_TCSETSW:
+   case VKI_TCSETSF:
       break; 
-   case TCGETS:
+   case VKI_TCGETS:
       VG_TRACK( post_mem_write, arg3, VKI_SIZEOF_STRUCT_TERMIOS );
       break;
-   case TCSETA:
-   case TCSETAW:
-   case TCSETAF:
+   case VKI_TCSETA:
+   case VKI_TCSETAW:
+   case VKI_TCSETAF:
       break;
-   case TCGETA:
-      VG_TRACK( post_mem_write, arg3, VKI_SIZEOF_STRUCT_TERMIO );
+   case VKI_TCGETA:
+      VG_TRACK( post_mem_write, arg3, sizeof(struct vki_termio) );
       break;
-   case TCSBRK:
-   case TCXONC:
-   case TCSBRKP:
-   case TCFLSH:
+   case VKI_TCSBRK:
+   case VKI_TCXONC:
+   case VKI_TCSBRKP:
+   case VKI_TCFLSH:
       break;
-   case TIOCGWINSZ:
-      VG_TRACK( post_mem_write, arg3, sizeof(struct winsize) );
+   case VKI_TIOCGWINSZ:
+      VG_TRACK( post_mem_write, arg3, sizeof(struct vki_winsize) );
       break;
-   case TIOCSWINSZ:
-   case TIOCMBIS:
-   case TIOCMBIC:
-   case TIOCMSET:
+   case VKI_TIOCSWINSZ:
+   case VKI_TIOCMBIS:
+   case VKI_TIOCMBIC:
+   case VKI_TIOCMSET:
       break;
-   case TIOCLINUX:
+   case VKI_TIOCLINUX:
       VG_TRACK( post_mem_write, arg3, sizeof(char *) );
       break;
-   case TIOCGPGRP:
+   case VKI_TIOCGPGRP:
       /* Get process group ID for foreground processing group. */
-      VG_TRACK( post_mem_write, arg3, sizeof(pid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_pid_t) );
       break;
-   case TIOCSPGRP:
+   case VKI_TIOCSPGRP:
       /* Set a process group ID? */
-      VG_TRACK( post_mem_write, arg3, sizeof(pid_t) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_pid_t) );
       break;
-   case TIOCGPTN: /* Get Pty Number (of pty-mux device) */
+   case VKI_TIOCGPTN: /* Get Pty Number (of pty-mux device) */
       VG_TRACK( post_mem_write, arg3, sizeof(int));
       break;
-   case TIOCSCTTY:
+   case VKI_TIOCSCTTY:
       break;
-   case TIOCSPTLCK: /* Lock/unlock Pty */
+   case VKI_TIOCSPTLCK: /* Lock/unlock Pty */
       break;
-   case FIONBIO:
+   case VKI_FIONBIO:
       break;
-   case FIOASYNC:
+   case VKI_FIOASYNC:
       break;
-   case FIONREAD:                /* identical to SIOCINQ */
+   case VKI_FIONREAD:                /* identical to SIOCINQ */
       VG_TRACK( post_mem_write, arg3, sizeof(int) );
       break;
 
-      /* If you get compilation problems here, change the #if
-        1 to #if 0 and get rid of <scsi/sg.h> in
-        vg_unsafe.h. */
-#       if 1
-   case SG_SET_COMMAND_Q:
+   case VKI_SG_SET_COMMAND_Q:
       break;
-#           if defined(SG_IO)
-   case SG_IO:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct sg_io_hdr));
+   case VKI_SG_IO:
+      VG_TRACK( post_mem_write,arg3, sizeof(vki_sg_io_hdr_t));
       break;
-#           endif /* SG_IO */
-   case SG_GET_SCSI_ID:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct sg_scsi_id));
+   case VKI_SG_GET_SCSI_ID:
+      VG_TRACK( post_mem_write,arg3, sizeof(vki_sg_scsi_id_t));
       break;
-   case SG_SET_RESERVED_SIZE:
+   case VKI_SG_SET_RESERVED_SIZE:
       break;
-   case SG_SET_TIMEOUT:
+   case VKI_SG_SET_TIMEOUT:
       break;
-   case SG_GET_RESERVED_SIZE:
+   case VKI_SG_GET_RESERVED_SIZE:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SG_GET_TIMEOUT:
+   case VKI_SG_GET_TIMEOUT:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SG_GET_VERSION_NUM:
+   case VKI_SG_GET_VERSION_NUM:
       break;
-   case SG_EMULATED_HOST:
+   case VKI_SG_EMULATED_HOST:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SG_GET_SG_TABLESIZE:
+   case VKI_SG_GET_SG_TABLESIZE:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;      
-#       endif
 
    case VKI_IIOCGETCPS:
       /* In early 2.4 kernels, ISDN_MAX_CHANNELS was only defined
@@ -3713,72 +3656,70 @@ POST(ioctl)
                 ISDN_MAX_CHANNELS * 2 * sizeof(unsigned long) );
       break;
    case VKI_IIOCNETGPN:
-      VG_TRACK( post_mem_write, arg3, sizeof(isdn_net_ioctl_phone) );
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_isdn_net_ioctl_phone) );
       break;
 
       /* These all use struct ifreq AFAIK */
-   case SIOCGIFINDEX:        /* get iface index              */
+   case VKI_SIOCGIFINDEX:        /* get iface index              */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_ifindex,
-                sizeof(((struct ifreq *)arg3)->ifr_ifindex) );
+                (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_ifindex,
+                sizeof(((struct vki_ifreq *)arg3)->vki_ifr_ifindex) );
       break;
-   case SIOCGIFFLAGS:        /* get flags                    */
+   case VKI_SIOCGIFFLAGS:        /* get flags                    */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_flags,
-                sizeof(((struct ifreq *)arg3)->ifr_flags) );
+                (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_flags,
+                sizeof(((struct vki_ifreq *)arg3)->vki_ifr_flags) );
       break;
-   case SIOCGIFHWADDR:       /* Get hardware address         */
+   case VKI_SIOCGIFHWADDR:       /* Get hardware address         */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_hwaddr,
-                sizeof(((struct ifreq *)arg3)->ifr_hwaddr) );
+                (Addr)&((struct vki_ifreq *)arg3)->ifr_hwaddr,
+                sizeof(((struct vki_ifreq *)arg3)->ifr_hwaddr) );
       break;
-   case SIOCGIFMTU:          /* get MTU size                 */
+   case VKI_SIOCGIFMTU:          /* get MTU size                 */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_mtu,
-                sizeof(((struct ifreq *)arg3)->ifr_mtu) );
+                (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_mtu,
+                sizeof(((struct vki_ifreq *)arg3)->vki_ifr_mtu) );
       break;
-   case SIOCGIFADDR:         /* get PA address               */
-   case SIOCGIFDSTADDR:      /* get remote PA address        */
-   case SIOCGIFBRDADDR:      /* get broadcast PA address     */
-   case SIOCGIFNETMASK:      /* get network PA mask          */
+   case VKI_SIOCGIFADDR:         /* get PA address               */
+   case VKI_SIOCGIFDSTADDR:      /* get remote PA address        */
+   case VKI_SIOCGIFBRDADDR:      /* get broadcast PA address     */
+   case VKI_SIOCGIFNETMASK:      /* get network PA mask          */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_addr,
-                sizeof(((struct ifreq *)arg3)->ifr_addr) );
+                (Addr)&((struct vki_ifreq *)arg3)->ifr_addr,
+                sizeof(((struct vki_ifreq *)arg3)->ifr_addr) );
       break;
-   case SIOCGIFMETRIC:       /* get metric                   */
+   case VKI_SIOCGIFMETRIC:       /* get metric                   */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_metric,
-                sizeof(((struct ifreq *)arg3)->ifr_metric) );
+                (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_metric,
+                sizeof(((struct vki_ifreq *)arg3)->vki_ifr_metric) );
       break;
-   case SIOCGIFMAP:          /* Get device parameters        */
+   case VKI_SIOCGIFMAP:          /* Get device parameters        */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_map,
-                sizeof(((struct ifreq *)arg3)->ifr_map) );
+                (Addr)&((struct vki_ifreq *)arg3)->ifr_map,
+                sizeof(((struct vki_ifreq *)arg3)->ifr_map) );
       break;
      break;
-   case SIOCGIFTXQLEN:       /* Get the tx queue length      */
+   case VKI_SIOCGIFTXQLEN:       /* Get the tx queue length      */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_qlen,
-                sizeof(((struct ifreq *)arg3)->ifr_qlen) );
+                (Addr)&((struct vki_ifreq *)arg3)->ifr_qlen,
+                sizeof(((struct vki_ifreq *)arg3)->ifr_qlen) );
       break;
-   case SIOCGIFNAME:         /* get iface name               */
+   case VKI_SIOCGIFNAME:         /* get iface name               */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct ifreq *)arg3)->ifr_name,
-                sizeof(((struct ifreq *)arg3)->ifr_name) );
+                (Addr)&((struct vki_ifreq *)arg3)->vki_ifr_name,
+                sizeof(((struct vki_ifreq *)arg3)->vki_ifr_name) );
       break;
-#ifdef HAVE_LINUX_MII_H
-   case SIOCGMIIPHY:         /* get hardware entry           */
+   case VKI_SIOCGMIIPHY:         /* get hardware entry           */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id,
-                sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->phy_id) );
+                (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id,
+                sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->phy_id) );
       break;
-   case SIOCGMIIREG:         /* get hardware entry registers */
+   case VKI_SIOCGMIIREG:         /* get hardware entry registers */
       VG_TRACK( post_mem_write,
-                (Addr)&((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->val_out,
-                sizeof(((struct mii_ioctl_data *)&((struct ifreq *)arg3)->ifr_data)->val_out) );
+                (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->val_out,
+                sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)arg3)->vki_ifr_data)->val_out) );
       break;
-#endif
-   case SIOCGIFCONF:         /* get iface list               */
+   case VKI_SIOCGIFCONF:         /* get iface list               */
       /* WAS:
         SYSCALL_TRACK( pre_mem_write,"ioctl(SIOCGIFCONF)", arg3, 
         sizeof(struct ifconf));
@@ -3787,137 +3728,131 @@ POST(ioctl)
         VG_TRACK( post_mem_write,arg3, sizeof(struct ifconf));
       */
       if (res == 0 && arg3 ) {
-        struct ifconf *ifc = (struct ifconf *) arg3;
-        if (ifc->ifc_buf != NULL)
-           VG_TRACK( post_mem_write, (Addr)(ifc->ifc_buf), 
+        struct vki_ifconf *ifc = (struct vki_ifconf *) arg3;
+        if (ifc->vki_ifc_buf != NULL)
+           VG_TRACK( post_mem_write, (Addr)(ifc->vki_ifc_buf), 
                      (UInt)(ifc->ifc_len) );
       }
       break;
-   case SIOCGSTAMP:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct timeval));
+   case VKI_SIOCGSTAMP:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_timeval));
       break;
       /* SIOCOUTQ is an ioctl that, when called on a socket, returns
         the number of bytes currently in that socket's send buffer.
         It writes this value as an int to the memory location
         indicated by the third argument of ioctl(2). */
-   case SIOCOUTQ:
+   case VKI_SIOCOUTQ:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SIOCGRARP:           /* get RARP table entry         */
-   case SIOCGARP:            /* get ARP table entry          */
-      VG_TRACK( post_mem_write,arg3, sizeof(struct arpreq));
+   case VKI_SIOCGRARP:           /* get RARP table entry         */
+   case VKI_SIOCGARP:            /* get ARP table entry          */
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_arpreq));
       break;
                     
-   case SIOCSIFFLAGS:        /* set flags                    */
-   case SIOCSIFMAP:          /* Set device parameters        */
-   case SIOCSIFTXQLEN:       /* Set the tx queue length      */
-   case SIOCSIFDSTADDR:      /* set remote PA address        */
-   case SIOCSIFBRDADDR:      /* set broadcast PA address     */
-   case SIOCSIFNETMASK:      /* set network PA mask          */
-   case SIOCSIFMETRIC:       /* set metric                   */
-   case SIOCSIFADDR:         /* set PA address               */
-   case SIOCSIFMTU:          /* set MTU size                 */
-   case SIOCSIFHWADDR:       /* set hardware address         */
-#ifdef HAVE_LINUX_MII_H
-   case SIOCSMIIREG:         /* set hardware entry registers */
-#endif
+   case VKI_SIOCSIFFLAGS:        /* set flags                    */
+   case VKI_SIOCSIFMAP:          /* Set device parameters        */
+   case VKI_SIOCSIFTXQLEN:       /* Set the tx queue length      */
+   case VKI_SIOCSIFDSTADDR:      /* set remote PA address        */
+   case VKI_SIOCSIFBRDADDR:      /* set broadcast PA address     */
+   case VKI_SIOCSIFNETMASK:      /* set network PA mask          */
+   case VKI_SIOCSIFMETRIC:       /* set metric                   */
+   case VKI_SIOCSIFADDR:         /* set PA address               */
+   case VKI_SIOCSIFMTU:          /* set MTU size                 */
+   case VKI_SIOCSIFHWADDR:       /* set hardware address         */
+   case VKI_SIOCSMIIREG:         /* set hardware entry registers */
       break;
       /* Routing table calls.  */
-   case SIOCADDRT:           /* add routing table entry      */
-   case SIOCDELRT:           /* delete routing table entry   */
+   case VKI_SIOCADDRT:           /* add routing table entry      */
+   case VKI_SIOCDELRT:           /* delete routing table entry   */
       break;
 
       /* RARP cache control calls. */
-   case SIOCDRARP:           /* delete RARP table entry      */
-   case SIOCSRARP:           /* set RARP table entry         */
+   case VKI_SIOCDRARP:           /* delete RARP table entry      */
+   case VKI_SIOCSRARP:           /* set RARP table entry         */
       /* ARP cache control calls. */
-   case SIOCSARP:            /* set ARP table entry          */
-   case SIOCDARP:            /* delete ARP table entry       */
+   case VKI_SIOCSARP:            /* set ARP table entry          */
+   case VKI_SIOCDARP:            /* delete ARP table entry       */
       break;
 
-   case SIOCGPGRP:
+   case VKI_SIOCGPGRP:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SIOCSPGRP:
+   case VKI_SIOCSPGRP:
       break;
 
       /* linux/soundcard interface (OSS) */
-   case SNDCTL_SEQ_GETOUTCOUNT:
-   case SNDCTL_SEQ_GETINCOUNT:
-   case SNDCTL_SEQ_PERCMODE:
-   case SNDCTL_SEQ_TESTMIDI:
-   case SNDCTL_SEQ_RESETSAMPLES:
-   case SNDCTL_SEQ_NRSYNTHS:
-   case SNDCTL_SEQ_NRMIDIS:
-   case SNDCTL_SEQ_GETTIME:
-   case SNDCTL_DSP_GETFMTS:
-   case SNDCTL_DSP_GETTRIGGER:
-   case SNDCTL_DSP_GETODELAY:
-#           if defined(SNDCTL_DSP_GETSPDIF)
-   case SNDCTL_DSP_GETSPDIF:
-#           endif
-   case SNDCTL_DSP_GETCAPS:
-   case SOUND_PCM_READ_RATE:
-   case SOUND_PCM_READ_CHANNELS:
-   case SOUND_PCM_READ_BITS:
-   case (SOUND_PCM_READ_BITS|0x40000000): /* what the fuck ? */
-   case SOUND_PCM_READ_FILTER:
+   case VKI_SNDCTL_SEQ_GETOUTCOUNT:
+   case VKI_SNDCTL_SEQ_GETINCOUNT:
+   case VKI_SNDCTL_SEQ_PERCMODE:
+   case VKI_SNDCTL_SEQ_TESTMIDI:
+   case VKI_SNDCTL_SEQ_RESETSAMPLES:
+   case VKI_SNDCTL_SEQ_NRSYNTHS:
+   case VKI_SNDCTL_SEQ_NRMIDIS:
+   case VKI_SNDCTL_SEQ_GETTIME:
+   case VKI_SNDCTL_DSP_GETFMTS:
+   case VKI_SNDCTL_DSP_GETTRIGGER:
+   case VKI_SNDCTL_DSP_GETODELAY:
+   case VKI_SNDCTL_DSP_GETSPDIF:
+   case VKI_SNDCTL_DSP_GETCAPS:
+   case VKI_SOUND_PCM_READ_RATE:
+   case VKI_SOUND_PCM_READ_CHANNELS:
+   case VKI_SOUND_PCM_READ_BITS:
+   case (VKI_SOUND_PCM_READ_BITS|0x40000000): /* what the fuck ? */
+   case VKI_SOUND_PCM_READ_FILTER:
       VG_TRACK( post_mem_write,arg3, sizeof(int));
       break;
-   case SNDCTL_SEQ_CTRLRATE:
-   case SNDCTL_DSP_SPEED:
-   case SNDCTL_DSP_STEREO:
-   case SNDCTL_DSP_GETBLKSIZE: 
-   case SNDCTL_DSP_CHANNELS:
-   case SOUND_PCM_WRITE_FILTER:
-   case SNDCTL_DSP_SUBDIVIDE:
-   case SNDCTL_DSP_SETFRAGMENT:
+   case VKI_SNDCTL_SEQ_CTRLRATE:
+   case VKI_SNDCTL_DSP_SPEED:
+   case VKI_SNDCTL_DSP_STEREO:
+   case VKI_SNDCTL_DSP_GETBLKSIZE: 
+   case VKI_SNDCTL_DSP_CHANNELS:
+   case VKI_SOUND_PCM_WRITE_FILTER:
+   case VKI_SNDCTL_DSP_SUBDIVIDE:
+   case VKI_SNDCTL_DSP_SETFRAGMENT:
 #           if defined(SNDCTL_DSP_GETCHANNELMASK)
-   case SNDCTL_DSP_GETCHANNELMASK:
+   case VKI_SNDCTL_DSP_GETCHANNELMASK:
 #           endif
 #           if defined(SNDCTL_DSP_BIND_CHANNEL)
-   case SNDCTL_DSP_BIND_CHANNEL:
+   case VKI_SNDCTL_DSP_BIND_CHANNEL:
 #           endif
-   case SNDCTL_TMR_TIMEBASE:
-   case SNDCTL_TMR_TEMPO:
-   case SNDCTL_TMR_SOURCE:
-   case SNDCTL_MIDI_PRETIME:
-   case SNDCTL_MIDI_MPUMODE:
+   case VKI_SNDCTL_TMR_TIMEBASE:
+   case VKI_SNDCTL_TMR_TEMPO:
+   case VKI_SNDCTL_TMR_SOURCE:
+   case VKI_SNDCTL_MIDI_PRETIME:
+   case VKI_SNDCTL_MIDI_MPUMODE:
       break;
-   case SNDCTL_DSP_GETOSPACE:
-   case SNDCTL_DSP_GETISPACE:
-      VG_TRACK( post_mem_write,arg3, sizeof(audio_buf_info));
+   case VKI_SNDCTL_DSP_GETOSPACE:
+   case VKI_SNDCTL_DSP_GETISPACE:
+      VG_TRACK( post_mem_write,arg3, sizeof(vki_audio_buf_info));
       break;
-   case SNDCTL_DSP_SETTRIGGER:
+   case VKI_SNDCTL_DSP_SETTRIGGER:
       break;
 
-   case SNDCTL_DSP_POST:
-   case SNDCTL_DSP_RESET:
-   case SNDCTL_DSP_SYNC:
-   case SNDCTL_DSP_SETSYNCRO:
-   case SNDCTL_DSP_SETDUPLEX:
+   case VKI_SNDCTL_DSP_POST:
+   case VKI_SNDCTL_DSP_RESET:
+   case VKI_SNDCTL_DSP_SYNC:
+   case VKI_SNDCTL_DSP_SETSYNCRO:
+   case VKI_SNDCTL_DSP_SETDUPLEX:
       break;
 
       /* Real Time Clock (/dev/rtc) ioctls */
-#           ifndef GLIBC_2_1
-   case RTC_UIE_ON:
-   case RTC_UIE_OFF:
-   case RTC_AIE_ON:
-   case RTC_AIE_OFF:
-   case RTC_PIE_ON:
-   case RTC_PIE_OFF:
-   case RTC_IRQP_SET:
-      break;
-   case RTC_RD_TIME:
-   case RTC_ALM_READ:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct rtc_time));
-      break;
-   case RTC_ALM_SET:
-      break;
-   case RTC_IRQP_READ:
+   case VKI_RTC_UIE_ON:
+   case VKI_RTC_UIE_OFF:
+   case VKI_RTC_AIE_ON:
+   case VKI_RTC_AIE_OFF:
+   case VKI_RTC_PIE_ON:
+   case VKI_RTC_PIE_OFF:
+   case VKI_RTC_IRQP_SET:
+      break;
+   case VKI_RTC_RD_TIME:
+   case VKI_RTC_ALM_READ:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_rtc_time));
+      break;
+   case VKI_RTC_ALM_SET:
+      break;
+   case VKI_RTC_IRQP_READ:
       VG_TRACK( post_mem_write,arg3, sizeof(unsigned long));
       break;
-#           endif /* GLIBC_2_1 */
 
 #           ifdef BLKGETSIZE
    case BLKGETSIZE:
@@ -3926,109 +3861,97 @@ POST(ioctl)
 #           endif /* BLKGETSIZE */
 
       /* Hard disks */
-   case HDIO_GET_IDENTITY: /* 0x030d */
-      VG_TRACK( post_mem_write,arg3, sizeof(struct hd_driveid));
+   case VKI_HDIO_GET_IDENTITY: /* 0x030d */
+      VG_TRACK( post_mem_write,arg3, VKI_SIZEOF_STRUCT_HD_DRIVEID );
       break;
 
       /* CD ROM stuff (??)  */
-   case CDROMSUBCHNL:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct cdrom_subchnl));
+   case VKI_CDROMSUBCHNL:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_cdrom_subchnl));
       break;
-   case CDROMREADTOCHDR:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct cdrom_tochdr));
+   case VKI_CDROMREADTOCHDR:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_cdrom_tochdr));
       break;
-   case CDROMREADTOCENTRY:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct cdrom_tochdr));
+   case VKI_CDROMREADTOCENTRY:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_cdrom_tochdr));
       break;
-   case CDROMMULTISESSION:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct cdrom_multisession));
+   case VKI_CDROMMULTISESSION:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_cdrom_multisession));
       break;
-   case CDROMVOLREAD:
-      VG_TRACK( post_mem_write,arg3, sizeof(struct cdrom_volctrl));
+   case VKI_CDROMVOLREAD:
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_cdrom_volctrl));
       break;
-   case CDROMREADAUDIO:
+   case VKI_CDROMREADAUDIO:
    {
-      struct cdrom_read_audio *cra = (struct cdrom_read_audio *) arg3;
+      struct vki_cdrom_read_audio *cra = (struct vki_cdrom_read_audio *) arg3;
       VG_TRACK( post_mem_write, (Addr)(cra->buf),
-                (UInt)(cra->nframes * CD_FRAMESIZE_RAW));
+                (UInt)(cra->nframes * VKI_CD_FRAMESIZE_RAW));
       break;
    }
       
-   case CDROMPLAYMSF:
+   case VKI_CDROMPLAYMSF:
       break;
       /* The following two are probably bogus (should check args
         for readability).  JRS 20021117 */
-   case CDROM_DRIVE_STATUS: /* 0x5326 */
-   case CDROM_CLEAR_OPTIONS: /* 0x5321 */
+   case VKI_CDROM_DRIVE_STATUS: /* 0x5326 */
+   case VKI_CDROM_CLEAR_OPTIONS: /* 0x5321 */
       break;
 
-   case FIGETBSZ:
+   case VKI_FIGETBSZ:
       VG_TRACK( post_mem_write,arg3, sizeof(unsigned long));
       break;
-   case FIBMAP:
+   case VKI_FIBMAP:
       VG_TRACK( post_mem_write,arg3, sizeof(unsigned long));
       break;
 
-#ifdef HAVE_LINUX_FB_H
-   case FBIOGET_VSCREENINFO: //0x4600
-      VG_TRACK( post_mem_write,arg3, sizeof(struct fb_var_screeninfo));
-      break;
-   case FBIOGET_FSCREENINFO: //0x4602
-      VG_TRACK( post_mem_write,arg3, sizeof(struct fb_fix_screeninfo));
-      break;
-#endif
-
-   case PPCLAIM:
-   case PPEXCL:
-   case PPYIELD:
-   case PPRELEASE:
-   case PPSETMODE:
-   case PPSETPHASE:
-#ifdef PPSETFLAGS
-   case PPSETFLAGS:
-#endif
-   case PPWDATA:
-   case PPWCONTROL:
-   case PPFCONTROL:
-   case PPDATADIR:
-   case PPNEGOT:
-   case PPWCTLONIRQ:
-   case PPSETTIME:
-      break;
-#ifdef PPGETMODE
-   case PPGETMODE:
+   case VKI_FBIOGET_VSCREENINFO: //0x4600
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_fb_var_screeninfo));
+      break;
+   case VKI_FBIOGET_FSCREENINFO: //0x4602
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_fb_fix_screeninfo));
+      break;
+
+   case VKI_PPCLAIM:
+   case VKI_PPEXCL:
+   case VKI_PPYIELD:
+   case VKI_PPRELEASE:
+   case VKI_PPSETMODE:
+   case VKI_PPSETPHASE:
+   case VKI_PPSETFLAGS:
+   case VKI_PPWDATA:
+   case VKI_PPWCONTROL:
+   case VKI_PPFCONTROL:
+   case VKI_PPDATADIR:
+   case VKI_PPNEGOT:
+   case VKI_PPWCTLONIRQ:
+   case VKI_PPSETTIME:
+      break;
+   case VKI_PPGETMODE:
       VG_TRACK( post_mem_write, arg3, sizeof(int) );
       break;
-#endif
-#ifdef PPGETPHASE
-   case PPGETPHASE:
+   case VKI_PPGETPHASE:
       VG_TRACK( post_mem_write, arg3, sizeof(int) );
       break;
-#endif
-#ifdef PPGETMODES
-   case PPGETMODES:
+   case VKI_PPGETMODES:
       VG_TRACK( post_mem_write, arg3, sizeof(unsigned int) );
       break;
-#endif
-#ifdef PPGETFLAGS
-   case PPGETFLAGS:
+   case VKI_PPGETFLAGS:
       VG_TRACK( post_mem_write, arg3, sizeof(int) );
       break;
-#endif
-   case PPRSTATUS:
+   case VKI_PPRSTATUS:
       VG_TRACK( post_mem_write, arg3, sizeof(unsigned char) );
       break;
-   case PPRDATA:
+   case VKI_PPRDATA:
       VG_TRACK( post_mem_write, arg3, sizeof(unsigned char) );
       break;
-   case PPRCONTROL:
+   case VKI_PPRCONTROL:
       VG_TRACK( post_mem_write, arg3, sizeof(unsigned char) );
       break;
-   case PPCLRIRQ:
+   case VKI_PPCLRIRQ:
       VG_TRACK( post_mem_write, arg3, sizeof(int) );
       break;
-   case PPGETTIME:
-      VG_TRACK( post_mem_write, arg3, sizeof(struct timeval) );
+   case VKI_PPGETTIME:
+      VG_TRACK( post_mem_write, arg3, sizeof(struct vki_timeval) );
       break;
 
       /* We don't have any specific information on it, so
@@ -4040,9 +3963,9 @@ POST(ioctl)
         writes a value to the ioctl value passed from the user
         space and the other way around with _IOC_WRITE. */
    default: {
-      UInt dir  = _IOC_DIR(arg2);
-      UInt size = _IOC_SIZE(arg2);
-      if (size > 0 && (dir & _IOC_READ)
+      UInt dir  = _VKI_IOC_DIR(arg2);
+      UInt size = _VKI_IOC_SIZE(arg2);
+      if (size > 0 && (dir & _VKI_IOC_READ)
          && res == 0
          && arg3 != (Addr)NULL)
         VG_TRACK( post_mem_write,arg3, size);
@@ -4066,7 +3989,7 @@ POST(kill)
    if (res >= 0 &&                                     /* if it was successful */
        arg2 != 0 &&                                    /* if a real signal */
        !VG_(is_sig_ign)(arg2) &&                       /* that isn't ignored and */
-       !VG_(ksigismember)(&tst->eff_sig_mask, arg2) && /*      we're not blocking it */
+       !VG_(sigismember)(&tst->eff_sig_mask, arg2) &&  /*      we're not blocking it */
        (arg1 == VG_(getpid)() ||                       /* directed at us or */
        arg1 == -1            ||                        /* directed at everyone or */
        arg1 == 0             ||                        /* directed at whole group or */
@@ -4100,13 +4023,13 @@ PRE(_llseek)
    MAYBE_PRINTF("llseek ( %d, 0x%x, 0x%x, %p, %d )\n",
                arg1,arg2,arg3,arg4,arg5);
    SYSCALL_TRACK( pre_mem_write, tid, "llseek(result)", arg4, 
-                 sizeof(loff_t));
+                 sizeof(vki_loff_t));
 }
 
 POST(_llseek)
 {
    if (res == 0)
-      VG_TRACK( post_mem_write, arg4, sizeof(loff_t) );
+      VG_TRACK( post_mem_write, arg4, sizeof(vki_loff_t) );
 }
 
 PRE(lstat)
@@ -4115,13 +4038,13 @@ PRE(lstat)
    MAYBE_PRINTF("lstat ( %p(%s), %p )\n",arg1,arg1,arg2);
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat(file_name)", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "lstat(buf)", arg2, 
-                 sizeof(struct stat) );
+                 sizeof(struct vki_stat) );
 }
 
 POST(lstat)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg2, sizeof(struct stat) );
+      VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat) );
    }
 }
 
@@ -4131,13 +4054,13 @@ PRE(lstat64)
    MAYBE_PRINTF("lstat64 ( %p(%s), %p )\n",arg1,arg1,arg2);
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat64(file_name)", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "lstat64(buf)", arg2, 
-                 sizeof(struct stat64) );
+                 sizeof(struct vki_stat64) );
 }
 
 POST(lstat64)
 {
    if (res == 0) {
-      VG_TRACK( post_mem_write, arg2, sizeof(struct stat64) );
+      VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat64) );
    }
 }
 
@@ -4175,7 +4098,7 @@ PRE(mmap2)
 POST(mmap2)
 {
    vg_assert(valid_client_addr(res, arg2, tid, "mmap2"));
-   mmap_segment( (Addr)res, arg2, arg3, arg4, arg5, arg6 * (ULong)VKI_BYTES_PER_PAGE );
+   mmap_segment( (Addr)res, arg2, arg3, arg4, arg5, arg6 * (ULong)VKI_PAGE_SIZE );
 }
 
 PRE(mmap)
@@ -4277,16 +4200,16 @@ PRE(nanosleep)
    /* int nanosleep(const struct timespec *req, struct timespec *rem); */
    MAYBE_PRINTF("nanosleep ( %p, %p )\n", arg1,arg2);
    SYSCALL_TRACK( pre_mem_read, tid, "nanosleep(req)", arg1, 
-                                        sizeof(struct timespec) );
+                                        sizeof(struct vki_timespec) );
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "nanosleep(rem)", arg2, 
-                     sizeof(struct timespec) );
+                     sizeof(struct vki_timespec) );
 }
 
 POST(nanosleep)
 {
    if (arg2 != (UInt)NULL && res == -VKI_EINTR)
-      VG_TRACK( post_mem_write, arg2, sizeof(struct timespec) );
+      VG_TRACK( post_mem_write, arg2, sizeof(struct vki_timespec) );
 }
 
 PRE(_newselect)
@@ -4308,7 +4231,7 @@ PRE(_newselect)
                     arg4, arg1/8 /* __FD_SETSIZE/8 */ );
    if (arg5 != 0)
       SYSCALL_TRACK( pre_mem_read, tid, "newselect(timeout)", arg5, 
-                    sizeof(struct timeval) );
+                    sizeof(struct vki_timeval) );
 }
 
 PRE(open)
@@ -4425,14 +4348,14 @@ PRE(poll)
    /* In fact some parts of this struct should be readable too.
       This should be fixed properly. */
    SYSCALL_TRACK( pre_mem_write, tid, "poll(ufds)", 
-                 arg1, arg2 * sizeof(struct pollfd) );
+                 arg1, arg2 * sizeof(struct vki_pollfd) );
 }
 
 POST(poll)
 {
    if (res > 0) {
       UInt i;
-      struct pollfd * arr = (struct pollfd *)arg1;
+      struct vki_pollfd * arr = (struct vki_pollfd *)arg1;
       for (i = 0; i < arg2; i++)
         VG_TRACK( post_mem_write, (Addr)(&arr[i].revents), 
                   sizeof(Short) );
@@ -4467,7 +4390,7 @@ PRE(epoll_ctl)
    MAYBE_PRINTF("epoll_ctl ( %d, %s, %d, %p )\n", 
                 arg1, ( arg2<3 ? epoll_ctl_s[arg2] : "?" ), arg3, arg4);
    SYSCALL_TRACK( pre_mem_read, tid, "epoll_ctl(event)",
-                  arg4, sizeof(struct vki_epoll_event) );
+                  arg4, sizeof(struct epoll_event) );
 }
 
 PRE(epoll_wait)
@@ -4476,13 +4399,13 @@ PRE(epoll_wait)
                      int maxevents, int timeout) */
    MAYBE_PRINTF("epoll_wait ( %d, %p, %d, %d )\n", arg1, arg2, arg3, arg4);
    SYSCALL_TRACK( pre_mem_write, tid, "epoll_wait(events)",
-                  arg2, sizeof(struct vki_epoll_event)*arg3);
+                  arg2, sizeof(struct epoll_event)*arg3);
 }
 
 POST(epoll_wait)
 {
    if (res > 0)
-      VG_TRACK( post_mem_write, arg2, sizeof(struct vki_epoll_event)*res ) ;
+      VG_TRACK( post_mem_write, arg2, sizeof(struct epoll_event)*res ) ;
 }
 
 PRE(readlink)
@@ -4502,15 +4425,15 @@ PRE(readv)
 {
    /* int readv(int fd, const struct iovec * vector, size_t count); */
    Int i;
-   struct iovec * vec;
+   struct vki_iovec * vec;
    MAYBE_PRINTF("readv ( %d, %p, %d )\n",arg1,arg2,arg3);
    if (!fd_allowed(arg1, "readv", tid, False)) {
       set_result( -VKI_EBADF );
    } else {
       SYSCALL_TRACK( pre_mem_read, tid, "readv(vector)", 
-                    arg2, arg3 * sizeof(struct iovec) );
+                    arg2, arg3 * sizeof(struct vki_iovec) );
       /* ToDo: don't do any of the following if the vector is invalid */
-      vec = (struct iovec *)arg2;
+      vec = (struct vki_iovec *)arg2;
       for (i = 0; i < (Int)arg3; i++)
         SYSCALL_TRACK( pre_mem_write, tid, "readv(vector[...])",
                        (Addr)vec[i].iov_base, vec[i].iov_len );
@@ -4521,7 +4444,7 @@ POST(readv)
 {
    if (res > 0) {
       Int i;
-      struct iovec * vec = (struct iovec *)arg2;
+      struct vki_iovec * vec = (struct vki_iovec *)arg2;
       Int remains = res;
 
       /* res holds the number of bytes read. */
@@ -4555,12 +4478,12 @@ PRE(sched_setparam)
    /* int sched_setparam(pid_t pid, const struct sched_param *p); */
    MAYBE_PRINTF("sched_setparam ( %d, %p )\n", arg1, arg2 );
    SYSCALL_TRACK( pre_mem_read, tid, "sched_setparam(ptr)",
-                 arg2, sizeof(struct sched_param) );
+                 arg2, sizeof(struct vki_sched_param) );
 }
 
 POST(sched_setparam)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct sched_param) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_sched_param) );
 }
 
 PRE(sched_getparam)
@@ -4568,12 +4491,12 @@ PRE(sched_getparam)
    /* int sched_getparam(pid_t pid, struct sched_param *p); */
    MAYBE_PRINTF("sched_getparam ( %d, %p )\n", arg1, arg2 );
    SYSCALL_TRACK( pre_mem_write, tid, "sched_getparam(ptr)",
-                 arg2, sizeof(struct sched_param) );
+                 arg2, sizeof(struct vki_sched_param) );
 }
 
 POST(sched_getparam)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct sched_param) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_sched_param) );
 }
 
 PRE(sched_yield)
@@ -4616,7 +4539,7 @@ PRE(select)
                        a1/8 /* __FD_SETSIZE/8 */ );
       if (a5 != (Addr)NULL)
         SYSCALL_TRACK( pre_mem_read, tid, "select(timeout)", a5, 
-                       sizeof(struct timeval) );
+                       sizeof(struct vki_timeval) );
    }
 }
 
@@ -4627,16 +4550,16 @@ PRE(setitimer)
          MAYBE_PRINTF("setitimer ( %d, %p, %p )\n", arg1,arg2,arg3);
          if (arg2 != (Addr)NULL)
             SYSCALL_TRACK( pre_mem_read,tid, "setitimer(value)", 
-                             arg2, sizeof(struct itimerval) );
+                             arg2, sizeof(struct vki_itimerval) );
          if (arg3 != (Addr)NULL)
             SYSCALL_TRACK( pre_mem_write,tid, "setitimer(ovalue)", 
-                             arg3, sizeof(struct itimerval));
+                             arg3, sizeof(struct vki_itimerval));
 }
 
 POST(setitimer)
 {
    if (arg3 != (Addr)NULL) {
-      VG_TRACK( post_mem_write,arg3, sizeof(struct itimerval));
+      VG_TRACK( post_mem_write,arg3, sizeof(struct vki_itimerval));
    }
 }
 
@@ -4666,7 +4589,7 @@ PRE(setgroups)
    MAYBE_PRINTF("setgroups ( %d, %p )\n", arg1, arg2);
    if (arg1 > 0)
       SYSCALL_TRACK( pre_mem_read, tid, "setgroups(list)", arg2, 
-                    arg1 * sizeof(gid_t) );
+                    arg1 * sizeof(vki_gid_t) );
 }
 
 PREALIAS(setgroups32, setgroups);
@@ -4710,33 +4633,33 @@ PRE(setrlimit)
                  arg2, sizeof(struct vki_rlimit) );
 
    if (arg1 == VKI_RLIMIT_NOFILE) {
-      if (((vki_rlimit *)arg2)->rlim_cur > VG_(fd_hard_limit) ||
-          ((vki_rlimit *)arg2)->rlim_max != VG_(fd_hard_limit)) {
+      if (((struct vki_rlimit *)arg2)->rlim_cur > VG_(fd_hard_limit) ||
+          ((struct vki_rlimit *)arg2)->rlim_max != VG_(fd_hard_limit)) {
          set_result( -VKI_EPERM );
       }
       else {
-         VG_(fd_soft_limit) = ((vki_rlimit *)arg2)->rlim_cur;
+         VG_(fd_soft_limit) = ((struct vki_rlimit *)arg2)->rlim_cur;
          set_result( 0 );
       }
    }
    else if (arg1 == VKI_RLIMIT_DATA) {
-      if (((vki_rlimit *)arg2)->rlim_cur > ((vki_rlimit *)arg2)->rlim_max ||
-          ((vki_rlimit *)arg2)->rlim_max > ((vki_rlimit *)arg2)->rlim_max) {
+      if (((struct vki_rlimit *)arg2)->rlim_cur > ((struct vki_rlimit *)arg2)->rlim_max ||
+          ((struct vki_rlimit *)arg2)->rlim_max > ((struct vki_rlimit *)arg2)->rlim_max) {
          set_result( -VKI_EPERM );
       }
       else {
-         VG_(client_rlimit_data) = *(vki_rlimit *)arg2;
+         VG_(client_rlimit_data) = *(struct vki_rlimit *)arg2;
          set_result( 0 );
       }
    }
    else if (arg1 == VKI_RLIMIT_STACK && tid == 1) {
-      if (((vki_rlimit *)arg2)->rlim_cur > ((vki_rlimit *)arg2)->rlim_max ||
-          ((vki_rlimit *)arg2)->rlim_max > ((vki_rlimit *)arg2)->rlim_max) {
+      if (((struct vki_rlimit *)arg2)->rlim_cur > ((struct vki_rlimit *)arg2)->rlim_max ||
+          ((struct vki_rlimit *)arg2)->rlim_max > ((struct vki_rlimit *)arg2)->rlim_max) {
          set_result( -VKI_EPERM );
       }
       else {
-         VG_(threads)[tid].stack_size = ((vki_rlimit *)arg2)->rlim_cur;
-         VG_(client_rlimit_stack) = *(vki_rlimit *)arg2;
+         VG_(threads)[tid].stack_size = ((struct vki_rlimit *)arg2)->rlim_cur;
+         VG_(client_rlimit_stack) = *(struct vki_rlimit *)arg2;
          set_result( 0 );
       }
    }
@@ -4756,7 +4679,7 @@ PRE(socketcall)
    MAYBE_PRINTF("socketcall ( %d, %p )\n",arg1,arg2);
    switch (arg1 /* request */) {
 
-   case SYS_SOCKETPAIR:
+   case VKI_SYS_SOCKETPAIR:
       /* int socketpair(int d, int type, int protocol, int sv[2]); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.socketpair(args)", 
                     arg2, 4*sizeof(Addr) );
@@ -4764,28 +4687,28 @@ PRE(socketcall)
                     ((UInt*)arg2)[3], 2*sizeof(int) );
       break;
 
-   case SYS_SOCKET:
+   case VKI_SYS_SOCKET:
       /* int socket(int domain, int type, int protocol); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.socket(args)", 
                     arg2, 3*sizeof(Addr) );
       break;
 
-   case SYS_BIND:
+   case VKI_SYS_BIND:
       /* int bind(int sockfd, struct sockaddr *my_addr, 
         int addrlen); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.bind(args)", 
                     arg2, 3*sizeof(Addr) );
       pre_mem_read_sockaddr( tid, "socketcall.bind(my_addr.%s)",
-                            (struct sockaddr *) (((UInt*)arg2)[1]), ((UInt*)arg2)[2]);
+                            (struct vki_sockaddr *) (((UInt*)arg2)[1]), ((UInt*)arg2)[2]);
       break;
                
-   case SYS_LISTEN:
+   case VKI_SYS_LISTEN:
       /* int listen(int s, int backlog); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.listen(args)", 
                     arg2, 2*sizeof(Addr) );
       break;
 
-   case SYS_ACCEPT: {
+   case VKI_SYS_ACCEPT: {
       /* int accept(int s, struct sockaddr *addr, int *addrlen); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.accept(args)", 
                     arg2, 3*sizeof(Addr) );
@@ -4800,7 +4723,7 @@ PRE(socketcall)
       break;
    }
 
-   case SYS_SENDTO:
+   case VKI_SYS_SENDTO:
       /* int sendto(int s, const void *msg, int len, 
         unsigned int flags, 
         const struct sockaddr *to, int tolen); */
@@ -4810,10 +4733,10 @@ PRE(socketcall)
                     ((UInt*)arg2)[1], /* msg */
                     ((UInt*)arg2)[2]  /* len */ );
       pre_mem_read_sockaddr( tid, "socketcall.sendto(to.%s)",
-                            (struct sockaddr *) (((UInt*)arg2)[4]), ((UInt*)arg2)[5]);
+                            (struct vki_sockaddr *) (((UInt*)arg2)[4]), ((UInt*)arg2)[5]);
       break;
 
-   case SYS_SEND:
+   case VKI_SYS_SEND:
       /* int send(int s, const void *msg, size_t len, int flags); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.send(args)", arg2,
                     4*sizeof(Addr) );
@@ -4822,7 +4745,7 @@ PRE(socketcall)
                     ((UInt*)arg2)[2]  /* len */ );
       break;
 
-   case SYS_RECVFROM:
+   case VKI_SYS_RECVFROM:
       /* int recvfrom(int s, void *buf, int len, unsigned int flags,
         struct sockaddr *from, int *fromlen); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.recvfrom(args)", 
@@ -4842,7 +4765,7 @@ PRE(socketcall)
       }
       break;
    
-   case SYS_RECV:
+   case VKI_SYS_RECV:
       /* int recv(int s, void *buf, int len, unsigned int flags); */
       /* man 2 recv says:
         The  recv call is normally used only on a connected socket
@@ -4856,7 +4779,7 @@ PRE(socketcall)
                     ((UInt*)arg2)[2]  /* len */ );
       break;
 
-   case SYS_CONNECT:
+   case VKI_SYS_CONNECT:
       /* int connect(int sockfd, 
         struct sockaddr *serv_addr, int addrlen ); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.connect(args)", 
@@ -4864,13 +4787,13 @@ PRE(socketcall)
       SYSCALL_TRACK( pre_mem_read, tid, 
                     "socketcall.connect(serv_addr.sa_family)",
                     ((UInt*)arg2)[1], /* serv_addr */
-                    sizeof (sa_family_t));
+                    sizeof(vki_sa_family_t));
       pre_mem_read_sockaddr( tid,
                             "socketcall.connect(serv_addr.%s)",
-                            (struct sockaddr *) (((UInt*)arg2)[1]), ((UInt*)arg2)[2]);
+                            (struct vki_sockaddr *) (((UInt*)arg2)[1]), ((UInt*)arg2)[2]);
       break;
 
-   case SYS_SETSOCKOPT:
+   case VKI_SYS_SETSOCKOPT:
       /* int setsockopt(int s, int level, int optname, 
         const void *optval, int optlen); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.setsockopt(args)", 
@@ -4880,7 +4803,7 @@ PRE(socketcall)
                     ((UInt*)arg2)[4]  /* optlen */ );
       break;
 
-   case SYS_GETSOCKOPT:
+   case VKI_SYS_GETSOCKOPT:
       /* int setsockopt(int s, int level, int optname, 
         void *optval, socklen_t *optlen); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.getsockopt(args)", 
@@ -4896,7 +4819,7 @@ PRE(socketcall)
       }
       break;
 
-   case SYS_GETSOCKNAME:
+   case VKI_SYS_GETSOCKNAME:
       /* int getsockname(int s, struct sockaddr* name, int* namelen) */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.getsockname(args)",
                     arg2, 3*sizeof(Addr) );
@@ -4911,7 +4834,7 @@ PRE(socketcall)
       }
       break;
 
-   case SYS_GETPEERNAME:
+   case VKI_SYS_GETPEERNAME:
       /* int getpeername(int s, struct sockaddr* name, int* namelen) */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.getpeername(args)",
                     arg2, 3*sizeof(Addr) );
@@ -4926,13 +4849,13 @@ PRE(socketcall)
       }
       break;
 
-   case SYS_SHUTDOWN:
+   case VKI_SYS_SHUTDOWN:
       /* int shutdown(int s, int how); */
       SYSCALL_TRACK( pre_mem_read, tid, "socketcall.shutdown(args)", 
                     arg2, 2*sizeof(Addr) );
       break;
 
-   case SYS_SENDMSG: {
+   case VKI_SYS_SENDMSG: {
       /* int sendmsg(int s, const struct msghdr *msg, int flags); */
 
       /* this causes warnings, and I don't get why. glibc bug?
@@ -4941,13 +4864,13 @@ PRE(socketcall)
        arg2, 3*sizeof(Addr) );
       */
 
-      struct msghdr *msg = (struct msghdr *)((UInt *)arg2)[ 1 ];
+      struct vki_msghdr *msg = (struct vki_msghdr *)((UInt *)arg2)[ 1 ];
       msghdr_foreachfield ( tid, msg, pre_mem_read_sendmsg );
 
       break;
    }
       
-   case SYS_RECVMSG: {
+   case VKI_SYS_RECVMSG: {
       /* int recvmsg(int s, struct msghdr *msg, int flags); */
 
       /* this causes warnings, and I don't get why. glibc bug?
@@ -4956,7 +4879,7 @@ PRE(socketcall)
        arg2, 3*sizeof(Addr) );
       */
 
-      struct msghdr *msg = (struct msghdr *)((UInt *)arg2)[ 1 ];
+      struct vki_msghdr *msg = (struct vki_msghdr *)((UInt *)arg2)[ 1 ];
       msghdr_foreachfield ( tid, msg, pre_mem_write_recvmsg );
 
       break;
@@ -4976,7 +4899,7 @@ POST(socketcall)
 
    switch (arg1 /* request */) {
 
-   case SYS_SOCKETPAIR: {
+   case VKI_SYS_SOCKETPAIR: {
       Int fd1 = ((UInt*)((UInt*)arg2)[3])[0];
       Int fd2 = ((UInt*)((UInt*)arg2)[3])[1];
       VG_TRACK( post_mem_write, ((UInt*)arg2)[3], 2*sizeof(int) );
@@ -4995,7 +4918,7 @@ POST(socketcall)
       break;
    }
 
-   case SYS_SOCKET:
+   case VKI_SYS_SOCKET:
       if (!fd_allowed(res, "socket", tid, True)) {
         VG_(close)(res);
         set_result( -VKI_EMFILE );
@@ -5005,16 +4928,16 @@ POST(socketcall)
       }
       break;
 
-   case SYS_BIND:
+   case VKI_SYS_BIND:
       /* int bind(int sockfd, struct sockaddr *my_addr, 
                        int addrlen); */
       break;
                
-   case SYS_LISTEN:
+   case VKI_SYS_LISTEN:
       /* int listen(int s, int backlog); */
       break;
 
-   case SYS_ACCEPT: {
+   case VKI_SYS_ACCEPT: {
       /* int accept(int s, struct sockaddr *addr, int *addrlen); */
       if (!fd_allowed(res, "accept", tid, True)) {
         VG_(close)(res);
@@ -5032,13 +4955,13 @@ POST(socketcall)
       break;
    }
 
-   case SYS_SENDTO:
+   case VKI_SYS_SENDTO:
       break;
 
-   case SYS_SEND:
+   case VKI_SYS_SEND:
       break;
 
-   case SYS_RECVFROM:
+   case VKI_SYS_RECVFROM:
       {
         Addr buf_p      = ((UInt*)arg2)[1];
         Int  len        = ((UInt*)arg2)[2];
@@ -5052,7 +4975,7 @@ POST(socketcall)
       }
       break;
 
-   case SYS_RECV:
+   case VKI_SYS_RECV:
       if (res >= 0 
          && ((UInt*)arg2)[1] != (UInt)NULL) {
         VG_TRACK( post_mem_write, ((UInt*)arg2)[1], /* buf */
@@ -5060,13 +4983,13 @@ POST(socketcall)
       }
       break;
 
-   case SYS_CONNECT:
+   case VKI_SYS_CONNECT:
       break;
 
-   case SYS_SETSOCKOPT:
+   case VKI_SYS_SETSOCKOPT:
       break;
 
-   case SYS_GETSOCKOPT:
+   case VKI_SYS_GETSOCKOPT:
       {
         Addr optval_p  = ((UInt*)arg2)[3];
         Addr optlen_p  = ((UInt*)arg2)[4];
@@ -5077,7 +5000,7 @@ POST(socketcall)
       }
       break;
 
-   case SYS_GETSOCKNAME:
+   case VKI_SYS_GETSOCKNAME:
       {
         Addr name_p     = ((UInt*)arg2)[1];
         Addr namelen_p  = ((UInt*)arg2)[2];
@@ -5087,7 +5010,7 @@ POST(socketcall)
       }
       break;
 
-   case SYS_GETPEERNAME:
+   case VKI_SYS_GETPEERNAME:
       {
         Addr name_p     = ((UInt*)arg2)[1];
         Addr namelen_p  = ((UInt*)arg2)[2];
@@ -5097,15 +5020,15 @@ POST(socketcall)
       }
       break;
 
-   case SYS_SHUTDOWN:
+   case VKI_SYS_SHUTDOWN:
       break;
 
-   case SYS_SENDMSG:
+   case VKI_SYS_SENDMSG:
       break;
 
-   case SYS_RECVMSG:
+   case VKI_SYS_RECVMSG:
    {
-      struct msghdr *msg = (struct msghdr *)((UInt *)arg2)[ 1 ];
+      struct vki_msghdr *msg = (struct vki_msghdr *)((UInt *)arg2)[ 1 ];
 
       msghdr_foreachfield( tid, msg, post_mem_write_recvmsg );
       check_cmsg_for_fds( tid, msg );
@@ -5126,12 +5049,12 @@ PRE(stat)
    MAYBE_PRINTF("stat ( %p, %p )\n",arg1,arg2);
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "stat(file_name)", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "stat(buf)", 
-                 arg2, sizeof(struct stat) );
+                 arg2, sizeof(struct vki_stat) );
 }
 
 POST(stat)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct stat) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat) );
 }
 
 PRE(statfs)
@@ -5175,12 +5098,12 @@ PRE(stat64)
    MAYBE_PRINTF("stat64 ( %p, %p )\n",arg1,arg2);
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "stat64(file_name)", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "stat64(buf)", 
-                 arg2, sizeof(struct stat64) );
+                 arg2, sizeof(struct vki_stat64) );
 }
 
 POST(stat64)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct stat64) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat64) );
 }
 
 PRE(fstat64)
@@ -5188,12 +5111,12 @@ PRE(fstat64)
    /* int fstat64(int filedes, struct stat64 *buf); */
    MAYBE_PRINTF("fstat64 ( %d, %p )\n",arg1,arg2);
    SYSCALL_TRACK( pre_mem_write, tid, "fstat64(buf)", 
-                 arg2, sizeof(struct stat64) );
+                 arg2, sizeof(struct vki_stat64) );
 }
 
 POST(fstat64)
 {
-   VG_TRACK( post_mem_write, arg2, sizeof(struct stat64) );
+   VG_TRACK( post_mem_write, arg2, sizeof(struct vki_stat64) );
 }
 
 PRE(sysinfo)
@@ -5201,12 +5124,12 @@ PRE(sysinfo)
    /* int sysinfo(struct sysinfo *info); */
    MAYBE_PRINTF("sysinfo ( %p )\n",arg1);
    SYSCALL_TRACK( pre_mem_write, tid, "sysinfo(info)", 
-                 arg1, sizeof(struct sysinfo) );
+                 arg1, sizeof(struct vki_sysinfo) );
 }
 
 POST(sysinfo)
 {
-   VG_TRACK( post_mem_write, arg1, sizeof(struct sysinfo) );
+   VG_TRACK( post_mem_write, arg1, sizeof(struct vki_sysinfo) );
 }
 
 PRE(time)
@@ -5214,14 +5137,14 @@ PRE(time)
    /* time_t time(time_t *t); */
    MAYBE_PRINTF("time ( %p )\n",arg1);
    if (arg1 != (UInt)NULL) {
-      SYSCALL_TRACK( pre_mem_write, tid, "time", arg1, sizeof(time_t) );
+      SYSCALL_TRACK( pre_mem_write, tid, "time", arg1, sizeof(vki_time_t) );
    }
 }
 
 POST(time)
 {
    if (arg1 != (UInt)NULL) {
-      VG_TRACK( post_mem_write, arg1, sizeof(time_t) );
+      VG_TRACK( post_mem_write, arg1, sizeof(vki_time_t) );
    }
 }
 
@@ -5230,13 +5153,13 @@ PRE(times)
    /* clock_t times(struct tms *buf); */
    MAYBE_PRINTF("times ( %p )\n",arg1);
    SYSCALL_TRACK( pre_mem_write, tid, "times(buf)", 
-                 arg1, sizeof(struct tms) );
+                 arg1, sizeof(struct vki_tms) );
 }
 
 POST(times)
 {
    if (arg1 != (UInt)NULL) {
-      VG_TRACK( post_mem_write, arg1, sizeof(struct tms) );
+      VG_TRACK( post_mem_write, arg1, sizeof(struct vki_tms) );
    }
 }
 
@@ -5265,13 +5188,13 @@ PRE(uname)
    /* int uname(struct utsname *buf); */
    MAYBE_PRINTF("uname ( %p )\n",arg1);
    SYSCALL_TRACK( pre_mem_write, tid, "uname(buf)", 
-                 arg1, sizeof(struct utsname) );
+                 arg1, sizeof(struct vki_new_utsname) );
 }
 
 POST(uname)
 {
    if (arg1 != (UInt)NULL) {
-      VG_TRACK( post_mem_write, arg1, sizeof(struct utsname) );
+      VG_TRACK( post_mem_write, arg1, sizeof(struct vki_new_utsname) );
    }
 }
 
@@ -5282,7 +5205,7 @@ PRE(utime)
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "utime(filename)", arg1 );
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid, "utime(buf)", arg2, 
-                    sizeof(struct utimbuf) );
+                    sizeof(struct vki_utimbuf) );
 }
 
 PRE(waitpid)
@@ -5308,14 +5231,14 @@ PRE(wait4)
       struct rusage *rusage) */
    MAYBE_PRINTF("wait4 ( %d, %p, %d, %p )\n",
                arg1,arg2,arg3,arg4);
-   arg3 &= ~(VKI__WCLONE | VKI__WALL);
+   arg3 &= ~(__VKI_WCLONE | __VKI_WALL);
 
    if (arg2 != (Addr)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "wait4(status)", 
                     arg2, sizeof(int) );
    if (arg4 != (Addr)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "wait4(rusage)", arg4, 
-                    sizeof(struct rusage) );
+                    sizeof(struct vki_rusage) );
 }
 
 POST(wait4)
@@ -5323,22 +5246,22 @@ POST(wait4)
    if (arg2 != (Addr)NULL)
       VG_TRACK( post_mem_write, arg2, sizeof(int) );
    if (arg4 != (Addr)NULL)
-      VG_TRACK( post_mem_write, arg4, sizeof(struct rusage) );
+      VG_TRACK( post_mem_write, arg4, sizeof(struct vki_rusage) );
 }
 
 PRE(writev)
 {
    /* int writev(int fd, const struct iovec * vector, size_t count); */
    Int i;
-   struct iovec * vec;
+   struct vki_iovec * vec;
    MAYBE_PRINTF("writev ( %d, %p, %d )\n",arg1,arg2,arg3);
    if (!fd_allowed(arg1, "writev", tid, False)) {
       set_result( -VKI_EBADF );
    } else {
       SYSCALL_TRACK( pre_mem_read, tid, "writev(vector)", 
-                    arg2, arg3 * sizeof(struct iovec) );
+                    arg2, arg3 * sizeof(struct vki_iovec) );
       /* ToDo: don't do any of the following if the vector is invalid */
-      vec = (struct iovec *)arg2;
+      vec = (struct vki_iovec *)arg2;
       for (i = 0; i < (Int)arg3; i++)
         SYSCALL_TRACK( pre_mem_read, tid, "writev(vector[...])",
                        (Addr)vec[i].iov_base, vec[i].iov_len );
@@ -5355,7 +5278,7 @@ PRE(prctl)
 
 PRE(adjtimex)
 {
-   struct timex *tx = (struct timex *)arg1;
+   struct vki_timex *tx = (struct vki_timex *)arg1;
    MAYBE_PRINTF("adjtimex ( %p )\n", arg1);
 
    SYSCALL_TRACK(pre_mem_read, tid, "adjtimex(timex->modes)", arg1, sizeof(tx->modes));
@@ -5373,12 +5296,12 @@ PRE(adjtimex)
    ADJX(ADJ_TICK, tick);
 #undef ADJX
    
-   SYSCALL_TRACK(pre_mem_write, tid, "adjtimex(timex)", arg1, sizeof(struct timex));
+   SYSCALL_TRACK(pre_mem_write, tid, "adjtimex(timex)", arg1, sizeof(struct vki_timex));
 }
 
 POST(adjtimex)
 {
-   VG_TRACK(post_mem_write, arg1, sizeof(struct timex));
+   VG_TRACK(post_mem_write, arg1, sizeof(struct vki_timex));
 }
 
 PRE(utimes)
@@ -5388,7 +5311,7 @@ PRE(utimes)
     SYSCALL_TRACK( pre_mem_read_asciiz, tid, "utimes(filename)", arg1 );
     if (arg2 != (UInt)NULL)
          SYSCALL_TRACK( pre_mem_read, tid, "utimes(tvp)", arg2,
-                       sizeof(struct timeval) );
+                       sizeof(struct vki_timeval) );
 }
 
 PRE(futex)
@@ -5398,7 +5321,7 @@ PRE(futex)
     SYSCALL_TRACK( pre_mem_read, tid, "futex(futex)", arg1, sizeof(int) );
     if (arg2 == VKI_FUTEX_WAIT && arg4 != (UInt)NULL)
        SYSCALL_TRACK( pre_mem_read, tid, "futex(timeout)", arg4,
-                      sizeof(struct timespec) );
+                      sizeof(struct vki_timespec) );
     if (arg2 == VKI_FUTEX_REQUEUE)
        SYSCALL_TRACK( pre_mem_read, tid, "futex(futex2)", arg4, sizeof(int) );
 }
@@ -5458,7 +5381,7 @@ PRE(rt_sigsuspend)
    if (arg1 != (Addr)NULL) {
       /* above NULL test is paranoia */
       SYSCALL_TRACK( pre_mem_read, tid, "sigsuspend(mask)", arg1, 
-                    sizeof(vki_ksigset_t) );
+                    sizeof(vki_sigset_t) );
    }
 }
 
@@ -5471,16 +5394,16 @@ PRE(rt_sigtimedwait)
    MAYBE_PRINTF("sigtimedwait ( %p, %p, timeout )\n", arg1, arg2);
    if (arg1 != (UInt)NULL) 
       SYSCALL_TRACK( pre_mem_read,  tid, "sigtimedwait(set)",  arg1,
-                     sizeof(vki_ksigset_t));
+                     sizeof(vki_sigset_t));
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "sigtimedwait(info)", arg2,
-                    sizeof(siginfo_t) );
+                    sizeof(vki_siginfo_t) );
 }
 
 POST(rt_sigtimedwait)
 {
    if (arg2 != (UInt)NULL)
-      VG_TRACK( post_mem_write, arg2, sizeof(siginfo_t) );
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_siginfo_t) );
 }
 
 PRE(rt_sigqueueinfo)
@@ -5489,7 +5412,7 @@ PRE(rt_sigqueueinfo)
    MAYBE_PRINTF("rt_sigqueueinfo(%d, %d, %p)\n", arg1, arg2, arg3);
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid, "sigqueueinfo(uinfo)", arg3, 
-                    sizeof(siginfo_t) );
+                    sizeof(vki_siginfo_t) );
 }
 
 POST(rt_sigqueueinfo)
@@ -5497,7 +5420,7 @@ POST(rt_sigqueueinfo)
    if (res >= 0 && 
        arg2 != 0 &&
        !VG_(is_sig_ign)(arg2) &&
-       !VG_(ksigismember)(&tst->eff_sig_mask, arg2) &&
+       !VG_(sigismember)(&tst->eff_sig_mask, arg2) &&
        arg1 == VG_(getpid)()) {
       VG_(proxy_waitsig)();
    }
@@ -5509,11 +5432,11 @@ PRE(sigaltstack)
    MAYBE_PRINTF("sigaltstack ( %p, %p )\n",arg1,arg2);
    if (arg1 != (UInt)NULL) {
       SYSCALL_TRACK( pre_mem_read, tid, "sigaltstack(ss)", 
-                    arg1, sizeof(vki_kstack_t) );
+                    arg1, sizeof(vki_stack_t) );
    }
    if (arg2 != (UInt)NULL) {
       SYSCALL_TRACK( pre_mem_write, tid, "sigaltstack(oss)", 
-                    arg2, sizeof(vki_kstack_t) );
+                    arg2, sizeof(vki_stack_t) );
    }
 
    if (SIGNAL_SIMULATION)
@@ -5523,7 +5446,7 @@ PRE(sigaltstack)
 POST(sigaltstack)
 {
    if (res == 0 && arg2 != (UInt)NULL)
-      VG_TRACK( post_mem_write, arg2, sizeof(vki_kstack_t));
+      VG_TRACK( post_mem_write, arg2, sizeof(vki_stack_t));
 }
 
 PRE(sigaction)
@@ -5533,10 +5456,10 @@ PRE(sigaction)
    MAYBE_PRINTF("sigaction ( %d, %p, %p )\n",arg1,arg2,arg3);
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid, "sigaction(act)", 
-                    arg2, sizeof(vki_ksigaction));
+                    arg2, sizeof(struct vki_sigaction));
    if (arg3 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "sigaction(oldact)", 
-                    arg3, sizeof(vki_ksigaction));
+                    arg3, sizeof(struct vki_sigaction));
 
    if (SIGNAL_SIMULATION)
       VG_(do__NR_sigaction)(tid);
@@ -5545,7 +5468,7 @@ PRE(sigaction)
 POST(sigaction)
 {
    if (res == 0 && arg3 != (UInt)NULL)
-      VG_TRACK( post_mem_write, arg3, sizeof(vki_ksigaction));
+      VG_TRACK( post_mem_write, arg3, sizeof(struct vki_sigaction));
 }
 
 PREALIAS(rt_sigaction, sigaction);
@@ -5558,22 +5481,22 @@ PRE(sigprocmask)
    MAYBE_PRINTF("sigprocmask ( %d, %p, %p )\n",arg1,arg2,arg3);
    if (arg2 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid, "sigprocmask(set)", 
-                    arg2, sizeof(vki_ksigset_t));
+                    arg2, sizeof(vki_sigset_t));
    if (arg3 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_write, tid, "sigprocmask(oldset)", 
-                    arg3, sizeof(vki_ksigset_t));
+                    arg3, sizeof(vki_sigset_t));
 
    if (SIGNAL_SIMULATION)
       VG_(do__NR_sigprocmask) ( tid, 
                                arg1 /*how*/, 
-                               (vki_ksigset_t*) arg2,
-                               (vki_ksigset_t*) arg3 );
+                               (vki_sigset_t*) arg2,
+                               (vki_sigset_t*) arg3 );
 }
 
 POST(sigprocmask)
 {
    if (res == 0 && arg3 != (UInt)NULL)
-      VG_TRACK( post_mem_write, arg3, sizeof(vki_ksigset_t));
+      VG_TRACK( post_mem_write, arg3, sizeof(vki_sigset_t));
 }
 
 PREALIAS(rt_sigprocmask, sigprocmask);
@@ -5584,12 +5507,12 @@ PRE(sigpending)
    /* int sigpending( sigset_t *set ) ; */
    MAYBE_PRINTF( "sigpending ( %p )\n", arg1 );
    SYSCALL_TRACK( pre_mem_write, tid, "sigpending(set)", 
-                 arg1, sizeof(vki_ksigset_t));
+                 arg1, sizeof(vki_sigset_t));
 }
 
 POST(sigpending)
 {
-   VG_TRACK( post_mem_write, arg1, sizeof( vki_ksigset_t ) ) ;
+   VG_TRACK( post_mem_write, arg1, sizeof( vki_sigset_t ) ) ;
 }
 
 PREALIAS(rt_sigpending, sigpending);
@@ -5605,7 +5528,7 @@ PRE(io_setup)
    SYSCALL_TRACK( pre_mem_write, tid, "io_setup(ctxp)",
                   arg2, sizeof(vki_aio_context_t) );
    
-   size = PGROUNDUP(sizeof(vki_aio_ring) + arg1 * sizeof(vki_io_event));
+   size = PGROUNDUP(sizeof(struct vki_aio_ring) + arg1 * sizeof(struct vki_io_event));
    addr = VG_(find_map_space)(0, size, True);
    VG_(map_segment)(addr, size, VKI_PROT_READ|VKI_PROT_EXEC, SF_FIXED);
    
@@ -5614,7 +5537,7 @@ PRE(io_setup)
    VG_(unpad_address_space)();
 
    if (res == 0) {
-      vki_aio_ring *r = *(vki_aio_ring **)arg2;
+      struct vki_aio_ring *r = *(struct vki_aio_ring **)arg2;
         
       vg_assert(addr == (Addr)r);
       vg_assert(valid_client_addr(addr, size, tid, "io_setup"));
@@ -5630,8 +5553,8 @@ PRE(io_setup)
 PRE(io_destroy)
 {
    Segment *s = VG_(find_segment)(arg1);
-   vki_aio_ring *r = *(vki_aio_ring **)arg1;
-   UInt size = PGROUNDUP(sizeof(vki_aio_ring) + r->nr * sizeof(vki_io_event));
+   struct vki_aio_ring *r = *(struct vki_aio_ring **)arg1;
+   UInt size = PGROUNDUP(sizeof(struct vki_aio_ring) + r->nr * sizeof(struct vki_io_event));
 
    /* long io_destroy (aio_context_t ctx); */
    MAYBE_PRINTF("io_destroy ( %ul )\n",arg1);
@@ -5651,10 +5574,10 @@ PRE(io_getevents)
    MAYBE_PRINTF("io_getevents ( %ul, %l, %l, %p, %p )\n",arg1,arg2,arg3,arg4,arg5);
    if (arg3 > 0)
       SYSCALL_TRACK( pre_mem_write, tid, "io_getevents(events)",
-                     arg4, sizeof(vki_io_event)*arg3 );
+                     arg4, sizeof(struct vki_io_event)*arg3 );
    if (arg5 != (UInt)NULL)
       SYSCALL_TRACK( pre_mem_read, tid, "io_getevents(timeout)",
-                     arg5, sizeof(struct timespec));
+                     arg5, sizeof(struct vki_timespec));
 }
 
 POST(io_getevents)
@@ -5662,10 +5585,10 @@ POST(io_getevents)
    int i;
 
    if (res > 0) {
-      VG_TRACK( post_mem_write, arg4, sizeof(vki_io_event)*res );
+      VG_TRACK( post_mem_write, arg4, sizeof(struct vki_io_event)*res );
       for (i = 0; i < res; i++) {
-         const vki_io_event *vev = ((vki_io_event *)arg4) + i;
-         const vki_iocb *cb = (vki_iocb *)(UInt)vev->obj;
+         const struct vki_io_event *vev = ((struct vki_io_event *)arg4) + i;
+         const struct vki_iocb *cb = (struct vki_iocb *)(UInt)vev->obj;
 
          switch (cb->aio_lio_opcode) {
          case VKI_IOCB_CMD_PREAD:
@@ -5691,11 +5614,11 @@ PRE(io_submit)
    /* long io_submit (aio_context_t ctx_id, long nr, struct iocb **iocbpp); */
    MAYBE_PRINTF("io_submit( %ul, %l, %p )\n",arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_read, tid, "io_submit(iocbpp)",
-                  arg3, sizeof(vki_iocb *)*arg2 );
+                  arg3, sizeof(struct vki_iocb *)*arg2 );
    for (i = 0; i < arg2; i++) {
-      vki_iocb *cb = ((vki_iocb **)arg3)[i];
+      struct vki_iocb *cb = ((struct vki_iocb **)arg3)[i];
       SYSCALL_TRACK( pre_mem_read, tid, "io_submit(iocb)",
-                     (Addr)cb, sizeof(vki_iocb) );
+                     (Addr)cb, sizeof(struct vki_iocb) );
       switch (cb->aio_lio_opcode) {
       case VKI_IOCB_CMD_PREAD:
          SYSCALL_TRACK( pre_mem_write, tid, "io_submit(PREAD)",
@@ -5720,14 +5643,14 @@ PRE(io_cancel)
                       struct io_event *result); */
    MAYBE_PRINTF("io_cancel( %ul, %p, %p )\n",arg1,arg2,arg3);
    SYSCALL_TRACK( pre_mem_read, tid, "io_cancel(iocb)",
-                  arg2, sizeof(vki_iocb) );
+                  arg2, sizeof(struct vki_iocb) );
    SYSCALL_TRACK( pre_mem_write, tid, "io_cancel(result)",
-                  arg3, sizeof(vki_io_event) );
+                  arg3, sizeof(struct vki_io_event) );
 }
 
 POST(io_cancel)
 {
-   VG_TRACK( post_mem_write, arg3, sizeof(vki_io_event) );
+   VG_TRACK( post_mem_write, arg3, sizeof(struct vki_io_event) );
 }
 
 PRE(mq_open)
@@ -5775,7 +5698,7 @@ PRE(mq_timedsend)
       SYSCALL_TRACK( pre_mem_read, tid, "mq_timedsend(msg_ptr)", arg2, arg3 );
       if (arg5 != 0)
          SYSCALL_TRACK( pre_mem_read, tid, "mq_timedsend(abs_timeout)", arg5,
-                        sizeof(struct timespec) );
+                        sizeof(struct vki_timespec) );
    }
 }
 
@@ -5795,7 +5718,7 @@ PRE(mq_timedreceive)
                         arg4, sizeof(unsigned int) );
       if (arg5 != 0)
          SYSCALL_TRACK( pre_mem_read, tid, "mq_timedreceive(abs_timeout)",
-                        arg5, sizeof(struct timespec) );
+                        arg5, sizeof(struct vki_timespec) );
    }
 }
 
@@ -5814,7 +5737,7 @@ PRE(mq_notify)
       set_result( -VKI_EBADF );
    else if (arg2 != 0)
       SYSCALL_TRACK( pre_mem_read, tid, "mq_notify", arg2,
-                     sizeof(struct sigevent) );
+                     sizeof(struct vki_sigevent) );
 }
 
 PRE(mq_getsetattr)
@@ -5849,14 +5772,14 @@ PRE(timer_create)
    MAYBE_PRINTF("timer_create( %d, %p, %p )\n", arg1,arg2,arg3);
    if (arg2 != 0)
       SYSCALL_TRACK( pre_mem_read, tid, "timer_create(evp)", arg2,
-                     sizeof(struct sigevent) );
+                     sizeof(struct vki_sigevent) );
    SYSCALL_TRACK( pre_mem_write, tid, "timer_create(timerid)", arg3,
-                  sizeof(timer_t) );
+                  sizeof(vki_timer_t) );
 }
 
 POST(timer_create)
 {
-   VG_TRACK( post_mem_write, arg3, sizeof(timer_t) );
+   VG_TRACK( post_mem_write, arg3, sizeof(vki_timer_t) );
 }
 
 PRE(timer_settime)
@@ -5908,7 +5831,7 @@ PRE(clock_settime)
     /* int clock_settime(clockid_t clk_id, const struct timespec *tp); */
     MAYBE_PRINTF("clock_settime( %d, %p )\n", arg1,arg2);
     SYSCALL_TRACK(pre_mem_read, tid, "clock_gettime(tp)",
-                  arg2, sizeof(struct timespec) );
+                  arg2, sizeof(struct vki_timespec) );
 }
 
 PRE(clock_gettime)
@@ -5916,12 +5839,12 @@ PRE(clock_gettime)
     /* int clock_gettime(clockid_t clk_id, struct timespec *tp); */
     MAYBE_PRINTF("clock_gettime( %d, %p )\n" , arg1,arg2);
     SYSCALL_TRACK(pre_mem_write, tid, "clock_gettime(tp)",
-                  arg2, sizeof(struct timespec) );
+                  arg2, sizeof(struct vki_timespec) );
 }
 
 POST(clock_gettime)
 {
-    VG_TRACK( post_mem_write, arg2, sizeof(struct timespec) );
+    VG_TRACK( post_mem_write, arg2, sizeof(struct vki_timespec) );
 }
 
 PRE(clock_getres)
@@ -5929,12 +5852,12 @@ PRE(clock_getres)
     /* int clock_getres(clockid_t clk_id, struct timespec *res); */
     MAYBE_PRINTF("clock_getres( %d, %p )\n" , arg1,arg2);
     SYSCALL_TRACK(pre_mem_write, tid, "clock_getres(res)",
-                  arg2, sizeof(struct timespec) );
+                  arg2, sizeof(struct vki_timespec) );
 }
 
 POST(clock_getres)
 {
-    VG_TRACK( post_mem_write, arg2, sizeof(struct timespec) );
+    VG_TRACK( post_mem_write, arg2, sizeof(struct vki_timespec) );
 }
 
 struct sys_info {
diff --git a/coregrind/vg_unsafe.h b/coregrind/vg_unsafe.h
deleted file mode 100644 (file)
index 3cad9ae..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- A header file for making sense of syscalls.  Unsafe in the   ---*/
-/*--- sense that we don't call any functions mentioned herein.     ---*/
-/*---                                                  vg_unsafe.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Valgrind, an extensible x86 protected-mode
-   emulator for monitoring program execution on x86-Unixes.
-
-   Copyright (C) 2000-2004 Julian Seward 
-      jseward@acm.org
-
-   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, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-
-/* These includes are only used for making sense of the args for
-   system calls. */
-#include "vki_unistd.h"    /* for system call numbers */
-#include <sys/mman.h>     /* for PROT_* */
-#include <sys/utsname.h>  /* for uname */
-#include <sys/time.h>     /* for struct timeval & struct timezone */
-#if defined(KERNEL_2_6) || defined(KERNEL_2_4)
-/* ugly hack to avoid that kernel headers redefine stuff from sys/time.h */
-#define _LINUX_TIME_H
-#endif
-#include <linux/fs.h>     /* for filing system ioctls */
-#include <linux/net.h>    /* for the SYS_* constants */
-#include <sys/resource.h> /* for struct rlimit */
-#include <linux/shm.h>    /* for struct shmid_ds & struct ipc_perm */
-#include <sys/socket.h>   /* for struct msghdr */
-#include <linux/sockios.h>/* for SIOCOUTQ */
-#include <sys/un.h>       /* for sockaddr_un */
-#include <linux/if.h>       /* for struct ifreq et al */
-#include <net/if_arp.h>   /* for struct arpreq */
-#include <net/route.h>    /* for struct rtentry */
-#ifdef HAVE_LINUX_COMPILER_H
-#include <linux/compiler.h> /* for __user definition */
-#endif
-#include <linux/msg.h>    /* for struct msgbuf */
-#include <asm/ipc.h>      /* for struct ipc_kludge */
-#include <linux/sem.h>    /* for struct sembuf */
-
-#include <scsi/sg.h>      /* for the SG_* ioctls */
-#include <sched.h>        /* for struct sched_param */
-#include <linux/sysctl.h> /* for struct __sysctl_args */
-#include <linux/cdrom.h>  /* for cd-rom ioctls */
-#include <signal.h>       /* for siginfo_t */
-#include <linux/timex.h>  /* for adjtimex */
-#include <linux/hdreg.h>  /* for hard drive ioctls */
-#include <linux/netlink.h>/* Some systems need this for linux/fs.h */
-#ifdef HAVE_LINUX_FB_H
-#include <linux/fb.h>     /* for fb_* structs */
-#endif
-#ifdef HAVE_LINUX_MII_H
-#ifndef HAVE_U16
-typedef unsigned short u16;
-#endif
-#include <linux/mii.h>    /* for mii_* structs */
-#endif
-#include <linux/ppdev.h>  /* for PP* ioctls */
-
-#define __USE_LARGEFILE64
-#include <sys/stat.h>     /* for struct stat */
-#undef __USE_LARGEFILE64
-
-#include <asm/ioctls.h>   /* for stuff for dealing with ioctl :( */
-#include <sys/soundcard.h> /* for various soundcard ioctl constants :( */
-
-#ifndef GLIBC_2_1
-#  include <linux/rtc.h>   /* for RTC_* ioctls */
-#endif
-
-#include <termios.h>
-#include <pty.h>
-
-/* 2.2 stuff ... */
-#include <sys/uio.h>
-
-/* Both */
-#include <utime.h>
-#include <sys/times.h>    /* for struct tms */
-
-/* 2.0 at least, for gid_t and loff_t */
-#include <sys/types.h>
-
-#include <sys/sysinfo.h>
-
-#include <sys/poll.h>
-
-/*--------------------------------------------------------------------*/
-/*--- end                                              vg_unsafe.h ---*/
-/*--------------------------------------------------------------------*/
index 608dfe8f09c7e5c8c1e973f3d0bb72574d65e6d8..0726110cde6b158cbcb8909896828565ec130f20 100644 (file)
@@ -74,9 +74,9 @@ extern Int VG_(sys_modify_ldt) ( ThreadId tid,
 
 /* Simulate the {get,set}_thread_area syscalls. */
 extern Int VG_(sys_set_thread_area) ( ThreadId tid,
-                                      struct vki_modify_ldt_ldt_s* info );
+                                      vki_modify_ldt_t* info );
 extern Int VG_(sys_get_thread_area) ( ThreadId tid,
-                                      struct vki_modify_ldt_ldt_s* info );
+                                      vki_modify_ldt_t* info );
 
 /* Called from generated code.  Given a segment selector and a virtual
    address, return a linear address, and do limit checks too. */
index 5202ac5699ea300eeec6151f3a2f5fd1049a3436..97ccbcda03cca6f1b13a35c80b167c6acbc159f2 100644 (file)
@@ -137,7 +137,7 @@ void VG_(clear_TLS_for_thread) ( VgLdtEntry* tls )
    if (0)
       VG_(printf)("clear_TLS_for_thread\n" );
 
-   for (tlsp = tls; tlsp < tls + VKI_GDT_TLS_ENTRIES; tlsp++) {
+   for (tlsp = tls; tlsp < tls + VKI_GDT_ENTRY_TLS_ENTRIES; tlsp++) {
       tlsp->LdtEnt.Words.word1 = 0;
       tlsp->LdtEnt.Words.word2 = 0;
    }
@@ -203,13 +203,13 @@ Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr )
    if (table == 0) {
       VgLdtEntry* the_tls;
 
-      vg_assert(seg_selector >= VKI_GDT_TLS_MIN && seg_selector < VKI_GDT_TLS_MAX);
+      vg_assert(seg_selector >= VKI_GDT_ENTRY_TLS_MIN && seg_selector <= VKI_GDT_ENTRY_TLS_MAX);
 
       /* Come up with a suitable GDT entry.  We look at the thread's TLS
         array, which is pointed to by a VG_(baseBlock) entry. */
       the_tls = (VgLdtEntry*)VG_(baseBlock)[VGOFF_(tls_ptr)];
-      base = (Addr)wine_ldt_get_base ( &the_tls[seg_selector-VKI_GDT_TLS_MIN] );
-      limit = (UInt)wine_ldt_get_limit ( &the_tls[seg_selector-VKI_GDT_TLS_MIN] );
+      base = (Addr)wine_ldt_get_base ( &the_tls[seg_selector-VKI_GDT_ENTRY_TLS_MIN] );
+      limit = (UInt)wine_ldt_get_limit ( &the_tls[seg_selector-VKI_GDT_ENTRY_TLS_MIN] );
    } else {
       VgLdtEntry* the_ldt;
 
@@ -257,7 +257,7 @@ Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr )
    Linux kernel's logic (cut-n-paste of code in linux/kernel/ldt.c).  */
 
 static
-void translate_to_hw_format ( /* IN  */ struct vki_modify_ldt_ldt_s* inn,
+void translate_to_hw_format ( /* IN  */ vki_modify_ldt_t* inn,
                              /* OUT */ VgLdtEntry* out,
                                         Int oldmode )
 {
@@ -351,7 +351,7 @@ Int write_ldt ( ThreadId tid, void* ptr, UInt bytecount, Int oldmode )
 {
    Int error;
    VgLdtEntry* ldt;
-   struct vki_modify_ldt_ldt_s* ldt_info; 
+   vki_modify_ldt_t* ldt_info; 
 
    if (0)
       VG_(printf)("write_ldt: tid = %d, ptr = %p, "
@@ -359,10 +359,10 @@ Int write_ldt ( ThreadId tid, void* ptr, UInt bytecount, Int oldmode )
                   tid, ptr, bytecount, oldmode );
 
    ldt      = VG_(threads)[tid].arch.ldt;
-   ldt_info = (struct vki_modify_ldt_ldt_s*)ptr;
+   ldt_info = (vki_modify_ldt_t*)ptr;
 
    error = -VKI_EINVAL;
-   if (bytecount != sizeof(struct vki_modify_ldt_ldt_s))
+   if (bytecount != sizeof(vki_modify_ldt_t))
       goto out;
 
    error = -VKI_EINVAL;
@@ -418,24 +418,24 @@ Int VG_(sys_modify_ldt) ( ThreadId tid,
 
 
 Int VG_(sys_set_thread_area) ( ThreadId tid,
-                               struct vki_modify_ldt_ldt_s* info )
+                               vki_modify_ldt_t* info )
 {
    Int idx = info->entry_number;
 
    if (idx == -1) {
-      for (idx = 0; idx < VKI_GDT_TLS_ENTRIES; idx++) {
+      for (idx = 0; idx < VKI_GDT_ENTRY_TLS_ENTRIES; idx++) {
          VgLdtEntry* tls = VG_(threads)[tid].arch.tls + idx;
 
          if (tls->LdtEnt.Words.word1 == 0 && tls->LdtEnt.Words.word2 == 0)
             break;
       }
 
-      if (idx == VKI_GDT_TLS_ENTRIES)
+      if (idx == VKI_GDT_ENTRY_TLS_ENTRIES)
          return -VKI_ESRCH;
-   } else if (idx < VKI_GDT_TLS_MIN || idx > VKI_GDT_TLS_MAX) {
+   } else if (idx < VKI_GDT_ENTRY_TLS_MIN || idx > VKI_GDT_ENTRY_TLS_MAX) {
       return -VKI_EINVAL;
    } else {
-      idx = info->entry_number - VKI_GDT_TLS_MIN;
+      idx = info->entry_number - VKI_GDT_ENTRY_TLS_MIN;
    }
 
    translate_to_hw_format(info, VG_(threads)[tid].arch.tls + idx, 0);
@@ -443,7 +443,7 @@ Int VG_(sys_set_thread_area) ( ThreadId tid,
    VG_TRACK( pre_mem_write, Vg_CoreSysCall, tid,
              "set_thread_area(info->entry)",
              (Addr) & info->entry_number, sizeof(unsigned int) );
-   info->entry_number = idx + VKI_GDT_TLS_MIN;
+   info->entry_number = idx + VKI_GDT_ENTRY_TLS_MIN;
    VG_TRACK( post_mem_write,
              (Addr) & info->entry_number, sizeof(unsigned int) );
 
@@ -452,15 +452,15 @@ Int VG_(sys_set_thread_area) ( ThreadId tid,
 
 
 Int VG_(sys_get_thread_area) ( ThreadId tid,
-                               struct vki_modify_ldt_ldt_s* info )
+                               vki_modify_ldt_t* info )
 {
    Int idx = info->entry_number;
    VgLdtEntry* tls;
 
-   if (idx < VKI_GDT_TLS_MIN || idx > VKI_GDT_TLS_MAX)
+   if (idx < VKI_GDT_ENTRY_TLS_MIN || idx > VKI_GDT_ENTRY_TLS_MAX)
       return -VKI_EINVAL;
 
-   tls = VG_(threads)[tid].arch.tls + idx - VKI_GDT_TLS_MIN;
+   tls = VG_(threads)[tid].arch.tls + idx - VKI_GDT_ENTRY_TLS_MIN;
 
    info->base_addr = ( tls->LdtEnt.Bits.BaseHi << 24 ) |
                      ( tls->LdtEnt.Bits.BaseMid << 16 ) |
index 9c20cec2c0baacd53a55d2a31e94ab5e399469b6..b1a251547d11e8aad22d4f69befda033b39d57c5 100644 (file)
@@ -258,7 +258,7 @@ typedef struct {
 
    /* TLS table. This consists of a small number (currently 3) of
       entries from the Global Descriptor Table. */
-   VgLdtEntry tls[VKI_GDT_TLS_ENTRIES];
+   VgLdtEntry tls[VKI_GDT_ENTRY_TLS_ENTRIES];
 
    /* Saved machine context.  Note the FPU state, %EIP and segment
       registers are not shadowed.
index 40db0bca0cb1b00451975b4efc1c471f69800f17..3c0c6ea9c9a763f5b2460900b172bbb5fed1075a 100644 (file)
@@ -130,7 +130,7 @@ void VGA_(thread_wrapper)(arch_thread_aux_t *aux)
 
    if (tls_data) {
       tcbhead_t *tcb = tls_data;
-      struct vki_modify_ldt_ldt_s ldt_info;
+      vki_modify_ldt_t ldt_info;
 
       /* Fill in the TCB header */
       tcb->tcb = tcb;
index db6a1f07784f4cbc210de5f9ba0c354804d164f1..ed8cf4bbd3a675fce954cfc3b87b93a714040b83 100644 (file)
@@ -73,7 +73,7 @@ typedef
       /* Sanity check word. */
       UInt magicPI;
       /* pointed to by psigInfo */
-      vki_ksiginfo_t sigInfo;
+      vki_siginfo_t sigInfo;
       /* pointed to by puContext */
       struct vki_ucontext uContext;
 
@@ -104,7 +104,7 @@ typedef
       UInt sh_eflags;
 
       /* saved signal mask to be restored when handler returns */
-      vki_ksigset_t    mask;
+      vki_sigset_t     mask;
 
       /* Scheduler-private stuff: what was the thread's status prior to
          delivering this signal? */
@@ -123,8 +123,8 @@ typedef
 /*------------------------------------------------------------*/
 
 /* Make up a plausible-looking thread state from the thread's current state */
-static void synth_ucontext(ThreadId tid, const vki_ksiginfo_t *si, 
-                          const vki_ksigset_t *set, struct vki_ucontext *uc)
+static void synth_ucontext(ThreadId tid, const vki_siginfo_t *si, 
+                          const vki_sigset_t *set, struct vki_ucontext *uc)
 {
    ThreadState *tst = VG_(get_ThreadState)(tid);
    struct vki_sigcontext *sc = &uc->uc_mcontext;
@@ -168,9 +168,9 @@ static void synth_ucontext(ThreadId tid, const vki_ksiginfo_t *si,
                   post_reg_write_deliver_signal)
 
 void VGA_(push_signal_frame)(ThreadId tid, Addr esp_top_of_frame,
-                             const vki_ksiginfo_t *siginfo,
+                             const vki_siginfo_t *siginfo,
                              void *handler, UInt flags,
-                             const vki_ksigset_t *mask)
+                             const vki_sigset_t *mask)
 {
    Addr                esp;
    ThreadState* tst;
@@ -211,7 +211,7 @@ void VGA_(push_signal_frame)(ThreadId tid, Addr esp_top_of_frame,
 
       VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame (siginfo)", 
                (Addr)&frame->sigInfo, sizeof(frame->sigInfo) );
-      VG_(memcpy)(&frame->sigInfo, siginfo, sizeof(vki_ksiginfo_t));
+      VG_(memcpy)(&frame->sigInfo, siginfo, sizeof(vki_siginfo_t));
       VG_TRACK( post_mem_write, (Addr)&frame->sigInfo, sizeof(frame->sigInfo) );
 
       VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame (siginfo)", 
@@ -232,7 +232,7 @@ void VGA_(push_signal_frame)(ThreadId tid, Addr esp_top_of_frame,
       VG_TRACK( post_mem_write, (Addr)&frame->handlerArgs, 
                sizeof(frame->handlerArgs.sigContext) );
       
-      frame->handlerArgs.sigContext.oldmask = tst->sig_mask.ws[0];
+      frame->handlerArgs.sigContext.oldmask = tst->sig_mask.sig[0];
    }
 
    frame->magicPI    = 0x31415927;
@@ -362,7 +362,7 @@ Int VGA_(pop_signal_frame)(ThreadId tid)
 /*--- Making coredumps                                     ---*/
 /*------------------------------------------------------------*/
 
-void VGA_(fill_elfregs_from_BB)(struct user_regs_struct* regs)
+void VGA_(fill_elfregs_from_BB)(struct vki_user_regs_struct* regs)
 {
    regs->eflags = VG_(baseBlock)[VGOFF_(m_eflags)];
    regs->esp    = VG_(baseBlock)[VGOFF_(m_esp)];
@@ -385,7 +385,7 @@ void VGA_(fill_elfregs_from_BB)(struct user_regs_struct* regs)
 }
 
 
-void VGA_(fill_elfregs_from_tst)(struct user_regs_struct* regs, 
+void VGA_(fill_elfregs_from_tst)(struct vki_user_regs_struct* regs, 
                                  const arch_thread_t* arch)
 {
    regs->eflags = arch->m_eflags;
@@ -408,7 +408,7 @@ void VGA_(fill_elfregs_from_tst)(struct user_regs_struct* regs,
    regs->gs     = arch->m_gs;
 }
 
-static void fill_fpu(elf_fpregset_t *fpu, const Char *from)
+static void fill_fpu(vki_elf_fpregset_t *fpu, const Char *from)
 {
    if (VG_(have_ssestate)) {
       UShort *to;
@@ -426,23 +426,23 @@ static void fill_fpu(elf_fpregset_t *fpu, const Char *from)
       VG_(memcpy)(fpu, from, sizeof(*fpu));
 }
 
-void VGA_(fill_elffpregs_from_BB)( elf_fpregset_t* fpu )
+void VGA_(fill_elffpregs_from_BB)( vki_elf_fpregset_t* fpu )
 {
    fill_fpu(fpu, (const Char *)&VG_(baseBlock)[VGOFF_(m_ssestate)]);
 }
 
-void VGA_(fill_elffpregs_from_tst)( elf_fpregset_t* fpu,
+void VGA_(fill_elffpregs_from_tst)( vki_elf_fpregset_t* fpu,
                                     const arch_thread_t* arch)
 {
    fill_fpu(fpu, (const Char *)&arch->m_sse);
 }
 
-void VGA_(fill_elffpxregs_from_BB) ( elf_fpxregset_t* xfpu )
+void VGA_(fill_elffpxregs_from_BB) ( vki_elf_fpxregset_t* xfpu )
 {
    VG_(memcpy)(xfpu, &VG_(baseBlock)[VGOFF_(m_ssestate)], sizeof(*xfpu));
 }
 
-void VGA_(fill_elffpxregs_from_tst) ( elf_fpxregset_t* xfpu,
+void VGA_(fill_elffpxregs_from_tst) ( vki_elf_fpxregset_t* xfpu,
                                       const arch_thread_t* arch )
 {
    VG_(memcpy)(xfpu, arch->m_sse, sizeof(*xfpu));
index 57df8aed260ea95f59468a56670a3ff1bd36d564..7bcdb1fa3e8271367fc91fac7217d294b36d5773 100644 (file)
@@ -570,7 +570,7 @@ Bool VGA_(setup_pointercheck)(void)
    vki_modify_ldt_t ldt = { 
       VG_POINTERCHECK_SEGIDX,    // entry_number
       VG_(client_base),          // base_addr
-      (VG_(client_end)-VG_(client_base)) / VKI_BYTES_PER_PAGE, // limit
+      (VG_(client_end)-VG_(client_base)) / VKI_PAGE_SIZE, // limit
       1,                         // seg_32bit
       0,                         // contents: data, RW, non-expanding
       0,                         // ! read_exec_only
@@ -595,7 +595,7 @@ Bool VGA_(setup_pointercheck)(void)
 
 Int VGA_(ptrace_setregs_from_BB)(Int pid)
 {
-   struct user_regs_struct regs;
+   struct vki_user_regs_struct regs;
 
    regs.cs     = VG_(baseBlock)[VGOFF_(m_cs)];
    regs.ss     = VG_(baseBlock)[VGOFF_(m_ss)];
@@ -619,7 +619,7 @@ Int VGA_(ptrace_setregs_from_BB)(Int pid)
 
 Int VGA_(ptrace_setregs_from_tst)(Int pid, arch_thread_t* arch)
 {
-   struct user_regs_struct regs;
+   struct vki_user_regs_struct regs;
 
    regs.cs     = arch->m_cs;
    regs.ss     = arch->m_ss;
index ad8370e547c4f4766c2b0d60ddd194c8f1641a7b..f9974627b547ae7265bfc4316a84b1fbfcfa1b0a 100644 (file)
@@ -1,5 +1,5 @@
 
-SUBDIRS = $(VG_ARCH) .
+SUBDIRS = $(VG_ARCH) $(VG_OS) $(VG_PLATFORM) .
 
 EXTRA_DIST = \
        tool.h.base \
@@ -12,7 +12,6 @@ incinc_HEADERS = \
        tool.h \
        tool_asm.h \
        valgrind.h \
-       vg_kerneliface.h \
        vg_skin.h
 
 BUILT_SOURCES = tool.h valgrind.h
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
new file mode 100644 (file)
index 0000000..4db7837
--- /dev/null
@@ -0,0 +1,4 @@
+incincdir = $(includedir)/valgrind/linux
+
+incinc_HEADERS = vki.h
+
diff --git a/include/linux/vki.h b/include/linux/vki.h
new file mode 100644 (file)
index 0000000..a26739b
--- /dev/null
@@ -0,0 +1,1714 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Linux-specific kernel interface.                 linux/vki.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, an extensible x86 protected-mode
+   emulator for monitoring program execution on x86-Unixes.
+
+   Copyright (C) 2000-2004 Julian Seward 
+      jseward@acm.org
+
+   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, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307, USA.
+
+   The GNU General Public License is contained in the file COPYING.
+*/
+
+/* This file defines types and constants for the kernel interface, and to
+   make that clear everything is prefixed VKI_/vki_.
+
+   All code is copied verbatim from kernel source files, except that:
+   - VKI_/vki_ prefixes are added
+   - a few extra constants are defined (eg. VKI_MAP_NOSYMS);  these are
+     marked 'internal'
+   - some extra explanatory comments are included;  they are all within
+     "[[ ]]"
+   - for some types, we only care about the size;  for a few of them (big
+     ones that are painful to fully drag in here), a VKI_SIZEOF_* constant
+     is used.
+   
+   The files the code is taken from is indicated.
+
+   Note especially that the types are not the glibc versions, many of which
+   are different to those in here. 
+
+   Also note that all the necessary headers for this architecture are in
+   this one file.  Since some Linux headers are generic, this means that
+   some code duplication will occur between different vki.h files between
+   different Linux Valgrind ports.  This is because it's difficult to
+   separate the generic and arch-specific parts for Valgrind's purpose
+   without introducing lots of separate files, since the dependencies
+   between headers is quite complex.  The resulting code duplication is not
+   a big deal, since the header code should not change over time.  
+
+   Finally, note that it is assumed that __KERNEL__ is set for all these
+   definitions, which affects some of them.
+*/
+
+#ifndef __LINUX_VKI_H
+#define __LINUX_VKI_H
+
+//----------------------------------------------------------------------
+// Arch-specific POSIX types
+//----------------------------------------------------------------------
+
+#include "vki_arch_posixtypes.h"
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/compiler.h
+//----------------------------------------------------------------------
+
+# define __user
+
+# define __attribute_const__    /* unimplemented */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/posix_types.h
+//----------------------------------------------------------------------
+
+typedef int __vki_kernel_key_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/types.h
+//----------------------------------------------------------------------
+
+typedef __vki_kernel_mode_t    vki_mode_t;
+typedef __vki_kernel_off_t     vki_off_t;
+typedef __vki_kernel_pid_t     vki_pid_t;
+typedef __vki_kernel_key_t     vki_key_t;
+typedef __vki_kernel_suseconds_t       vki_suseconds_t;
+typedef __vki_kernel_timer_t   vki_timer_t;
+
+// [[Nb: it's a bit unclear due to a #ifdef, but I think this is right. --njn]]
+typedef __vki_kernel_uid32_t   vki_uid_t;
+typedef __vki_kernel_gid32_t   vki_gid_t;
+
+typedef __vki_kernel_loff_t    vki_loff_t;
+
+typedef __vki_kernel_size_t    vki_size_t;
+typedef __vki_kernel_time_t    vki_time_t;
+typedef __vki_kernel_clock_t   vki_clock_t;
+typedef __vki_kernel_caddr_t   vki_caddr_t;
+
+//----------------------------------------------------------------------
+// Now the rest of the arch-specific stuff
+//----------------------------------------------------------------------
+
+#include "vki_arch.h"
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/limits.h
+//----------------------------------------------------------------------
+
+#define VKI_PATH_MAX       4096        /* # chars in a path name including nul */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/kernel.h
+//----------------------------------------------------------------------
+
+struct vki_sysinfo {
+       long uptime;                    /* Seconds since boot */
+       unsigned long loads[3];         /* 1, 5, and 15 minute load averages */
+       unsigned long totalram;         /* Total usable main memory size */
+       unsigned long freeram;          /* Available memory size */
+       unsigned long sharedram;        /* Amount of shared memory */
+       unsigned long bufferram;        /* Memory used by buffers */
+       unsigned long totalswap;        /* Total swap space size */
+       unsigned long freeswap;         /* swap space still available */
+       unsigned short procs;           /* Number of current processes */
+       unsigned short pad;             /* explicit padding for m68k */
+       unsigned long totalhigh;        /* Total high memory size */
+       unsigned long freehigh;         /* Available high memory size */
+       unsigned int mem_unit;          /* Memory unit size in bytes */
+       char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/byteorder/swab.h
+//----------------------------------------------------------------------
+
+#define ___vki_swab16(x) \
+({ \
+       __vki_u16 __x = (x); \
+       ((__vki_u16)( \
+               (((__vki_u16)(__x) & (__vki_u16)0x00ffU) << 8) | \
+               (((__vki_u16)(__x) & (__vki_u16)0xff00U) >> 8) )); \
+})
+
+/*
+ * provide defaults when no architecture-specific optimization is detected
+ */
+#ifndef __vki_arch__swab16
+#  define __vki_arch__swab16(x) ({ __vki_u16 __tmp = (x) ; ___vki_swab16(__tmp); })
+#endif
+
+// [[Nb: using the non-OPTIMIZE version here -- easier to understand, and
+//   we don't need the optimised version as we use this very rarely]]
+#  define __vki_swab16(x) __vki_fswab16(x)
+
+static __inline__ __attribute_const__ __vki_u16 __vki_fswab16(__vki_u16 x)
+{
+       return __vki_arch__swab16(x);
+}
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/byteorder/little_endian.h
+//----------------------------------------------------------------------
+
+#ifdef VKI_LITTLE_ENDIAN
+#define __vki_be16_to_cpu(x) __vki_swab16((x))
+#endif // VKI_LITTLE_ENDIAN
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/byteorder/big_endian.h
+//----------------------------------------------------------------------
+
+#ifdef VKI_BIG_ENDIAN
+#define __vki_be16_to_cpu(x) ((__vki_u16)(x))
+#endif // VKI_BIG_ENDIAN
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/byteorder/generic.h
+//----------------------------------------------------------------------
+
+#define ___vki_ntohs(x) __vki_be16_to_cpu(x)
+
+#define vki_ntohs(x) ___vki_ntohs(x)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/time.h
+//----------------------------------------------------------------------
+
+struct vki_timespec {
+       vki_time_t      tv_sec;         /* seconds */
+       long            tv_nsec;        /* nanoseconds */
+};
+
+struct vki_timeval {
+       vki_time_t      tv_sec;         /* seconds */
+       vki_suseconds_t tv_usec;        /* microseconds */
+};
+
+struct vki_timezone {
+       int     tz_minuteswest; /* minutes west of Greenwich */
+       int     tz_dsttime;     /* type of dst correction */
+};
+
+struct  vki_itimerspec {
+        struct  vki_timespec it_interval;    /* timer period */
+        struct  vki_timespec it_value;       /* timer expiration */
+};
+
+struct vki_itimerval {
+       struct  vki_timeval it_interval;        /* timer interval */
+       struct  vki_timeval it_value;   /* current value */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/timex.h
+//----------------------------------------------------------------------
+
+struct vki_timex {
+       unsigned int modes;     /* mode selector */
+       long offset;            /* time offset (usec) */
+       long freq;              /* frequency offset (scaled ppm) */
+       long maxerror;          /* maximum error (usec) */
+       long esterror;          /* estimated error (usec) */
+       int status;             /* clock command/status */
+       long constant;          /* pll time constant */
+       long precision;         /* clock precision (usec) (read only) */
+       long tolerance;         /* clock frequency tolerance (ppm)
+                                * (read only)
+                                */
+       struct vki_timeval time;        /* (read only) */
+       long tick;              /* (modified) usecs between clock ticks */
+
+       long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
+       long jitter;            /* pps jitter (us) (ro) */
+       int shift;              /* interval duration (s) (shift) (ro) */
+       long stabil;            /* pps stability (scaled ppm) (ro) */
+       long jitcnt;            /* jitter limit exceeded (ro) */
+       long calcnt;            /* calibration intervals (ro) */
+       long errcnt;            /* calibration errors (ro) */
+       long stbcnt;            /* stability limit exceeded (ro) */
+
+       int  :32; int  :32; int  :32; int  :32;
+       int  :32; int  :32; int  :32; int  :32;
+       int  :32; int  :32; int  :32; int  :32;
+};
+
+//#define ADJ_OFFSET           0x0001  /* time offset */
+#define ADJ_FREQUENCY          0x0002  /* frequency offset */
+#define ADJ_MAXERROR           0x0004  /* maximum time error */
+#define ADJ_ESTERROR           0x0008  /* estimated time error */
+#define ADJ_STATUS             0x0010  /* clock status */
+#define ADJ_TIMECONST          0x0020  /* pll time constant */
+#define ADJ_TICK               0x4000  /* tick value */
+//#define ADJ_OFFSET_SINGLESHOT        0x8001  /* old-fashioned adjtime */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/times.h
+//----------------------------------------------------------------------
+
+struct vki_tms {
+       vki_clock_t tms_utime;
+       vki_clock_t tms_stime;
+       vki_clock_t tms_cutime;
+       vki_clock_t tms_cstime;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/utime.h
+//----------------------------------------------------------------------
+
+struct vki_utimbuf {
+       vki_time_t actime;
+       vki_time_t modtime;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/sched.h
+//----------------------------------------------------------------------
+
+#define VKI_CLONE_VM           0x00000100      /* set if VM shared between processes */
+#define VKI_CLONE_FS           0x00000200      /* set if fs info shared between processes */
+#define VKI_CLONE_FILES                0x00000400      /* set if open files shared between processes */
+#define VKI_CLONE_SIGHAND      0x00000800      /* set if signal handlers and blocked signals shared */
+#define VKI_CLONE_THREAD       0x00010000      /* Same thread group? */
+#define VKI_CLONE_PARENT_SETTID        0x00100000      /* set the TID in the parent */
+#define VKI_CLONE_CHILD_CLEARTID       0x00200000      /* clear the TID in the child */
+#define VKI_CLONE_DETACHED     0x00400000      /* Unused, ignored */
+#define VKI_CLONE_CHILD_SETTID 0x01000000      /* set the TID in the child */
+
+struct vki_sched_param {
+       int sched_priority;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-generic/siginfo.h
+//----------------------------------------------------------------------
+
+typedef union vki_sigval {
+       int sival_int;
+       void __user *sival_ptr;
+} vki_sigval_t;
+
+#ifndef __VKI_ARCH_SI_PREAMBLE_SIZE
+#define __VKI_ARCH_SI_PREAMBLE_SIZE    (3 * sizeof(int))
+#endif
+
+#define VKI_SI_MAX_SIZE        128
+
+#ifndef VKI_SI_PAD_SIZE
+#define VKI_SI_PAD_SIZE        ((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
+#endif
+
+#ifndef __VKI_ARCH_SI_UID_T
+#define __VKI_ARCH_SI_UID_T    vki_uid_t
+#endif
+
+#ifndef __VKI_ARCH_SI_BAND_T
+#define __VKI_ARCH_SI_BAND_T long
+#endif
+
+// [[Nb: this type changed between 2.4 and 2.6, but not in a way that
+// affects Valgrind.]]
+typedef struct vki_siginfo {
+       int si_signo;
+       int si_errno;
+       int si_code;
+
+       union {
+               int _pad[VKI_SI_PAD_SIZE];
+
+               /* kill() */
+               struct {
+                       vki_pid_t _pid;         /* sender's pid */
+                       __VKI_ARCH_SI_UID_T _uid;       /* sender's uid */
+               } _kill;
+
+               /* POSIX.1b timers */
+               struct {
+                       vki_timer_t _tid;               /* timer id */
+                       int _overrun;           /* overrun count */
+                       char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)];
+                       vki_sigval_t _sigval;   /* same as below */
+                       int _sys_private;       /* not to be passed to user */
+               } _timer;
+
+               /* POSIX.1b signals */
+               struct {
+                       vki_pid_t _pid;         /* sender's pid */
+                       __VKI_ARCH_SI_UID_T _uid;       /* sender's uid */
+                       vki_sigval_t _sigval;
+               } _rt;
+
+               /* SIGCHLD */
+               struct {
+                       vki_pid_t _pid;         /* which child */
+                       __VKI_ARCH_SI_UID_T _uid;       /* sender's uid */
+                       int _status;            /* exit code */
+                       vki_clock_t _utime;
+                       vki_clock_t _stime;
+               } _sigchld;
+
+               /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
+               struct {
+                       void __user *_addr; /* faulting insn/memory ref. */
+#ifdef __ARCH_SI_TRAPNO
+                       int _trapno;    /* TRAP # which caused the signal */
+#endif
+               } _sigfault;
+
+               /* SIGPOLL */
+               struct {
+                       __VKI_ARCH_SI_BAND_T _band;     /* POLL_IN, POLL_OUT, POLL_MSG */
+                       int _fd;
+               } _sigpoll;
+       } _sifields;
+} vki_siginfo_t;
+
+/*
+ * si_code values
+ * Digital reserves positive values for kernel-generated signals.
+ */
+#define VKI_SI_USER    0               /* sent by kill, sigsend, raise */
+#define VKI_SI_TKILL   -6              /* sent by tkill system call */
+
+#define VKI_SIGEV_MAX_SIZE     64
+#ifndef VKI_SIGEV_PAD_SIZE
+#define VKI_SIGEV_PAD_SIZE     ((VKI_SIGEV_MAX_SIZE/sizeof(int)) - 3)
+#endif
+
+// [[Nb: in 2.6.8.1, this constant is never defined...]]
+#ifndef HAVE_ARCH_SIGEVENT_T
+
+typedef struct vki_sigevent {
+       vki_sigval_t sigev_value;
+       int sigev_signo;
+       int sigev_notify;
+       union {
+               int _pad[VKI_SIGEV_PAD_SIZE];
+                int _tid;
+
+               struct {
+                       void (*_function)(vki_sigval_t);
+                       void *_attribute;       /* really pthread_attr_t */
+               } _sigev_thread;
+       } _sigev_un;
+} vki_sigevent_t;
+
+#endif
+
+//----------------------------------------------------------------------
+// From elsewhere...
+//----------------------------------------------------------------------
+
+// [[The kernel actually uses the numbers 0,1,2 directly here, believe it or
+// not.  So we introduce our own constants, based on the glibc ones.]]
+#define VKI_SEEK_SET              0
+#define VKI_SEEK_CUR              1
+#define VKI_SEEK_END              2
+
+// [[Our own additional mmap flags]]
+#define VKI_MAP_NOSYMS  0x40000000      // internal: disable symbol loading
+#define VKI_MAP_CLIENT  0x80000000      // internal: distinguish client mappings
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/net.h
+//----------------------------------------------------------------------
+
+#define VKI_SYS_SOCKET         1       /* sys_socket(2)                */
+#define VKI_SYS_BIND           2       /* sys_bind(2)                  */
+#define VKI_SYS_CONNECT                3       /* sys_connect(2)               */
+#define VKI_SYS_LISTEN         4       /* sys_listen(2)                */
+#define VKI_SYS_ACCEPT         5       /* sys_accept(2)                */
+#define VKI_SYS_GETSOCKNAME    6       /* sys_getsockname(2)           */
+#define VKI_SYS_GETPEERNAME    7       /* sys_getpeername(2)           */
+#define VKI_SYS_SOCKETPAIR     8       /* sys_socketpair(2)            */
+#define VKI_SYS_SEND           9       /* sys_send(2)                  */
+#define VKI_SYS_RECV           10      /* sys_recv(2)                  */
+#define VKI_SYS_SENDTO         11      /* sys_sendto(2)                */
+#define VKI_SYS_RECVFROM       12      /* sys_recvfrom(2)              */
+#define VKI_SYS_SHUTDOWN       13      /* sys_shutdown(2)              */
+#define VKI_SYS_SETSOCKOPT     14      /* sys_setsockopt(2)            */
+#define VKI_SYS_GETSOCKOPT     15      /* sys_getsockopt(2)            */
+#define VKI_SYS_SENDMSG                16      /* sys_sendmsg(2)               */
+#define VKI_SYS_RECVMSG                17      /* sys_recvmsg(2)               */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/uio.h
+//----------------------------------------------------------------------
+
+struct vki_iovec
+{
+       void __user *iov_base;  /* BSD uses caddr_t (1003.1g requires void *) */
+       __vki_kernel_size_t iov_len; /* Must be size_t (1003.1g) */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/socket.h
+//----------------------------------------------------------------------
+
+// [[Resolved arbitrarily;  doesn't really matter whether it's '__inline__'
+//   or 'inline']]
+#define __KINLINE static __inline__
+
+typedef unsigned short vki_sa_family_t;
+
+struct vki_sockaddr {
+       vki_sa_family_t sa_family;      /* address family, AF_xxx       */
+       char            sa_data[14];    /* 14 bytes of protocol address */
+};
+
+struct vki_msghdr {
+       void    *       msg_name;       /* Socket name                  */
+       int             msg_namelen;    /* Length of name               */
+       struct vki_iovec *      msg_iov;        /* Data blocks                  */
+       __vki_kernel_size_t     msg_iovlen;     /* Number of blocks             */
+       void    *       msg_control;    /* Per protocol magic (eg BSD file descriptor passing) */
+       __vki_kernel_size_t     msg_controllen; /* Length of cmsg list */
+       unsigned        msg_flags;
+};
+
+struct vki_cmsghdr {
+       __vki_kernel_size_t     cmsg_len;       /* data byte count, including hdr */
+        int            cmsg_level;     /* originating protocol */
+        int            cmsg_type;      /* protocol-specific type */
+};
+
+#define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
+#define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
+
+#define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
+
+#define VKI_CMSG_DATA(cmsg)    ((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
+
+#define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
+                                 (struct vki_cmsghdr *)(ctl) : \
+                                 (struct vki_cmsghdr *)NULL)
+#define VKI_CMSG_FIRSTHDR(msg) __VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+
+// [[Urgh, this is revolting...]
+__KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_t __size,
+                                              struct vki_cmsghdr *__cmsg)
+{
+       struct vki_cmsghdr * __ptr;
+
+       __ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
+       if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
+               return (struct vki_cmsghdr *)0;
+
+       return __ptr;
+}
+
+__KINLINE struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
+{
+       return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
+}
+
+#define        VKI_SCM_RIGHTS  0x01            /* rw: access rights (array of int) */
+
+#define VKI_AF_UNIX    1       /* Unix domain sockets          */
+#define VKI_AF_INET    2       /* Internet IP Protocol         */
+#define VKI_AF_INET6   10      /* IP version 6                 */
+
+#define VKI_MSG_NOSIGNAL       0x4000  /* Do not generate SIGPIPE */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/in.h
+//----------------------------------------------------------------------
+
+struct vki_in_addr {
+       __vki_u32       s_addr;
+};
+
+/* Structure describing an Internet (IP) socket address. */
+#define __VKI_SOCK_SIZE__      16      /* sizeof(struct sockaddr)      */
+struct vki_sockaddr_in {
+  vki_sa_family_t      sin_family;     /* Address family               */
+  unsigned short int   sin_port;       /* Port number                  */
+  struct vki_in_addr   sin_addr;       /* Internet address             */
+
+  /* Pad to size of `struct sockaddr'. */
+  unsigned char                __pad[__VKI_SOCK_SIZE__ - sizeof(short int) -
+                       sizeof(unsigned short int) - sizeof(struct vki_in_addr)];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/in6.h
+//----------------------------------------------------------------------
+
+struct vki_in6_addr
+{
+       union 
+       {
+               __vki_u8        u6_addr8[16];
+               __vki_u16       u6_addr16[8];
+               __vki_u32       u6_addr32[4];
+       } vki_in6_u;
+#define vki_s6_addr            vki_in6_u.u6_addr8
+#define vki_s6_addr16          vki_in6_u.u6_addr16
+#define vki_s6_addr32          vki_in6_u.u6_addr32
+};
+
+struct vki_sockaddr_in6 {
+       unsigned short int      sin6_family;    /* AF_INET6 */
+       __vki_u16               sin6_port;      /* Transport layer port # */
+       __vki_u32               sin6_flowinfo;  /* IPv6 flow information */
+       struct vki_in6_addr     sin6_addr;      /* IPv6 address */
+       __vki_u32               sin6_scope_id;  /* scope id (new in RFC2553) */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/un.h
+//----------------------------------------------------------------------
+
+#define VKI_UNIX_PATH_MAX      108
+
+struct vki_sockaddr_un {
+       vki_sa_family_t sun_family;     /* AF_UNIX */
+       char sun_path[VKI_UNIX_PATH_MAX];       /* pathname */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/if.h
+//----------------------------------------------------------------------
+
+#define        VKI_IFNAMSIZ    16
+
+struct vki_ifmap 
+{
+       unsigned long mem_start;
+       unsigned long mem_end;
+       unsigned short base_addr; 
+       unsigned char irq;
+       unsigned char dma;
+       unsigned char port;
+       /* 3 bytes spare */
+};
+
+struct vki_if_settings
+{
+       unsigned int type;      /* Type of physical device or protocol */
+       unsigned int size;      /* Size of the data allocated by the caller */
+       union {
+                // [[Nb: converted these all to void* to avoid pulling in
+                //   unnecessary headers]]]
+               /* {atm/eth/dsl}_settings anyone ? */
+               void /*raw_hdlc_proto           */__user *raw_hdlc;
+               void /*cisco_proto              */__user *cisco;
+               void /*fr_proto                 */__user *fr;
+               void /*fr_proto_pvc             */__user *fr_pvc;
+               void /*fr_proto_pvc_info        */__user *fr_pvc_info;
+
+               /* interface settings */
+               void /*sync_serial_settings     */__user *sync;
+               void /*te1_settings             */__user *te1;
+       } ifs_ifsu;
+};
+
+struct vki_ifreq 
+{
+#define VKI_IFHWADDRLEN        6
+       union
+       {
+               char    ifrn_name[VKI_IFNAMSIZ];                /* if name, e.g. "en0" */
+       } ifr_ifrn;
+       
+       union {
+               struct  vki_sockaddr ifru_addr;
+               struct  vki_sockaddr ifru_dstaddr;
+               struct  vki_sockaddr ifru_broadaddr;
+               struct  vki_sockaddr ifru_netmask;
+               struct  vki_sockaddr ifru_hwaddr;
+               short   ifru_flags;
+               int     ifru_ivalue;
+               int     ifru_mtu;
+               struct  vki_ifmap ifru_map;
+               char    ifru_slave[VKI_IFNAMSIZ];       /* Just fits the size */
+               char    ifru_newname[VKI_IFNAMSIZ];
+               void __user *   ifru_data;
+               struct  vki_if_settings ifru_settings;
+       } ifr_ifru;
+};
+
+#define vki_ifr_name   ifr_ifrn.ifrn_name      /* interface name       */
+#define ifr_hwaddr     ifr_ifru.ifru_hwaddr    /* MAC address          */
+#define        ifr_addr        ifr_ifru.ifru_addr      /* address              */
+#define        ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-p lnk */
+#define        ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address    */
+#define        ifr_netmask     ifr_ifru.ifru_netmask   /* interface net mask   */
+#define        vki_ifr_flags   ifr_ifru.ifru_flags     /* flags                */
+#define        vki_ifr_metric  ifr_ifru.ifru_ivalue    /* metric               */
+#define        vki_ifr_mtu             ifr_ifru.ifru_mtu       /* mtu                  */
+#define ifr_map                ifr_ifru.ifru_map       /* device map           */
+#define ifr_slave      ifr_ifru.ifru_slave     /* slave device         */
+#define        vki_ifr_data    ifr_ifru.ifru_data      /* for use by interface */
+#define vki_ifr_ifindex        ifr_ifru.ifru_ivalue    /* interface index      */
+#define ifr_bandwidth  ifr_ifru.ifru_ivalue    /* link bandwidth       */
+#define ifr_qlen       ifr_ifru.ifru_ivalue    /* Queue length         */
+#define ifr_newname    ifr_ifru.ifru_newname   /* New name             */
+#define ifr_settings   ifr_ifru.ifru_settings  /* Device/proto settings*/
+
+struct vki_ifconf 
+{
+       int     ifc_len;                        /* size of buffer       */
+       union 
+       {
+               char __user *ifcu_buf;
+               struct vki_ifreq __user *ifcu_req;
+       } ifc_ifcu;
+};
+#define        vki_ifc_buf     ifc_ifcu.ifcu_buf       /* buffer address       */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/if_arp.h
+//----------------------------------------------------------------------
+
+struct vki_arpreq {
+  struct vki_sockaddr  arp_pa;         /* protocol address             */
+  struct vki_sockaddr  arp_ha;         /* hardware address             */
+  int                  arp_flags;      /* flags                        */
+  struct vki_sockaddr   arp_netmask;    /* netmask (only for proxy arps) */
+  char                 arp_dev[16];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/route.h
+//----------------------------------------------------------------------
+
+struct vki_rtentry 
+{
+       unsigned long   rt_pad1;
+       struct vki_sockaddr     rt_dst;         /* target address               */
+       struct vki_sockaddr     rt_gateway;     /* gateway addr (RTF_GATEWAY)   */
+       struct vki_sockaddr     rt_genmask;     /* target network mask (IP)     */
+       unsigned short  rt_flags;
+       short           rt_pad2;
+       unsigned long   rt_pad3;
+       void            *rt_pad4;
+       short           rt_metric;      /* +1 for binary compatibility! */
+       char __user     *rt_dev;        /* forcing the device at add    */
+       unsigned long   rt_mtu;         /* per route MTU/Window         */
+// [[Not important for Valgrind]]
+//#ifndef __KERNEL__
+//#define rt_mss       rt_mtu          /* Compatibility :-(            */
+//#endif
+       unsigned long   rt_window;      /* Window clamping              */
+       unsigned short  rt_irtt;        /* Initial RTT                  */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/resource.h
+//----------------------------------------------------------------------
+
+struct vki_rusage {
+       struct vki_timeval ru_utime;    /* user time used */
+       struct vki_timeval ru_stime;    /* system time used */
+       long    ru_maxrss;              /* maximum resident set size */
+       long    ru_ixrss;               /* integral shared memory size */
+       long    ru_idrss;               /* integral unshared data size */
+       long    ru_isrss;               /* integral unshared stack size */
+       long    ru_minflt;              /* page reclaims */
+       long    ru_majflt;              /* page faults */
+       long    ru_nswap;               /* swaps */
+       long    ru_inblock;             /* block input operations */
+       long    ru_oublock;             /* block output operations */
+       long    ru_msgsnd;              /* messages sent */
+       long    ru_msgrcv;              /* messages received */
+       long    ru_nsignals;            /* signals received */
+       long    ru_nvcsw;               /* voluntary context switches */
+       long    ru_nivcsw;              /* involuntary " */
+};
+
+struct vki_rlimit {
+       unsigned long   rlim_cur;
+       unsigned long   rlim_max;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/elfcore.h
+//----------------------------------------------------------------------
+
+struct vki_elf_siginfo
+{
+       int     si_signo;                       /* signal number */
+       int     si_code;                        /* extra code */
+       int     si_errno;                       /* errno */
+};
+
+// [[Removed some commented out lines here]]
+struct vki_elf_prstatus
+{
+       struct vki_elf_siginfo pr_info; /* Info associated with signal */
+       short   pr_cursig;              /* Current signal */
+       unsigned long pr_sigpend;       /* Set of pending signals */
+       unsigned long pr_sighold;       /* Set of held signals */
+       vki_pid_t       pr_pid;
+       vki_pid_t       pr_ppid;
+       vki_pid_t       pr_pgrp;
+       vki_pid_t       pr_sid;
+       struct vki_timeval pr_utime;    /* User time */
+       struct vki_timeval pr_stime;    /* System time */
+       struct vki_timeval pr_cutime;   /* Cumulative user time */
+       struct vki_timeval pr_cstime;   /* Cumulative system time */
+       vki_elf_gregset_t pr_reg;       /* GP registers */
+       int pr_fpvalid;         /* True if math co-processor being used.  */
+};
+
+#define VKI_ELF_PRARGSZ        (80)    /* Number of chars for args */
+
+struct vki_elf_prpsinfo
+{
+       char    pr_state;       /* numeric process state */
+       char    pr_sname;       /* char for pr_state */
+       char    pr_zomb;        /* zombie */
+       char    pr_nice;        /* nice val */
+       unsigned long pr_flag;  /* flags */
+       __vki_kernel_uid_t      pr_uid;
+       __vki_kernel_gid_t      pr_gid;
+       vki_pid_t       pr_pid, pr_ppid, pr_pgrp, pr_sid;
+       /* Lots missing */
+       char    pr_fname[16];   /* filename of executable */
+       char    pr_psargs[VKI_ELF_PRARGSZ];     /* initial part of arg list */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/eventpoll.h
+//----------------------------------------------------------------------
+
+#ifdef __x86_64__
+#define VKI_EPOLL_PACKED __attribute__((packed))
+#else
+#define VKI_EPOLL_PACKED
+#endif
+
+struct epoll_event {
+       __vki_u32 events;
+       __vki_u64 data;
+} VKI_EPOLL_PACKED;
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/mqueue.h
+//----------------------------------------------------------------------
+
+struct vki_mq_attr {
+       long    mq_flags;       /* message queue flags                  */
+       long    mq_maxmsg;      /* maximum number of messages           */
+       long    mq_msgsize;     /* maximum message size                 */
+       long    mq_curmsgs;     /* number of messages currently queued  */
+       long    __reserved[4];  /* ignored for input, zeroed for output */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/utsname.h
+//----------------------------------------------------------------------
+
+// [[Nb: newer kernels seem to use new_utsname, rather than old_utsname or
+//   oldold_utsname]]
+struct vki_new_utsname {
+       char sysname[65];
+       char nodename[65];
+       char release[65];
+       char version[65];
+       char machine[65];
+       char domainname[65];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/mii.h
+//----------------------------------------------------------------------
+
+/* This structure is used in all SIOCxMIIxxx ioctl calls */
+struct vki_mii_ioctl_data {
+       vki_u16         phy_id;
+       vki_u16         reg_num;
+       vki_u16         val_in;
+       vki_u16         val_out;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/capability.h
+//----------------------------------------------------------------------
+
+// [[capget()/capset() man page says this, ominously:
+//
+//   The kernel API is likely to change and use of these functions  (in
+//   particular the format of the cap_user_*_t types) is subject to
+//   change with each kernel revision.
+//
+// However, the format hasn't changed since at least Linux 2.4.6.]]
+
+typedef struct __vki_user_cap_header_struct {
+       __vki_u32 version;
+       int pid;
+} __user *vki_cap_user_header_t;
+typedef struct __vki_user_cap_data_struct {
+        __vki_u32 effective;
+        __vki_u32 permitted;
+        __vki_u32 inheritable;
+} __user *vki_cap_user_data_t;
+  
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/module.h
+//----------------------------------------------------------------------
+
+// [[We do a VKI_SIZEOF_* here because this type is so big, and its size
+//   depends on the word size, so see vki_arch.h]]
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/ipc.h
+//----------------------------------------------------------------------
+
+/* Obsolete, used only for backwards compatibility and libc5 compiles */
+struct vki_ipc_perm
+{
+       __vki_kernel_key_t      key;
+       __vki_kernel_uid_t      uid;
+       __vki_kernel_gid_t      gid;
+       __vki_kernel_uid_t      cuid;
+       __vki_kernel_gid_t      cgid;
+       __vki_kernel_mode_t     mode; 
+       unsigned short  seq;
+};
+
+#define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
+#define VKI_IPC_EXCL   00002000   /* fail if key exists */
+#define VKI_IPC_NOWAIT 00004000   /* return error on wait */
+
+//#define VKI_IPC_RMID 0     /* remove resource */
+#define VKI_IPC_SET  1     /* set ipc_perm options */
+#define VKI_IPC_STAT 2     /* get ipc_perm options */
+#define VKI_IPC_INFO 3     /* see ipcs */
+
+#define VKI_IPC_64  0x0100  /* New version (support 32-bit UIDs, bigger
+                              message sizes, etc. */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/sem.h
+//----------------------------------------------------------------------
+
+#define VKI_GETALL  13       /* get all semval's */
+#define VKI_SETVAL  16       /* set semval */
+#define VKI_SETALL  17       /* set all semval's */
+
+#define VKI_SEM_STAT 18
+#define VKI_SEM_INFO 19
+
+/* Obsolete, used only for backwards compatibility and libc5 compiles */
+struct vki_semid_ds {
+       struct vki_ipc_perm     sem_perm;               /* permissions .. see ipc.h */
+       __vki_kernel_time_t     sem_otime;              /* last semop time */
+       __vki_kernel_time_t     sem_ctime;              /* last change time */
+        // [[Use void* to avoid excess header copying]]
+       void/*struct sem        */*sem_base;            /* ptr to first semaphore in array */
+       void/*struct sem_queue */*sem_pending;          /* pending operations to be processed */
+       void/*struct sem_queue */**sem_pending_last;    /* last pending operation */
+       void/*struct sem_undo   */*undo;                        /* undo requests on this array */
+       unsigned short  sem_nsems;              /* no. of semaphores in array */
+};
+
+struct vki_sembuf {
+       unsigned short  sem_num;        /* semaphore index in array */
+       short           sem_op;         /* semaphore operation */
+       short           sem_flg;        /* operation flags */
+};
+
+union vki_semun {
+       int val;                        /* value for SETVAL */
+       struct vki_semid_ds __user *buf;        /* buffer for IPC_STAT & IPC_SET */
+       unsigned short __user *array;   /* array for GETALL & SETALL */
+       struct vki_seminfo __user *__buf;       /* buffer for IPC_INFO */
+       void __user *__pad;
+};
+
+struct  vki_seminfo {
+       int semmap;
+       int semmni;
+       int semmns;
+       int semmnu;
+       int semmsl;
+       int semopm;
+       int semume;
+       int semusz;
+       int semvmx;
+       int semaem;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-generic/errno-base.h
+//----------------------------------------------------------------------
+
+#define        VKI_EPERM                1      /* Operation not permitted */
+#define        VKI_ESRCH                3      /* No such process */
+#define        VKI_EINTR                4      /* Interrupted system call */
+#define        VKI_EBADF                9      /* Bad file number */
+#define        VKI_ENOMEM              12      /* Out of memory */
+#define        VKI_EACCES              13      /* Permission denied */
+#define        VKI_EFAULT              14      /* Bad address */
+#define        VKI_EEXIST              17      /* File exists */
+#define        VKI_EINVAL              22      /* Invalid argument */
+#define        VKI_EMFILE              24      /* Too many open files */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-generic/errno.h
+//----------------------------------------------------------------------
+
+#define        VKI_ENOSYS              38      /* Function not implemented */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/wait.h
+//----------------------------------------------------------------------
+
+#define VKI_WNOHANG    0x00000001
+
+#define __VKI_WALL     0x40000000      /* Wait on all children, regardless of type */
+#define __VKI_WCLONE   0x80000000      /* Wait only on non-SIGCHLD children */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/mman.h
+//----------------------------------------------------------------------
+
+#define VKI_MREMAP_MAYMOVE     1
+#define VKI_MREMAP_FIXED       2
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/futex.h
+//----------------------------------------------------------------------
+
+#define VKI_FUTEX_WAIT (0)
+#define VKI_FUTEX_FD (2)
+#define VKI_FUTEX_REQUEUE (3)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/errno.h
+//----------------------------------------------------------------------
+
+#define VKI_ERESTARTSYS        512
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/stat.h
+//----------------------------------------------------------------------
+
+#define VKI_S_IRUSR 00400
+#define VKI_S_IWUSR 00200
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/dirent.h
+//----------------------------------------------------------------------
+
+struct vki_dirent {
+       long            d_ino;
+       __vki_kernel_off_t      d_off;
+       unsigned short  d_reclen;
+       char            d_name[256]; /* We must not include limits.h! */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/sysctl.h
+//----------------------------------------------------------------------
+
+struct __vki_sysctl_args {
+       int __user *name;
+       int nlen;
+       void __user *oldval;
+       vki_size_t __user *oldlenp;
+       void __user *newval;
+       vki_size_t newlen;
+       unsigned long __unused[4];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/aio_abi.h
+//----------------------------------------------------------------------
+
+typedef unsigned long  vki_aio_context_t;
+
+enum {
+       VKI_IOCB_CMD_PREAD = 0,
+       VKI_IOCB_CMD_PWRITE = 1,
+};
+
+/* read() from /dev/aio returns these structures. */
+struct vki_io_event {
+       __vki_u64       data;           /* the data field from the iocb */
+       __vki_u64       obj;            /* what iocb this event came from */
+        // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is
+        //   a macro in vg_syscalls.c!]]
+       __vki_s64       result;         /* result code for this event */
+       __vki_s64       result2;        /* secondary result */
+};
+
+#define VKI_PADDED(x,y)        x, y
+#if defined(VKI_LITTLE_ENDIAN)
+#define VKI_PADDED(x,y)        x, y
+#elif defined(VKI_BIG_ENDIAN)
+#define VKI_PADDED(x,y)        y, x
+#else
+#error edit for your odd byteorder.
+#endif
+
+struct vki_iocb {
+       /* these are internal to the kernel/libc. */
+       __vki_u64       aio_data;       /* data to be returned in event's data */
+       __vki_u32       VKI_PADDED(aio_key, aio_reserved1);
+                               /* the kernel sets aio_key to the req # */
+
+       /* common fields */
+       __vki_u16       aio_lio_opcode; /* see IOCB_CMD_ above */
+       __vki_s16       aio_reqprio;
+       __vki_u32       aio_fildes;
+
+       __vki_u64       aio_buf;
+       __vki_u64       aio_nbytes;
+       __vki_s64       aio_offset;
+
+       /* extra parameters */
+       __vki_u64       aio_reserved2;  /* TODO: use this for a (struct sigevent *) */
+       __vki_u64       aio_reserved3;
+}; /* 64 bytes */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/aio.h
+//----------------------------------------------------------------------
+
+struct vki_aio_ring {
+       unsigned        id;     /* kernel internal index number */
+       unsigned        nr;     /* number of io_events */
+       unsigned        head;
+       unsigned        tail;
+
+       unsigned        magic;
+       unsigned        compat_features;
+       unsigned        incompat_features;
+       unsigned        header_length;  /* size of aio_ring */
+
+       struct vki_io_event             io_events[0];
+}; /* 128 bytes + ring size */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/msg.h
+//----------------------------------------------------------------------
+
+#define VKI_MSG_STAT 11
+#define VKI_MSG_INFO 12
+
+struct vki_msqid_ds {
+       struct vki_ipc_perm msg_perm;
+       struct vki_msg *msg_first;              /* first message on queue,unused  */
+       struct vki_msg *msg_last;               /* last message in queue,unused */
+       __vki_kernel_time_t msg_stime;  /* last msgsnd time */
+       __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
+       __vki_kernel_time_t msg_ctime;  /* last change time */
+       unsigned long  msg_lcbytes;     /* Reuse junk fields for 32 bit */
+       unsigned long  msg_lqbytes;     /* ditto */
+       unsigned short msg_cbytes;      /* current number of bytes on queue */
+       unsigned short msg_qnum;        /* number of messages in queue */
+       unsigned short msg_qbytes;      /* max number of bytes on queue */
+       __vki_kernel_ipc_pid_t msg_lspid;       /* pid of last msgsnd */
+       __vki_kernel_ipc_pid_t msg_lrpid;       /* last receive pid */
+};
+
+struct vki_msgbuf {
+       long mtype;         /* type of message */
+       char mtext[1];      /* message text */
+};
+
+struct vki_msginfo {
+       int msgpool;
+       int msgmap; 
+       int msgmax; 
+       int msgmnb; 
+       int msgmni; 
+       int msgssz; 
+       int msgtql; 
+       unsigned short  msgseg; 
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/shm.h
+//----------------------------------------------------------------------
+
+struct vki_shmid_ds {
+       struct vki_ipc_perm             shm_perm;       /* operation perms */
+       int                     shm_segsz;      /* size of segment (bytes) */
+       __vki_kernel_time_t             shm_atime;      /* last attach time */
+       __vki_kernel_time_t             shm_dtime;      /* last detach time */
+       __vki_kernel_time_t             shm_ctime;      /* last change time */
+       __vki_kernel_ipc_pid_t  shm_cpid;       /* pid of creator */
+       __vki_kernel_ipc_pid_t  shm_lpid;       /* pid of last operator */
+       unsigned short          shm_nattch;     /* no. of current attaches */
+       unsigned short          shm_unused;     /* compatibility */
+       void                    *shm_unused2;   /* ditto - used by DIPC */
+       void                    *shm_unused3;   /* unused */
+};
+
+#define VKI_SHM_STAT   13
+#define VKI_SHM_INFO   14
+
+/* Obsolete, used only for backwards compatibility */
+struct vki_shminfo {
+       int shmmax;
+       int shmmin;
+       int shmmni;
+       int shmseg;
+       int shmall;
+};
+
+struct vki_shm_info {
+       int used_ids;
+       unsigned long shm_tot;  /* total allocated shm */
+       unsigned long shm_rss;  /* total resident shm */
+       unsigned long shm_swp;  /* total swapped shm */
+       unsigned long swap_attempts;
+       unsigned long swap_successes;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/rtc.h
+//----------------------------------------------------------------------
+
+struct vki_rtc_time {
+       int tm_sec;
+       int tm_min;
+       int tm_hour;
+       int tm_mday;
+       int tm_mon;
+       int tm_year;
+       int tm_wday;
+       int tm_yday;
+       int tm_isdst;
+};
+
+#define VKI_RTC_AIE_ON _VKI_IO('p', 0x01)      /* Alarm int. enable on */
+#define VKI_RTC_AIE_OFF        _VKI_IO('p', 0x02)      /* ... off              */
+#define VKI_RTC_UIE_ON _VKI_IO('p', 0x03)      /* Update int. enable on*/
+#define VKI_RTC_UIE_OFF        _VKI_IO('p', 0x04)      /* ... off              */
+#define VKI_RTC_PIE_ON _VKI_IO('p', 0x05)      /* Periodic int. enable on*/
+#define VKI_RTC_PIE_OFF        _VKI_IO('p', 0x06)      /* ... off              */
+
+#define VKI_RTC_ALM_SET                _VKI_IOW('p', 0x07, struct vki_rtc_time) /* Set alarm time  */
+#define VKI_RTC_ALM_READ       _VKI_IOR('p', 0x08, struct vki_rtc_time) /* Read alarm time */
+#define VKI_RTC_RD_TIME                _VKI_IOR('p', 0x09, struct vki_rtc_time) /* Read RTC time   */
+//#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
+#define VKI_RTC_IRQP_READ      _VKI_IOR('p', 0x0b, unsigned long)       /* Read IRQ rate   */
+#define VKI_RTC_IRQP_SET       _VKI_IOW('p', 0x0c, unsigned long)       /* Set IRQ rate    */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/isdn.h
+//----------------------------------------------------------------------
+
+#define VKI_IIOCGETCPS  _VKI_IO('I',21)
+
+#define VKI_IIOCNETGPN  _VKI_IO('I',34)
+
+#define VKI_ISDN_MSNLEN          32
+
+typedef struct {
+  char name[10];
+  char phone[VKI_ISDN_MSNLEN];
+  int  outgoing;
+} vki_isdn_net_ioctl_phone;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/sockios.h
+//----------------------------------------------------------------------
+
+#define VKI_SIOCOUTQ           VKI_TIOCOUTQ
+
+#define VKI_SIOCADDRT          0x890B  /* add routing table entry      */
+#define VKI_SIOCDELRT          0x890C  /* delete routing table entry   */
+
+#define VKI_SIOCGIFNAME                0x8910  /* get iface name               */
+#define VKI_SIOCGIFCONF                0x8912  /* get iface list               */
+#define VKI_SIOCGIFFLAGS       0x8913  /* get flags                    */
+#define VKI_SIOCSIFFLAGS       0x8914  /* set flags                    */
+#define VKI_SIOCGIFADDR                0x8915  /* get PA address               */
+#define VKI_SIOCSIFADDR                0x8916  /* set PA address               */
+#define VKI_SIOCGIFDSTADDR     0x8917  /* get remote PA address        */
+#define VKI_SIOCSIFDSTADDR     0x8918  /* set remote PA address        */
+#define VKI_SIOCGIFBRDADDR     0x8919  /* get broadcast PA address     */
+#define VKI_SIOCSIFBRDADDR     0x891a  /* set broadcast PA address     */
+#define VKI_SIOCGIFNETMASK     0x891b  /* get network PA mask          */
+#define VKI_SIOCSIFNETMASK     0x891c  /* set network PA mask          */
+#define VKI_SIOCGIFMETRIC      0x891d  /* get metric                   */
+#define VKI_SIOCSIFMETRIC      0x891e  /* set metric                   */
+#define VKI_SIOCGIFMTU         0x8921  /* get MTU size                 */
+#define VKI_SIOCSIFMTU         0x8922  /* set MTU size                 */
+#define        VKI_SIOCSIFHWADDR       0x8924  /* set hardware address         */
+#define VKI_SIOCGIFHWADDR      0x8927  /* Get hardware address         */
+#define VKI_SIOCGIFINDEX       0x8933  /* name -> if_index mapping     */
+
+#define VKI_SIOCGIFTXQLEN      0x8942  /* Get the tx queue length      */
+#define VKI_SIOCSIFTXQLEN      0x8943  /* Set the tx queue length      */
+
+#define VKI_SIOCGMIIPHY                0x8947  /* Get address of MII PHY in use. */
+#define VKI_SIOCGMIIREG                0x8948  /* Read MII PHY register.       */
+#define VKI_SIOCSMIIREG                0x8949  /* Write MII PHY register.      */
+
+#define VKI_SIOCDARP           0x8953  /* delete ARP table entry       */
+#define VKI_SIOCGARP           0x8954  /* get ARP table entry          */
+#define VKI_SIOCSARP           0x8955  /* set ARP table entry          */
+
+#define VKI_SIOCDRARP          0x8960  /* delete RARP table entry      */
+#define VKI_SIOCGRARP          0x8961  /* get RARP table entry         */
+#define VKI_SIOCSRARP          0x8962  /* set RARP table entry         */
+
+#define VKI_SIOCGIFMAP         0x8970  /* Get device parameters        */
+#define VKI_SIOCSIFMAP         0x8971  /* Set device parameters        */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/ppdev.h
+//----------------------------------------------------------------------
+
+#define VKI_PP_MAJOR   99
+
+#define VKI_PP_IOCTL   'p'
+
+/* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
+#define VKI_PPSETMODE  _VKI_IOW(VKI_PP_IOCTL, 0x80, int)
+
+/* Read status */
+#define VKI_PPRSTATUS  _VKI_IOR(VKI_PP_IOCTL, 0x81, unsigned char)
+//#define PPWSTATUS    OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
+
+/* Read/write control */
+#define VKI_PPRCONTROL _VKI_IOR(VKI_PP_IOCTL, 0x83, unsigned char)
+#define VKI_PPWCONTROL _VKI_IOW(VKI_PP_IOCTL, 0x84, unsigned char)
+
+struct vki_ppdev_frob_struct {
+       unsigned char mask;
+       unsigned char val;
+};
+#define VKI_PPFCONTROL      _VKI_IOW(VKI_PP_IOCTL, 0x8e, struct vki_ppdev_frob_struct)
+
+/* Read/write data */
+#define VKI_PPRDATA            _VKI_IOR(VKI_PP_IOCTL, 0x85, unsigned char)
+#define VKI_PPWDATA            _VKI_IOW(VKI_PP_IOCTL, 0x86, unsigned char)
+
+/* Claim the port to start using it */
+#define VKI_PPCLAIM            _VKI_IO(VKI_PP_IOCTL, 0x8b)
+
+/* Release the port when you aren't using it */
+#define VKI_PPRELEASE  _VKI_IO(VKI_PP_IOCTL, 0x8c)
+
+/* Yield the port (release it if another driver is waiting,
+ * then reclaim) */
+#define VKI_PPYIELD            _VKI_IO(VKI_PP_IOCTL, 0x8d)
+
+/* Register device exclusively (must be before PPCLAIM). */
+#define VKI_PPEXCL             _VKI_IO(VKI_PP_IOCTL, 0x8f)
+
+/* Data line direction: non-zero for input mode. */
+#define VKI_PPDATADIR  _VKI_IOW(VKI_PP_IOCTL, 0x90, int)
+
+/* Negotiate a particular IEEE 1284 mode. */
+#define VKI_PPNEGOT    _VKI_IOW(VKI_PP_IOCTL, 0x91, int)
+
+/* Set control lines when an interrupt occurs. */
+#define VKI_PPWCTLONIRQ        _VKI_IOW(VKI_PP_IOCTL, 0x92, unsigned char)
+
+/* Clear (and return) interrupt count. */
+#define VKI_PPCLRIRQ   _VKI_IOR(VKI_PP_IOCTL, 0x93, int)
+
+/* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
+#define VKI_PPSETPHASE _VKI_IOW(VKI_PP_IOCTL, 0x94, int)
+
+/* Set and get port timeout (struct timeval's) */
+#define VKI_PPGETTIME  _VKI_IOR(VKI_PP_IOCTL, 0x95, struct vki_timeval)
+#define VKI_PPSETTIME  _VKI_IOW(VKI_PP_IOCTL, 0x96, struct vki_timeval)
+
+#define VKI_PPGETMODES _VKI_IOR(VKI_PP_IOCTL, 0x97, unsigned int)
+
+#define VKI_PPGETMODE  _VKI_IOR(VKI_PP_IOCTL, 0x98, int)
+#define VKI_PPGETPHASE _VKI_IOR(VKI_PP_IOCTL, 0x99, int)
+
+#define VKI_PPGETFLAGS _VKI_IOR(VKI_PP_IOCTL, 0x9a, int)
+#define VKI_PPSETFLAGS _VKI_IOW(VKI_PP_IOCTL, 0x9b, int)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/fs.h
+//----------------------------------------------------------------------
+
+#define VKI_FIBMAP     _VKI_IO(0x00,1) /* bmap access */
+#define VKI_FIGETBSZ    _VKI_IO(0x00,2)        /* get the block size used for bmap */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/scsi/sg.h
+//----------------------------------------------------------------------
+
+typedef struct vki_sg_io_hdr
+{
+    int interface_id;           /* [i] 'S' for SCSI generic (required) */
+    int dxfer_direction;        /* [i] data transfer direction  */
+    unsigned char cmd_len;      /* [i] SCSI command length ( <= 16 bytes) */
+    unsigned char mx_sb_len;    /* [i] max length to write to sbp */
+    unsigned short iovec_count; /* [i] 0 implies no scatter gather */
+    unsigned int dxfer_len;     /* [i] byte count of data transfer */
+    void __user *dxferp;       /* [i], [*io] points to data transfer memory
+                                             or scatter gather list */
+    unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
+    void __user *sbp;          /* [i], [*o] points to sense_buffer memory */
+    unsigned int timeout;       /* [i] MAX_UINT->no timeout (unit: millisec) */
+    unsigned int flags;         /* [i] 0 -> default, see SG_FLAG... */
+    int pack_id;                /* [i->o] unused internally (normally) */
+    void __user * usr_ptr;      /* [i->o] unused internally */
+    unsigned char status;       /* [o] scsi status */
+    unsigned char masked_status;/* [o] shifted, masked scsi status */
+    unsigned char msg_status;   /* [o] messaging level data (optional) */
+    unsigned char sb_len_wr;    /* [o] byte count actually written to sbp */
+    unsigned short host_status; /* [o] errors from host adapter */
+    unsigned short driver_status;/* [o] errors from software driver */
+    int resid;                  /* [o] dxfer_len - actual_transferred */
+    unsigned int duration;      /* [o] time taken by cmd (unit: millisec) */
+    unsigned int info;          /* [o] auxiliary information */
+} vki_sg_io_hdr_t;  /* 64 bytes long (on i386) */
+
+typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
+    int host_no;        /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
+    int channel;
+    int scsi_id;        /* scsi id of target device */
+    int lun;
+    int scsi_type;      /* TYPE_... defined in scsi/scsi.h */
+    short h_cmd_per_lun;/* host (adapter) maximum commands per lun */
+    short d_queue_depth;/* device (or adapter) maximum queue length */
+    int unused[2];      /* probably find a good use, set 0 for now */
+} vki_sg_scsi_id_t; /* 32 bytes long on i386 */
+
+#define VKI_SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
+
+#define VKI_SG_SET_RESERVED_SIZE 0x2275  /* request a new reserved buffer size */
+#define VKI_SG_GET_RESERVED_SIZE 0x2272  /* actual size of reserved buffer */
+
+#define VKI_SG_GET_SCSI_ID 0x2276   /* Yields fd's bus, chan, dev, lun + type */
+
+#define VKI_SG_GET_SG_TABLESIZE 0x227F  /* 0 implies can't do scatter gather */
+
+#define VKI_SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
+
+#define VKI_SG_IO 0x2285   /* similar effect as write() followed by read() */
+
+#define VKI_SG_SET_TIMEOUT 0x2201  /* unit: jiffies (10ms on i386) */
+#define VKI_SG_GET_TIMEOUT 0x2202  /* yield timeout as _return_ value */
+
+//#define SG_GET_COMMAND_Q 0x2270   /* Yields 0 (queuing off) or 1 (on) */
+#define VKI_SG_SET_COMMAND_Q 0x2271   /* Change queuing state with 0 or 1 */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/cdrom.h
+//----------------------------------------------------------------------
+
+#define VKI_CDROMPLAYMSF       0x5303 /* Play Audio MSF (struct cdrom_msf) */
+#define VKI_CDROMREADTOCHDR    0x5305 /* Read TOC header 
+                                           (struct cdrom_tochdr) */
+#define VKI_CDROMREADTOCENTRY  0x5306 /* Read TOC entry 
+                                           (struct cdrom_tocentry) */
+#define VKI_CDROMSUBCHNL       0x530b /* Read subchannel data 
+                                           (struct cdrom_subchnl) */
+#define VKI_CDROMREADMODE2     0x530c /* Read CDROM mode 2 data (2336 Bytes) 
+                                           (struct cdrom_read) */
+#define VKI_CDROMREADAUDIO     0x530e /* (struct cdrom_read_audio) */
+#define VKI_CDROMMULTISESSION  0x5310 /* Obtain the start-of-last-session 
+                                           address of multi session disks 
+                                           (struct cdrom_multisession) */
+#define VKI_CDROM_GET_MCN      0x5311 /* Obtain the "Universal Product Code" 
+                                           if available (struct cdrom_mcn) */
+#define VKI_CDROMVOLREAD       0x5313 /* Get the drive's volume setting
+                                          (struct cdrom_volctrl) */
+#define VKI_CDROM_CLEAR_OPTIONS        0x5321  /* Clear behavior options */
+#define VKI_CDROM_DRIVE_STATUS 0x5326  /* Get tray position, etc. */
+
+#define VKI_CDROM_SEND_PACKET  0x5393  /* send a packet to the drive */
+
+struct vki_cdrom_msf0          
+{
+       __vki_u8        minute;
+       __vki_u8        second;
+       __vki_u8        frame;
+};
+
+union vki_cdrom_addr           
+{
+       struct vki_cdrom_msf0   msf;
+       int                     lba;
+};
+
+struct vki_cdrom_msf 
+{
+       __vki_u8        cdmsf_min0;     /* start minute */
+       __vki_u8        cdmsf_sec0;     /* start second */
+       __vki_u8        cdmsf_frame0;   /* start frame */
+       __vki_u8        cdmsf_min1;     /* end minute */
+       __vki_u8        cdmsf_sec1;     /* end second */
+       __vki_u8        cdmsf_frame1;   /* end frame */
+};
+
+struct vki_cdrom_tochdr        
+{
+       __vki_u8        cdth_trk0;      /* start track */
+       __vki_u8        cdth_trk1;      /* end track */
+};
+
+struct vki_cdrom_volctrl
+{
+       __vki_u8        channel0;
+       __vki_u8        channel1;
+       __vki_u8        channel2;
+       __vki_u8        channel3;
+};
+
+struct vki_cdrom_subchnl 
+{
+       __vki_u8        cdsc_format;
+       __vki_u8        cdsc_audiostatus;
+       __vki_u8        cdsc_adr:       4;
+       __vki_u8        cdsc_ctrl:      4;
+       __vki_u8        cdsc_trk;
+       __vki_u8        cdsc_ind;
+       union vki_cdrom_addr cdsc_absaddr;
+       union vki_cdrom_addr cdsc_reladdr;
+};
+
+struct vki_cdrom_tocentry 
+{
+       __vki_u8        cdte_track;
+       __vki_u8        cdte_adr        :4;
+       __vki_u8        cdte_ctrl       :4;
+       __vki_u8        cdte_format;
+       union vki_cdrom_addr cdte_addr;
+       __vki_u8        cdte_datamode;
+};
+
+struct vki_cdrom_read      
+{
+       int     cdread_lba;
+       char    *cdread_bufaddr;
+       int     cdread_buflen;
+};
+
+struct vki_cdrom_read_audio
+{
+       union vki_cdrom_addr addr; /* frame address */
+       __vki_u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
+       int nframes;           /* number of 2352-byte-frames to read at once */
+       __vki_u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
+};
+
+struct vki_cdrom_multisession
+{
+       union vki_cdrom_addr addr; /* frame address: start-of-last-session 
+                                  (not the new "frame 16"!).  Only valid
+                                  if the "xa_flag" is true. */
+       __vki_u8 xa_flag;        /* 1: "is XA disk" */
+       __vki_u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
+};
+
+struct vki_cdrom_mcn 
+{
+  __vki_u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
+};
+
+#define VKI_CDROM_PACKET_SIZE  12
+
+struct vki_cdrom_generic_command
+{
+       unsigned char           cmd[VKI_CDROM_PACKET_SIZE];
+       unsigned char           __user *buffer;
+       unsigned int            buflen;
+       int                     stat;
+        // [[replace with void* to reduce inclusion amounts]]
+       void/*struct vki_request_sense  */__user *sense;
+       unsigned char           data_direction;
+       int                     quiet;
+       int                     timeout;
+       void                    __user *reserved[1];    /* unused, actually */
+};
+
+#define VKI_CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
+#define VKI_CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
+#define VKI_CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
+#define VKI_CD_FRAMESIZE_RAW0 (VKI_CD_FRAMESIZE_RAW-VKI_CD_SYNC_SIZE-VKI_CD_HEAD_SIZE) /*2336*/
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/soundcard.h
+//----------------------------------------------------------------------
+
+#ifndef _VKI_SIOWR
+#if defined(_VKI_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
+/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
+#define        _VKI_SIO                _VKI_IO
+#define        _VKI_SIOR               _VKI_IOR
+#define        _VKI_SIOW               _VKI_IOW
+#define        _VKI_SIOWR              _VKI_IOWR
+#else
+// [[Valgrind: Install this case if/when necessary]
+#error Valgrind: Cannot handle sparc/sun case yet...
+#  endif /* _IOWR */
+#endif  /* !_VKI_SIOWR */
+
+#define VKI_SNDCTL_SEQ_CTRLRATE                _VKI_SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
+#define VKI_SNDCTL_SEQ_GETOUTCOUNT     _VKI_SIOR ('Q', 4, int)
+#define VKI_SNDCTL_SEQ_GETINCOUNT      _VKI_SIOR ('Q', 5, int)
+#define VKI_SNDCTL_SEQ_PERCMODE                _VKI_SIOW ('Q', 6, int)
+#define VKI_SNDCTL_SEQ_TESTMIDI                _VKI_SIOW ('Q', 8, int)
+#define VKI_SNDCTL_SEQ_RESETSAMPLES    _VKI_SIOW ('Q', 9, int)
+#define VKI_SNDCTL_SEQ_NRSYNTHS                _VKI_SIOR ('Q',10, int)
+#define VKI_SNDCTL_SEQ_NRMIDIS         _VKI_SIOR ('Q',11, int)
+#define VKI_SNDCTL_SEQ_GETTIME         _VKI_SIOR ('Q',19, int)
+
+#define VKI_SNDCTL_TMR_TIMEBASE                _VKI_SIOWR('T', 1, int)
+#define VKI_SNDCTL_TMR_TEMPO           _VKI_SIOWR('T', 5, int)
+#define VKI_SNDCTL_TMR_SOURCE          _VKI_SIOWR('T', 6, int)
+
+#define VKI_SNDCTL_MIDI_PRETIME                _VKI_SIOWR('m', 0, int)
+#define VKI_SNDCTL_MIDI_MPUMODE                _VKI_SIOWR('m', 1, int)
+
+#define VKI_SNDCTL_DSP_RESET           _VKI_SIO  ('P', 0)
+#define VKI_SNDCTL_DSP_SYNC            _VKI_SIO  ('P', 1)
+#define VKI_SNDCTL_DSP_SPEED           _VKI_SIOWR('P', 2, int)
+#define VKI_SNDCTL_DSP_STEREO          _VKI_SIOWR('P', 3, int)
+#define VKI_SNDCTL_DSP_GETBLKSIZE      _VKI_SIOWR('P', 4, int)
+#define VKI_SNDCTL_DSP_CHANNELS                _VKI_SIOWR('P', 6, int)
+#define VKI_SOUND_PCM_WRITE_FILTER     _VKI_SIOWR('P', 7, int)
+#define VKI_SNDCTL_DSP_POST            _VKI_SIO  ('P', 8)
+#define VKI_SNDCTL_DSP_SUBDIVIDE       _VKI_SIOWR('P', 9, int)
+#define VKI_SNDCTL_DSP_SETFRAGMENT     _VKI_SIOWR('P',10, int)
+
+#define VKI_SNDCTL_DSP_GETFMTS         _VKI_SIOR ('P',11, int) /* Returns a mask */
+
+typedef struct vki_audio_buf_info {
+                       int fragments;  /* # of available fragments (partially usend ones not counted) */
+                       int fragstotal; /* Total # of fragments allocated */
+                       int fragsize;   /* Size of a fragment in bytes */
+
+                       int bytes;      /* Available space in bytes (includes partially used fragments) */
+                       /* Note! 'bytes' could be more than fragments*fragsize */
+               } vki_audio_buf_info;
+
+#define VKI_SNDCTL_DSP_GETOSPACE       _VKI_SIOR ('P',12, vki_audio_buf_info)
+#define VKI_SNDCTL_DSP_GETISPACE       _VKI_SIOR ('P',13, vki_audio_buf_info)
+//#define VKI_SNDCTL_DSP_NONBLOCK      _VKI_SIO  ('P',14)
+#define VKI_SNDCTL_DSP_GETCAPS         _VKI_SIOR ('P',15, int)
+
+#define VKI_SNDCTL_DSP_GETTRIGGER      _VKI_SIOR ('P',16, int)
+#define VKI_SNDCTL_DSP_SETTRIGGER      _VKI_SIOW ('P',16, int)
+
+#define VKI_SNDCTL_DSP_SETSYNCRO       _VKI_SIO  ('P', 21)
+#define VKI_SNDCTL_DSP_SETDUPLEX       _VKI_SIO  ('P', 22)
+#define VKI_SNDCTL_DSP_GETODELAY       _VKI_SIOR ('P', 23, int)
+
+#define VKI_SNDCTL_DSP_SETSPDIF                _VKI_SIOW ('P', 66, int)
+#define VKI_SNDCTL_DSP_GETSPDIF                _VKI_SIOR ('P', 67, int)
+
+#define VKI_SOUND_PCM_READ_RATE                _VKI_SIOR ('P', 2, int)
+#define VKI_SOUND_PCM_READ_CHANNELS    _VKI_SIOR ('P', 6, int)
+#define VKI_SOUND_PCM_READ_BITS                _VKI_SIOR ('P', 5, int)
+#define VKI_SOUND_PCM_READ_FILTER      _VKI_SIOR ('P', 7, int)
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/hdreg.h
+//----------------------------------------------------------------------
+
+#define VKI_HDIO_GET_IDENTITY  0x030d  /* get IDE identification info */
+
+// [[Nb: done like this because the original type is a huge struct that will
+//   always be the same size.]]
+#define VKI_SIZEOF_STRUCT_HD_DRIVEID   512
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/fb.h
+//----------------------------------------------------------------------
+
+#define VKI_FBIOGET_VSCREENINFO        0x4600
+#define VKI_FBIOGET_FSCREENINFO        0x4602
+
+struct vki_fb_fix_screeninfo {
+       char id[16];                    /* identification string eg "TT Builtin" */
+       unsigned long smem_start;       /* Start of frame buffer mem */
+                                       /* (physical address) */
+       __vki_u32 smem_len;                     /* Length of frame buffer mem */
+       __vki_u32 type;                 /* see FB_TYPE_*                */
+       __vki_u32 type_aux;             /* Interleave for interleaved Planes */
+       __vki_u32 visual;               /* see FB_VISUAL_*              */ 
+       __vki_u16 xpanstep;             /* zero if no hardware panning  */
+       __vki_u16 ypanstep;             /* zero if no hardware panning  */
+       __vki_u16 ywrapstep;            /* zero if no hardware ywrap    */
+       __vki_u32 line_length;          /* length of a line in bytes    */
+       unsigned long mmio_start;       /* Start of Memory Mapped I/O   */
+                                       /* (physical address) */
+       __vki_u32 mmio_len;             /* Length of Memory Mapped I/O  */
+       __vki_u32 accel;                /* Indicate to driver which     */
+                                       /*  specific chip/card we have  */
+       __vki_u16 reserved[3];          /* Reserved for future compatibility */
+};
+
+struct vki_fb_bitfield {
+       __vki_u32 offset;               /* beginning of bitfield        */
+       __vki_u32 length;               /* length of bitfield           */
+       __vki_u32 msb_right;            /* != 0 : Most significant bit is */ 
+                                       /* right */ 
+};
+
+struct vki_fb_var_screeninfo {
+       __vki_u32 xres;                 /* visible resolution           */
+       __vki_u32 yres;
+       __vki_u32 xres_virtual;         /* virtual resolution           */
+       __vki_u32 yres_virtual;
+       __vki_u32 xoffset;              /* offset from virtual to visible */
+       __vki_u32 yoffset;              /* resolution                   */
+
+       __vki_u32 bits_per_pixel;       /* guess what                   */
+       __vki_u32 grayscale;            /* != 0 Graylevels instead of colors */
+
+       struct vki_fb_bitfield red;     /* bitfield in fb mem if true color, */
+       struct vki_fb_bitfield green;   /* else only length is significant */
+       struct vki_fb_bitfield blue;
+       struct vki_fb_bitfield transp;  /* transparency                 */      
+
+       __vki_u32 nonstd;               /* != 0 Non standard pixel format */
+
+       __vki_u32 activate;             /* see FB_ACTIVATE_*            */
+
+       __vki_u32 height;               /* height of picture in mm    */
+       __vki_u32 width;                /* width of picture in mm     */
+
+       __vki_u32 accel_flags;          /* (OBSOLETE) see fb_info.flags */
+
+       /* Timing: All values in pixclocks, except pixclock (of course) */
+       __vki_u32 pixclock;             /* pixel clock in ps (pico seconds) */
+       __vki_u32 left_margin;          /* time from sync to picture    */
+       __vki_u32 right_margin;         /* time from picture to sync    */
+       __vki_u32 upper_margin;         /* time from sync to picture    */
+       __vki_u32 lower_margin;
+       __vki_u32 hsync_len;            /* length of horizontal sync    */
+       __vki_u32 vsync_len;            /* length of vertical sync      */
+       __vki_u32 sync;                 /* see FB_SYNC_*                */
+       __vki_u32 vmode;                /* see FB_VMODE_*               */
+       __vki_u32 rotate;               /* angle we rotate counter clockwise */
+       __vki_u32 reserved[5];          /* Reserved for future compatibility */
+};
+
+#endif // __LINUX_VKI_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
index 4f9133100f1ff1b396908e4e921223ae1a2dfe3e..5830494c8be364edbbe973567dd7ddad3e6b5ecb 100644 (file)
@@ -69,7 +69,7 @@ typedef UChar                  Bool;      //  8              8
    ------------------------------------------------------------------ */
 
 #include "tool_arch.h"          // arch-specific tool stuff
-#include "vg_kerneliface.h"
+#include "vki.h"
 
 /* ---------------------------------------------------------------------
    Where to send bug reports to.
@@ -556,41 +556,41 @@ extern void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init);
 
    Note that these use the vk_ (kernel) structure
    definitions, which are different in places from those that glibc
-   defines -- hence the 'k' prefix.  Since we're operating right at the
-   kernel interface, glibc's view of the world is entirely irrelevant. */
+   defines.  Since we're operating right at the kernel interface, glibc's view
+   of the world is entirely irrelevant. */
 
 /* --- Signal set ops --- */
-extern Int  VG_(ksigfillset)  ( vki_ksigset_t* set );
-extern Int  VG_(ksigemptyset) ( vki_ksigset_t* set );
+extern Int  VG_(sigfillset)  ( vki_sigset_t* set );
+extern Int  VG_(sigemptyset) ( vki_sigset_t* set );
 
-extern Bool VG_(kisfullsigset)  ( vki_ksigset_t* set );
-extern Bool VG_(kisemptysigset) ( vki_ksigset_t* set );
+extern Bool VG_(isfullsigset)  ( vki_sigset_t* set );
+extern Bool VG_(isemptysigset) ( vki_sigset_t* set );
 
-extern Int  VG_(ksigaddset)   ( vki_ksigset_t* set, Int signum );
-extern Int  VG_(ksigdelset)   ( vki_ksigset_t* set, Int signum );
-extern Int  VG_(ksigismember) ( vki_ksigset_t* set, Int signum );
+extern Int  VG_(sigaddset)   ( vki_sigset_t* set, Int signum );
+extern Int  VG_(sigdelset)   ( vki_sigset_t* set, Int signum );
+extern Int  VG_(sigismember) ( vki_sigset_t* set, Int signum );
 
-extern void VG_(ksigaddset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
-extern void VG_(ksigdelset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
+extern void VG_(sigaddset_from_set) ( vki_sigset_t* dst, vki_sigset_t* src );
+extern void VG_(sigdelset_from_set) ( vki_sigset_t* dst, vki_sigset_t* src );
 
 /* --- Mess with the kernel's sig state --- */
-extern Int VG_(ksigprocmask) ( Int how, const vki_ksigset_t* set,
-                                       vki_ksigset_t* oldset );
-extern Int VG_(ksigaction)   ( Int signum,
-                               const vki_ksigaction* act,
-                               vki_ksigaction* oldact );
+extern Int VG_(sigprocmask) ( Int how, const vki_sigset_t* set,
+                              vki_sigset_t* oldset );
+extern Int VG_(sigaction)   ( Int signum,
+                              const struct vki_sigaction* act,
+                              struct vki_sigaction* oldact );
 
-extern Int VG_(ksigtimedwait)( const vki_ksigset_t *, vki_ksiginfo_t *, 
-                              const struct vki_timespec * );
+extern Int VG_(sigtimedwait)( const vki_sigset_t *, vki_siginfo_t *, 
+                             const struct vki_timespec * );
 
-extern Int VG_(ksignal)      ( Int signum, void (*sighandler)(Int) );
-extern Int VG_(ksigaltstack) ( const vki_kstack_t* ss, vki_kstack_t* oss );
+extern Int VG_(signal)      ( Int signum, void (*sighandler)(Int) );
+extern Int VG_(sigaltstack) ( const vki_stack_t* ss, vki_stack_t* oss );
 
-extern Int VG_(kkill)        ( Int pid, Int signo );
-extern Int VG_(ktkill)       ( Int pid, Int signo );
-extern Int VG_(ksigpending)  ( vki_ksigset_t* set );
+extern Int VG_(kill)        ( Int pid, Int signo );
+extern Int VG_(tkill)       ( Int pid, Int signo );
+extern Int VG_(sigpending)  ( vki_sigset_t* set );
 
-extern Int VG_(waitpid)             ( Int pid, Int *status, Int options );
+extern Int VG_(waitpid)            ( Int pid, Int *status, Int options );
 
 /* ------------------------------------------------------------------ */
 /* socket.h. */
diff --git a/include/vg_kerneliface.h b/include/vg_kerneliface.h
deleted file mode 100644 (file)
index 3d50b97..0000000
+++ /dev/null
@@ -1,943 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- A header file defining structures and constants which are    ---*/
-/*--- important at the kernel boundary for this platform.          ---*/
-/*---                                             vg_kerneliface.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
-   This file is part of Valgrind, an extensible x86 protected-mode
-   emulator for monitoring program execution on x86-Unixes.
-
-   Copyright (C) 2000-2004 Julian Seward 
-      jseward@acm.org
-
-   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, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307, USA.
-
-   The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef __VG_KERNELIFACE_H
-#define __VG_KERNELIFACE_H
-
-/* This file is ONLY to be included into core.h.  Do not include
-   it directly into valgrind source .c files.  This file defines types
-   and constants for the kernel interface, and to make that clear
-   everything is prefixed VKI. */
-
-/*--- All the following stuff is correct for Linux kernels 2.2.X and
-      2.4.X. 
----*/
-
-/* Should really get this from an include file somewhere. */
-#define VKI_BYTES_PER_PAGE_BITS 12
-#define VKI_BYTES_PER_PAGE (1 << VKI_BYTES_PER_PAGE_BITS)
-
-#define VKI_BYTES_PER_WORD 4
-#define VKI_WORDS_PER_PAGE (VKI_BYTES_PER_PAGE / VKI_BYTES_PER_WORD)
-
-
-/* An implementation of signal sets.  These are the same as the sigset
-   implementations in the relevant Linux kernels.  Note carefully that
-   this has nothing to do with glibc's signal sets.  We work entirely
-   at the kernel boundary, so the libc stuff is invisible and
-   irrelevant.  */
-
-/* The following is copied from
-   /usr/src/linux-2.4.9-13/include/asm-i386/signal.h */
-#define VKI_KNSIG       64  /* true for linux 2.2.X and 2.4.X */
-#define VKI_KNSIG_BPW   32  /* since we're using UInts */
-#define VKI_KNSIG_WORDS (VKI_KNSIG / VKI_KNSIG_BPW)
-
-typedef 
-   struct { 
-      UInt ws[VKI_KNSIG_WORDS]; 
-   }
-   vki_ksigset_t;
-
-
-typedef
-   struct {
-      void*         ksa_handler;
-      unsigned long ksa_flags;
-      void (*ksa_restorer)(void);
-      vki_ksigset_t ksa_mask;
-   }
-   vki_ksigaction;
-
-typedef 
-   struct {
-      void* ss_sp;
-      Int   ss_flags;
-      UInt  ss_size;
-   } 
-   vki_kstack_t;
-
-#define SI_MAX_SIZE    128
-#define SI_PAD_SIZE    ((SI_MAX_SIZE/sizeof(int)) - 3)
-
-union vki_sigval {
-   Int sival_int;
-   void *sival_ptr;
-};
-
-typedef
-   struct {
-      Int si_signo;
-      Int si_errno;
-      Int si_code;
-
-      union {
-        Int _pad[SI_PAD_SIZE];
-
-        /* kill() */
-        struct {
-           Int _pid;           /* sender's pid */
-           Short _uid;         /* sender's uid */
-        } _kill;
-
-        /* POSIX.1b timers */
-        struct {
-           UInt _timer1;
-           UInt _timer2;
-        } _timer;
-
-        /* POSIX.1b signals */
-        struct {
-           Int _pid;           /* sender's pid */
-           UShort _uid;                /* sender's uid */
-           union vki_sigval _sigval;
-        } _rt;
-
-        /* SIGCHLD */
-        struct {
-           Int _pid;           /* which child */
-           UShort _uid;                /* sender's uid */
-           Int _status;                /* exit code */
-           Int _utime;
-           Int _stime;
-        } _sigchld;
-
-        /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
-        struct {
-           void *_addr; /* faulting insn/memory ref. */
-        } _sigfault;
-
-        /* SIGPOLL */
-        struct {
-           Int _band;  /* POLL_IN, POLL_OUT, POLL_MSG */
-           Int _fd;
-        } _sigpoll;
-      } _sifields;
-   } vki_ksiginfo_t;
-
-/* linux-2.6/include/asm-generic/siginfo.h */
-
-#define VKI_SI_USER    0
-#define VKI_SI_QUEUE   -1
-#define VKI_SI_TKILL   -6
-
-struct vki_fpreg {
-       UShort significand[4];
-       UShort exponent;
-};
-
-struct vki_fpxreg {
-       UShort significand[4];
-       UShort exponent;
-       UShort padding[3];
-};
-
-struct vki_xmmreg {
-       UInt element[4];
-};
-
-struct vki_fpstate {
-       /* Regular FPU environment */
-       unsigned long   cw;
-       unsigned long   sw;
-       unsigned long   tag;
-       unsigned long   ipoff;
-       unsigned long   cssel;
-       unsigned long   dataoff;
-       unsigned long   datasel;
-       struct vki_fpreg        _st[8];
-       unsigned short  status;
-       unsigned short  magic;          /* 0xffff = regular FPU data only */
-
-       /* FXSR FPU environment */
-       unsigned long   _fxsr_env[6];   /* FXSR FPU env is ignored */
-       unsigned long   mxcsr;
-       unsigned long   reserved;
-       struct vki_fpxreg       _fxsr_st[8];    /* FXSR FPU reg data is ignored */
-       struct vki_xmmreg       _xmm[8];
-       unsigned long   padding[56];
-};
-
-#define X86_FXSR_MAGIC         0x0000
-
-struct vki_sigcontext {
-       UShort  gs, __gsh;
-       UShort  fs, __fsh;
-       UShort  es, __esh;
-       UShort  ds, __dsh;
-       UInt    edi;
-       UInt    esi;
-       UInt    ebp;
-       UInt    esp;
-       UInt    ebx;
-       UInt    edx;
-       UInt    ecx;
-       UInt    eax;
-       UInt    trapno;
-       UInt    err;
-       UInt    eip;
-       UShort  cs, __csh;
-       UInt    eflags;
-       UInt    esp_at_signal;
-       UShort  ss, __ssh;
-       struct  vki_fpstate * fpstate;
-       UInt    oldmask;
-       UInt    cr2;
-};
-
-struct vki_ucontext {
-       UInt              uc_flags;
-       struct vki_ucontext  *uc_link;
-       vki_kstack_t      uc_stack;
-       struct vki_sigcontext uc_mcontext;
-       vki_ksigset_t     uc_sigmask;   /* mask last for extensibility */
-};
-
-
-/* sigaltstack controls */
-#define VKI_SS_ONSTACK      1
-#define VKI_SS_DISABLE      2
-
-#define VKI_MINSIGSTKSZ     2048
-#define VKI_SIGSTKSZ        8192
-
-
-
-#define VKI_SIG_BLOCK          0    /* for blocking signals */
-#define VKI_SIG_UNBLOCK        1    /* for unblocking signals */
-#define VKI_SIG_SETMASK        2    /* for setting the signal mask */
-
-#define VKI_SIG_DFL ((void*)0)     /* default signal handling */
-#define VKI_SIG_IGN ((void*)1)     /* ignore signal */
-#define VKI_SIG_ERR ((void*)-1)    /* error return from signal */
-
-#define VKI_SA_ONSTACK      0x08000000
-#define VKI_SA_RESTART      0x10000000
-#define VKI_SA_NOCLDSTOP    0x00000001
-#define VKI_SA_SIGINFO      0x00000004
-#define VKI_SA_RESETHAND    0x80000000
-#define VKI_SA_ONESHOT      VKI_SA_RESETHAND
-#define VKI_SA_NODEFER      0x40000000
-#define VKI_SA_NOMASK       VKI_SA_NODEFER
-#define VKI_SA_NOCLDWAIT    0x00000002
-#define VKI_SA_RESTORER     0x04000000
-#if 0
-#define VKI_SA_INTERRUPT    0x20000000 /* dummy -- ignored */
-#endif
-
-/* extra wait flags */
-#define        VKI_WNOHANG     1               /* Don't block waiting.  */
-#define        VKI_WUNTRACED   2               /* Report status of stopped children.  */
-#define VKI__WALL      0x40000000      /* Wait for any child.  */
-#define VKI__WCLONE    0x80000000      /* Wait for cloned process.  */
-
-#define        VKI_SIGHUP      1       /* Hangup (POSIX).  */
-#define        VKI_SIGINT      2       /* Interrupt (ANSI).  */
-#define        VKI_SIGQUIT     3       /* Quit (POSIX).  */
-#define        VKI_SIGILL      4       /* Illegal instruction (ANSI).  */
-#define        VKI_SIGTRAP     5       /* Trace trap (POSIX).  */
-#define        VKI_SIGABRT     6       /* Abort (ANSI).  */
-#define        VKI_SIGIOT      6       /* IOT trap (4.2 BSD).  */
-#define        VKI_SIGBUS      7       /* BUS error (4.2 BSD).  */
-#define        VKI_SIGFPE      8       /* Floating-point exception (ANSI).  */
-#define        VKI_SIGKILL     9       /* Kill, unblockable (POSIX).  */
-#define        VKI_SIGUSR1     10      /* User-defined signal 1 (POSIX).  */
-#define        VKI_SIGSEGV     11      /* Segmentation violation (ANSI).  */
-#define        VKI_SIGUSR2     12      /* User-defined signal 2 (POSIX).  */
-#define        VKI_SIGPIPE     13      /* Broken pipe (POSIX).  */
-#define        VKI_SIGALRM     14      /* Alarm clock (POSIX).  */
-#define        VKI_SIGTERM     15      /* Termination (ANSI).  */
-#define        VKI_SIGSTKFLT   16      /* Stack fault.  */
-#define        VKI_SIGCLD      SIGCHLD /* Same as SIGCHLD (System V).  */
-#define        VKI_SIGCHLD     17      /* Child status has changed (POSIX).  */
-#define        VKI_SIGCONT     18      /* Continue (POSIX).  */
-#define        VKI_SIGSTOP     19      /* Stop, unblockable (POSIX).  */
-#define        VKI_SIGTSTP     20      /* Keyboard stop (POSIX).  */
-#define        VKI_SIGTTIN     21      /* Background read from tty (POSIX).  */
-#define        VKI_SIGTTOU     22      /* Background write to tty (POSIX).  */
-#define        VKI_SIGURG      23      /* Urgent condition on socket (4.2 BSD).  */
-#define        VKI_SIGXCPU     24      /* CPU limit exceeded (4.2 BSD).  */
-#define        VKI_SIGXFSZ     25      /* File size limit exceeded (4.2 BSD).  */
-#define        VKI_SIGVTALRM   26      /* Virtual alarm clock (4.2 BSD).  */
-#define        VKI_SIGPROF     27      /* Profiling alarm clock (4.2 BSD).  */
-#define        VKI_SIGWINCH    28      /* Window size change (4.3 BSD, Sun).  */
-#define        VKI_SIGPOLL     SIGIO   /* Pollable event occurred (System V).  */
-#define        VKI_SIGIO       29      /* I/O now possible (4.2 BSD).  */
-#define        VKI_SIGPWR      30      /* Power failure restart (System V).  */
-#define        VKI_SIGSYS      31      /* Bad system call.  */
-#define        VKI_SIGUNUSED   31
-
-#define VKI_SIGRTMIN       32
-#define VKI_SIGRTMAX       63
-
-#define VKI_SIGVGINT       (VKI_SIGRTMIN+0) /* signal for internal use - interrupt */
-#define VKI_SIGVGKILL      (VKI_SIGRTMIN+1) /* signal for internal use - kill */
-#define VKI_SIGRTUSERMIN    (VKI_SIGRTMIN+2) /* first user-usable RT signal */
-
-/* The following are copied from include/asm-i386/mman.h .*/
-
-#define VKI_PROT_NONE      0x0            /* No page permissions */
-#define VKI_PROT_READ      0x1             /* Page can be read.  */
-#define VKI_PROT_WRITE     0x2             /* Page can be written.  */
-#define VKI_PROT_EXEC      0x4             /* Page can be executed.  */
-#define VKI_MAP_ANONYMOUS  0x20            /* Don't use a file.  */
-#define VKI_MAP_SHARED    0x01            /* Share changes.  */
-#define VKI_MAP_PRIVATE    0x02            /* Changes are private.  */
-#define VKI_MAP_FIXED      0x10            /* Interpret addr exactly */
-#define VKI_MAP_NOSYMS     0x40000000     /* internal pseudo-flag to disable symbol loading */
-#define VKI_MAP_CLIENT     0x80000000     /* internal pseudo-flag to distinguish client mappings */
-
-/* linux/mman.h */
-#define VKI_MREMAP_MAYMOVE     1
-#define VKI_MREMAP_FIXED       2
-
-/* Copied from linux-2.4.19/include/asm-i386/fcntl.h */
-
-#define VKI_O_ACCMODE         0003
-#define VKI_O_RDONLY             00
-#define VKI_O_WRONLY             01
-#define VKI_O_RDWR               02
-#define VKI_O_CREAT            0100 /* not fcntl */
-#define VKI_O_EXCL             0200 /* not fcntl */
-#define VKI_O_TRUNC           01000 /* not fcntl */
-#define VKI_O_APPEND          02000
-#define VKI_O_NONBLOCK        04000
-#define VKI_O_SYNC           010000
-#define VKI_FASYNC           020000 /* fcntl, for BSD compatibility */
-#define VKI_O_DIRECT         040000 /* direct disk access hint */
-#define VKI_O_LARGEFILE     0100000
-#define VKI_O_DIRECTORY     0200000 /* must be a directory */
-#define VKI_O_NOFOLLOW      0400000 /* don't follow links */
-
-#define VKI_SEEK_SET              0
-#define VKI_SEEK_CUR              1
-#define VKI_SEEK_END              2
-
-/* Copied from linux-2.4.19/include/linux/stat.h */
-
-#define VKI_S_IRWXU 00700
-#define VKI_S_IRUSR 00400
-#define VKI_S_IWUSR 00200
-#define VKI_S_IXUSR 00100
-
-#define VKI_S_IRWXG 00070
-#define VKI_S_IRGRP 00040
-#define VKI_S_IWGRP 00020
-#define VKI_S_IXGRP 00010
-
-#define VKI_S_IRWXO 00007
-#define VKI_S_IROTH 00004
-#define VKI_S_IWOTH 00002
-#define VKI_S_IXOTH 00001
-
-
-/* Copied from /usr/src/linux-2.4.9-13/include/asm/errno.h */
-
-#define VKI_EPERM            1      /* Operation not permitted */
-#define VKI_ENOENT          2      /* No such file or directory */
-#define VKI_ESRCH            3      /* No such process */
-#define VKI_EINTR            4      /* Interrupted system call */
-#define VKI_EBADF            9      /* Bad file number */
-#define VKI_ENOMEM          12      /* Out of memory */
-#define VKI_EWOULDBLOCK     VKI_EAGAIN  /* Operation would block */
-#define VKI_EAGAIN          11      /* Try again */
-#define        VKI_EACCES          13      /* Permission denied */
-#define        VKI_EFAULT          14      /* Bad address */
-#define VKI_EEXIST         17      /* File exists */
-#define VKI_EINVAL          22      /* Invalid argument */
-#define VKI_ENFILE          23      /* File table overflow */
-#define VKI_EMFILE         24      /* Too many open files */
-#define VKI_ENOSYS          38      /* Function not implemented */
-
-#define VKI_ERESTARTSYS            512     /* Restart the syscall */
-
-/* Copied from linux/isdn.h */
-
-#define VKI_IIOCGETCPS  _IO( 'I',21 )
-#define VKI_IIOCNETGPN  _IO( 'I',34 )
-
-#define ISDN_MSNLEN          32
-
-typedef struct {
-    char name[ 10 ];
-    char phone[ ISDN_MSNLEN ];
-    int  outgoing;
-} isdn_net_ioctl_phone;
-
-
-/* Gawd ... hack ... */
-
-typedef struct vki__user_cap_header_struct {
-        UInt version;
-        int pid;
-} vki_cap_user_header_t;
-typedef struct vki__user_cap_data_struct {
-        UInt effective;
-        UInt permitted;
-        UInt inheritable;
-} vki_cap_user_data_t;
-  
-
-/* "Byrial Jensen" <byrial@image.dk> says:
-               [various] ioctls take a pointer to a "struct
-               termios" but this is another and shorter "struct
-               termios" than the one defined in <termios.h> and used
-               by tcgetattr(3) and tcsetattr(3) and other library
-               functions. GNU libc translate between its library
-               termios and the kernel termios. 
-*/
-
-#define VKI_SIZEOF_STRUCT_TERMIOS 36
-
-/* Adam Gundy <arg@cyberscience.com>, 20 Mar 2002, says: */
-#define VKI_SIZEOF_STRUCT_TERMIO 17
-
-
-/* File descriptor sets, for doing select().  Copied from
-   /usr/src/linux-2.4.9-31/include/linux/posix_types.h 
-*/
-/*
- * This allows for 1024 file descriptors: if NR_OPEN is ever grown
- * beyond that you'll have to change this too. But 1024 fd's seem to be
- * enough even for such "real" unices like OSF/1, so hopefully this is
- * one limit that doesn't have to be changed [again].
- *
- * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in
- * <sys/time.h> (and thus <linux/time.h>) - but this is a more logical
- * place for them. Solved by having dummy defines in <sys/time.h>.
- */
-
-/*
- * Those macros may have been defined in <gnu/types.h>. But we always
- * use the ones here. 
- */
-#undef VKI_NFDBITS
-#define VKI_NFDBITS       (8 * sizeof(unsigned long))
-
-#undef VKI_FD_SETSIZE
-#define VKI_FD_SETSIZE    1024
-
-#undef VKI_FDSET_LONGS
-#define VKI_FDSET_LONGS   (VKI_FD_SETSIZE/VKI_NFDBITS)
-
-#undef VKI_FDELT
-#define VKI_FDELT(d)      ((d) / VKI_NFDBITS)
-
-#undef VKI_FDMASK
-#define VKI_FDMASK(d)     (1UL << ((d) % VKI_NFDBITS))
-
-typedef struct {
-        unsigned long vki_fds_bits [VKI_FDSET_LONGS];
-} vki_fd_set;
-
-
-struct vki_pollfd {
-   Int         fd;
-   Short       events;
-   Short       revents;
-};
-
-/* asm/poll.h */
-#define VKI_POLLIN          0x0001
-#define VKI_POLLPRI         0x0002
-#define VKI_POLLOUT         0x0004
-#define VKI_POLLERR         0x0008
-#define VKI_POLLHUP         0x0010
-#define VKI_POLLNVAL        0x0020
-
-
-/* sys/epoll.h */
-typedef union vki_epoll_data {
-   void *ptr;
-   Int   fd;
-   UInt  u32;
-   ULong u64;
-} vki_epoll_data_t;
-
-struct vki_epoll_event {
-   UInt events;            /* Epoll events */
-   vki_epoll_data_t data;      /* User data variable */
-};
-
-
-/* 
-./include/asm-i386/posix_types.h:typedef long           __kernel_suseconds_t;
-./include/linux/types.h:typedef __kernel_suseconds_t    suseconds_t;
-
-./include/asm-i386/posix_types.h:typedef long           __kernel_time_t;
-./include/linux/types.h:typedef __kernel_time_t         time_t;
-*/
-
-struct vki_timeval {
-        /* time_t */ long         tv_sec;         /* seconds */
-        /* suseconds_t */ long    tv_usec;        /* microseconds */
-};
-
-
-
-/* For fcntl on fds ..
-   from ./include/asm-i386/fcntl.h */
-#define VKI_F_DUPFD        0       /* dup */
-#define VKI_F_GETFD        1       /* get close_on_exec */
-#define VKI_F_SETFD        2       /* set/clear close_on_exec */
-#define VKI_F_GETFL         3       /* get file->f_flags */
-#define VKI_F_SETFL         4       /* set file->f_flags */
-#define VKI_F_GETLK         5
-#define VKI_F_SETLK         6
-#define VKI_F_SETLKW        7
-#define VKI_F_GETLK64       12      /*  using 'struct flock64' */
-#define VKI_F_SETLK64       13
-#define VKI_F_SETLKW64      14
-
-/* for F_[GET|SET]FL */
-#define VKI_FD_CLOEXEC     1       /* actually anything with low bit set goes */
-
-#define VKI_O_NONBLOCK        04000
-
-/* For nanosleep ... 
-   from ./include/linux/time.h */
-struct vki_timespec {
-        /* time_t */ long tv_sec;         /* seconds */
-        long    tv_nsec;        /* nanoseconds */
-};
-
-/* POSIX.1b structure for timer start values and intervals.  */
-struct vki_itimerspec {
-       struct vki_timespec it_interval;
-       struct vki_timespec it_value;
-};
-
-/* STAT stuff 
-   from /usr/src/linux-2.4.9-31/include/asm-i386/stat.h */
-struct vki_stat {
-        unsigned short st_dev;
-        unsigned short __pad1;
-        unsigned long st_ino;
-        unsigned short st_mode;
-        unsigned short st_nlink;
-        unsigned short st_uid;
-        unsigned short st_gid;
-        unsigned short st_rdev;
-        unsigned short __pad2;
-        unsigned long  st_size;
-        unsigned long  st_blksize;
-        unsigned long  st_blocks;
-        unsigned long  st_atime;
-        unsigned long  __unused1;
-        unsigned long  st_mtime;
-        unsigned long  __unused2;
-        unsigned long  st_ctime;
-        unsigned long  __unused3;
-        unsigned long  __unused4;
-        unsigned long  __unused5;
-};
-
-
-/* To do with the ELF frame constructed by the kernel on a process'
-   stack just before it transfers control to the program's interpreter
-   (to use the ELF parlance).
-   Constants from /usr/src/linux-2.4.9-31/include/linux/elf.h
-   Logic from     /usr/src/linux-2.4.9-31/fs/binfmt_elf.c
-                  and its counterpart in the 2.2.14 kernel sources 
-                  in Red Hat 6.2.  */
-#define VKI_AT_NULL   0
-#define VKI_AT_SYSINFO 32   /* address of system info page */
-#define VKI_AT_CLKTCK 17    /* frequency at which times() increments */
-#define VKI_AT_HWCAP  16    /* arch dependent hints at CPU capabilities */
-#define VKI_AT_BASE   7     /* base address of interpreter */
-#define VKI_AT_PAGESZ 6     /* system page size */
-#define VKI_AT_PHNUM  5     /* number of program headers */
-#define VKI_AT_PHENT  4     /* size of program header entry */
-#define VKI_AT_PHDR   3     /* program headers for program */
-#define VKI_AT_USER_AUX_SEGMENT 23  /* tell glibc what address segment
-                                       0x3B points to.  (Needed for
-                                       Red Hat Limbo, 7.3.92) */
-
-/* Including <linux/module.h> leads to loads of hassle because then we
-   need <asm/atomic.h> sometimes (RedHat 7.3) and that is a
-   kernel-only header which deliberately #errors on gcc-3.1.  Mucho
-   hassle considering that we only want to know sizeof(struct module).
-   Hence ...
-   #include <stdio.h>
-   #include <asm/atomic.h>
-   #include <linux/module.h>
-
-   int main ( void )
-   {
-      printf ("sizeof(struct module) = %d\n", sizeof(struct module) );
-      return 0;
-    }
-*/
-
-#define VKI_SIZEOF_STRUCT_MODULE 96
-
-
-/* This is the structure passed to the modify_ldt syscall.  Just so as
-   to confuse and annoy everyone, this is _not_ the same as an
-   VgLdtEntry and has to be translated into such.  The logic for doing
-   so, in vg_ldt.c, is copied from the kernel sources. */
-/*
- * ldt.h
- *
- * Definitions of structures used with the modify_ldt system call.
- */
-typedef struct vki_modify_ldt_ldt_s {
-        unsigned int  entry_number;
-        unsigned long base_addr;
-        unsigned int  limit;
-        unsigned int  seg_32bit:1;
-        unsigned int  contents:2;
-        unsigned int  read_exec_only:1;
-        unsigned int  limit_in_pages:1;
-        unsigned int  seg_not_present:1;
-        unsigned int  useable:1;
-        unsigned int  reserved:25;
-} vki_modify_ldt_t;
-
-#define VKI_MODIFY_LDT_CONTENTS_DATA        0
-#define VKI_MODIFY_LDT_CONTENTS_STACK       1
-#define VKI_MODIFY_LDT_CONTENTS_CODE        2
-
-#define VKI_GDT_TLS_ENTRIES 3
-#define VKI_GDT_TLS_MIN     6
-#define VKI_GDT_TLS_MAX     (VKI_GDT_TLS_MIN + VKI_GDT_TLS_ENTRIES)
-
-/* Flags for clone() */
-/* linux/sched.h */
-#define VKI_CSIGNAL            0x000000ff      /* signal mask to be sent at exit */
-#define VKI_CLONE_VM           0x00000100      /* set if VM shared between processes */
-#define VKI_CLONE_FS           0x00000200      /* set if fs info shared between processes */
-#define VKI_CLONE_FILES                0x00000400      /* set if open files shared between processes */
-#define VKI_CLONE_SIGHAND      0x00000800      /* set if signal handlers and blocked signals shared */
-#define VKI_CLONE_IDLETASK     0x00001000      /* set if new pid should be 0 (kernel only)*/
-#define VKI_CLONE_PTRACE       0x00002000      /* set if we want to let tracing continue on the child too */
-#define VKI_CLONE_VFORK                0x00004000      /* set if the parent wants the child to wake it up on mm_release */
-#define VKI_CLONE_PARENT       0x00008000      /* set if we want to have the same parent as the cloner */
-#define VKI_CLONE_THREAD       0x00010000      /* Same thread group? */
-#define VKI_CLONE_NEWNS                0x00020000      /* New namespace group? */
-#define VKI_CLONE_SYSVSEM      0x00040000      /* share system V SEM_UNDO semantics */
-#define VKI_CLONE_SETTLS       0x00080000      /* create a new TLS for the child */
-#define VKI_CLONE_PARENT_SETTID        0x00100000      /* set the TID in the parent */
-#define VKI_CLONE_CHILD_CLEARTID       0x00200000      /* clear the TID in the child */
-#define VKI_CLONE_DETACHED     0x00400000      /* parent wants no child-exit signal */
-#define VKI_CLONE_UNTRACED     0x00800000      /* set if the tracing process can't force VKI_CLONE_PTRACE on this clone */
-#define VKI_CLONE_CHILD_SETTID 0x01000000      /* set the TID in the child */
-
-/* This is the structure passed to the getdents syscall. */
-/*
- * linux/dirent.h
- */
-typedef struct vki_dirent {
-       long           d_ino;
-       long           d_off;
-       unsigned short d_reclen;
-       char           d_name[256];
-} vki_dirent;
-
-
-
-/* This is the structure passed to the getrlimit syscall. */
-/*
- * bits/resource.h
- */
-typedef struct vki_rlimit {
-       unsigned long rlim_cur;
-       unsigned long rlim_max;
-} vki_rlimit;
-
-#define VKI_RLIMIT_CPU         0               /* CPU time in ms */
-#define VKI_RLIMIT_FSIZE       1               /* Maximum filesize */
-#define VKI_RLIMIT_DATA                2               /* max data size */
-#define VKI_RLIMIT_STACK       3               /* max stack size */
-#define VKI_RLIMIT_CORE                4               /* max core file size */
-#define VKI_RLIMIT_RSS         5               /* max resident set size */
-#define VKI_RLIMIT_NPROC       6               /* max number of processes */
-#define VKI_RLIMIT_NOFILE      7               /* max number of open files */
-#define VKI_RLIMIT_MEMLOCK     8               /* max locked-in-memory address space */
-#define VKI_RLIMIT_AS          9               /* address space limit */
-#define VKI_RLIMIT_LOCKS       10              /* maximum file locks held */
-
-/* Socket stuff. */
-/*
- * sys/socket.h
- */
-typedef unsigned short vki_sa_family_t;
-struct vki_sockaddr {
-  vki_sa_family_t sa_family;     /* Address family. */
-  char            sa_data[14];   /* Address data. */
-};
-
-/* statfs structs */
-/*
- * bits/statfs.h
- */
-
-struct vki_statfs {
-        unsigned int f_type;
-        unsigned int f_bsize;
-        unsigned int f_blocks;
-        unsigned int f_bfree;
-        unsigned int f_bavail;
-        unsigned int f_files;
-        unsigned int f_ffree;
-        int f_fsid[ 2 ];
-        unsigned int f_namelen;
-        unsigned int f_frsize;
-        unsigned int f_spare[5];
-};
-
-struct vki_statfs64 {
-        unsigned int f_type;
-        unsigned int f_bsize;
-        unsigned long long f_blocks;
-        unsigned long long f_bfree;
-        unsigned long long f_bavail;
-        unsigned long long f_files;
-        unsigned long long f_ffree;
-        int f_fsid[ 2 ];
-        unsigned int f_namelen;
-        unsigned int f_frsize;
-        unsigned int f_spare[5];
-};
-
-/* 
- * linux/futex.h
- */
-
-#define VKI_FUTEX_WAIT    0
-#define VKI_FUTEX_WAKE    1
-#define VKI_FUTEX_FD      2
-#define VKI_FUTEX_REQUEUE 3
-
-/*
- * linux/ipc.h
- */
-
-#define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
-#define VKI_IPC_EXCL   00002000   /* fail if key exists */
-#define VKI_IPC_NOWAIT 00004000   /* return error on wait */
-
-/* 
- * linux/elfcore.h
- */
-
-struct elf_siginfo
-{
-       int     si_signo;                       /* signal number */
-       int     si_code;                        /* extra code */
-       int     si_errno;                       /* errno */
-};
-
-/*
- * This is the old layout of "struct pt_regs", and
- * is still the layout used by user mode (the new
- * pt_regs doesn't have all registers as the kernel
- * doesn't use the extra segment registers)
- */
-struct user_regs_struct {
-       long ebx, ecx, edx, esi, edi, ebp, eax;
-       unsigned short ds, __ds, es, __es;
-       unsigned short fs, __fs, gs, __gs;
-       long orig_eax, eip;
-       unsigned short cs, __cs;
-       long eflags, esp;
-       unsigned short ss, __ss;
-};
-
-struct user_i387_struct {
-       long    cwd;
-       long    swd;
-       long    twd;
-       long    fip;
-       long    fcs;
-       long    foo;
-       long    fos;
-       long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
-};
-
-struct user_fxsr_struct {
-       unsigned short  cwd;
-       unsigned short  swd;
-       unsigned short  twd;
-       unsigned short  fop;
-       long    fip;
-       long    fcs;
-       long    foo;
-       long    fos;
-       long    mxcsr;
-       long    reserved;
-       long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
-       long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
-       long    padding[56];
-};
-
-typedef unsigned long elf_greg_t;
-
-#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-
-typedef struct user_i387_struct elf_fpregset_t;
-typedef struct user_fxsr_struct elf_fpxregset_t;
-
-
-/*
- * Definitions to generate Intel SVR4-like core files.
- * These mostly have the same names as the SVR4 types with "elf_"
- * tacked on the front to prevent clashes with linux definitions,
- * and the typedef forms have been avoided.  This is mostly like
- * the SVR4 structure, but more Linuxy, with things that Linux does
- * not support and which gdb doesn't really use excluded.
- * Fields present but not used are marked with "XXX".
- */
-struct elf_prstatus
-{
-#if 0
-       long    pr_flags;       /* XXX Process flags */
-       short   pr_why;         /* XXX Reason for process halt */
-       short   pr_what;        /* XXX More detailed reason */
-#endif
-       struct elf_siginfo pr_info;     /* Info associated with signal */
-       short   pr_cursig;              /* Current signal */
-       unsigned long pr_sigpend;       /* Set of pending signals */
-       unsigned long pr_sighold;       /* Set of held signals */
-#if 0
-       struct sigaltstack pr_altstack; /* Alternate stack info */
-       struct sigaction pr_action;     /* Signal action for current sig */
-#endif
-       Int     pr_pid;
-       Int     pr_ppid;
-       Int     pr_pgrp;
-       Int     pr_sid;
-       struct vki_timeval pr_utime;    /* User time */
-       struct vki_timeval pr_stime;    /* System time */
-       struct vki_timeval pr_cutime;   /* Cumulative user time */
-       struct vki_timeval pr_cstime;   /* Cumulative system time */
-#if 0
-       long    pr_instr;               /* Current instruction */
-#endif
-       elf_gregset_t pr_reg;   /* GP registers */
-       int pr_fpvalid;         /* True if math co-processor being used.  */
-};
-
-#define ELF_PRARGSZ    (80)    /* Number of chars for args */
-
-struct elf_prpsinfo
-{
-       char    pr_state;       /* numeric process state */
-       char    pr_sname;       /* char for pr_state */
-       char    pr_zomb;        /* zombie */
-       char    pr_nice;        /* nice val */
-       unsigned long pr_flag;  /* flags */
-       Int     pr_uid;
-       Int     pr_gid;
-       Int     pr_pid, pr_ppid, pr_pgrp, pr_sid;
-       /* Lots missing */
-       char    pr_fname[16];   /* filename of executable */
-       char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
-};
-
-/*
- * linux/aio_abi.h
- */
-
-typedef struct {
-       unsigned        id;     /* kernel internal index number */
-       unsigned        nr;     /* number of io_events */
-       unsigned        head;
-       unsigned        tail;
-       unsigned        magic;
-       unsigned        compat_features;
-       unsigned        incompat_features;
-       unsigned        header_length;  /* size of aio_ring */  
-} vki_aio_ring ;
-
-typedef vki_aio_ring *vki_aio_context_t;
-
-typedef struct {
-    ULong data;
-    ULong obj;
-    Long  result;
-    Long  result2;
-} vki_io_event;
-
-typedef struct {
-       /* these are internal to the kernel/libc. */
-       ULong   aio_data;       /* data to be returned in event's data */
-        ULong  aio_key;
-                               /* the kernel sets aio_key to the req # */
-
-       /* common fields */
-        UShort aio_lio_opcode; /* see IOCB_CMD_ above */
-       UShort  aio_reqprio;
-       UInt    aio_fildes;
-
-       ULong   aio_buf;
-       ULong   aio_nbytes;
-       Long    aio_offset;
-
-       /* extra parameters */
-       ULong   aio_reserved2;  /* TODO: use this for a (struct sigevent *) */
-       ULong   aio_reserved3;
-} vki_iocb; /* 64 bytes */
-
-enum {
-    VKI_IOCB_CMD_PREAD = 0,
-    VKI_IOCB_CMD_PWRITE = 1,
-    VKI_IOCB_CMD_FSYNC = 2,
-    VKI_IOCB_CMD_FDSYNC = 3,
-    /* These two are experimental.
-     * IOCB_CMD_PREADX = 4,
-     * IOCB_CMD_POLL = 5,
-     */
-    VKI_IOCB_CMD_NOOP = 6,
-};
-
-/*
- * linux/mqueue.h
- */
-
-struct vki_mq_attr {
-       long    mq_flags;       /* message queue flags                  */
-       long    mq_maxmsg;      /* maximum number of messages           */
-       long    mq_msgsize;     /* maximum message size                 */
-       long    mq_curmsgs;     /* number of messages currently queued  */
-       long    __reserved[4];  /* ignored for input, zeroed for output */
-};
-
-#endif /*  __VG_KERNELIFACE_H */
-
-/*--------------------------------------------------------------------*/
-/*--- end                                         vg_kerneliface.h ---*/
-/*--------------------------------------------------------------------*/
diff --git a/include/x86-linux/.cvsignore b/include/x86-linux/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/include/x86-linux/Makefile.am b/include/x86-linux/Makefile.am
new file mode 100644 (file)
index 0000000..2e5c005
--- /dev/null
@@ -0,0 +1,5 @@
+incincdir = $(includedir)/valgrind/x86-linux
+
+incinc_HEADERS = \
+    vki_arch.h \
+    vki_arch_posixtypes.h
diff --git a/include/x86-linux/vki_arch.h b/include/x86-linux/vki_arch.h
new file mode 100644 (file)
index 0000000..2d50c25
--- /dev/null
@@ -0,0 +1,732 @@
+
+/*--------------------------------------------------------------------*/
+/*--- x86/Linux-specific kernel interface.    x86-linux/vki_arch.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, an extensible x86 protected-mode
+   emulator for monitoring program execution on x86-Unixes.
+
+   Copyright (C) 2000-2004 Julian Seward 
+      jseward@acm.org
+
+   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, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307, USA.
+
+   The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __X86_LINUX_VKI_ARCH_H
+#define __X86_LINUX_VKI_ARCH_H
+
+// x86 is little-endian.
+#define VKI_LITTLE_ENDIAN  1
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/types.h
+//----------------------------------------------------------------------
+
+typedef unsigned char __vki_u8;
+
+typedef __signed__ short __vki_s16;
+typedef unsigned short __vki_u16;
+
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long long __vki_s64;
+typedef unsigned long long __vki_u64;
+
+typedef unsigned short vki_u16;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/page.h
+//----------------------------------------------------------------------
+
+/* PAGE_SHIFT determines the page size */
+#define VKI_PAGE_SHIFT 12
+#define VKI_PAGE_SIZE  (1UL << VKI_PAGE_SHIFT)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/signal.h
+//----------------------------------------------------------------------
+
+#define VKI_MINSIGSTKSZ        2048
+
+#define VKI_SIG_BLOCK          0       /* for blocking signals */
+#define VKI_SIG_UNBLOCK        1       /* for unblocking signals */
+#define VKI_SIG_SETMASK        2       /* for setting the signal mask */
+
+/* Type of a signal handler.  */
+typedef void __vki_signalfn_t(int);
+typedef __vki_signalfn_t __user *__vki_sighandler_t;
+
+typedef void __vki_restorefn_t(void);
+typedef __vki_restorefn_t __user *__vki_sigrestore_t;
+
+#define VKI_SIG_DFL    ((__vki_sighandler_t)0) /* default signal handling */
+#define VKI_SIG_IGN    ((__vki_sighandler_t)1) /* ignore signal */
+
+//#ifdef __KERNEL__
+/* Most things should be clean enough to redefine this at will, if care
+   is taken to make libc match.  */
+
+#define _VKI_NSIG      64
+#define _VKI_NSIG_BPW  32
+#define _VKI_NSIG_WORDS        (_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef struct {
+       unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+//#endif
+
+#define VKI_SIGHUP              1
+#define VKI_SIGINT              2
+#define VKI_SIGQUIT             3
+#define VKI_SIGILL              4
+#define VKI_SIGTRAP             5
+#define VKI_SIGABRT             6
+//#define VKI_SIGIOT            6
+#define VKI_SIGBUS              7
+#define VKI_SIGFPE              8
+#define VKI_SIGKILL             9
+#define VKI_SIGUSR1            10
+#define VKI_SIGSEGV            11
+#define VKI_SIGUSR2            12
+#define VKI_SIGPIPE            13
+#define VKI_SIGALRM            14
+#define VKI_SIGTERM            15
+#define VKI_SIGSTKFLT          16
+#define VKI_SIGCHLD            17
+#define VKI_SIGCONT            18
+#define VKI_SIGSTOP            19
+#define VKI_SIGTSTP            20
+#define VKI_SIGTTIN            21
+#define VKI_SIGTTOU            22
+#define VKI_SIGURG             23
+#define VKI_SIGXCPU            24
+#define VKI_SIGXFSZ            25
+#define VKI_SIGVTALRM          26
+#define VKI_SIGPROF            27
+#define VKI_SIGWINCH           28
+#define VKI_SIGIO              29
+#define VKI_SIGPWR             30
+#define VKI_SIGSYS             31
+#define        VKI_SIGUNUSED           31
+
+/* These should not be considered constants from userland.  */
+#define VKI_SIGRTMIN   32
+// [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
+#define VKI_SIGRTMAX   _VKI_NSIG
+
+#define VKI_SIGVGINT        (VKI_SIGRTMIN+0) // [[internal: interrupt]]
+#define VKI_SIGVGKILL       (VKI_SIGRTMIN+1) // [[internal: kill]]
+#define VKI_SIGVGRTUSERMIN  (VKI_SIGRTMIN+2) // [[internal: first
+                                             //   user-usable RT signal]]
+
+#define VKI_SA_NOCLDSTOP       0x00000001u
+#define VKI_SA_NOCLDWAIT       0x00000002u
+#define VKI_SA_SIGINFO         0x00000004u
+#define VKI_SA_ONSTACK         0x08000000u
+#define VKI_SA_RESTART         0x10000000u
+#define VKI_SA_NODEFER         0x40000000u
+#define VKI_SA_RESETHAND       0x80000000u
+
+#define VKI_SA_NOMASK          VKI_SA_NODEFER
+#define VKI_SA_ONESHOT         VKI_SA_RESETHAND
+//#define VKI_SA_INTERRUPT     0x20000000 /* dummy -- ignored */
+
+#define VKI_SA_RESTORER                0x04000000
+
+#define VKI_SS_ONSTACK 1
+#define VKI_SS_DISABLE 2
+
+struct vki_sigaction {
+        // [[Nb: a 'k' prefix is added to "sa_handler" because
+        // bits/sigaction.h (which gets dragged in somehow via signal.h)
+        // #defines it as something else.  Since that is done for glibc's
+        // purposes, which we don't care about here, we use our own name.]]
+       __vki_sighandler_t ksa_handler;
+       unsigned long sa_flags;
+       __vki_sigrestore_t sa_restorer;
+       vki_sigset_t sa_mask;           /* mask last for extensibility */
+};
+
+typedef struct vki_sigaltstack {
+       void __user *ss_sp;
+       int ss_flags;
+       vki_size_t ss_size;
+} vki_stack_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/sigcontext.h
+//----------------------------------------------------------------------
+
+struct _vki_fpreg {
+       unsigned short significand[4];
+       unsigned short exponent;
+};
+
+struct _vki_fpxreg {
+       unsigned short significand[4];
+       unsigned short exponent;
+       unsigned short padding[3];
+};
+
+struct _vki_xmmreg {
+       unsigned long element[4];
+};
+
+struct _vki_fpstate {
+       /* Regular FPU environment */
+       unsigned long   cw;
+       unsigned long   sw;
+       unsigned long   tag;
+       unsigned long   ipoff;
+       unsigned long   cssel;
+       unsigned long   dataoff;
+       unsigned long   datasel;
+       struct _vki_fpreg       _st[8];
+       unsigned short  status;
+       unsigned short  magic;          /* 0xffff = regular FPU data only */
+
+       /* FXSR FPU environment */
+       unsigned long   _fxsr_env[6];   /* FXSR FPU env is ignored */
+       unsigned long   mxcsr;
+       unsigned long   reserved;
+       struct _vki_fpxreg      _fxsr_st[8];    /* FXSR FPU reg data is ignored */
+       struct _vki_xmmreg      _xmm[8];
+       unsigned long   padding[56];
+};
+
+struct vki_sigcontext {
+       unsigned short gs, __gsh;
+       unsigned short fs, __fsh;
+       unsigned short es, __esh;
+       unsigned short ds, __dsh;
+       unsigned long edi;
+       unsigned long esi;
+       unsigned long ebp;
+       unsigned long esp;
+       unsigned long ebx;
+       unsigned long edx;
+       unsigned long ecx;
+       unsigned long eax;
+       unsigned long trapno;
+       unsigned long err;
+       unsigned long eip;
+       unsigned short cs, __csh;
+       unsigned long eflags;
+       unsigned long esp_at_signal;
+       unsigned short ss, __ssh;
+       struct _vki_fpstate __user * fpstate;
+       unsigned long oldmask;
+       unsigned long cr2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/mman.h
+//----------------------------------------------------------------------
+
+//#define VKI_PROT_NONE        0x0             /* No page permissions */
+#define VKI_PROT_READ  0x1             /* page can be read */
+#define VKI_PROT_WRITE 0x2             /* page can be written */
+#define VKI_PROT_EXEC  0x4             /* page can be executed */
+
+#define VKI_MAP_SHARED 0x01            /* Share changes */
+#define VKI_MAP_PRIVATE        0x02            /* Changes are private */
+//#define VKI_MAP_TYPE 0x0f            /* Mask for type of mapping */
+#define VKI_MAP_FIXED  0x10            /* Interpret addr exactly */
+#define VKI_MAP_ANONYMOUS      0x20    /* don't use a file */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/fcntl.h
+//----------------------------------------------------------------------
+
+#define VKI_O_RDONLY        00
+#define VKI_O_WRONLY        01
+#define VKI_O_CREAT       0100 /* not fcntl */
+#define VKI_O_EXCL        0200 /* not fcntl */
+#define VKI_O_TRUNC      01000 /* not fcntl */
+#define VKI_O_NONBLOCK   04000
+
+#define VKI_F_DUPFD            0       /* dup */
+//#define VKI_F_GETFD          1       /* get close_on_exec */
+#define VKI_F_SETFD            2       /* set/clear close_on_exec */
+#define VKI_F_GETFL            3       /* get file->f_flags */
+#define VKI_F_SETFL            4       /* set file->f_flags */
+//#define VKI_F_GETLK          5
+//#define VKI_F_SETLK          6
+#define VKI_F_SETLKW           7
+
+#define VKI_F_SETLKW64         14
+
+/* for F_[GET|SET]FL */
+#define VKI_FD_CLOEXEC 1       /* actually anything with low bit set goes */
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/resource.h
+//----------------------------------------------------------------------
+
+#define VKI_RLIMIT_DATA                2       /* max data size */
+#define VKI_RLIMIT_STACK       3       /* max stack size */
+#define VKI_RLIMIT_CORE                4       /* max core file size */
+#define VKI_RLIMIT_NOFILE      7       /* max number of open files */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/socket.h
+//----------------------------------------------------------------------
+
+#define VKI_SOL_SOCKET 1
+
+#define VKI_SO_TYPE    3
+
+#define VKI_SOCK_STREAM        1               /* stream (connection) socket   */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/sockios.h
+//----------------------------------------------------------------------
+
+#define VKI_SIOCSPGRP  0x8902
+#define VKI_SIOCGPGRP  0x8904
+#define VKI_SIOCGSTAMP 0x8906          /* Get stamp */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/stat.h
+//----------------------------------------------------------------------
+
+struct vki_stat {
+       unsigned long  st_dev;
+       unsigned long  st_ino;
+       unsigned short st_mode;
+       unsigned short st_nlink;
+       unsigned short st_uid;
+       unsigned short st_gid;
+       unsigned long  st_rdev;
+       unsigned long  st_size;
+       unsigned long  st_blksize;
+       unsigned long  st_blocks;
+       unsigned long  st_atime;
+       unsigned long  st_atime_nsec;
+       unsigned long  st_mtime;
+       unsigned long  st_mtime_nsec;
+       unsigned long  st_ctime;
+       unsigned long  st_ctime_nsec;
+       unsigned long  __unused4;
+       unsigned long  __unused5;
+};
+
+struct vki_stat64 {
+       unsigned long long      st_dev;
+       unsigned char   __pad0[4];
+
+#define STAT64_HAS_BROKEN_ST_INO       1
+       unsigned long   __st_ino;
+
+       unsigned int    st_mode;
+       unsigned int    st_nlink;
+
+       unsigned long   st_uid;
+       unsigned long   st_gid;
+
+       unsigned long long      st_rdev;
+       unsigned char   __pad3[4];
+
+       long long       st_size;
+       unsigned long   st_blksize;
+
+       unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
+       unsigned long   __pad4;         /* future possible st_blocks high bits */
+
+       unsigned long   st_atime;
+       unsigned long   st_atime_nsec;
+
+       unsigned long   st_mtime;
+       unsigned int    st_mtime_nsec;
+
+       unsigned long   st_ctime;
+       unsigned long   st_ctime_nsec;
+
+       unsigned long long      st_ino;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/statfs.h
+//----------------------------------------------------------------------
+
+struct vki_statfs {
+       __vki_u32 f_type;
+       __vki_u32 f_bsize;
+       __vki_u32 f_blocks;
+       __vki_u32 f_bfree;
+       __vki_u32 f_bavail;
+       __vki_u32 f_files;
+       __vki_u32 f_ffree;
+       __vki_kernel_fsid_t f_fsid;
+       __vki_u32 f_namelen;
+       __vki_u32 f_frsize;
+       __vki_u32 f_spare[5];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/termios.h
+//----------------------------------------------------------------------
+
+struct vki_winsize {
+       unsigned short ws_row;
+       unsigned short ws_col;
+       unsigned short ws_xpixel;
+       unsigned short ws_ypixel;
+};
+
+#define VKI_NCC 8
+struct vki_termio {
+       unsigned short c_iflag;         /* input mode flags */
+       unsigned short c_oflag;         /* output mode flags */
+       unsigned short c_cflag;         /* control mode flags */
+       unsigned short c_lflag;         /* local mode flags */
+       unsigned char c_line;           /* line discipline */
+       unsigned char c_cc[VKI_NCC];    /* control characters */
+};
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/termbits.h
+//----------------------------------------------------------------------
+
+#define VKI_SIZEOF_STRUCT_TERMIOS      17
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ioctl.h
+//----------------------------------------------------------------------
+
+#define _VKI_IOC_NRBITS        8
+#define _VKI_IOC_TYPEBITS      8
+#define _VKI_IOC_SIZEBITS      14
+#define _VKI_IOC_DIRBITS       2
+
+#define _VKI_IOC_SIZEMASK      ((1 << _VKI_IOC_SIZEBITS)-1)
+#define _VKI_IOC_DIRMASK       ((1 << _VKI_IOC_DIRBITS)-1)
+
+#define _VKI_IOC_NRSHIFT       0
+#define _VKI_IOC_TYPESHIFT     (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
+#define _VKI_IOC_SIZESHIFT     (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
+#define _VKI_IOC_DIRSHIFT      (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
+
+#define _VKI_IOC_NONE  0U
+#define _VKI_IOC_WRITE 1U
+#define _VKI_IOC_READ  2U
+
+#define _VKI_IOC(dir,type,nr,size) \
+       (((dir)  << _VKI_IOC_DIRSHIFT) | \
+        ((type) << _VKI_IOC_TYPESHIFT) | \
+        ((nr)   << _VKI_IOC_NRSHIFT) | \
+        ((size) << _VKI_IOC_SIZESHIFT))
+
+/* provoke compile error for invalid uses of size argument */
+extern unsigned int __vki_invalid_size_argument_for_IOC;
+#define _VKI_IOC_TYPECHECK(t) \
+       ((sizeof(t) == sizeof(t[1]) && \
+         sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \
+         sizeof(t) : __vki_invalid_size_argument_for_IOC)
+
+/* used to create numbers */
+#define _VKI_IO(type,nr)       _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
+#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
+#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
+#define _VKI_IOWR(type,nr,size)        _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
+
+/* used to decode ioctl numbers.. */
+#define _VKI_IOC_DIR(nr)       (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
+#define _VKI_IOC_SIZE(nr)      (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ioctls.h
+//----------------------------------------------------------------------
+
+#define VKI_TCGETS     0x5401
+#define VKI_TCSETS     0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
+#define VKI_TCSETSW    0x5403
+#define VKI_TCSETSF    0x5404
+#define VKI_TCGETA     0x5405
+#define VKI_TCSETA     0x5406
+#define VKI_TCSETAW    0x5407
+#define VKI_TCSETAF    0x5408
+#define VKI_TCSBRK     0x5409
+#define VKI_TCXONC     0x540A
+#define VKI_TCFLSH     0x540B
+#define VKI_TIOCSCTTY  0x540E
+#define VKI_TIOCGPGRP  0x540F
+#define VKI_TIOCSPGRP  0x5410
+#define VKI_TIOCOUTQ   0x5411
+#define VKI_TIOCGWINSZ 0x5413
+#define VKI_TIOCSWINSZ 0x5414
+#define VKI_TIOCMBIS   0x5416
+#define VKI_TIOCMBIC   0x5417
+#define VKI_TIOCMSET   0x5418
+#define VKI_FIONREAD   0x541B
+#define VKI_TIOCLINUX  0x541C
+#define VKI_FIONBIO    0x5421
+#define VKI_TCSBRKP    0x5425  /* Needed for POSIX tcsendbreak() */
+#define VKI_TIOCGPTN   _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
+
+#define VKI_FIOASYNC   0x5452
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/poll.h
+//----------------------------------------------------------------------
+
+/* These are specified by iBCS2 */
+#define VKI_POLLIN             0x0001
+
+struct vki_pollfd {
+       int fd;
+       short events;
+       short revents;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/user.h
+//----------------------------------------------------------------------
+
+struct vki_user_i387_struct {
+       long    cwd;
+       long    swd;
+       long    twd;
+       long    fip;
+       long    fcs;
+       long    foo;
+       long    fos;
+       long    st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
+};
+
+struct vki_user_fxsr_struct {
+       unsigned short  cwd;
+       unsigned short  swd;
+       unsigned short  twd;
+       unsigned short  fop;
+       long    fip;
+       long    fcs;
+       long    foo;
+       long    fos;
+       long    mxcsr;
+       long    reserved;
+       long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
+       long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
+       long    padding[56];
+};
+
+/*
+ * This is the old layout of "struct pt_regs", and
+ * is still the layout used by user mode (the new
+ * pt_regs doesn't have all registers as the kernel
+ * doesn't use the extra segment registers)
+ */
+struct vki_user_regs_struct {
+       long ebx, ecx, edx, esi, edi, ebp, eax;
+       unsigned short ds, __ds, es, __es;
+       unsigned short fs, __fs, gs, __gs;
+       long orig_eax, eip;
+       unsigned short cs, __cs;
+       long eflags, esp;
+       unsigned short ss, __ss;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/elf.h
+//----------------------------------------------------------------------
+
+typedef unsigned long vki_elf_greg_t;
+
+#define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
+typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
+
+typedef struct vki_user_i387_struct vki_elf_fpregset_t;
+typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t;
+
+#define VKI_AT_SYSINFO         32
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ucontext.h
+//----------------------------------------------------------------------
+
+struct vki_ucontext {
+       unsigned long           uc_flags;
+       struct vki_ucontext    *uc_link;
+       vki_stack_t             uc_stack;
+       struct vki_sigcontext   uc_mcontext;
+       vki_sigset_t            uc_sigmask;     /* mask last for extensibility */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/segment.h
+//----------------------------------------------------------------------
+
+#define VKI_GDT_ENTRY_TLS_ENTRIES      3
+#define VKI_GDT_ENTRY_TLS_MIN  6
+#define VKI_GDT_ENTRY_TLS_MAX  (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ldt.h
+//----------------------------------------------------------------------
+
+/* [[Nb: This is the structure passed to the modify_ldt syscall.  Just so as
+   to confuse and annoy everyone, this is _not_ the same as an
+   VgLdtEntry and has to be translated into such.  The logic for doing
+   so, in vg_ldt.c, is copied from the kernel sources.]] */
+struct vki_user_desc {
+       unsigned int  entry_number;
+       unsigned long base_addr;
+       unsigned int  limit;
+       unsigned int  seg_32bit:1;
+       unsigned int  contents:2;
+       unsigned int  read_exec_only:1;
+       unsigned int  limit_in_pages:1;
+       unsigned int  seg_not_present:1;
+       unsigned int  useable:1;
+        // [[Nb: this field is not in the kernel sources, but it has always
+        // been in the Valgrind sources so I will keep it there in case it's
+        // important... this is an x86-defined data structure so who
+        // knows;  maybe it's important to set this field to zero at some
+        // point.  --njn]]
+       unsigned int  reserved:25;
+};
+
+// [[Nb: for our convenience within Valgrind, use a more specific name]]
+typedef struct vki_user_desc vki_modify_ldt_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ipcbuf.h
+//----------------------------------------------------------------------
+
+struct vki_ipc64_perm
+{
+       __vki_kernel_key_t      key;
+       __vki_kernel_uid32_t    uid;
+       __vki_kernel_gid32_t    gid;
+       __vki_kernel_uid32_t    cuid;
+       __vki_kernel_gid32_t    cgid;
+       __vki_kernel_mode_t     mode;
+       unsigned short          __pad1;
+       unsigned short          seq;
+       unsigned short          __pad2;
+       unsigned long           __unused1;
+       unsigned long           __unused2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/sembuf.h
+//----------------------------------------------------------------------
+
+struct vki_semid64_ds {
+       struct vki_ipc64_perm sem_perm;         /* permissions .. see ipc.h */
+       __vki_kernel_time_t     sem_otime;              /* last semop time */
+       unsigned long   __unused1;
+       __vki_kernel_time_t     sem_ctime;              /* last change time */
+       unsigned long   __unused2;
+       unsigned long   sem_nsems;              /* no. of semaphores in array */
+       unsigned long   __unused3;
+       unsigned long   __unused4;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/msgbuf.h
+//----------------------------------------------------------------------
+
+struct vki_msqid64_ds {
+       struct vki_ipc64_perm msg_perm;
+       __vki_kernel_time_t msg_stime;  /* last msgsnd time */
+       unsigned long   __unused1;
+       __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
+       unsigned long   __unused2;
+       __vki_kernel_time_t msg_ctime;  /* last change time */
+       unsigned long   __unused3;
+       unsigned long  msg_cbytes;      /* current number of bytes on queue */
+       unsigned long  msg_qnum;        /* number of messages in queue */
+       unsigned long  msg_qbytes;      /* max number of bytes on queue */
+       __vki_kernel_pid_t msg_lspid;   /* pid of last msgsnd */
+       __vki_kernel_pid_t msg_lrpid;   /* last receive pid */
+       unsigned long  __unused4;
+       unsigned long  __unused5;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/ipc.h
+//----------------------------------------------------------------------
+
+struct vki_ipc_kludge {
+       struct vki_msgbuf __user *msgp;
+       long msgtyp;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/shmbuf.h
+//----------------------------------------------------------------------
+
+struct vki_shmid64_ds {
+       struct vki_ipc64_perm   shm_perm;       /* operation perms */
+       vki_size_t              shm_segsz;      /* size of segment (bytes) */
+       __vki_kernel_time_t     shm_atime;      /* last attach time */
+       unsigned long           __unused1;
+       __vki_kernel_time_t     shm_dtime;      /* last detach time */
+       unsigned long           __unused2;
+       __vki_kernel_time_t     shm_ctime;      /* last change time */
+       unsigned long           __unused3;
+       __vki_kernel_pid_t      shm_cpid;       /* pid of creator */
+       __vki_kernel_pid_t      shm_lpid;       /* pid of last operator */
+       unsigned long           shm_nattch;     /* no. of current attaches */
+       unsigned long           __unused4;
+       unsigned long           __unused5;
+};
+
+struct vki_shminfo64 {
+       unsigned long   shmmax;
+       unsigned long   shmmin;
+       unsigned long   shmmni;
+       unsigned long   shmseg;
+       unsigned long   shmall;
+       unsigned long   __unused1;
+       unsigned long   __unused2;
+       unsigned long   __unused3;
+       unsigned long   __unused4;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/module.h
+//----------------------------------------------------------------------
+
+// [[This VKI_SIZEOF_* value is arch-specific, because it depends on the
+// word size.  The values are really guesses, but they are only needed for
+// init_module() which is very rare]]
+
+#if defined(KERNEL_2_2) || defined(KERNEL_2_4)
+// [[This is actually an over-estimate;  only 60 bytes are mandated.]]
+#  define VKI_SIZEOF_STRUCT_MODULE  96
+#else
+// [[This is a conservative guesstimate;  it can be longer, depending on
+//   certain #ifdefs.  Close enough.]]
+#  define VKI_SIZEOF_STRUCT_MODULE  160
+#endif
+
+//----------------------------------------------------------------------
+// And that's it!
+//----------------------------------------------------------------------
+
+#endif // __X86_LINUX_VKI_ARCH_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/x86-linux/vki_arch_posixtypes.h b/include/x86-linux/vki_arch_posixtypes.h
new file mode 100644 (file)
index 0000000..1e9dced
--- /dev/null
@@ -0,0 +1,64 @@
+
+/*--------------------------------------------------------------------*/
+/*--- x86/Linux-specific kernel interface: posix types.            ---*/
+/*---                                        vki_arch_posixtypes.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, an extensible x86 protected-mode
+   emulator for monitoring program execution on x86-Unixes.
+
+   Copyright (C) 2000-2004 Julian Seward 
+      jseward@acm.org
+
+   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, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307, USA.
+
+   The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __X86_LINUX_VKI_ARCH_POSIXTYPES_H
+#define __X86_LINUX_VKI_ARCH_POSIXTYPES_H
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/posix_types.h
+//----------------------------------------------------------------------
+
+typedef unsigned short __vki_kernel_mode_t;
+typedef long           __vki_kernel_off_t;
+typedef int            __vki_kernel_pid_t;
+typedef unsigned short __vki_kernel_ipc_pid_t;
+typedef unsigned short __vki_kernel_uid_t;
+typedef unsigned short __vki_kernel_gid_t;
+typedef unsigned int   __vki_kernel_size_t;
+typedef long           __vki_kernel_time_t;
+typedef long           __vki_kernel_suseconds_t;
+typedef long           __vki_kernel_clock_t;
+typedef int            __vki_kernel_timer_t;
+typedef char *         __vki_kernel_caddr_t;
+typedef unsigned int   __vki_kernel_uid32_t;
+typedef unsigned int   __vki_kernel_gid32_t;
+
+typedef long long      __vki_kernel_loff_t;
+
+typedef struct {
+       int     val[2];
+} __vki_kernel_fsid_t;
+
+#endif // __X86_LINUX_VKI_ARCH_POSIXTYPES_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
index e33a0aa10f7fdd1c489fdfa9f5cf391c3f611cab..5068564208e1efcf4fb8e3dc5b3598ba96cf106b 100644 (file)
@@ -438,7 +438,12 @@ Some more specific things are:
     <code>sbrk</code>, <code>setjmp</code> and <code>longjmp</code>.
 
 <p>
-<li>Similarly, valgrind should not really import any headers other
+<li>[Update: this is now out of date;  there are a number of such
+    kernel interface files -- vki*.h -- and now no kernel headers are used by
+    Valgrind at all.  We did this because unfortunately kernel headers
+    are frequently broken, and cannot be relied on.]
+
+    Similarly, valgrind should not really import any headers other
     than the Linux kernel headers, since it knows of no API other than
     the kernel interface to talk to.  At the moment this is really not
     in a good state, and <code>vg_syscall_mem</code> imports, via
index 23c9e45155aab8ed243f461232a21adfe090da78..c839c176748d7cab7c60883f52f56f87a3e6183c 100644 (file)
@@ -78,55 +78,55 @@ UInt vg_scan_all_valid_memory ( Bool is_valid_64k_chunk ( UInt ),
    volatile UInt res, numPages, page, primaryMapNo;
    volatile UInt page_first_word, nWordsNotified;
 
-   vki_ksigaction sigbus_saved;
-   vki_ksigaction sigbus_new;
-   vki_ksigaction sigsegv_saved;
-   vki_ksigaction sigsegv_new;
-   vki_ksigset_t  blockmask_saved;
-   vki_ksigset_t  unblockmask_new;
+   struct vki_sigaction sigbus_saved;
+   struct vki_sigaction sigbus_new;
+   struct vki_sigaction sigsegv_saved;
+   struct vki_sigaction sigsegv_new;
+   vki_sigset_t  blockmask_saved;
+   vki_sigset_t  unblockmask_new;
 
    /* Temporarily install a new sigsegv and sigbus handler, and make
       sure SIGBUS, SIGSEGV and SIGTERM are unblocked.  (Perhaps the
       first two can never be blocked anyway?)  */
 
    sigbus_new.ksa_handler = vg_scan_all_valid_memory_sighandler;
-   sigbus_new.ksa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
-   sigbus_new.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sigbus_new.ksa_mask );
+   sigbus_new.sa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
+   sigbus_new.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sigbus_new.sa_mask );
    sk_assert(res == 0);
 
    sigsegv_new.ksa_handler = vg_scan_all_valid_memory_sighandler;
-   sigsegv_new.ksa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
-   sigsegv_new.ksa_restorer = NULL;
-   res = VG_(ksigemptyset)( &sigsegv_new.ksa_mask );
+   sigsegv_new.sa_flags = VKI_SA_ONSTACK | VKI_SA_RESTART;
+   sigsegv_new.sa_restorer = NULL;
+   res = VG_(sigemptyset)( &sigsegv_new.sa_mask );
    sk_assert(res == 0+0);
 
-   res =  VG_(ksigemptyset)( &unblockmask_new );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGBUS );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGSEGV );
-   res |= VG_(ksigaddset)( &unblockmask_new, VKI_SIGTERM );
+   res =  VG_(sigemptyset)( &unblockmask_new );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGBUS );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGSEGV );
+   res |= VG_(sigaddset)( &unblockmask_new, VKI_SIGTERM );
    sk_assert(res == 0+0+0);
 
-   res = VG_(ksigaction)( VKI_SIGBUS, &sigbus_new, &sigbus_saved );
+   res = VG_(sigaction)( VKI_SIGBUS, &sigbus_new, &sigbus_saved );
    sk_assert(res == 0+0+0+0);
 
-   res = VG_(ksigaction)( VKI_SIGSEGV, &sigsegv_new, &sigsegv_saved );
+   res = VG_(sigaction)( VKI_SIGSEGV, &sigsegv_new, &sigsegv_saved );
    sk_assert(res == 0+0+0+0+0);
 
-   res = VG_(ksigprocmask)( VKI_SIG_UNBLOCK, &unblockmask_new, &blockmask_saved );
+   res = VG_(sigprocmask)( VKI_SIG_UNBLOCK, &unblockmask_new, &blockmask_saved );
    sk_assert(res == 0+0+0+0+0+0);
 
    /* The signal handlers are installed.  Actually do the memory scan. */
-   numPages = 1 << (32-VKI_BYTES_PER_PAGE_BITS);
+   numPages = 1 << (32-VKI_PAGE_SHIFT);
    sk_assert(numPages == 1048576);
-   sk_assert(4096 == (1 << VKI_BYTES_PER_PAGE_BITS));
+   sk_assert(4096 == (1 << VKI_PAGE_SHIFT));
 
    nWordsNotified = 0;
 
    for (page = 0; page < numPages; page++) {
 
       /* Base address of this 4k page. */
-      pageBase = page << VKI_BYTES_PER_PAGE_BITS;
+      pageBase = page << VKI_PAGE_SHIFT;
 
       /* Skip if this page is in an unused 64k chunk. */
       primaryMapNo = pageBase >> 16;
@@ -141,7 +141,7 @@ UInt vg_scan_all_valid_memory ( Bool is_valid_64k_chunk ( UInt ),
          segment all the way down to here, which is seriously bad.
          Hence: */
       anyValid = False;
-      for (addr = pageBase; addr < pageBase+VKI_BYTES_PER_PAGE; addr += 4) {
+      for (addr = pageBase; addr < pageBase+VKI_PAGE_SIZE; addr += 4) {
          if (is_valid_address(addr)) {
             anyValid = True;
             break;
@@ -158,7 +158,7 @@ UInt vg_scan_all_valid_memory ( Bool is_valid_64k_chunk ( UInt ),
          page_first_word = * (volatile UInt*)pageBase;
          /* we get here if we didn't get a fault */
          /* Scan the page */
-         for (addr = pageBase; addr < pageBase+VKI_BYTES_PER_PAGE; addr += 4) {
+         for (addr = pageBase; addr < pageBase+VKI_PAGE_SIZE; addr += 4) {
             if (is_valid_address(addr)) {
                nWordsNotified++;
                notify_word ( addr, *(UInt*)addr );
@@ -177,13 +177,13 @@ UInt vg_scan_all_valid_memory ( Bool is_valid_64k_chunk ( UInt ),
    }
 
    /* Restore signal state to whatever it was before. */
-   res = VG_(ksigaction)( VKI_SIGBUS, &sigbus_saved, NULL );
+   res = VG_(sigaction)( VKI_SIGBUS, &sigbus_saved, NULL );
    sk_assert(res == 0 +0);
 
-   res = VG_(ksigaction)( VKI_SIGSEGV, &sigsegv_saved, NULL );
+   res = VG_(sigaction)( VKI_SIGSEGV, &sigsegv_saved, NULL );
    sk_assert(res == 0 +0 +0);
 
-   res = VG_(ksigprocmask)( VKI_SIG_SETMASK, &blockmask_saved, NULL );
+   res = VG_(sigprocmask)( VKI_SIG_SETMASK, &blockmask_saved, NULL );
    sk_assert(res == 0 +0 +0 +0);
 
    return nWordsNotified;
@@ -433,7 +433,7 @@ void MAC_(do_detect_memory_leaks) (
 
    /* Do the scan of memory. */
    bytes_notified
-       = VKI_BYTES_PER_WORD
+       = sizeof(UWord)
          * vg_scan_all_valid_memory (
               is_valid_64k_chunk,
               is_valid_address,
index 92f9c841d29edd2384037fd0ca214fed0cbd5ecd..d6290424d39fe869f6f02e2944c9b1fee91eb14f 100644 (file)
@@ -38,9 +38,11 @@ make install DESTDIR=$RPM_BUILD_ROOT
 /usr/include/valgrind/helgrind.h
 /usr/include/valgrind/tool.h
 /usr/include/valgrind/tool_asm.h
-/usr/include/valgrind/vg_kerneliface.h
 /usr/include/valgrind/vg_skin.h
 /usr/include/valgrind/x86/tool_arch.h
+/usr/include/valgrind/linux/vki.h
+/usr/include/valgrind/x86-linux/vki_arch.h
+/usr/include/valgrind/x86-linux/vki_arch_posixtypes.h
 /usr/bin/valgrind
 /usr/bin/cg_annotate
 /usr/lib/valgrind