Create a new module, m_vki, and move all knowledge about the kernel
interface, except for the syscall numbers, into that.  Mostly this
means moving include/vki-*.h to include/vki/vki-*.h.

include/pub_tool_basics.h previously dragged in the entire kernel
interface.  I've done away with that, so that modules which need to
see the kernel interface now have to include pub_{core,tool}_vki.h
explicitly.  This is why there are many modified .c files -- they have
all acquired an extra #include line.

This certainly breaks all platforms except x86.  Will fix shortly.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6225 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 8d216b3..b2b0bf5 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -108,6 +108,7 @@
 	pub_core_transtab.h	\
 	pub_core_transtab_asm.h	\
 	pub_core_ume.h		\
+	pub_core_vki.h		\
 	pub_core_vkiscnums.h	\
 	m_coredump/priv_elf.h	\
 	m_debuginfo/priv_storage.h	\
@@ -162,6 +163,7 @@
 	m_translate.c \
 	m_transtab.c \
 	m_ume.c \
+	m_vki.c \
 	m_vkiscnums.c \
 	m_aspacemgr/aspacemgr.c \
 	m_debuginfo/storage.c \
diff --git a/coregrind/launcher.c b/coregrind/launcher.c
index 30ed02d..ab24345 100644
--- a/coregrind/launcher.c
+++ b/coregrind/launcher.c
@@ -46,6 +46,8 @@
 #include <unistd.h>
 
 #include "pub_core_debuglog.h"
+#include "pub_core_vki.h"       // Avoids warnings from
+                                // pub_core_libcfile.h
 #include "pub_core_libcproc.h"  // For VALGRIND_LIB, VALGRIND_LAUNCHER
 #include "pub_core_ume.h"
 
diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c
index 0e857cd..28c8a46 100644
--- a/coregrind/m_aspacemgr/aspacemgr.c
+++ b/coregrind/m_aspacemgr/aspacemgr.c
@@ -35,6 +35,7 @@
    minimal set of imports. */
 
 #include "pub_core_basics.h"     // types
+#include "pub_core_vki.h"
 
 #include "pub_core_debuglog.h"   // VG_(debugLog)
 
diff --git a/coregrind/m_clientstate.c b/coregrind/m_clientstate.c
index 2db9299..fd16cff 100644
--- a/coregrind/m_clientstate.c
+++ b/coregrind/m_clientstate.c
@@ -31,6 +31,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_clientstate.h"
 
 /*-----------------------------------------------------------------*/
diff --git a/coregrind/m_commandline.c b/coregrind/m_commandline.c
index c4637f3..2d1a83f 100644
--- a/coregrind/m_commandline.c
+++ b/coregrind/m_commandline.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcfile.h"
diff --git a/coregrind/m_coredump/coredump-elf.c b/coregrind/m_coredump/coredump-elf.c
index 814026b..87fad6f 100644
--- a/coregrind/m_coredump/coredump-elf.c
+++ b/coregrind/m_coredump/coredump-elf.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_machine.h"
diff --git a/coregrind/m_coredump/coredump-x86-linux.c b/coregrind/m_coredump/coredump-x86-linux.c
index 754df98..ed2f95f 100644
--- a/coregrind/m_coredump/coredump-x86-linux.c
+++ b/coregrind/m_coredump/coredump-x86-linux.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_coredump.h"
 #include "pub_core_threadstate.h"
diff --git a/coregrind/m_debugger.c b/coregrind/m_debugger.c
index 7122be8..ae30646 100644
--- a/coregrind/m_debugger.c
+++ b/coregrind/m_debugger.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_debugger.h"
diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c
index d4d34f1..23256ac 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -35,6 +35,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"   /* self */
 #include "pub_core_demangle.h"
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index e3318e6..49c0c1a 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -35,6 +35,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcprint.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c
index 2fb30f4..cb71883 100644
--- a/coregrind/m_errormgr.c
+++ b/coregrind/m_errormgr.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"      // For VG_N_THREADS
 #include "pub_core_debugger.h"
 #include "pub_core_debuginfo.h"
diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c
index 5e4c5ed..1f50fed 100644
--- a/coregrind/m_libcassert.c
+++ b/coregrind/m_libcassert.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c
index ec455841..37bdb07 100644
--- a/coregrind/m_libcfile.c
+++ b/coregrind/m_libcfile.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcfile.h"
diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c
index 118cad1..e425590 100644
--- a/coregrind/m_libcprint.c
+++ b/coregrind/m_libcprint.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_debuglog.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c
index 16efd4d..b3d1747 100644
--- a/coregrind/m_libcproc.c
+++ b/coregrind/m_libcproc.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcprint.h"
diff --git a/coregrind/m_libcsignal.c b/coregrind/m_libcsignal.c
index 39c81cd..9e11ed0 100644
--- a/coregrind/m_libcsignal.c
+++ b/coregrind/m_libcsignal.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcsignal.h"
diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c
index f0d6630..357fbdb 100644
--- a/coregrind/m_machine.c
+++ b/coregrind/m_machine.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcbase.h"
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index 4bb7eea..207c4ed 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_aspacemgr.h"
diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c
index f607eeb..d1bd9d1 100644
--- a/coregrind/m_mallocfree.c
+++ b/coregrind/m_mallocfree.c
@@ -30,6 +30,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_debuglog.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_aspacemgr.h"
diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c
index 4d1783c..6d6800a 100644
--- a/coregrind/m_replacemalloc/vg_replace_malloc.c
+++ b/coregrind/m_replacemalloc/vg_replace_malloc.c
@@ -45,6 +45,7 @@
    ------------------------------------------------------------------ */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"           // VKI_EINVAL, VKI_ENOMEM, VKI_PAGE_SIZE
 #include "pub_core_clreq.h"         // for VALGRIND_INTERNAL_PRINTF,
                                     //   VALGRIND_NON_SIMD_CALL[12]
 #include "pub_core_debuginfo.h"     // needed for pub_core_redir.h :(
diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c
index c2f4333..6788b29 100644
--- a/coregrind/m_scheduler/scheduler.c
+++ b/coregrind/m_scheduler/scheduler.c
@@ -58,6 +58,8 @@
  */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_clreq.h"         // for VG_USERREQ__*
@@ -81,7 +83,6 @@
 #include "pub_core_tooliface.h"
 #include "pub_core_translate.h"     // For VG_(translate)()
 #include "pub_core_transtab.h"
-#include "pub_core_vkiscnums.h"
 #include "priv_sema.h"
 
 /* #include "pub_core_debuginfo.h" */   // DEBUGGING HACK ONLY
diff --git a/coregrind/m_scheduler/sema.c b/coregrind/m_scheduler/sema.c
index a50e0d0..bc9fc69 100644
--- a/coregrind/m_scheduler/sema.c
+++ b/coregrind/m_scheduler/sema.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcfile.h"
 #include "pub_core_libcproc.h"      // For VG_(gettid)()
diff --git a/coregrind/m_sigframe/sigframe-x86-linux.c b/coregrind/m_sigframe/sigframe-x86-linux.c
index a6a50d1..6f90460 100644
--- a/coregrind/m_sigframe/sigframe-x86-linux.c
+++ b/coregrind/m_sigframe/sigframe-x86-linux.c
@@ -30,6 +30,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h" /* find_segment */
 #include "pub_core_libcbase.h"
diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index 3ca1398..5aabb68 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -80,6 +80,7 @@
  */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_debuglog.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_clientstate.h"
diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c
index c502a3f..d7d9d16 100644
--- a/coregrind/m_stacktrace.c
+++ b/coregrind/m_stacktrace.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"
 #include "pub_core_aspacemgr.h"     // For VG_(is_addressable)()
diff --git a/coregrind/m_syscall.c b/coregrind/m_syscall.c
index 2514069..721dafa 100644
--- a/coregrind/m_syscall.c
+++ b/coregrind/m_syscall.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_syscall.h"
 
 /* ---------------------------------------------------------------------
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index 3812e19..19a694e 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -29,6 +29,8 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"     // VG_(di_notify_*)
 #include "pub_core_aspacemgr.h"
@@ -55,8 +57,6 @@
 #include "priv_types_n_macros.h"
 #include "priv_syswrap-generic.h"
 
-#include "pub_core_vkiscnums.h"     /* for the __NR_* constants */
-
 
 /* Returns True iff address range is something the client can
    plausibly mess with: all of it is either already belongs to the
diff --git a/coregrind/m_syswrap/syswrap-linux-variants.c b/coregrind/m_syswrap/syswrap-linux-variants.c
index a4cdcca..d805d1f 100644
--- a/coregrind/m_syswrap/syswrap-linux-variants.c
+++ b/coregrind/m_syswrap/syswrap-linux-variants.c
@@ -46,6 +46,7 @@
 
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_debuginfo.h"    // VG_(di_notify_*)
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index de5e737..cd46345 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -29,6 +29,8 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_debuginfo.h"    // VG_(di_notify_*)
@@ -53,7 +55,6 @@
 #include "priv_syswrap-generic.h"
 #include "priv_syswrap-linux.h"
 
-#include "pub_core_vkiscnums.h"    /* for the __NR_* constants */
 
 // Run a thread from beginning to end and return the thread's
 // scheduler-return-code.
diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c
index a2fb0ca..cc0da7d 100644
--- a/coregrind/m_syswrap/syswrap-main.c
+++ b/coregrind/m_syswrap/syswrap-main.c
@@ -30,6 +30,8 @@
 
 #include "libvex_guest_offsets.h"
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_basics.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index a782af1..26a0d9b 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -34,6 +34,8 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_debuginfo.h"     // VG_(di_notify_mmap)
 #include "pub_core_aspacemgr.h"
@@ -58,8 +60,6 @@
 #include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
 #include "priv_syswrap-main.h"
 
-#include "pub_core_vkiscnums.h"      /* for the __NR_* constants */
-
 
 /* ---------------------------------------------------------------------
    clone() handling
diff --git a/coregrind/m_threadmodel.c b/coregrind/m_threadmodel.c
index 6e3c64f..e7d3a09 100644
--- a/coregrind/m_threadmodel.c
+++ b/coregrind/m_threadmodel.c
@@ -61,6 +61,7 @@
  */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_errormgr.h"
 #include "pub_core_execontext.h"
 #include "pub_core_libcassert.h"
diff --git a/coregrind/m_threadstate.c b/coregrind/m_threadstate.c
index a5d0891..1c4633e 100644
--- a/coregrind/m_threadstate.c
+++ b/coregrind/m_threadstate.c
@@ -29,6 +29,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
 #include "pub_core_libcassert.h"
 
diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c
index baf2541..63dbb20 100644
--- a/coregrind/m_translate.c
+++ b/coregrind/m_translate.c
@@ -30,6 +30,7 @@
 */
 
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_aspacemgr.h"
 
 #include "pub_core_machine.h"    // VG_(fnptr_to_fnentry)
diff --git a/coregrind/m_ume.c b/coregrind/m_ume.c
index 4ff5953..8151267 100644
--- a/coregrind/m_ume.c
+++ b/coregrind/m_ume.c
@@ -38,6 +38,7 @@
 // included ahead of the glibc ones.  This fix is a kludge;  the right
 // solution is to entirely remove the glibc dependency.
 #include "pub_core_basics.h"
+#include "pub_core_vki.h"
 #include "pub_core_aspacemgr.h"   // various mapping fns
 #include "pub_core_debuglog.h"
 #include "pub_core_libcbase.h"
diff --git a/coregrind/m_vki.c b/coregrind/m_vki.c
new file mode 100644
index 0000000..7cd88e7
--- /dev/null
+++ b/coregrind/m_vki.c
@@ -0,0 +1,43 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Notional "implementation" for m_vki.                         ---*/
+/*---                                                      m_vki.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2006-2006 OpenWorks LLP
+      info@open-works.co.uk
+
+   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.
+*/
+
+#include "pub_core_basics.h"
+#include "pub_core_vki.h"     /* self */
+
+/* We have pub_{core,tool}_vki.h.  This is the matching implementation
+   for that interface.  In fact there is no implementation, as the
+   sole purpose of the module is to export types and constants
+   describing the kernel interface, so this file is empty. */
+
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                  m_vki.c ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/pub_core_vki.h b/coregrind/pub_core_vki.h
new file mode 100644
index 0000000..38999bb
--- /dev/null
+++ b/coregrind/pub_core_vki.h
@@ -0,0 +1,50 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Top level for kernel interface declarations.                 ---*/
+/*---                                               pub_core_vki.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2006 Julian Seward
+      jseward@acm.org
+   Copyright (C) 2005-2006 Nicholas Nethercote
+      njn@valgrind.org
+   Copyright (C) 2006-2006 OpenWorks LLP
+      info@open-works.co.uk
+
+   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 __PUB_CORE_VKI_H
+#define __PUB_CORE_VKI_H
+
+/* Most unfortunately, all the kernel decls are visible to tools.  Not
+   really necessary, but to avoid this would require some tedious
+   refactoring of the sources.  Anyway, we live with this kludge, and
+   that means the only thing to be done here is ... */
+
+#include "pub_tool_vki.h"
+
+#endif // __PUB_CORE_VKI_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/