Initial import of valgrind 3.6.0.
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..33d0857
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,63 @@
+
+# The "nobase" means that the vki/ path on some of them will be preserved
+# when they are installed into $(includedir)/valgrind.
+nobase_pkginclude_HEADERS = \
+	pub_tool_basics.h 		\
+	pub_tool_basics_asm.h 		\
+	pub_tool_aspacehl.h 		\
+	pub_tool_aspacemgr.h 		\
+	pub_tool_clientstate.h		\
+	pub_tool_clreq.h		\
+	pub_tool_cpuid.h 		\
+	pub_tool_debuginfo.h 		\
+	pub_tool_errormgr.h 		\
+	pub_tool_execontext.h 		\
+	pub_tool_hashtable.h 		\
+	pub_tool_libcbase.h 		\
+	pub_tool_libcassert.h 		\
+	pub_tool_libcfile.h 		\
+	pub_tool_libcprint.h 		\
+	pub_tool_libcproc.h 		\
+	pub_tool_libcsignal.h 		\
+	pub_tool_machine.h 		\
+	pub_tool_mallocfree.h 		\
+	pub_tool_options.h 		\
+	pub_tool_oset.h 		\
+	pub_tool_redir.h		\
+	pub_tool_replacemalloc.h	\
+	pub_tool_seqmatch.h		\
+	pub_tool_signals.h 		\
+	pub_tool_sparsewa.h		\
+	pub_tool_stacktrace.h 		\
+	pub_tool_threadstate.h 		\
+	pub_tool_tooliface.h 		\
+	pub_tool_vki.h			\
+	pub_tool_vkiscnums.h		\
+	pub_tool_vkiscnums_asm.h	\
+	pub_tool_wordfm.h		\
+	pub_tool_xarray.h		\
+	valgrind.h			\
+	vki/vki-linux.h			\
+	vki/vki-darwin.h		\
+	vki/vki-posixtypes-amd64-linux.h \
+	vki/vki-posixtypes-ppc32-linux.h \
+	vki/vki-posixtypes-ppc64-linux.h \
+	vki/vki-posixtypes-x86-linux.h	 \
+	vki/vki-posixtypes-arm-linux.h	 \
+	vki/vki-amd64-linux.h		\
+	vki/vki-ppc32-linux.h		\
+	vki/vki-ppc64-linux.h		\
+	vki/vki-x86-linux.h		\
+	vki/vki-arm-linux.h		\
+	vki/vki-scnums-amd64-linux.h	\
+	vki/vki-scnums-ppc32-linux.h	\
+	vki/vki-scnums-ppc64-linux.h	\
+	vki/vki-scnums-x86-linux.h	\
+	vki/vki-scnums-arm-linux.h	\
+	vki/vki-scnums-darwin.h
+
+noinst_HEADERS = \
+	vki/vki-ppc32-aix5.h		\
+	vki/vki-ppc64-aix5.h		\
+	vki/vki-scnums-aix5.h
+
diff --git a/include/Makefile.in b/include/Makefile.in
new file mode 100644
index 0000000..2750e25
--- /dev/null
+++ b/include/Makefile.in
@@ -0,0 +1,532 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = include
+DIST_COMMON = $(nobase_pkginclude_HEADERS) $(noinst_HEADERS) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgincludedir)"
+HEADERS = $(nobase_pkginclude_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_CFLAGS = @BOOST_CFLAGS@
+BOOST_LIBS = @BOOST_LIBS@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_SUPP = @DEFAULT_SUPP@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DIFF = @DIFF@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FLAG_FNO_STACK_PROTECTOR = @FLAG_FNO_STACK_PROTECTOR@
+FLAG_M32 = @FLAG_M32@
+FLAG_M64 = @FLAG_M64@
+FLAG_MAIX32 = @FLAG_MAIX32@
+FLAG_MAIX64 = @FLAG_MAIX64@
+FLAG_MMMX = @FLAG_MMMX@
+FLAG_MSSE = @FLAG_MSSE@
+FLAG_NO_BUILD_ID = @FLAG_NO_BUILD_ID@
+FLAG_UNLIMITED_INLINE_UNIT_GROWTH = @FLAG_UNLIMITED_INLINE_UNIT_GROWTH@
+FLAG_W_EXTRA = @FLAG_W_EXTRA@
+FLAG_W_NO_EMPTY_BODY = @FLAG_W_NO_EMPTY_BODY@
+FLAG_W_NO_FORMAT_ZERO_LENGTH = @FLAG_W_NO_FORMAT_ZERO_LENGTH@
+FLAG_W_NO_UNINITIALIZED = @FLAG_W_NO_UNINITIALIZED@
+GDB = @GDB@
+GLIBC_VERSION = @GLIBC_VERSION@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MPI_CC = @MPI_CC@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PREFERRED_STACK_BOUNDARY = @PREFERRED_STACK_BOUNDARY@
+QTCORE_CFLAGS = @QTCORE_CFLAGS@
+QTCORE_LIBS = @QTCORE_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VALT_LOAD_ADDRESS_PRI = @VALT_LOAD_ADDRESS_PRI@
+VALT_LOAD_ADDRESS_SEC = @VALT_LOAD_ADDRESS_SEC@
+VERSION = @VERSION@
+VGCONF_ARCH_PRI = @VGCONF_ARCH_PRI@
+VGCONF_ARCH_SEC = @VGCONF_ARCH_SEC@
+VGCONF_OS = @VGCONF_OS@
+VGCONF_PLATFORM_PRI_CAPS = @VGCONF_PLATFORM_PRI_CAPS@
+VGCONF_PLATFORM_SEC_CAPS = @VGCONF_PLATFORM_SEC_CAPS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# The "nobase" means that the vki/ path on some of them will be preserved
+# when they are installed into $(includedir)/valgrind.
+nobase_pkginclude_HEADERS = \
+	pub_tool_basics.h 		\
+	pub_tool_basics_asm.h 		\
+	pub_tool_aspacehl.h 		\
+	pub_tool_aspacemgr.h 		\
+	pub_tool_clientstate.h		\
+	pub_tool_clreq.h		\
+	pub_tool_cpuid.h 		\
+	pub_tool_debuginfo.h 		\
+	pub_tool_errormgr.h 		\
+	pub_tool_execontext.h 		\
+	pub_tool_hashtable.h 		\
+	pub_tool_libcbase.h 		\
+	pub_tool_libcassert.h 		\
+	pub_tool_libcfile.h 		\
+	pub_tool_libcprint.h 		\
+	pub_tool_libcproc.h 		\
+	pub_tool_libcsignal.h 		\
+	pub_tool_machine.h 		\
+	pub_tool_mallocfree.h 		\
+	pub_tool_options.h 		\
+	pub_tool_oset.h 		\
+	pub_tool_redir.h		\
+	pub_tool_replacemalloc.h	\
+	pub_tool_seqmatch.h		\
+	pub_tool_signals.h 		\
+	pub_tool_sparsewa.h		\
+	pub_tool_stacktrace.h 		\
+	pub_tool_threadstate.h 		\
+	pub_tool_tooliface.h 		\
+	pub_tool_vki.h			\
+	pub_tool_vkiscnums.h		\
+	pub_tool_vkiscnums_asm.h	\
+	pub_tool_wordfm.h		\
+	pub_tool_xarray.h		\
+	valgrind.h			\
+	vki/vki-linux.h			\
+	vki/vki-darwin.h		\
+	vki/vki-posixtypes-amd64-linux.h \
+	vki/vki-posixtypes-ppc32-linux.h \
+	vki/vki-posixtypes-ppc64-linux.h \
+	vki/vki-posixtypes-x86-linux.h	 \
+	vki/vki-posixtypes-arm-linux.h	 \
+	vki/vki-amd64-linux.h		\
+	vki/vki-ppc32-linux.h		\
+	vki/vki-ppc64-linux.h		\
+	vki/vki-x86-linux.h		\
+	vki/vki-arm-linux.h		\
+	vki/vki-scnums-amd64-linux.h	\
+	vki/vki-scnums-ppc32-linux.h	\
+	vki/vki-scnums-ppc64-linux.h	\
+	vki/vki-scnums-x86-linux.h	\
+	vki/vki-scnums-arm-linux.h	\
+	vki/vki-scnums-darwin.h
+
+noinst_HEADERS = \
+	vki/vki-ppc32-aix5.h		\
+	vki/vki-ppc64-aix5.h		\
+	vki/vki-scnums-aix5.h
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign include/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-nobase_pkgincludeHEADERS: $(nobase_pkginclude_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
+	@list='$(nobase_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
+	$(am__nobase_list) | while read dir files; do \
+	  xfiles=; for file in $$files; do \
+	    if test -f "$$file"; then xfiles="$$xfiles $$file"; \
+	    else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
+	  test -z "$$xfiles" || { \
+	    test "x$$dir" = x. || { \
+	      echo "$(MKDIR_P) '$(DESTDIR)$(pkgincludedir)/$$dir'"; \
+	      $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)/$$dir"; }; \
+	    echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(pkgincludedir)/$$dir'"; \
+	    $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(pkgincludedir)/$$dir" || exit $$?; }; \
+	done
+
+uninstall-nobase_pkgincludeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nobase_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
+	$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(pkgincludedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(pkgincludedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(pkgincludedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-nobase_pkgincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-nobase_pkgincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	ctags distclean distclean-generic distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man \
+	install-nobase_pkgincludeHEADERS install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+	pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-nobase_pkgincludeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/include/pub_tool_aspacehl.h b/include/pub_tool_aspacehl.h
new file mode 100644
index 0000000..00f0093
--- /dev/null
+++ b/include/pub_tool_aspacehl.h
@@ -0,0 +1,44 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Services layered on top of m_aspacemgr.  pub_tool_aspacehl.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2009-2010 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 __PUB_TOOL_ASPACEHL_H
+#define __PUB_TOOL_ASPACEHL_H
+
+// Extract from aspacem a vector of the current segment start
+// addresses.  The vector is dynamically allocated and should be freed
+// by the caller when done.  REQUIRES m_mallocfree to be running.
+// Writes the number of addresses required into *n_acquired.
+extern Addr* VG_(get_segment_starts) ( /*OUT*/Int* n_acquired );
+
+#endif   // __PUB_TOOL_ASPACEHL_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h
new file mode 100644
index 0000000..100b632
--- /dev/null
+++ b/include/pub_tool_aspacemgr.h
@@ -0,0 +1,158 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Address space manager.                  pub_tool_aspacemgr.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_ASPACEMGR_H
+#define __PUB_TOOL_ASPACEMGR_H
+
+
+//--------------------------------------------------------------
+// Definition of address-space segments
+
+/* Describes segment kinds. */
+typedef
+   enum {
+      SkFree,   // unmapped space
+      SkAnonC,  // anonymous mapping belonging to the client
+      SkAnonV,  // anonymous mapping belonging to valgrind
+      SkFileC,  // file mapping belonging to the client
+      SkFileV,  // file mapping belonging to valgrind
+      SkShmC,   // shared memory segment belonging to the client
+      SkResvn   // reservation
+   }
+   SegKind;
+
+/* Describes how a reservation segment can be resized. */
+typedef
+   enum {
+      SmLower,  // lower end can move up
+      SmFixed,  // cannot be shrunk
+      SmUpper   // upper end can move down
+   }
+   ShrinkMode;
+
+/* Describes a segment.  Invariants:
+
+     kind == SkFree:
+        // the only meaningful fields are .start and .end
+
+     kind == SkAnon{C,V}:
+        // smode==SmFixed
+        // there's no associated file:
+        dev==ino==foff = 0, fnidx == -1
+        // segment may have permissions
+
+     kind == SkFile{C,V}:
+        // smode==SmFixed
+        moveLo == moveHi == NotMovable, maxlen == 0
+        // there is an associated file
+        // segment may have permissions
+
+     kind == SkShmC:
+        // smode==SmFixed
+        // there's no associated file:
+        dev==ino==foff = 0, fnidx == -1
+        // segment may have permissions
+
+     kind == SkResvn
+        // the segment may be resized if required
+        // there's no associated file:
+        dev==ino==foff = 0, fnidx == -1
+        // segment has no permissions
+        hasR==hasW==hasX==anyTranslated == False
+
+     Also: anyTranslated==True is only allowed in SkFileV and SkAnonV
+           (viz, not allowed to make translations from non-client areas)
+*/
+typedef
+   struct {
+      SegKind kind;
+      /* Extent (SkFree, SkAnon{C,V}, SkFile{C,V}, SkResvn) */
+      Addr    start;    // lowest address in range
+      Addr    end;      // highest address in range
+      /* Shrinkable? (SkResvn only) */
+      ShrinkMode smode;
+      /* Associated file (SkFile{C,V} only) */
+      ULong   dev;
+      ULong   ino;
+      Off64T  offset;
+      UInt    mode;
+      Int     fnIdx;    // file name table index, if name is known
+      /* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
+      Bool    hasR;
+      Bool    hasW;
+      Bool    hasX;
+      Bool    hasT;     // True --> translations have (or MAY have)
+                        // been taken from this segment
+      Bool    isCH;     // True --> is client heap (SkAnonC ONLY)
+      /* Admin */
+      Bool    mark;
+   }
+   NSegment;
+
+
+/* Collect up the start addresses of all non-free, non-resvn segments.
+   The interface is a bit strange in order to avoid potential
+   segment-creation races caused by dynamic allocation of the result
+   buffer *starts.
+
+   The function first computes how many entries in the result
+   buffer *starts will be needed.  If this number <= nStarts,
+   they are placed in starts[0..], and the number is returned.
+   If nStarts is not large enough, nothing is written to
+   starts[0..], and the negation of the size is returned.
+
+   Correct use of this function may mean calling it multiple times in
+   order to establish a suitably-sized buffer. */
+extern Int VG_(am_get_segment_starts)( Addr* starts, Int nStarts );
+
+
+// See pub_core_aspacemgr.h for description.
+extern NSegment const * VG_(am_find_nsegment) ( Addr a ); 
+
+// See pub_core_aspacemgr.h for description.
+extern HChar* VG_(am_get_filename)( NSegment const * );
+
+// See pub_core_aspacemgr.h for description.
+extern Bool VG_(am_is_valid_for_client) ( Addr start, SizeT len, 
+                                          UInt prot );
+
+// See pub_core_aspacemgr.h for description.
+/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
+extern void* VG_(am_shadow_alloc)(SizeT size);
+
+/* Unmap the given address range and update the segment array
+   accordingly.  This fails if the range isn't valid for valgrind. */
+extern SysRes VG_(am_munmap_valgrind)( Addr start, SizeT length );
+
+#endif   // __PUB_TOOL_ASPACEMGR_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
new file mode 100644
index 0000000..6e92ff2
--- /dev/null
+++ b/include/pub_tool_basics.h
@@ -0,0 +1,342 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Header included by every tool C file.      pub_tool_basics.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_BASICS_H
+#define __PUB_TOOL_BASICS_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This header should be imported by every single C file in
+// tools.  It contains the basic types and other things needed everywhere.
+// There is no corresponding C file because this isn't a module
+// containing executable code, it's all just declarations.
+//--------------------------------------------------------------------
+
+/* ---------------------------------------------------------------------
+   Other headers to include
+   ------------------------------------------------------------------ */
+
+// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong,
+// Addr32, Addr64, HWord, HChar, Bool, False and True.
+#include "libvex_basictypes.h"
+
+// For varargs types
+#include <stdarg.h>
+
+
+/* ---------------------------------------------------------------------
+   symbol prefixing
+   ------------------------------------------------------------------ */
+ 
+// All symbols externally visible from Valgrind are prefixed
+// as specified here to avoid namespace conflict problems.
+//
+// VG_ is for symbols exported from modules.  ML_ (module-local) is
+// for symbols which are not intended to be visible outside modules,
+// but which cannot be declared as C 'static's since they need to be
+// visible across C files within a given module.  It is a mistake for
+// a ML_ name to appear in a pub_core_*.h or pub_tool_*.h file.
+// Likewise it is a mistake for a VG_ name to appear in a priv_*.h
+// file. 
+
+#define VGAPPEND(str1,str2) str1##str2
+
+#define VG_(str)    VGAPPEND(vgPlain_,          str)
+#define ML_(str)    VGAPPEND(vgModuleLocal_,    str)
+
+
+/* ---------------------------------------------------------------------
+   builtin types
+   ------------------------------------------------------------------ */
+
+// By choosing the right types, we can get these right for 32-bit and 64-bit
+// platforms without having to do any conditional compilation or anything.
+// POSIX references:
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/stddef.h.html
+// 
+// Size in bits on:                          32-bit archs   64-bit archs
+//                                           ------------   ------------
+typedef unsigned long          UWord;     // 32             64
+typedef   signed long           Word;     // 32             64
+
+// Addr is for holding an address.  AddrH was intended to be "Addr on the
+// host", for the notional case where host word size != guest word size.
+// But since the assumption that host arch == guest arch has become so
+// deeply wired in, it's a pretty pointless distinction now.
+typedef UWord                  Addr;      // 32             64
+typedef UWord                  AddrH;     // 32             64
+
+// Our equivalents of POSIX 'size_t' and 'ssize_t':
+// - size_t is an "unsigned integer type of the result of the sizeof operator".
+// - ssize_t is "used for a count of bytes or an error indication".
+typedef UWord                  SizeT;     // 32             64
+typedef  Word                 SSizeT;     // 32             64
+
+// Our equivalent of POSIX 'ptrdiff_t':
+// - ptrdiff_t is a "signed integer type of the result of subtracting two
+//   pointers".
+// We use it for memory offsets, eg. the offset into a memory block.
+typedef  Word                 PtrdiffT;   // 32             64
+
+// Our equivalent of POSIX 'off_t':
+// - off_t is "used for file sizes".
+// At one point we were using it for memory offsets, but PtrdiffT should be
+// used in those cases.
+// Nb: on Linux and AIX, off_t is a signed word-sized int.  On Darwin it's
+// always a signed 64-bit int.  So we defined our own Off64T as well.
+#if defined(VGO_linux) || defined(VGO_aix5)
+typedef Word                   OffT;      // 32             64
+#elif defined(VGO_darwin)
+typedef Long                   OffT;      // 64             64
+#else
+#  error Unknown OS
+#endif
+typedef Long                 Off64T;      // 64             64
+
+#if !defined(NULL)
+#  define NULL ((void*)0)
+#endif
+
+/* This is just too useful to not have around the place somewhere. */
+typedef  struct { UWord uw1; UWord uw2; }  UWordPair;
+
+
+/* ---------------------------------------------------------------------
+   non-builtin types
+   ------------------------------------------------------------------ */
+
+// These probably shouldn't be here, but moving them to their logical
+// modules results in a lot more #includes...
+
+/* ThreadIds are simply indices into the VG_(threads)[] array. */
+typedef UInt ThreadId;
+
+/* An abstraction of syscall return values.
+   Linux:
+      When _isError == False, 
+         _val holds the return value.
+      When _isError == True,  
+         _err holds the error code.
+
+   AIX:
+      _res is the POSIX result of the syscall.
+      _err is the corresponding errno value.
+      _isError === _err==0
+
+      Unlike on Linux, it is possible for _err to be nonzero (thus an
+      error has occurred), nevertheless _res is also nonzero.  AIX
+      userspace does not appear to consistently inspect _err to
+      determine whether or not an error has occurred.  For example,
+      sys_open() will return -1 for _val if a file cannot be opened,
+      as well as the relevant errno value in _err, but AIX userspace
+      then consults _val to figure out if the syscall failed, rather
+      than looking at _err.  Hence we need to represent them both.
+
+   Darwin:
+      Interpretation depends on _mode:
+      MACH, MDEP:
+         these can never 'fail' (apparently).  The result of the
+         syscall is a single host word, _wLO.
+      UNIX:
+         Can record a double-word error or a double-word result:
+         When _mode is SysRes_UNIX_OK,  _wHI:_wLO holds the result.
+         When _mode is SysRes_UNIX_ERR, _wHI:_wLO holds the error code.
+         Probably the high word of an error is always ignored by
+         userspace, but we have to record it, so that we can correctly
+         update both {R,E}DX and {R,E}AX (in guest state) given a SysRes,
+         if we're required to.
+*/
+#if defined(VGO_linux)
+typedef
+   struct {
+      UWord _val;
+      Bool  _isError;
+   }
+   SysRes;
+#elif defined(VGO_aix5)
+typedef
+   struct {
+      UWord _res;
+      UWord _err;
+      Bool  _isError;
+   }
+   SysRes;
+#elif defined(VGO_darwin)
+typedef
+   enum { 
+      SysRes_MACH=40,  // MACH, result is _wLO
+      SysRes_MDEP,     // MDEP, result is _wLO
+      SysRes_UNIX_OK,  // UNIX, success, result is _wHI:_wLO
+      SysRes_UNIX_ERR  // UNIX, error,   error  is _wHI:_wLO
+   }
+   SysResMode;
+typedef
+   struct {
+      UWord _wLO;
+      UWord _wHI;
+      SysResMode _mode;
+   }
+   SysRes;
+#else
+#  error "Unknown OS"
+#endif
+
+
+/* ---- And now some basic accessor functions for it. ---- */
+
+#if defined(VGO_linux)
+
+static inline Bool sr_isError ( SysRes sr ) {
+   return sr._isError;
+}
+static inline UWord sr_Res ( SysRes sr ) {
+   return sr._isError ? 0 : sr._val;
+}
+static inline UWord sr_ResHI ( SysRes sr ) {
+   return 0;
+}
+static inline UWord sr_Err ( SysRes sr ) {
+   return sr._isError ? sr._val : 0;
+}
+static inline Bool sr_EQ ( SysRes sr1, SysRes sr2 ) {
+   return sr1._val == sr2._val 
+          && ((sr1._isError && sr2._isError) 
+              || (!sr1._isError && !sr2._isError));
+}
+
+#elif defined(VGO_aix5)
+#  error "need to define SysRes accessors on AIX5 (copy from 3.4.1 sources)"
+
+
+#elif defined(VGO_darwin)
+
+static inline Bool sr_isError ( SysRes sr ) {
+   switch (sr._mode) {
+      case SysRes_UNIX_ERR: return True;
+      default:              return False;
+      /* should check tags properly and assert here, but we can't here */
+   }
+}
+
+static inline UWord sr_Res ( SysRes sr ) {
+   switch (sr._mode) {
+      case SysRes_MACH:
+      case SysRes_MDEP:
+      case SysRes_UNIX_OK: return sr._wLO;
+      default: return 0; /* should assert, but we can't here */
+   }
+}
+
+static inline UWord sr_ResHI ( SysRes sr ) {
+   switch (sr._mode) {
+      case SysRes_UNIX_OK: return sr._wHI;
+      default: return 0; /* should assert, but we can't here */
+   }
+}
+
+static inline UWord sr_Err ( SysRes sr ) {
+   switch (sr._mode) {
+      case SysRes_UNIX_ERR: return sr._wLO;
+      default: return 0; /* should assert, but we can't here */
+   }
+}
+
+static inline Bool sr_EQ ( SysRes sr1, SysRes sr2 ) {
+   return sr1._mode == sr2._mode
+          && sr1._wLO == sr2._wLO && sr1._wHI == sr2._wHI;
+}
+
+#else
+#  error "Unknown OS"
+#endif
+
+
+/* ---------------------------------------------------------------------
+   Miscellaneous (word size, endianness, regparmness, stringification)
+   ------------------------------------------------------------------ */
+
+/* Word size: this is going to be either 4 or 8. */
+// It should probably be in m_machine.
+#define VG_WORDSIZE VEX_HOST_WORDSIZE
+
+/* Endianness */
+#undef VG_BIGENDIAN
+#undef VG_LITTLEENDIAN
+
+#if defined(VGA_x86) || defined(VGA_amd64) || defined (VGA_arm)
+#  define VG_LITTLEENDIAN 1
+#elif defined(VGA_ppc32) || defined(VGA_ppc64)
+#  define VG_BIGENDIAN 1
+#else
+#  error Unknown arch
+#endif
+
+/* Regparmness */
+#if defined(VGA_x86)
+#  define VG_REGPARM(n)            __attribute__((regparm(n)))
+#elif defined(VGA_amd64) || defined(VGA_ppc32) \
+      || defined(VGA_ppc64) || defined(VGA_arm)
+#  define VG_REGPARM(n)            /* */
+#else
+#  error Unknown arch
+#endif
+
+/* Macro games */
+#define VG_STRINGIFZ(__str)  #__str
+#define VG_STRINGIFY(__str)  VG_STRINGIFZ(__str)
+
+// Where to send bug reports to.
+#define VG_BUGS_TO "www.valgrind.org"
+
+/* Branch prediction hints. */
+#if 1 /*HAVE_BUILTIN_EXPECT*/
+#  define LIKELY(x)   __builtin_expect(!!(x), 1)
+#  define UNLIKELY(x) __builtin_expect((x), 0)
+#else
+#  define LIKELY(x)   (x)
+#  define UNLIKELY(x) (x)
+#endif
+
+// printf format string checking for gcc.
+// This feature has been supported since at least gcc version 2.95.
+// For more information about the format attribute, see
+// http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html.
+#if defined(__GNUC__)
+#define PRINTF_CHECK(x, y) __attribute__((format(__printf__, x, y)))
+#else
+#define PRINTF_CHECK(x, y)
+#endif
+
+
+#endif /* __PUB_TOOL_BASICS_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h
new file mode 100644
index 0000000..84582af
--- /dev/null
+++ b/include/pub_tool_basics_asm.h
@@ -0,0 +1,65 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Header imported directly by every tool asm file.             ---*/
+/*---                                        pub_tool_basics_asm.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_BASICS_ASM_H
+#define __PUB_TOOL_BASICS_ASM_H
+
+// See pub_tool_basics.h for the purpose of these macros.
+//
+// Note that although the macros here (which are used in asm files) have the
+// same name as those in pub_tool_basics.h (which are used in C files), they
+// have different definitions.  Actually, on Linux the definitions are the
+// same, but on Darwin they are different.  The reason is that C names on
+// Darwin always get a '_' prepended to them by the compiler.  But in order to
+// refer to them from asm code, we have to add the '_' ourselves.  Having two
+// versions of these macros makes that difference transparent, so we can use
+// VG_/ML_ in both asm and C files.
+//
+// Note also that the exact prefixes used have to match those used in
+// pub_tool_basics.h.
+
+#define VGAPPEND(str1,str2) str1##str2
+ 
+#if defined(VGO_linux) || defined(VGO_aix5)
+#  define VG_(str)    VGAPPEND( vgPlain_,          str)
+#  define ML_(str)    VGAPPEND( vgModuleLocal_,    str)
+#elif defined(VGO_darwin)
+#  define VG_(str)    VGAPPEND(_vgPlain_,          str)
+#  define ML_(str)    VGAPPEND(_vgModuleLocal_,    str)
+#else
+#  error Unknown OS
+#endif
+
+#endif /* __PUB_TOOL_BASICS_ASM_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_clientstate.h b/include/pub_tool_clientstate.h
new file mode 100644
index 0000000..81df4e5
--- /dev/null
+++ b/include/pub_tool_clientstate.h
@@ -0,0 +1,70 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Misc client state info                pub_tool_clientstate.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_CLIENTSTATE_H
+#define __PUB_TOOL_CLIENTSTATE_H
+
+/* Note, this header requires pub_{core,tool}_xarray.h to be
+   included ahead of it. */
+
+// Command line pieces, after they have been extracted from argv in
+// m_main.main().  These are all NULL-terminated vectors.
+
+/* Args for the client. */
+extern XArray* /* of HChar* */ VG_(args_for_client);
+
+/* Args for V.  This is the concatenation of the following:
+   - contents of ~/.valgrindrc
+   - contents of $VALGRIND_OPTS
+   - contents of ./.valgrindrc
+   - args from the command line
+   in the stated order.
+
+   Only the last of these is passed onwards to child Valgrinds at
+   client sys_execve, since the children will re-acquire the first 3
+   categories for themselves.  Therefore we also record the number of
+   these no-pass-at-execve arguments -- that is what
+   VG_(args_for_valgrind_noexecpass) is. */
+extern XArray* /* of HChar* */ VG_(args_for_valgrind);
+
+/* Number of leading args in VG_(args_for_valgrind) not to pass on at
+   exec time. */
+extern Int VG_(args_for_valgrind_noexecpass);
+
+/* The name of the client executable, as specified on the command
+   line. */
+extern const HChar* VG_(args_the_exename);
+
+
+#endif   // __PUB_TOOL_CLIENTSTATE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_clreq.h b/include/pub_tool_clreq.h
new file mode 100644
index 0000000..33ae9bb
--- /dev/null
+++ b/include/pub_tool_clreq.h
@@ -0,0 +1,40 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Client requests.                            pub_tool_clreq.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_CLREQ_H
+#define __PUB_TOOL_CLREQ_H
+
+#include "valgrind.h"
+
+#endif   // __PUB_TOOL_CLREQ_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_cpuid.h b/include/pub_tool_cpuid.h
new file mode 100644
index 0000000..51a7b12
--- /dev/null
+++ b/include/pub_tool_cpuid.h
@@ -0,0 +1,46 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Interface to CPUID.                         pub_tool_cpuid.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_CPUID_H
+#define __PUB_TOOL_CPUID_H
+
+#if defined(VGA_x86) || defined(VGA_amd64)
+extern Bool VG_(has_cpuid) ( void );
+
+extern void VG_(cpuid) ( UInt eax,
+                         UInt* eax_ret, UInt* ebx_ret,
+                         UInt* ecx_ret, UInt* edx_ret );
+#endif
+
+#endif   // __PUB_TOOL_CPUID_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h
new file mode 100644
index 0000000..2259047
--- /dev/null
+++ b/include/pub_tool_debuginfo.h
@@ -0,0 +1,249 @@
+
+/*--------------------------------------------------------------------*/
+/*--- DebugInfo.                              pub_tool_debuginfo.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_DEBUGINFO_H
+#define __PUB_TOOL_DEBUGINFO_H
+
+/*====================================================================*/
+/*=== Obtaining debug information                                  ===*/
+/*====================================================================*/
+
+/* Get the file/function/line number of the instruction at address
+   'a'.  For these four, if debug info for the address is found, it
+   copies the info into the buffer/UInt and returns True.  If not, it
+   returns False and nothing is copied.  VG_(get_fnname) always
+   demangles C++ function names.  VG_(get_fnname_w_offset) is the
+   same, except it appends "+N" to symbol names to indicate offsets.  */
+extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename );
+extern Bool VG_(get_fnname)   ( Addr a, Char* fnname,   Int n_fnname   );
+extern Bool VG_(get_linenum)  ( Addr a, UInt* linenum );
+extern Bool VG_(get_fnname_w_offset)
+                              ( Addr a, Char* fnname,   Int n_fnname   );
+
+/* This one is the most general.  It gives filename, line number and
+   optionally directory name.  filename and linenum may not be NULL.
+   dirname may be NULL, meaning that the caller does not want
+   directory name info, in which case dirname_available must also be
+   NULL.  If dirname is non-null, directory info is written to it, if
+   it is available; if not available, '\0' is written to the first
+   byte.  In either case *dirname_available is set to indicate whether
+   or not directory information was available.
+
+   Returned value indicates whether any filename/line info could be
+   found. */
+extern Bool VG_(get_filename_linenum)
+                              ( Addr a, 
+                                /*OUT*/Char* filename, Int n_filename,
+                                /*OUT*/Char* dirname,  Int n_dirname,
+                                /*OUT*/Bool* dirname_available,
+                                /*OUT*/UInt* linenum );
+
+/* Succeeds only if we find from debug info that 'a' is the address of the
+   first instruction in a function -- as opposed to VG_(get_fnname) which
+   succeeds if we find from debug info that 'a' is the address of any
+   instruction in a function.  Use this to instrument the start of
+   a particular function.  Nb: if an executable/shared object is stripped
+   of its symbols, this function will not be able to recognise function
+   entry points within it. */
+extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
+
+typedef
+   enum {
+      Vg_FnNameNormal,        // A normal function.
+      Vg_FnNameMain,          // "main"
+      Vg_FnNameBelowMain      // Something below "main", eg. __libc_start_main.
+   } Vg_FnNameKind;           //   Such names are often filtered.
+
+/* Indicates what kind of fnname it is. */
+extern Vg_FnNameKind VG_(get_fnname_kind) ( Char* name );
+
+/* Like VG_(get_fnname_kind), but takes a code address. */
+extern Vg_FnNameKind VG_(get_fnname_kind_from_IP) ( Addr ip );
+
+/* Looks up data_addr in the collection of data symbols, and if found
+   puts its name (or as much as will fit) into dname[0 .. n_dname-1],
+   which is guaranteed to be zero terminated.  Also data_addr's offset
+   from the symbol start is put into *offset. */
+extern Bool VG_(get_datasym_and_offset)( Addr data_addr,
+                                         /*OUT*/Char* dname, Int n_dname,
+                                         /*OUT*/PtrdiffT* offset );
+
+/* Try to form some description of DATA_ADDR by looking at the DWARF3
+   debug info we have.  This considers all global variables, and all
+   frames in the stacks of all threads.  Result is written at the ends
+   of DNAME{1,2}V, which are XArray*s of HChar, that have been
+   initialised by the caller, and True is returned.  If no description
+   is created, False is returned.  Regardless of the return value,
+   DNAME{1,2}V are guaranteed to be zero terminated after the call.
+
+   Note that after the call, DNAME{1,2} may have more than one
+   trailing zero, so callers should establish the useful text length
+   using VG_(strlen) on the contents, rather than VG_(sizeXA) on the
+   XArray itself.
+*/
+Bool VG_(get_data_description)( 
+        /*MOD*/ void* /* really, XArray* of HChar */ dname1v,
+        /*MOD*/ void* /* really, XArray* of HChar */ dname2v,
+        Addr data_addr
+     );
+
+/* Succeeds if the address is within a shared object or the main executable.
+   It doesn't matter if debug info is present or not. */
+extern Bool VG_(get_objname)  ( Addr a, Char* objname, Int n_objname );
+
+/* Puts into 'buf' info about the code address %eip:  the address, function
+   name (if known) and filename/line number (if known), like this:
+
+      0x4001BF05: realloc (vg_replace_malloc.c:339)
+
+   'n_buf' gives length of 'buf'.  Returns 'buf'.
+*/
+extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf);
+
+
+/* Get an XArray of StackBlock which describe the stack (auto) blocks
+   for this ip.  The caller is expected to free the XArray at some
+   point.  If 'arrays_only' is True, only array-typed blocks are
+   returned; otherwise blocks of all types are returned. */
+
+typedef
+   struct {
+      PtrdiffT base;       /* offset from sp or fp */
+      SizeT    szB;        /* size in bytes */
+      Bool     spRel;      /* True => sp-rel, False => fp-rel */
+      Bool     isVec;      /* does block have an array type, or not? */
+      HChar    name[16];   /* first 15 chars of name (asciiz) */
+   }
+   StackBlock;
+
+extern void* /* really, XArray* of StackBlock */
+             VG_(di_get_stack_blocks_at_ip)( Addr ip, Bool arrays_only );
+
+
+/* Get an array of GlobalBlock which describe the global blocks owned
+   by the shared object characterised by the given di_handle.  Asserts
+   if the handle is invalid.  The caller is responsible for freeing
+   the array at some point.  If 'arrays_only' is True, only
+   array-typed blocks are returned; otherwise blocks of all types are
+   returned. */
+
+typedef
+   struct {
+      Addr  addr;
+      SizeT szB;
+      Bool  isVec;      /* does block have an array type, or not? */
+      HChar name[16];   /* first 15 chars of name (asciiz) */
+      HChar soname[16]; /* first 15 chars of name (asciiz) */
+   }
+   GlobalBlock;
+
+extern void* /* really, XArray* of GlobalBlock */
+VG_(di_get_global_blocks_from_dihandle) ( ULong di_handle,
+                                          Bool  arrays_only );
+
+
+/*====================================================================*/
+/*=== Obtaining debug information                                  ===*/
+/*====================================================================*/
+
+/* A way to make limited debuginfo queries on a per-mapped-object
+   basis. */
+typedef  struct _DebugInfo  DebugInfo;
+
+/* Returns NULL if the DebugInfo isn't found.  It doesn't matter if
+   debug info is present or not. */
+DebugInfo* VG_(find_DebugInfo) ( Addr a );
+
+/* Fish bits out of DebugInfos. */
+Addr          VG_(DebugInfo_get_text_avma)   ( const DebugInfo *di );
+SizeT         VG_(DebugInfo_get_text_size)   ( const DebugInfo *di );
+Addr          VG_(DebugInfo_get_plt_avma)    ( const DebugInfo *di );
+SizeT         VG_(DebugInfo_get_plt_size)    ( const DebugInfo *di );
+Addr          VG_(DebugInfo_get_gotplt_avma) ( const DebugInfo *di );
+SizeT         VG_(DebugInfo_get_gotplt_size) ( const DebugInfo *di );
+const UChar*  VG_(DebugInfo_get_soname)      ( const DebugInfo *di );
+const UChar*  VG_(DebugInfo_get_filename)    ( const DebugInfo *di );
+PtrdiffT      VG_(DebugInfo_get_text_bias)   ( const DebugInfo *di );
+
+/* Function for traversing the DebugInfo list.  When called with NULL
+   it returns the first element; otherwise it returns the given
+   element's successor.  Note that the order of elements in the list
+   changes in response to most of the queries listed in this header,
+   that explicitly or implicitly have to search the list for a
+   particular code address.  So it isn't safe to assume that the order
+   of the list stays constant. */
+const DebugInfo* VG_(next_DebugInfo)    ( const DebugInfo *di );
+
+/* Functions for traversing all the symbols in a DebugInfo.  _howmany
+   tells how many there are.  _getidx retrieves the n'th, for n in 0
+   .. _howmany-1.  You may not modify the function name thereby
+   acquired; if you want to do so, first strdup it. */
+Int  VG_(DebugInfo_syms_howmany) ( const DebugInfo *di );
+void VG_(DebugInfo_syms_getidx)  ( const DebugInfo *di, 
+                                   Int idx,
+                                   /*OUT*/Addr*   avma,
+                                   /*OUT*/Addr*   tocptr,
+                                   /*OUT*/UInt*   size,
+                                   /*OUT*/HChar** name,
+                                   /*OUT*/Bool*   isText,
+                                   /*OUT*/Bool*   isIFunc );
+
+/* A simple enumeration to describe the 'kind' of various kinds of
+   segments that arise from the mapping of object files. */
+typedef
+   enum {
+      Vg_SectUnknown,
+      Vg_SectText,
+      Vg_SectData,
+      Vg_SectBSS,
+      Vg_SectGOT,
+      Vg_SectPLT,
+      Vg_SectGOTPLT,
+      Vg_SectOPD
+   }
+   VgSectKind;
+
+/* Convert a VgSectKind to a string, which must be copied if you want
+   to change it. */
+const HChar* VG_(pp_SectKind)( VgSectKind kind );
+
+/* Given an address 'a', make a guess of which section of which object
+   it comes from.  If name is non-NULL, then the last n_name-1
+   characters of the object's name is put in name[0 .. n_name-2], and
+   name[n_name-1] is set to zero (guaranteed zero terminated). */
+VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/UChar* name, SizeT n_name, 
+                                     Addr a);
+
+
+#endif   // __PUB_TOOL_DEBUGINFO_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_errormgr.h b/include/pub_tool_errormgr.h
new file mode 100644
index 0000000..42e6b8e
--- /dev/null
+++ b/include/pub_tool_errormgr.h
@@ -0,0 +1,136 @@
+/*--------------------------------------------------------------------*/
+/*--- ErrorMgr: management of errors and suppressions.             ---*/
+/*---                                          pub_tool_errormgr.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_ERRORMGR_H
+#define __PUB_TOOL_ERRORMGR_H
+
+#include "pub_tool_execontext.h"
+
+/* ------------------------------------------------------------------ */
+/* Error records contain enough info to generate an error report.  The idea
+   is that (typically) the same few points in the program generate thousands
+   of errors, and we don't want to spew out a fresh error message for each
+   one.  Instead, we use these structures to common up duplicates.
+*/
+
+typedef
+   Int         /* Do not make this unsigned! */
+   ErrorKind;
+
+/* The tool-relevant parts of an Error are:
+     kind:   what kind of error; must be in the range (0..)
+     addr:   use is optional.  0 by default.
+     string: use is optional.  NULL by default.
+     extra:  use is optional.  NULL by default.  void* so it's extensible.
+*/
+typedef
+   struct _Error
+   Error;
+
+/* Useful in VG_(tdict).tool_error_matches_suppression(),
+ * VG_(tdict).tool_pp_Error(), etc */
+ExeContext* VG_(get_error_where)   ( Error* err );
+ErrorKind   VG_(get_error_kind)    ( Error* err );
+Addr        VG_(get_error_address) ( Error* err );
+Char*       VG_(get_error_string)  ( Error* err );
+void*       VG_(get_error_extra)   ( Error* err );
+
+/* Call this when an error occurs.  It will be recorded if it hasn't been
+   seen before.  If it has, the existing error record will have its count
+   incremented.
+
+   'tid' can be found as for VG_(record_ExeContext)().  The `extra' field can
+   be stack-allocated;  it will be copied by the core if needed (but it
+   won't be copied if it's NULL).
+
+   If no 'a', 's' or 'extra' of interest needs to be recorded, just use
+   NULL for them.  */
+extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
+                                      Addr a, Char* s, void* extra );
+
+/* Similar to VG_(maybe_record_error)(), except this one doesn't record the
+   error -- useful for errors that can only happen once.  The errors can be
+   suppressed, though.  Return value is True if it was suppressed.
+   'print_error' dictates whether to print the error, which is a bit of a
+   hack that's useful sometimes if you just want to know if the error would
+   be suppressed without possibly printing it.  'count_error' dictates
+   whether to add the error in the error total count (another mild hack). */
+extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
+                                Addr a, Char* s, void* extra,
+                                ExeContext* where, Bool print_error,
+                                Bool allow_GDB_attach, Bool count_error );
+
+/* Gets a non-blank, non-comment line from fd.  bufpp is a pointer to a
+   pointer to a buffer that must be allocated with VG_(malloc);  nBufp is a
+   pointer to size_t holding its size;  if the buffer is too small for the
+   line, it will be realloc'd until big enough (updating *bufpp and *nBufp in
+   the process).  (It will bomb out if the size gets ridiculous).  Skips
+   leading spaces on the line.  Increments lineno with the number of lines
+   read if lineno is non-NULL. Returns True if EOF was hit.  */
+extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno );
+
+
+/* ------------------------------------------------------------------ */
+/* Suppressions describe errors which we want to suppress, ie, not
+   show the user, usually because it is caused by a problem in a library
+   which we can't fix, replace or work around.  Suppressions are read from
+   a file at startup time.  This gives flexibility so that new
+   suppressions can be added to the file as and when needed.
+*/
+typedef
+   Int         /* Do not make this unsigned! */
+   SuppKind;
+
+/* The tool-relevant parts of a suppression are:
+     kind:   what kind of suppression; must be in the range (0..)
+     string: use is optional.  NULL by default.
+     extra:  use is optional.  NULL by default.  void* so it's extensible.
+*/
+typedef
+   struct _Supp
+   Supp;
+
+/* Useful in VG_(tdict).tool_error_matches_suppression() */
+SuppKind VG_(get_supp_kind)   ( Supp* su );
+Char*    VG_(get_supp_string) ( Supp* su );
+void*    VG_(get_supp_extra)  ( Supp* su );
+
+/* Must be used in VG_(recognised_suppression)() */
+void VG_(set_supp_kind)   ( Supp* su, SuppKind suppkind );
+/* May be used in VG_(read_extra_suppression_info)() */
+void VG_(set_supp_string) ( Supp* su, Char* string );
+void VG_(set_supp_extra)  ( Supp* su, void* extra );
+
+
+#endif   // __PUB_TOOL_ERRORMGR_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_execontext.h b/include/pub_tool_execontext.h
new file mode 100644
index 0000000..19c6d75
--- /dev/null
+++ b/include/pub_tool_execontext.h
@@ -0,0 +1,117 @@
+/*--------------------------------------------------------------------*/
+/*--- ExeContexts: long-lived stack traces.  pub_tool_execontext.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_EXECONTEXT_H
+#define __PUB_TOOL_EXECONTEXT_H
+
+// It's an abstract type.
+typedef
+   struct _ExeContext
+   ExeContext;
+
+// Resolution type used to decide how closely to compare two errors for
+// equality.
+typedef
+   enum { Vg_LowRes, Vg_MedRes, Vg_HighRes }
+   VgRes;
+
+// Take a snapshot of the client's stack.  Search our collection of
+// ExeContexts to see if we already have it, and if not, allocate a
+// new one.  Either way, return a pointer to the context.  Context size
+// controlled by --num-callers option.
+//
+// This should only be used for long-lived stack traces.  If you want a
+// short-lived stack trace, use VG_(get_StackTrace)().
+//
+// If called from generated code, use VG_(get_running_tid)() to get the
+// current ThreadId.  If called from non-generated code, the current
+// ThreadId should be passed in by the core.  The initial IP value to 
+// use is adjusted by first_ip_delta before the stack is unwound.
+// A safe value to pass is zero.
+//
+// See comments in pub_tool_stacktrace.h for precise definition of
+// the meaning of the code addresses in the returned ExeContext.
+extern 
+ExeContext* VG_(record_ExeContext) ( ThreadId tid, Word first_ip_delta );
+
+// Trivial version of VG_(record_ExeContext), which just records the
+// thread's current program counter but does not do any stack
+// unwinding.  This is useful in some rare cases when we suspect the
+// stack might be outside mapped storage, and so unwinding
+// might cause a segfault.  In this case we can at least safely
+// produce a one-element stack trace, which is better than nothing.
+extern
+ExeContext* VG_(record_depth_1_ExeContext)( ThreadId tid );
+
+// Apply a function to every element in the ExeContext.  The parameter 'n'
+// gives the index of the passed ip.  Doesn't go below main() unless
+// --show-below-main=yes is set.
+extern void VG_(apply_ExeContext)( void(*action)(UInt n, Addr ip),
+                                   ExeContext* ec, UInt n_ips );
+
+// Compare two ExeContexts.  Number of callers considered depends on `res':
+//   Vg_LowRes:  2
+//   Vg_MedRes:  4
+//   Vg_HighRes: all
+extern Bool VG_(eq_ExeContext) ( VgRes res, ExeContext* e1, ExeContext* e2 );
+
+// Print an ExeContext.
+extern void VG_(pp_ExeContext) ( ExeContext* ec );
+
+// Get the 32-bit unique reference number for this ExeContext
+// (the "ExeContext Unique").  Guaranteed to be nonzero and to be a
+// multiple of four (iow, the lowest two bits are guaranteed to
+// be zero, so that callers can store other information there.
+extern UInt VG_(get_ECU_from_ExeContext)( ExeContext* e );
+
+// How many entries (frames) in this ExeContext?
+extern Int VG_(get_ExeContext_n_ips)( ExeContext* e );
+
+// Find the ExeContext that has the given ECU, if any.
+// NOTE: very slow.  Do not call often.
+extern ExeContext* VG_(get_ExeContext_from_ECU)( UInt uniq );
+
+// Make an ExeContext containing just 'a', and nothing else
+ExeContext* VG_(make_depth_1_ExeContext_from_Addr)( Addr a );
+
+// Is this a plausible-looking ECU ?  Catches some obvious stupid
+// cases, but does not guarantee that the ECU is really valid, that
+// is, has an associated ExeContext.
+static inline Bool VG_(is_plausible_ECU)( UInt ecu ) {
+   return (ecu > 0) && ((ecu & 3) == 0);
+}
+
+// Make an ExeContext containing exactly the specified stack frames.
+ExeContext* VG_(make_ExeContext_from_StackTrace)( Addr* ips, UInt n_ips );
+
+#endif   // __PUB_TOOL_EXECONTEXT_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_hashtable.h b/include/pub_tool_hashtable.h
new file mode 100644
index 0000000..50c0844
--- /dev/null
+++ b/include/pub_tool_hashtable.h
@@ -0,0 +1,101 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A hash table implementation.            pub_tool_hashtable.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 Nicholas Nethercote
+      njn@valgrind.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 __PUB_TOOL_HASHTABLE_H
+#define __PUB_TOOL_HASHTABLE_H
+
+/* Generic type for a separately-chained hash table.  Via a kind of dodgy
+   C-as-C++ style inheritance, tools can extend the VgHashNode type, so long
+   as the first two fields match the sizes of these two fields.  Requires
+   a bit of casting by the tool. */
+
+// Problems with this data structure:
+// - Separate chaining gives bad cache behaviour.  Hash tables with linear
+//   probing give better cache behaviour.
+
+typedef
+   struct _VgHashNode {
+      struct _VgHashNode * next;
+      UWord              key;
+   }
+   VgHashNode;
+
+typedef struct _VgHashTable * VgHashTable;
+
+/* Make a new table.  Allocates the memory with VG_(calloc)(), so can
+   be freed with VG_(free)().  The table starts small but will
+   periodically be expanded.  This is transparent to the users of this
+   module. */
+extern VgHashTable VG_(HT_construct) ( HChar* name );
+
+/* Count the number of nodes in a table. */
+extern Int VG_(HT_count_nodes) ( VgHashTable table );
+
+/* Add a node to the table.  Duplicate keys are permitted. */
+extern void VG_(HT_add_node) ( VgHashTable t, void* node );
+
+/* Looks up a VgHashNode in the table.  Returns NULL if not found.  If entries
+ * with duplicate keys are present, the most recently-added of the dups will
+ * be returned, but it's probably better to avoid dups altogether. */
+extern void* VG_(HT_lookup) ( VgHashTable table, UWord key );
+
+/* Removes a VgHashNode from the table.  Returns NULL if not found. */
+extern void* VG_(HT_remove) ( VgHashTable table, UWord key );
+
+/* Allocates a suitably-sized array, copies pointers to all the hashtable
+   elements into it, then returns both the array and the size of it.  The
+   array must be freed with VG_(free). */
+extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_elems );
+
+/* Reset the table's iterator to point to the first element. */
+extern void VG_(HT_ResetIter) ( VgHashTable table );
+
+/* Return the element pointed to by the iterator and move on to the
+   next one.  Returns NULL if the last one has been passed, or if
+   HT_ResetIter() has not been called previously.  Asserts if the
+   table has been modified (HT_add_node, HT_remove) since
+   HT_ResetIter.  This guarantees that callers cannot screw up by
+   modifying the table whilst iterating over it (and is necessary to
+   make the implementation safe; specifically we must guarantee that
+   the table will not get resized whilst iteration is happening.
+   Since resizing only happens as a result of calling HT_add_node,
+   disallowing HT_add_node during iteration should give the required
+   assurance. */
+extern void* VG_(HT_Next) ( VgHashTable table );
+
+/* Destroy a table. */
+extern void VG_(HT_destruct) ( VgHashTable t );
+
+
+#endif   // __PUB_TOOL_HASHTABLE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcassert.h b/include/pub_tool_libcassert.h
new file mode 100644
index 0000000..af92112
--- /dev/null
+++ b/include/pub_tool_libcassert.h
@@ -0,0 +1,66 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Assertions, etc.                       pub_tool_libcassert.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCBASSERT_H
+#define __PUB_TOOL_LIBCBASSERT_H
+
+#define tl_assert(expr)                                                 \
+  ((void) ((expr) ? 0 :                                                 \
+           (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr,     \
+                              (const Char*)__FILE__, __LINE__,          \
+                              (const Char*)__PRETTY_FUNCTION__,         \
+                              (const HChar*)""),                        \
+                              0)))
+
+#define tl_assert2(expr, format, args...)                               \
+  ((void) ((expr) ? 0 :                                                 \
+           (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr,     \
+                              (const Char*)__FILE__, __LINE__,          \
+                              (const Char*)__PRETTY_FUNCTION__,         \
+                              format, ##args),                          \
+                              0)))
+
+__attribute__ ((__noreturn__))
+extern void VG_(exit)( Int status );
+
+/* Prints a panic message, appends newline and bug reporting info, aborts. */
+__attribute__ ((__noreturn__))
+extern void  VG_(tool_panic) ( Char* str );
+
+__attribute__ ((__noreturn__))
+extern void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file, 
+                               Int line, const Char* fn, 
+                               const HChar* format, ... );
+
+#endif   // __PUB_TOOL_LIBCBASSERT_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcbase.h b/include/pub_tool_libcbase.h
new file mode 100644
index 0000000..2897235
--- /dev/null
+++ b/include/pub_tool_libcbase.h
@@ -0,0 +1,186 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Standalone libc stuff.                   pub_tool_libcbase.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCBASE_H
+#define __PUB_TOOL_LIBCBASE_H
+
+/* ---------------------------------------------------------------------
+   Char functions.
+   ------------------------------------------------------------------ */
+
+extern Bool VG_(isspace) ( Char c );
+extern Bool VG_(isdigit) ( Char c );
+extern Char VG_(tolower) ( Char c );
+
+/* ---------------------------------------------------------------------
+   Converting strings to numbers
+   ------------------------------------------------------------------ */
+
+// Convert strings to numbers according to various bases.  Leading
+// whitespace is ignored.  A subsequent '-' or '+' is accepted.  For strtoll16,
+// accepts an initial "0x" or "0X" prefix, but only if it's followed by a
+// hex digit (if not, the '0' will be read and then it will stop on the
+// "x"/"X".)  If 'endptr' isn't NULL, it gets filled in with the first
+// non-digit char.  Returns 0 if no number could be converted, and 'endptr'
+// is set to the start of the string.  None of them test that the number
+// fits into 64 bits.
+//
+// Nb: if you're wondering why we don't just have a single VG_(strtoll) which
+// takes a base, it's because I wanted it to assert if it was given a bogus
+// base (the standard glibc one sets 'errno' in this case).  But
+// m_libcbase.c doesn't import any code, not even vg_assert. --njn
+// 
+// Nb: we also don't provide VG_(atoll*);  these functions are worse than
+// useless because they don't do any error checking and so accept malformed
+// numbers and non-numbers -- eg. "123xyz" gives 123, and "foo" gives 0!
+// If you really want that behaviour, you can use "VG_(strtoll10)(str, NULL)".
+extern Long  VG_(strtoll10) ( Char* str, Char** endptr );
+extern Long  VG_(strtoll16) ( Char* str, Char** endptr );
+
+// Convert a string to a double.  After leading whitespace is ignored, a
+// '+' or '-' is allowed, and then it accepts a non-empty sequence of
+// decimal digits possibly containing a '.'.  Hexadecimal floats are not
+// accepted, nor are "fancy" floats (eg. "3.4e-5", "NAN").
+extern double VG_(strtod)  ( Char* str, Char** endptr );
+
+/* ---------------------------------------------------------------------
+   String functions and macros
+   ------------------------------------------------------------------ */
+
+/* Use this for normal null-termination-style string comparison. */
+#define VG_STREQ(s1,s2) ( (s1 != NULL && s2 != NULL \
+                           && VG_(strcmp)((s1),(s2))==0) ? True : False )
+#define VG_STREQN(n,s1,s2) ( (s1 != NULL && s2 != NULL \
+                             && VG_(strncmp)((s1),(s2),(n))==0) ? True : False )
+
+extern SizeT VG_(strlen)         ( const Char* str );
+extern Char* VG_(strcat)         ( Char* dest, const Char* src );
+extern Char* VG_(strncat)        ( Char* dest, const Char* src, SizeT n );
+extern Char* VG_(strpbrk)        ( const Char* s, const Char* accpt );
+extern Char* VG_(strcpy)         ( Char* dest, const Char* src );
+extern Char* VG_(strncpy)        ( Char* dest, const Char* src, SizeT ndest );
+extern Int   VG_(strcmp)         ( const Char* s1, const Char* s2 );
+extern Int   VG_(strcasecmp)     ( const Char* s1, const Char* s2 );
+extern Int   VG_(strncmp)        ( const Char* s1, const Char* s2, SizeT nmax );
+extern Int   VG_(strncasecmp)    ( const Char* s1, const Char* s2, SizeT nmax );
+extern Char* VG_(strstr)         ( const Char* haystack, Char* needle );
+extern Char* VG_(strcasestr)     ( const Char* haystack, Char* needle );
+extern Char* VG_(strchr)         ( const Char* s, Char c );
+extern Char* VG_(strrchr)        ( const Char* s, Char c );
+extern SizeT VG_(strspn)         ( const Char* s, const Char* accpt );
+extern SizeT VG_(strcspn)        ( const Char* s, const char* reject );
+
+/* Like strncpy(), but if 'src' is longer than 'ndest' inserts a '\0' as the
+   last character. */
+extern void  VG_(strncpy_safely) ( Char* dest, const Char* src, SizeT ndest );
+
+/* ---------------------------------------------------------------------
+   mem* functions
+   ------------------------------------------------------------------ */
+
+extern void* VG_(memcpy) ( void *d, const void *s, SizeT sz );
+extern void* VG_(memmove)( void *d, const void *s, SizeT sz );
+extern void* VG_(memset) ( void *s, Int c, SizeT sz );
+extern Int   VG_(memcmp) ( const void* s1, const void* s2, SizeT n );
+
+/* Zero out up to 8 words quickly in-line.  Do not use this for blocks
+   of size which are unknown at compile time, since the whole point is
+   for it to be inlined, and then for gcc to remove all code except
+   for the relevant 'sz' case. */
+inline __attribute__((always_inline))
+static void VG_(bzero_inline) ( void* s, SizeT sz )
+{
+   if (LIKELY(0 == (((Addr)sz) & (Addr)(sizeof(UWord)-1)))
+       && LIKELY(0 == (((Addr)s) & (Addr)(sizeof(UWord)-1)))) {
+      UWord* p = (UWord*)s;
+      switch (sz / (SizeT)sizeof(UWord)) {
+          case 8: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = p[6] = p[7] = 0UL; return;
+          case 7: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = p[6] = 0UL; return;
+          case 6: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = 0UL; return;
+          case 5: p[0] = p[1] = p[2] = p[3] = p[4] = 0UL; return;
+          case 4: p[0] = p[1] = p[2] = p[3] = 0UL; return;
+          case 3: p[0] = p[1] = p[2] = 0UL; return;
+          case 2: p[0] = p[1] = 0UL; return;
+          case 1: p[0] = 0UL; return;
+          case 0: return;
+          default: break;
+      }
+   }
+   VG_(memset)(s, 0, sz);
+}
+
+
+/* ---------------------------------------------------------------------
+   Address computation helpers
+   ------------------------------------------------------------------ */
+
+// Check if an address/whatever is aligned
+#define VG_IS_2_ALIGNED(aaa_p)    (0 == (((Addr)(aaa_p)) & ((Addr)0x1)))
+#define VG_IS_4_ALIGNED(aaa_p)    (0 == (((Addr)(aaa_p)) & ((Addr)0x3)))
+#define VG_IS_8_ALIGNED(aaa_p)    (0 == (((Addr)(aaa_p)) & ((Addr)0x7)))
+#define VG_IS_16_ALIGNED(aaa_p)   (0 == (((Addr)(aaa_p)) & ((Addr)0xf)))
+#define VG_IS_32_ALIGNED(aaa_p)   (0 == (((Addr)(aaa_p)) & ((Addr)0x1f)))
+#define VG_IS_WORD_ALIGNED(aaa_p) (0 == (((Addr)(aaa_p)) & ((Addr)(sizeof(Addr)-1))))
+#define VG_IS_PAGE_ALIGNED(aaa_p) (0 == (((Addr)(aaa_p)) & ((Addr)(VKI_PAGE_SIZE-1))))
+
+// 'a' -- the alignment -- must be a power of 2.
+// The latter two require the vki-*.h header to be imported also.
+#define VG_ROUNDDN(p, a)   ((Addr)(p) & ~((Addr)(a)-1))
+#define VG_ROUNDUP(p, a)   VG_ROUNDDN((p)+(a)-1, (a))
+#define VG_PGROUNDDN(p)    VG_ROUNDDN(p, VKI_PAGE_SIZE)
+#define VG_PGROUNDUP(p)    VG_ROUNDUP(p, VKI_PAGE_SIZE)
+
+/* ---------------------------------------------------------------------
+   Misc useful functions
+   ------------------------------------------------------------------ */
+
+/* Like qsort().  The name VG_(ssort) is for historical reasons -- it used
+ * to be a shell sort, but is now a quicksort. */
+extern void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
+                        Int (*compar)(void*, void*) );
+
+/* Returns the base-2 logarithm of x.  Returns -1 if x is not a power
+   of two.  Nb: VG_(log2)(1) == 0.  */
+extern Int VG_(log2) ( UInt x );
+
+// A pseudo-random number generator returning a random UInt.  If pSeed
+// is NULL, it uses its own seed, which starts at zero.  If pSeed is
+// non-NULL, it uses and updates whatever pSeed points at.
+extern UInt VG_(random) ( /*MOD*/UInt* pSeed );
+#define VG_RAND_MAX (1ULL << 32)
+
+#endif   // __PUB_TOOL_LIBCBASE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcfile.h b/include/pub_tool_libcfile.h
new file mode 100644
index 0000000..8f08cd2
--- /dev/null
+++ b/include/pub_tool_libcfile.h
@@ -0,0 +1,99 @@
+
+/*--------------------------------------------------------------------*/
+/*--- File/socket-related libc stuff.          pub_tool_libcfile.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCFILE_H
+#define __PUB_TOOL_LIBCFILE_H
+
+/* ---------------------------------------------------------------------
+   File-related functions.
+   ------------------------------------------------------------------ */
+
+/* To use this file you must first include pub_tool_vki.h. */
+
+/* Note that VG_(stat) and VG_(fstat) write to a 'struct vg_stat*' and
+   not a 'struct vki_stat*' or a 'struct vki_stat64*'.  'struct
+   vg_stat*' is not the same as either of the vki_ versions.  No
+   specific vki_stat{,64} kernel structure will work and is
+   consistently available on different architectures on Linux, so we
+   have to use this 'struct vg_stat' impedance-matching type
+   instead.
+
+   Also note that the fieldnames aren't prefixed with "st_".  This is because
+   st_atime et al are macros in sys/stat.h on Darwin, and using those names
+   screws things up.
+*/
+struct vg_stat {
+   ULong   dev;
+   ULong   ino;
+   ULong   nlink;
+   UInt    mode;
+   UInt    uid;
+   UInt    gid;
+   ULong   rdev;
+   Long    size;
+   ULong   blksize;
+   ULong   blocks;
+   ULong   atime;
+   ULong   atime_nsec;
+   ULong   mtime;
+   ULong   mtime_nsec;
+   ULong   ctime;
+   ULong   ctime_nsec;
+};
+
+extern SysRes VG_(open)   ( const Char* pathname, Int flags, Int mode );
+extern void   VG_(close)  ( Int fd );
+extern Int    VG_(read)   ( Int fd, void* buf, Int count);
+extern Int    VG_(write)  ( Int fd, const void* buf, Int count);
+extern Int    VG_(pipe)   ( Int fd[2] );
+extern OffT   VG_(lseek)  ( Int fd, OffT offset, Int whence );
+
+extern SysRes VG_(stat)   ( const Char* file_name, struct vg_stat* buf );
+extern Int    VG_(fstat)  ( Int   fd,        struct vg_stat* buf );
+extern SysRes VG_(dup)    ( Int oldfd );
+extern SysRes VG_(dup2)   ( Int oldfd, Int newfd );
+extern Int    VG_(rename) ( const Char* old_name, const Char* new_name );
+extern Int    VG_(unlink) ( const Char* file_name );
+
+extern Int    VG_(readlink)( const Char* path, Char* buf, UInt bufsize );
+extern Int    VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count );
+
+extern Char*  VG_(basename)( const Char* path );
+extern Char*  VG_(dirname) ( const Char* path );
+
+/* Copy the working directory at startup into buf[0 .. size-1], or return
+   False if buf is too small. */
+extern Bool VG_(get_startup_wd) ( Char* buf, SizeT size );
+
+#endif   // __PUB_TOOL_LIBCFILE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h
new file mode 100644
index 0000000..1621851
--- /dev/null
+++ b/include/pub_tool_libcprint.h
@@ -0,0 +1,147 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Printing libc stuff.                    pub_tool_libcprint.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCPRINT_H
+#define __PUB_TOOL_LIBCPRINT_H
+
+/* ---------------------------------------------------------------------
+   Formatting functions
+   ------------------------------------------------------------------ */
+
+extern UInt VG_(sprintf)  ( Char* buf, const HChar* format, ... )
+                          PRINTF_CHECK(2, 3);
+
+extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs )
+                          PRINTF_CHECK(2, 0);
+
+extern UInt VG_(snprintf) ( Char* buf, Int size, 
+                                       const HChar *format, ... )
+                          PRINTF_CHECK(3, 4);
+
+extern UInt VG_(vsnprintf)( Char* buf, Int size, 
+                                       const HChar *format, va_list vargs )
+                          PRINTF_CHECK(3, 0);
+
+// Percentify n/m with d decimal places.  Includes the '%' symbol at the end.
+// Right justifies in 'buf'.
+extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
+
+
+/* ---------------------------------------------------------------------
+   Output-printing functions
+   ------------------------------------------------------------------ */
+
+// Note that almost all output goes to the file descriptor given by the
+// --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr).
+// (Except that some text always goes to stdout/stderr at startup, and
+// debugging messages always go to stderr.)  Hence no need for
+// VG_(fprintf)().
+
+/* No, really.  I _am_ that strange. */
+#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d\n",nnn)
+
+/* Print a message with a prefix that depends on the VgMsgKind.
+   Should be used for all user output. */
+
+typedef
+   enum {                 // Prefix
+      Vg_FailMsg,         // "valgrind:"
+      Vg_UserMsg,         // "==pid=="
+      Vg_DebugMsg,        // "--pid--"
+      Vg_ClientMsg        // "**pid**"
+   }
+   VgMsgKind;
+
+// These print output that isn't prefixed with anything, and should be
+// used in very few cases, such as printing usage messages.
+extern UInt VG_(printf)   ( const HChar *format, ... )
+                          PRINTF_CHECK(1, 2);
+extern UInt VG_(vprintf)  ( const HChar *format, va_list vargs )
+                          PRINTF_CHECK(1, 0);
+
+// The "_no_f_c" functions here are just like their non-"_no_f_c" counterparts
+// but without the PRINTF_CHECK, so they can be used with our non-standard %t
+// format specifier.
+
+// These are the same as the non "_xml" versions above, except the
+// output goes on the selected XML output channel instead of the
+// normal one.
+extern UInt VG_(printf_xml)  ( const HChar *format, ... )
+                             PRINTF_CHECK(1, 2);
+
+extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
+                             PRINTF_CHECK(1, 0);
+
+extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... );
+
+/* Yet another, totally general, version of vprintf, which hands all
+   output bytes to CHAR_SINK, passing it OPAQUE as the second arg. */
+extern void VG_(vcbprintf)( void(*char_sink)(HChar, void* opaque),
+                            void* opaque,
+                            const HChar* format, va_list vargs );
+
+extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... );
+extern UInt VG_(message)( VgMsgKind kind, const HChar* format, ... )
+   PRINTF_CHECK(2, 3);
+
+extern UInt VG_(vmessage)( VgMsgKind kind, const HChar* format, va_list vargs )
+   PRINTF_CHECK(2, 0);
+
+// Short-cuts for VG_(message)().
+
+// This is used for messages printed due to start-up failures that occur
+// before the preamble is printed, eg. due a bad executable.
+extern UInt VG_(fmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+
+// This is used if an option was bad for some reason.  Note: don't use it just
+// because an option was unrecognised -- return 'False' from
+// VG_(tdict).tool_process_cmd_line_option) to indicate that -- use it if eg.
+// an option was given an inappropriate argument.  This function prints an
+// error message, then shuts down the entire system.
+__attribute__((noreturn))
+extern void VG_(fmsg_bad_option) ( HChar* opt, const HChar* format, ... )
+   PRINTF_CHECK(2, 3);
+
+// This is used for messages that are interesting to the user:  info about
+// their program (eg. preamble, tool error messages, postamble) or stuff they
+// requested.
+extern UInt VG_(umsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+
+// This is used for debugging messages that are only of use to developers.
+extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+
+/* Flush any output cached by previous calls to VG_(message) et al. */
+extern void VG_(message_flush) ( void );
+
+#endif   // __PUB_TOOL_LIBCPRINT_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h
new file mode 100644
index 0000000..2770dda
--- /dev/null
+++ b/include/pub_tool_libcproc.h
@@ -0,0 +1,99 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Process-related libc stuff               pub_tool_libcproc.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCPROC_H
+#define __PUB_TOOL_LIBCPROC_H
+
+/* ---------------------------------------------------------------------
+   Command-line and environment stuff
+   ------------------------------------------------------------------ */
+
+/* Client environment. */
+extern Char** VG_(client_envp);
+
+/* Looks up VG_(client_envp) */
+extern Char* VG_(getenv) ( Char* name );
+
+/* Path to all our library/aux files */
+extern const Char *VG_(libdir);
+
+// The name of the LD_PRELOAD-equivalent variable.  It varies across
+// platforms.
+extern const Char* VG_(LD_PRELOAD_var_name);
+
+/* ---------------------------------------------------------------------
+   Important syscalls
+   ------------------------------------------------------------------ */
+
+extern Int  VG_(waitpid)( Int pid, Int *status, Int options );
+extern Int  VG_(system) ( Char* cmd );
+extern Int  VG_(fork)   ( void);
+extern void VG_(execv)  ( Char* filename, Char** argv );
+
+/* ---------------------------------------------------------------------
+   Resource limits
+   ------------------------------------------------------------------ */
+
+extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
+extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim );
+
+/* ---------------------------------------------------------------------
+   pids, etc
+   ------------------------------------------------------------------ */
+
+extern Int VG_(gettid)  ( void );
+extern Int VG_(getpid)  ( void );
+extern Int VG_(getppid) ( void );
+extern Int VG_(getpgrp) ( void );
+extern Int VG_(geteuid) ( void );
+extern Int VG_(getegid) ( void );
+
+/* ---------------------------------------------------------------------
+   Timing
+   ------------------------------------------------------------------ */
+
+// Returns the number of milliseconds passed since the progam started
+// (roughly;  it gets initialised partway through Valgrind's initialisation
+// steps).
+extern UInt VG_(read_millisecond_timer) ( void );
+
+/* ---------------------------------------------------------------------
+   atfork
+   ------------------------------------------------------------------ */
+
+typedef void (*vg_atfork_t)(ThreadId);
+extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child);
+
+
+#endif   // __PUB_TOOL_LIBCPROC_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcsignal.h b/include/pub_tool_libcsignal.h
new file mode 100644
index 0000000..025c84a
--- /dev/null
+++ b/include/pub_tool_libcsignal.h
@@ -0,0 +1,47 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Signal-related libc stuff.             pub_tool_libcsignal.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_LIBCBSIGNAL_H
+#define __PUB_TOOL_LIBCBSIGNAL_H
+
+/* Note that these use the vki_ (kernel) structure
+   definitions, which are different in places from those that glibc
+   defines.  Since we're operating right at the kernel interface, glibc's view
+   of the world is entirely irrelevant. */
+
+/* --- Mess with the kernel's sig state --- */
+extern Int VG_(sigprocmask) ( Int how, const vki_sigset_t* set,
+                              vki_sigset_t* oldset );
+
+#endif   // __PUB_TOOL_LIBCBSIGNAL_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h
new file mode 100644
index 0000000..35b3c49
--- /dev/null
+++ b/include/pub_tool_machine.h
@@ -0,0 +1,169 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Machine-related stuff.                    pub_tool_machine.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_MACHINE_H
+#define __PUB_TOOL_MACHINE_H
+
+#if defined(VGP_x86_linux)
+#  define VG_MIN_INSTR_SZB          1  // min length of native instruction
+#  define VG_MAX_INSTR_SZB         16  // max length of native instruction
+#  define VG_CLREQ_SZB             14  // length of a client request, may
+                                       //   be larger than VG_MAX_INSTR_SZB
+#  define VG_STACK_REDZONE_SZB      0  // number of addressable bytes below %RSP
+
+#elif defined(VGP_amd64_linux)
+#  define VG_MIN_INSTR_SZB          1
+#  define VG_MAX_INSTR_SZB         16
+#  define VG_CLREQ_SZB             19
+#  define VG_STACK_REDZONE_SZB    128
+
+#elif defined(VGP_ppc32_linux)
+#  define VG_MIN_INSTR_SZB          4
+#  define VG_MAX_INSTR_SZB          4 
+#  define VG_CLREQ_SZB             20
+#  define VG_STACK_REDZONE_SZB      0
+
+#elif defined(VGP_ppc64_linux)
+#  define VG_MIN_INSTR_SZB          4
+#  define VG_MAX_INSTR_SZB          4 
+#  define VG_CLREQ_SZB             20
+#  define VG_STACK_REDZONE_SZB    288  // number of addressable bytes below R1
+                                       // from 64-bit PowerPC ELF ABI 
+                                       // Supplement 1.7
+
+#elif defined(VGP_arm_linux)
+#  define VG_MIN_INSTR_SZB          2
+#  define VG_MAX_INSTR_SZB          4 
+#  define VG_CLREQ_SZB             20
+#  define VG_STACK_REDZONE_SZB      0
+
+#elif defined(VGP_ppc32_aix5)
+#  define VG_MIN_INSTR_SZB          4
+#  define VG_MAX_INSTR_SZB          4 
+#  define VG_CLREQ_SZB             20
+   /* The PowerOpen ABI actually says 220 bytes, but that is not an
+      8-aligned number, and frequently forces Memcheck's
+      mc_{new,die}_mem_stack_N routines into slow cases by losing
+      8-alignment of the area to be messed with.  So let's just say
+      224 instead.  Gdb has a similar kludge. */
+#  define VG_STACK_REDZONE_SZB    224
+
+#elif defined(VGP_ppc64_aix5)
+#  define VG_MIN_INSTR_SZB          4
+#  define VG_MAX_INSTR_SZB          4 
+#  define VG_CLREQ_SZB             20
+#  define VG_STACK_REDZONE_SZB    288 // is this right?
+
+#elif defined(VGP_x86_darwin)
+#  define VG_MIN_INSTR_SZB          1  // min length of native instruction
+#  define VG_MAX_INSTR_SZB         16  // max length of native instruction
+#  define VG_CLREQ_SZB             14  // length of a client request, may
+                                       //   be larger than VG_MAX_INSTR_SZB
+#  define VG_STACK_REDZONE_SZB      0  // number of addressable bytes below %RSP
+
+#elif defined(VGP_amd64_darwin)
+#  define VG_MIN_INSTR_SZB          1
+#  define VG_MAX_INSTR_SZB         16
+#  define VG_CLREQ_SZB             19
+#  define VG_STACK_REDZONE_SZB    128
+
+#else
+#  error Unknown platform
+#endif
+
+// Guest state accessors
+// Are mostly in the core_ header.
+//  Only these two are available to tools.
+Addr VG_(get_IP) ( ThreadId tid );
+Addr VG_(get_SP) ( ThreadId tid );
+
+
+// For get/set, 'area' is where the asked-for guest state will be copied
+// into/from.  If shadowNo == 0, the real (non-shadow) guest state is
+// accessed.  If shadowNo == 1, the first shadow area is accessed, and
+// if shadowNo == 2, the second shadow area is accessed.  This gives a
+// completely general way to read/modify a thread's guest register state
+// providing you know the offsets you need.
+void
+VG_(get_shadow_regs_area) ( ThreadId tid, 
+                            /*DST*/UChar* dst,
+                            /*SRC*/Int shadowNo, PtrdiffT offset, SizeT size );
+void
+VG_(set_shadow_regs_area) ( ThreadId tid, 
+                            /*DST*/Int shadowNo, PtrdiffT offset, SizeT size,
+                            /*SRC*/const UChar* src );
+
+// Sets the shadow values for the syscall return value register(s).
+// This is platform specific.
+void VG_(set_syscall_return_shadows) ( ThreadId tid,
+                                       /* shadow vals for the result */
+                                       UWord s1res, UWord s2res,
+                                       /* shadow vals for the error val */
+                                       UWord s1err, UWord s2err );
+
+// Apply a function 'f' to all the general purpose registers in all the
+// current threads.
+// This is very Memcheck-specific -- it's used to find the roots when
+// doing leak checking.
+extern void VG_(apply_to_GP_regs)(void (*f)(UWord val));
+
+// This iterator lets you inspect each live thread's stack bounds.
+// Returns False at the end.  'tid' is the iterator and you can only
+// safely change it by making calls to these functions.
+extern void VG_(thread_stack_reset_iter) ( /*OUT*/ThreadId* tid );
+extern Bool VG_(thread_stack_next)       ( /*MOD*/ThreadId* tid,
+                                           /*OUT*/Addr* stack_min, 
+                                           /*OUT*/Addr* stack_max );
+
+// Returns .client_stack_highest_word for the given thread
+extern Addr VG_(thread_get_stack_max) ( ThreadId tid );
+
+// Returns how many bytes have been allocated for the stack of the given thread
+extern SizeT VG_(thread_get_stack_size) ( ThreadId tid );
+
+// Returns the bottommost address of the alternate signal stack.
+// See also the man page of sigaltstack().
+extern Addr VG_(thread_get_altstack_min) ( ThreadId tid );
+
+// Returns how many bytes have been allocated for the alternate signal stack.
+// See also the man page of sigaltstack().
+extern SizeT VG_(thread_get_altstack_size) ( ThreadId tid );
+
+// Given a pointer to a function as obtained by "& functionname" in C,
+// produce a pointer to the actual entry point for the function.  For
+// most platforms it's the identity function.  Unfortunately, on
+// ppc64-linux it isn't (sigh).
+extern void* VG_(fnptr_to_fnentry)( void* );
+
+#endif   // __PUB_TOOL_MACHINE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_mallocfree.h b/include/pub_tool_mallocfree.h
new file mode 100644
index 0000000..694e1f5
--- /dev/null
+++ b/include/pub_tool_mallocfree.h
@@ -0,0 +1,60 @@
+
+/*--------------------------------------------------------------------*/
+/*--- MallocFree: high-level memory management.                    ---*/
+/*---                                        pub_tool_mallocfree.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_MALLOCFREE_H
+#define __PUB_TOOL_MALLOCFREE_H
+
+// These can be for allocating memory used by tools.
+// Nb: the allocators *always succeed* -- they never return NULL (Valgrind
+// will abort if they can't allocate the memory).
+// The 'cc' is a string that identifies the allocation point.  It's used when
+// --profile-heap=yes is specified.
+extern void* VG_(malloc)         ( HChar* cc, SizeT nbytes );
+extern void  VG_(free)           ( void* p );
+extern void* VG_(calloc)         ( HChar* cc, SizeT n, SizeT bytes_per_elem );
+extern void* VG_(realloc)        ( HChar* cc, void* p, SizeT size );
+extern Char* VG_(strdup)         ( HChar* cc, const Char* s );
+
+// Returns the usable size of a heap-block.  It's the asked-for size plus
+// possibly some more due to rounding up.
+extern SizeT VG_(malloc_usable_size)( void* p );
+
+// TODO: move somewhere else
+// Call here to bomb the system when out of memory (mmap anon fails)
+__attribute__((noreturn))
+extern void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB );
+
+#endif   // __PUB_TOOL_MALLOCFREE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
+
diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h
new file mode 100644
index 0000000..7f85492
--- /dev/null
+++ b/include/pub_tool_options.h
@@ -0,0 +1,193 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Command line options.                     pub_tool_options.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_OPTIONS_H
+#define __PUB_TOOL_OPTIONS_H
+
+#include "libvex.h"              // for VexControl
+
+
+// Higher-level command-line option recognisers;  use in if/else chains. 
+// Note that they assign a value to the 'qq_var' argument.  So often they
+// can be used like this:
+//
+//   if VG_STR_CLO(arg, "--foo", clo_foo) { }
+//
+// But if you want to do further checking or processing, you can do this:
+//
+//   if VG_STR_CLO(arg, "--foo", clo_foo) { <further checking or processing> }
+//
+// They use GNU statement expressions to do the qq_var assignment within a
+// conditional expression.
+
+// String argument, eg. --foo=yes or --foo=no
+#define VG_BOOL_CLO(qq_arg, qq_option, qq_var) \
+   (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+    ({ \
+      Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+      if      VG_STREQ(val, "yes") (qq_var) = True; \
+      else if VG_STREQ(val, "no")  (qq_var) = False; \
+      True; \
+    }) \
+   )
+
+// String argument, eg. --foo=bar
+#define VG_STR_CLO(qq_arg, qq_option, qq_var) \
+   (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+    ({ \
+      Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+      (qq_var) = val; \
+      True; \
+    }) \
+   )
+
+// Unbounded integer arg, eg. --foo=10
+#define VG_INT_CLO(qq_arg, qq_option, qq_var) \
+   (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+    ({ \
+      Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+      Char* s; \
+      Long n = VG_(strtoll10)( val, &s ); \
+      (qq_var) = n; \
+      /* Check for non-numeralness, or overflow. */ \
+      if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
+      True; \
+     }) \
+    )
+
+// Bounded integer arg, eg. --foo=10 ;  if the value exceeds the bounds it
+// causes an abort.  'qq_base' can be 10 or 16.
+#define VG_BINTN_CLO(qq_base, qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+   (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+    ({ \
+      Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+      Char* s; \
+      Long n = VG_(strtoll##qq_base)( val, &s ); \
+      (qq_var) = n; \
+      /* MMM: separate the two cases, and explain the problem;  likewise */ \
+      /* for all the other macros in this file. */ \
+      /* Check for non-numeralness, or overflow. */ \
+      /* Nb: it will overflow if qq_var is unsigned and qq_val is negative! */ \
+      if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
+      /* Check bounds. */ \
+      if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \
+         VG_(fmsg_bad_option)(qq_arg, \
+            "'%s' argument must be between %lld and %lld\n", \
+            (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \
+      } \
+      True; \
+     }) \
+    )
+
+// Bounded decimal integer arg, eg. --foo=100
+#define VG_BINT_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+   VG_BINTN_CLO(10, (qq_arg), qq_option, (qq_var), (qq_lo), (qq_hi))
+
+// Bounded hexadecimal integer arg, eg. --foo=0x1fa8
+#define VG_BHEX_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+   VG_BINTN_CLO(16, (qq_arg), qq_option, (qq_var), (qq_lo), (qq_hi))
+
+// Double (decimal) arg, eg. --foo=4.6
+// XXX: there's not VG_BDBL_CLO because we don't have a good way of printing
+// floats at the moment!
+#define VG_DBL_CLO(qq_arg, qq_option, qq_var) \
+   (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+    ({ \
+      Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+      Char* s; \
+      double n = VG_(strtod)( val, &s ); \
+      (qq_var) = n; \
+      /* Check for non-numeralness */ \
+      if ('\0' != s[0]) VG_(fmsg_bad_option)(qq_arg, ""); \
+      True; \
+     }) \
+    )
+
+// Arg whose value is denoted by the exact presence of the given string;
+// if it matches, qq_var is assigned the value in qq_val.
+#define VG_XACT_CLO(qq_arg, qq_option, qq_var, qq_val) \
+   (VG_STREQ((qq_arg), (qq_option)) && \
+    ({ \
+      (qq_var) = (qq_val); \
+      True; \
+    }) \
+   )
+
+/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
+extern Int  VG_(clo_verbosity);
+
+/* Show tool and core statistics */
+extern Bool VG_(clo_stats);
+
+/* Emit all messages as XML? default: NO */
+/* If clo_xml is set, various other options are set in a non-default
+   way.  See vg_main.c and mc_main.c. */
+extern Bool VG_(clo_xml);
+
+/* An arbitrary user-supplied string which is copied into the
+   XML output, in between <usercomment> tags. */
+extern HChar* VG_(clo_xml_user_comment);
+
+/* Vex iropt control.  Tool-visible so tools can make Vex optimise
+   less aggressively if that is needed (callgrind needs this). */
+extern VexControl VG_(clo_vex_control);
+
+/* Number of parents of a backtrace.  Default: 8.  */
+extern Int   VG_(clo_backtrace_size);
+
+/* Continue stack traces below main()?  Default: NO */
+extern Bool VG_(clo_show_below_main);
+
+
+/* Used to expand file names.  "option_name" is the option name, eg.
+   "--log-file".  'format' is what follows, eg. "cachegrind.out.%p".  In
+   'format': 
+   - "%p" is replaced with PID.
+   - "%q{QUAL}" is replaced with the environment variable $QUAL.  If $QUAL
+     isn't set, we abort.  If the "{QUAL}" part is malformed, we abort.
+   - "%%" is replaced with "%".
+   Anything else after '%' causes an abort.
+   If the format specifies a relative file name, it's put in the program's
+   initial working directory.  If it specifies an absolute file name (ie.
+   starts with '/') then it is put there.
+
+   Note that "option_name" has no effect on the returned string: the
+   returned string depends only on "format" and the PIDs and
+   environment variables that it references (if any). "option_name" is
+   merely used in printing error messages, if an error message needs
+   to be printed due to malformedness of the "format" argument.
+*/
+extern Char* VG_(expand_file_name)(Char* option_name, Char* format);
+
+#endif   // __PUB_TOOL_OPTIONS_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_oset.h b/include/pub_tool_oset.h
new file mode 100644
index 0000000..bc71daa
--- /dev/null
+++ b/include/pub_tool_oset.h
@@ -0,0 +1,262 @@
+
+/*--------------------------------------------------------------------*/
+/*--- OSet: a fast data structure with no dups.    pub_tool_oset.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 Nicholas Nethercote
+      njn@valgrind.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 __PUB_TOOL_OSET_H
+#define __PUB_TOOL_OSET_H
+
+// This module implements an ordered set, a data structure with fast
+// (eg. amortised log(n) or better) insertion, lookup and deletion of
+// elements.  It does not allow duplicates, and will assert if you insert a
+// duplicate to an OSet.
+//
+// It has two interfaces.  
+//
+// - The "OSetWord_" interface provides an easier-to-use interface for the
+//   case where you just want to store UWord-sized values.  The user
+//   provides the allocation and deallocation functions, and possibly a 
+//   comparison function.
+//
+// - The "OSetGen_" interface provides a totally generic interface, which
+//   allows any kind of structure to be put into the set.  The user provides
+//   the allocation and deallocation functions.  Also, each element has a
+//   key, which the lookup is done with.  The key may be the whole element
+//   (eg. in an OSet of integers, each integer serves both as an element and
+//   a key), or it may be only part of it (eg. if the key is a single field
+//   in a struct).  The user can provide a function that compares an element
+//   with a key;  this is very flexible, and with the right comparison
+//   function even a (non-overlapping) interval list can be created.  But
+//   the cost of calling a function for every comparison can be high during
+//   lookup.  If no comparison function is provided, we assume that keys are
+//   (signed or unsigned) words, and that the key is the first word in each
+//   element.  This fast comparison is suitable for an OSet containing
+//   structs where the first element is an Addr, for example.
+//
+// Each OSet interface also has an iterator, which makes it simple to
+// traverse all the nodes in order.  Note that the iterator maintains state
+// and so is non-reentrant.
+//
+// Note that once you insert an element into an OSet, if you modify any part
+// of it looked at by your cmp() function, this may cause incorrect
+// behaviour as the sorted order maintained will be wrong.
+
+/*--------------------------------------------------------------------*/
+/*--- Types                                                        ---*/
+/*--------------------------------------------------------------------*/
+
+typedef struct _OSet     OSet;
+
+// - Cmp:   returns -1, 0 or 1 if key is <, == or > elem.
+// - Alloc: allocates a chunk of memory.
+// - Free:  frees a chunk of memory allocated with Alloc.
+
+typedef Word  (*OSetCmp_t)         ( const void* key, const void* elem );
+typedef void* (*OSetAlloc_t)       ( HChar* cc, SizeT szB );
+typedef void  (*OSetFree_t)        ( void* p );
+
+/*--------------------------------------------------------------------*/
+/*--- Creating and destroying OSets (UWord)                        ---*/
+/*--------------------------------------------------------------------*/
+
+// * Create: allocates and initialises the OSet.  Arguments:
+//   - alloc     The allocation function used internally for allocating the
+//               OSet and all its nodes.
+//   - cc        Cost centre string used by 'alloc'.
+//   - free      The deallocation function used internally for freeing nodes
+//               called by VG_(OSetWord_Destroy)().
+//
+// * CreateWithCmp: like Create, but you specify your own comparison
+//   function.
+//
+// * Destroy: frees all nodes in the table, plus the memory used by
+//   the table itself.  The passed-in function is called on each node first
+//   to allow the destruction of any attached resources;  if NULL it is not
+//   called.
+
+extern OSet* VG_(OSetWord_Create)       ( OSetAlloc_t alloc, HChar* cc, 
+                                          OSetFree_t _free );
+extern void  VG_(OSetWord_Destroy)      ( OSet* os );
+
+/*--------------------------------------------------------------------*/
+/*--- Operations on OSets (UWord)                                  ---*/
+/*--------------------------------------------------------------------*/
+
+// In everything that follows, the parameter 'key' is always the *address*
+// of the key, and 'elem' is *address* of the elem, as are the return values
+// of the functions that return elems.
+//
+// * Size: The number of elements in the set.
+//
+// * Contains: Determines if the value is in the set.
+//
+// * Insert: Inserts a new element into the set.  Duplicates are forbidden,
+//   and will cause assertion failures.
+//
+// * Remove: Removes the value from the set, if present.  Returns a Bool
+//   indicating if the value was removed.
+//
+// * ResetIter: Each OSet has an iterator.  This resets it to point to the
+//   first element in the OSet.
+// 
+// * Next: Copies the next value according to the OSet's iterator into &val,
+//   advances the iterator by one, and returns True;  the elements are
+//   visited in increasing order of unsigned words (UWord).  Or, returns
+//   False if the iterator has reached the set's end.
+//   
+//   You can thus iterate in order through a set like this:
+//
+//     Word val;
+//     VG_(OSetWord_ResetIter)(oset);
+//     while ( VG_(OSetWord_Next)(oset, &val) ) {
+//        ... do stuff with 'val' ...
+//     }
+//
+//   Note that iterators are cleared any time an element is inserted or
+//   removed from the OSet, to avoid possible mayhem caused by the iterator
+//   getting out of sync with the OSet's contents.  "Cleared" means that
+//   they will return False if VG_(OSetWord_Next)() is called without an
+//   intervening call to VG_(OSetWord_ResetIter)().
+
+extern Word  VG_(OSetWord_Size)         ( OSet* os );
+extern void  VG_(OSetWord_Insert)       ( OSet* os, UWord val );
+extern Bool  VG_(OSetWord_Contains)     ( OSet* os, UWord val );
+extern Bool  VG_(OSetWord_Remove)       ( OSet* os, UWord val );
+extern void  VG_(OSetWord_ResetIter)    ( OSet* os );
+extern Bool  VG_(OSetWord_Next)         ( OSet* os, /*OUT*/UWord* val );
+
+
+/*--------------------------------------------------------------------*/
+/*--- Creating and destroying OSets and OSet members (Gen)         ---*/
+/*--------------------------------------------------------------------*/
+
+// * Create: allocates and initialises the OSet.  Arguments:
+//   - keyOff    The offset of the key within the element.
+//   - cmp       The comparison function between keys and elements, or NULL
+//               if the OSet should use fast comparisons.
+//   - alloc     The allocation function used for allocating the OSet itself;
+//               it's also called for each invocation of
+//               VG_(OSetGen_AllocNode)().
+//   - cc        Cost centre string used by 'alloc'.
+//   - free      The deallocation function used by VG_(OSetGen_FreeNode)() and
+//               VG_(OSetGen_Destroy)().
+//
+//   If cmp is NULL, keyOff must be zero.  This is checked.
+//
+// * Destroy: frees all nodes in the table, plus the memory used by
+//   the table itself.  The passed-in function is called on each node first
+//   to allow the destruction of any attached resources;  if NULL it is not
+//   called.
+//
+// * AllocNode: Allocate and zero memory for a node to go into the OSet.
+//   Uses the alloc function given to VG_(OSetGen_Create)() to allocated a
+//   node which is big enough for both an element and the OSet metadata.
+//   Not all elements in one OSet have to be the same size.
+//
+//   Note that the element allocated will be at most word-aligned, which may
+//   be less aligned than the element type would normally be.
+//
+// * FreeNode: Deallocate a node allocated with OSetGen_AllocNode().  Using
+//   a deallocation function (such as VG_(free)()) directly will likely
+//   lead to assertions in Valgrind's allocator.
+
+extern OSet* VG_(OSetGen_Create)    ( PtrdiffT keyOff, OSetCmp_t cmp,
+                                      OSetAlloc_t alloc, HChar* cc,
+                                      OSetFree_t _free );
+extern void  VG_(OSetGen_Destroy)   ( OSet* os );
+extern void* VG_(OSetGen_AllocNode) ( OSet* os, SizeT elemSize );
+extern void  VG_(OSetGen_FreeNode)  ( OSet* os, void* elem );
+
+/*--------------------------------------------------------------------*/
+/*--- Operations on OSets (Gen)                                    ---*/
+/*--------------------------------------------------------------------*/
+
+// In everything that follows, the parameter 'key' is always the *address*
+// of the key, and 'elem' is *address* of the elem, as are the return values
+// of the functions that return elems.
+//
+// * Size: The number of elements in the set.
+//
+// * Insert: Inserts a new element into the set.  Note that 'elem' must
+//   have been allocated using VG_(OSetGen_AllocNode)(), otherwise you will
+//   get assertion failures about "bad magic".  Duplicates are forbidden,
+//   and will also cause assertion failures.
+//
+// * Contains: Determines if any element in the OSet matches the key.
+//
+// * Lookup: Returns a pointer to the element matching the key, if there is
+//   one, otherwise returns NULL.
+//
+// * LookupWithCmp: Like Lookup, but you specify the comparison function,
+//   which overrides the OSet's normal one.
+//
+// * Remove: Removes the element matching the key, if there is one.  Returns
+//   NULL if no element matches the key.
+//
+// * ResetIter: Each OSet has an iterator.  This resets it to point to the
+//   first element in the OSet.
+// 
+// * ResetIterAt: Like ResetIter, but instead of resetting the iterator to the
+//   smallest element, it resets the iterator to point to the smallest element
+//   in the set whose key is greater-than-or-equal to the given key.  (In many
+//   cases this will be the element whose key equals that of the given key.)
+//
+// * Next: Returns a pointer to the element pointed to by the OSet's
+//   iterator, and advances the iterator by one;  the elements are visited
+//   in order.  Or, returns NULL if the iterator has reached the OSet's end.
+//   
+//   You can thus iterate in order through a set like this:
+//
+//     VG_(OSetGen_ResetIter)(oset);
+//     while ( (elem = VG_(OSetGen_Next)(oset)) ) {
+//        ... do stuff with 'elem' ...
+//     }
+//
+//   Note that iterators are cleared any time an element is inserted or
+//   removed from the OSet, to avoid possible mayhem caused by the iterator
+//   getting out of sync with the OSet's contents.  "Cleared" means that
+//   they will return NULL if VG_(OSetGen_Next)() is called without an
+//   intervening call to VG_(OSetGen_ResetIter)().
+
+extern Word  VG_(OSetGen_Size)         ( const OSet* os );
+extern void  VG_(OSetGen_Insert)       ( OSet* os, void* elem );
+extern Bool  VG_(OSetGen_Contains)     ( const OSet* os, const void* key );
+extern void* VG_(OSetGen_Lookup)       ( const OSet* os, const void* key );
+extern void* VG_(OSetGen_LookupWithCmp)( OSet* os,
+                                         const void* key, OSetCmp_t cmp );
+extern void* VG_(OSetGen_Remove)       ( OSet* os, const void* key );
+extern void  VG_(OSetGen_ResetIter)    ( OSet* os );
+extern void  VG_(OSetGen_ResetIterAt)  ( OSet* os, const void* key );
+extern void* VG_(OSetGen_Next)         ( OSet* os );
+
+
+#endif   // __PUB_TOOL_OSET_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h
new file mode 100644
index 0000000..0631ac4
--- /dev/null
+++ b/include/pub_tool_redir.h
@@ -0,0 +1,249 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Redirections, etc.                          pub_tool_redir.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_REDIR_H
+#define __PUB_TOOL_REDIR_H
+
+/* The following macros facilitate function replacement and wrapping.
+
+   Function wrapping and function replacement are similar but not
+   identical.
+
+   A replacement for some function F simply diverts all calls to F
+   to the stated replacement.  There is no way to get back to F itself
+   from the replacement.
+
+   A wrapper for a function F causes all calls to F to instead go to
+   the wrapper.  However, from inside the wrapper, it is possible
+   (with some difficulty) to get to F itself.
+
+   You may notice that replacement is a special case of wrapping, in
+   which the call to the original is omitted.  For implementation
+   reasons, though, it is important to use the following macros
+   correctly: in particular, if you want to write a replacement, make
+   sure you use the VG_REPLACE_FN_ macros and not the VG_WRAP_FN_
+   macros.
+
+   Replacement
+   ~~~~~~~~~~~
+   To write a replacement function, do this:
+
+      ret_type 
+      VG_REPLACE_FUNCTION_ZU(zEncodedSoname,fnname) ( .. args .. )
+      {
+         ... body ...
+      }
+
+   zEncodedSoname should be a Z-encoded soname (see below for Z-encoding
+   details) and fnname should be an unencoded fn name.  The resulting name is
+
+      _vgrZU_zEncodedSoname_fnname
+
+   The "_vgrZU_" is a prefix that gets discarded upon decoding.
+
+   It is also possible to write
+
+      ret_type 
+      VG_REPLACE_FUNCTION_ZZ(zEncodedSoname,zEncodedFnname) ( .. args .. )
+      {
+         ... body ...
+      }
+   
+   which means precisely the same, but the function name is also
+   Z-encoded.  This can sometimes be necessary.  In this case the
+   resulting function name is
+
+      _vgrZZ_zEncodedSoname_zEncodedFnname
+
+   When it sees this either such name, the core's symbol-table reading
+   machinery and redirection machinery first Z-decode the soname and 
+   if necessary the fnname.  They are encoded so that they may include
+   arbitrary characters, and in particular they may contain '*', which
+   acts as a wildcard.
+
+   They then will conspire to cause calls to any function matching
+   'fnname' in any object whose soname matches 'soname' to actually be
+   routed to this function.  This is used in Valgrind to define dozens
+   of replacements of malloc, free, etc.
+
+   The soname must be a Z-encoded bit of text because sonames can
+   contain dots etc which are not valid symbol names.  The function
+   name may or may not be Z-encoded: to include wildcards it has to be,
+   but Z-encoding C++ function names which are themselves already mangled
+   using Zs in some way is tedious and error prone, so the _ZU variant
+   allows them not to be Z-encoded.
+
+   Note that the soname "NONE" is specially interpreted to match any
+   shared object which doesn't have a soname.
+
+   Note also that the replacement function should probably (must be?) in
+   client space, so it runs on the simulated CPU.  So it must be in
+   either vgpreload_<tool>.so or vgpreload_core.so.  It also only works
+   with functions in shared objects, I think.
+   
+   It is important that the Z-encoded names contain no unencoded
+   underscores, since the intercept-handlers in m_redir.c detect the
+   end of the soname by looking for the first trailing underscore.
+
+   Wrapping
+   ~~~~~~~~
+   This is identical to replacement, except that you should use the
+   macro names
+
+      VG_WRAP_FUNCTION_ZU
+      VG_WRAP_FUNCTION_ZZ
+
+   instead.
+
+   Z-encoding
+   ~~~~~~~~~~
+   Z-encoding details: the scheme is like GHC's.  It is just about
+   readable enough to make a preprocessor unnecessary.  First the
+   "_vgrZU_" or "_vgrZZ_" prefix is added, and then the following
+   characters are transformed.
+
+     *         -->  Za    (asterisk)
+     :         -->  Zc    (colon)
+     .         -->  Zd    (dot)
+     -         -->  Zh    (hyphen)
+     +         -->  Zp    (plus)
+     (space)   -->  Zs    (space)
+     _         -->  Zu    (underscore)
+     @         -->  ZA    (at)
+     $         -->  ZD    (dollar)
+     (         -->  ZL    (left)
+     )         -->  ZR    (right)
+     Z         -->  ZZ    (Z)
+
+   Everything else is left unchanged.
+*/
+
+/* If you change these, the code in VG_(maybe_Z_demangle) needs to be
+   changed accordingly.  NOTE: duplicates
+   I_{WRAP,REPLACE}_SONAME_FNNAME_Z{U,Z} in valgrind.h. */
+
+/* Use an extra level of macroisation so as to ensure the soname/fnname
+   args are fully macro-expanded before pasting them together. */
+#define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd
+
+#define VG_REPLACE_FUNCTION_ZU(soname,fnname) VG_CONCAT4(_vgrZU_,soname,_,fnname)
+#define VG_REPLACE_FUNCTION_ZZ(soname,fnname) VG_CONCAT4(_vgrZZ_,soname,_,fnname)
+
+#define VG_WRAP_FUNCTION_ZU(soname,fnname) VG_CONCAT4(_vgwZU_,soname,_,fnname)
+#define VG_WRAP_FUNCTION_ZZ(soname,fnname) VG_CONCAT4(_vgwZZ_,soname,_,fnname)
+
+/* --------- Some handy Z-encoded names. --------- */
+
+// Nb: ALL THESE NAMES MUST BEGIN WITH "VG_Z_".  Why?  If we applied
+// conditional compilation inconsistently we could accidentally use an
+// undefined constant like VG_Z_LIBC_DOT_A, resulting in a bogus Z-encoded
+// name like "_vgrZU_VG_Z_LIBC_DOT_A_foo".  This can't be detected at
+// compile-time, because both the constant's name and its value are
+// identifiers.  However, by always using "VG_Z_" as a prefix, we can do a
+// run-time check and abort if any name has "VG_Z_" in it, because that
+// indicates that the constant has been used without being defined.
+
+/* --- Soname of the standard C library. --- */
+
+#if defined(VGO_linux)
+#  define  VG_Z_LIBC_SONAME  libcZdsoZa              // libc.so*
+#elif defined(VGP_ppc32_aix5)
+   /* AIX has both /usr/lib/libc.a and /usr/lib/libc_r.a. */
+#  define  VG_Z_LIBC_SONAME  libcZaZdaZLshrZdoZR     // libc*.a(shr.o)
+#elif defined(VGP_ppc64_aix5)
+#  define  VG_Z_LIBC_SONAME  libcZaZdaZLshrZu64ZdoZR // libc*.a(shr_64.o)
+#elif defined(VGO_darwin)
+#  define  VG_Z_LIBC_SONAME  libSystemZdZaZddylib    // libSystem.*.dylib
+#else
+#  error "Unknown platform"
+#endif
+
+/* --- Soname of the GNU C++ library. --- */
+
+// Valid on all platforms(?)
+#define  VG_Z_LIBSTDCXX_SONAME  libstdcZpZpZa           // libstdc++*
+
+/* --- Soname of XLC's C++ library. --- */
+
+/* AIX: xlC's C++ runtime library is called libC.a, and the
+   interesting symbols appear to be in ansicore_32.o or ansicore_64.o
+   respectively. */
+#if defined(VGP_ppc32_aix5)
+#  define  VG_Z_LIBC_DOT_A   libCZdaZLansicoreZu32ZdoZR // libC.a(ansicore_32.o)
+#elif defined(VGP_ppc64_aix5)
+#  define  VG_Z_LIBC_DOT_A   libCZdaZLansicoreZu64ZdoZR // libC.a(ansicore_64.o)
+#endif
+
+/* --- Soname of the pthreads library. --- */
+
+#if defined(VGO_linux) || defined(VGO_aix5)
+#  define  VG_Z_LIBPTHREAD_SONAME  libpthreadZdsoZd0     // libpthread.so.0
+#elif defined(VGO_darwin)
+#  define  VG_Z_LIBPTHREAD_SONAME  libSystemZdZaZddylib  // libSystem.*.dylib
+#else
+#  error "Unknown platform"
+#endif
+
+/* --- Sonames for Linux ELF linkers, plus unencoded versions. --- */
+
+#if defined(VGO_linux)
+
+#define  VG_Z_LD_LINUX_SO_3         ldZhlinuxZdsoZd3           // ld-linux.so.3
+#define  VG_U_LD_LINUX_SO_3         "ld-linux.so.3"
+
+#define  VG_Z_LD_LINUX_SO_2         ldZhlinuxZdsoZd2           // ld-linux.so.2
+#define  VG_U_LD_LINUX_SO_2         "ld-linux.so.2"
+
+#define  VG_Z_LD_LINUX_X86_64_SO_2  ldZhlinuxZhx86Zh64ZdsoZd2  // ld-linux-x86-64.so.2
+#define  VG_U_LD_LINUX_X86_64_SO_2  "ld-linux-x86-64.so.2"
+
+#define  VG_Z_LD64_SO_1             ld64ZdsoZd1                // ld64.so.1
+#define  VG_U_LD64_SO_1             "ld64.so.1"
+
+#define  VG_Z_LD_SO_1               ldZdsoZd1                  // ld.so.1
+#define  VG_U_LD_SO_1               "ld.so.1"
+
+#endif
+
+/* --- Executable name for Darwin Mach-O linker. --- */
+
+#if defined(VGO_darwin)
+
+#define  VG_Z_DYLD               dyld                       // dyld
+#define  VG_U_DYLD               "dyld"
+
+#endif
+
+
+#endif   // __PUB_TOOL_REDIR_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_replacemalloc.h b/include/pub_tool_replacemalloc.h
new file mode 100644
index 0000000..7db215d
--- /dev/null
+++ b/include/pub_tool_replacemalloc.h
@@ -0,0 +1,72 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Malloc replacement.                 pub_tool_replacemalloc.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_REPLACEMALLOC_H
+#define __PUB_TOOL_REPLACEMALLOC_H
+
+/* If a tool replaces malloc() et al, the easiest way to do so is to
+   link libreplacemalloc_toolpreload.o into its vgpreload_*.so file, and
+   use the functions declared below.  You can do it from scratch,
+   though, if you enjoy that sort of thing. */
+
+/* Can be called from VG_(tdict).malloc_malloc et al to do the actual
+ * alloc/freeing. */
+extern void* VG_(cli_malloc) ( SizeT align, SizeT nbytes );
+extern void  VG_(cli_free)   ( void* p );
+
+/* If a tool uses deferred freeing (e.g. memcheck to catch accesses to
+   freed memory) it can maintain number and total size of queued blocks
+   in these variable to provide more accurate statistics about client
+   memory usage. Currently used by mallinfo(). */
+extern Long VG_(free_queue_volume);
+extern Long VG_(free_queue_length);
+
+/* Check if an address is within a range, allowing for redzones at edges */
+extern Bool VG_(addr_is_in_block)( Addr a, Addr start,
+                                   SizeT size, SizeT rz_szB );
+
+/* ------------------------------------------------------------------ */
+/* Some options that can be used by a tool if malloc() et al are replaced.
+   The tool should call the functions in the appropriate places to give
+   control over these aspects of Valgrind's version of malloc(). */
+
+/* DEBUG: print malloc details?  default: NO */
+extern Bool VG_(clo_trace_malloc);
+/* Minimum alignment in functions that don't specify alignment explicitly.
+   default: VG_MIN_MALLOC_SZB */
+extern UInt VG_(clo_alignment);
+
+extern Bool VG_(replacement_malloc_process_cmd_line_option) ( Char* arg );
+
+#endif   // __PUB_TOOL_REPLACEMALLOC_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_seqmatch.h b/include/pub_tool_seqmatch.h
new file mode 100644
index 0000000..acce3be
--- /dev/null
+++ b/include/pub_tool_seqmatch.h
@@ -0,0 +1,91 @@
+
+/*--------------------------------------------------------------------*/
+/*--- A simple sequence matching facility.                         ---*/
+/*---                                          pub_tool_seqmatch.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2008-2010 OpenWorks Ltd
+      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_TOOL_SEQMATCH_H
+#define __PUB_TOOL_SEQMATCH_H
+
+/* Perform totally abstractified sequence matching, of an input
+   sequence against a pattern sequence.  The pattern sequence may
+   include '*' elements (matches any number of anything) and '?'
+   elements (matches exactly one element).  '*' patterns are matched
+   frugally, meaning that they are "assigned" the minimum amount of
+   input needed to make the match work.
+
+   This routine is recursive.  The recursion depth is equal to the
+   number of '*' elements in the pattern.  There is no guard against
+   excessive recursion.  This function has no global state and so is
+   thread-safe and re-entrant.  (It needs to be, since m_errormgr will
+   effectively construct two simultaneous calls to it, once to match
+   at the frame level, and whilst that is happening, once at the
+   function/object-name level.)
+
+   When matchAll is True, the entire input sequence must match the
+   pattern, else the match fails.  When False, it's ok for some tail
+   of the input sequence to be unused -- so we're only matching a
+   prefix.
+
+   The pattern array is starts at 'patt' and consists of 'nPatt'
+   elements each of size 'szbPatt'.  For the initial call, pass a
+   value of zero to 'ixPatt'.
+
+   Ditto for input/nInput/szbInput/ixInput.
+
+   pIsStar should return True iff the pointed-to pattern element is
+   conceptually a '*'.
+
+   pIsQuery should return True iff the pointed-to-pattern element is
+   conceptually a '?'.
+
+   pattEQinp takes a pointer to a pattern element and a pointer to an
+   input element.  It should return True iff they are considered
+   equal.  Note that the pattern element is guaranteed to be neither
+   (conceptually) '*' nor '?', so it must be a literal (in the sense
+   that all the input sequence elements are literal).
+*/
+Bool VG_(generic_match) ( 
+        Bool matchAll,
+        void* patt,  SizeT szbPatt,  UWord nPatt,  UWord ixPatt,
+        void* input, SizeT szbInput, UWord nInput, UWord ixInput,
+        Bool (*pIsStar)(void*),
+        Bool (*pIsQuery)(void*),
+        Bool (*pattEQinp)(void*,void*)
+     );
+
+/* Mini-regexp function.  Searches for 'pat' in 'str'.  Supports
+   meta-symbols '*' and '?'.  There is no way to escape meta-symbols
+   in the pattern. */
+Bool VG_(string_match) ( const Char* pat, const Char* str );
+
+#endif   // __PUB_TOOL_SEQMATCH_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                      pub_tool_seqmatch.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_signals.h b/include/pub_tool_signals.h
new file mode 100644
index 0000000..3ffefd5
--- /dev/null
+++ b/include/pub_tool_signals.h
@@ -0,0 +1,47 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Signals stuff.                            pub_tool_signals.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_SIGNALS_H
+#define __PUB_TOOL_SIGNALS_H
+
+// Register an interest in apparently internal faults; used code which
+// wanders around dangerous memory (ie, leakcheck).  The catcher is
+// not expected to return.
+//
+// It's frustrating that we need this header for a single function used
+// only by Memcheck during leak checking.  We should find a way to remove
+// the need for this file.
+extern void VG_(set_fault_catcher)(void (*catcher)(Int sig, Addr addr));
+
+#endif   // __PUB_TOOL_SIGNALS_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_sparsewa.h b/include/pub_tool_sparsewa.h
new file mode 100644
index 0000000..d037043
--- /dev/null
+++ b/include/pub_tool_sparsewa.h
@@ -0,0 +1,99 @@
+
+/*--------------------------------------------------------------------*/
+/*--- An sparse array (of words) implementation.                   ---*/
+/*---                                          pub_tool_sparsewa.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2008-2010 OpenWorks Ltd
+      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_TOOL_SPARSEWA_H
+#define __PUB_TOOL_SPARSEWA_H
+
+//--------------------------------------------------------------------
+// PURPOSE: (see coregrind/pub_core_sparsewa.h for details)
+//--------------------------------------------------------------------
+
+/////////////////////////////////////////////////////////
+//                                                     //
+// SparseWA: Interface                                 //
+//                                                     //
+/////////////////////////////////////////////////////////
+
+// This interface is a very cut-down version of WordFM.
+// If you understand how to use WordFM then it should be
+// trivial to use SparseWA.
+
+typedef  struct _SparseWA  SparseWA; /* opaque */
+
+// Create a new one, using the specified allocator/deallocator
+SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(HChar* cc, SizeT), 
+                        HChar* cc,
+                        void(*dealloc)(void*) );
+
+// Delete one, and free all associated storage
+void VG_(deleteSWA) ( SparseWA* swa );
+
+// Add the binding key -> val to this swa.  Any existing binding is
+// overwritten.  Returned Bool is True iff a previous binding existed.
+Bool VG_(addToSWA) ( SparseWA* swa, UWord key, UWord val );
+
+// Delete key from swa, returning associated key and val if found.
+// Note: returning associated key is stupid (it can only be the
+// key you just specified).  This behaviour is retained to make it
+// easier to migrate from WordFM.  Returned Bool is True iff
+// the key was actually bound in the mapping.
+Bool VG_(delFromSWA) ( SparseWA* swa,
+                       /*OUT*/UWord* oldK, /*OUT*/UWord* oldV,
+                       UWord key );
+
+// Indexes swa at 'key' (or, if you like, looks up 'key' in the
+// mapping), and returns the associated value, if any, in *valP.  For
+// compatibility with WordFM, 'key' is also returned in *keyP.  Returned
+// Bool is True iff a binding for 'key' actually existed.
+Bool VG_(lookupSWA) ( SparseWA* swa,
+                      /*OUT*/UWord* keyP, /*OUT*/UWord* valP,
+                      UWord key );
+
+// Set up 'swa' for iteration.
+void VG_(initIterSWA) ( SparseWA* swa );
+
+// Get the next key/val pair.  Behaviour undefined (highly likely 
+// to segfault) if 'swa' has been modified since initIterSWA was
+// called.  Returned Bool is False iff there are no more pairs
+// that can be extracted.
+Bool VG_(nextIterSWA)( SparseWA* swa,
+                       /*OUT*/UWord* keyP, /*OUT*/UWord* valP );
+
+// How many elements are there in 'swa'?  NOTE: dangerous in the
+// sense that this is not an O(1) operation but rather O(N),
+// since it involves walking the whole tree.
+UWord VG_(sizeSWA) ( SparseWA* swa );
+
+#endif   // __PUB_TOOL_SPARSEWA_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                      pub_tool_sparsewa.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_stacktrace.h b/include/pub_tool_stacktrace.h
new file mode 100644
index 0000000..d22a824
--- /dev/null
+++ b/include/pub_tool_stacktrace.h
@@ -0,0 +1,87 @@
+/*--------------------------------------------------------------------*/
+/*--- Stack traces: getting, traversing, printing.                 ---*/
+/*---                                            tool_stacktrace.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_STACKTRACE_H
+#define __PUB_TOOL_STACKTRACE_H
+
+// The basic stack trace type:  just an array of code addresses.
+typedef Addr* StackTrace;
+
+// Walks the stack to get instruction pointers from the top stack frames 
+// for thread 'tid'.  Maximum of 'n_ips' addresses put into 'ips';
+// 0 is the top of the stack, 1 is its caller, etc.  Everything from
+// ips[return_value] onwards is undefined and should not be read.
+// The initial IP value to use is adjusted by first_ip_delta before
+// the stack is unwound. A safe value to pass is zero.
+//
+// The specific meaning of the returned addresses is:
+//
+// [0] is the IP of thread 'tid'
+// [1] points to the last byte of the call instruction that called [0].
+// [2] points to the last byte of the call instruction that called [1].
+// etc etc
+//
+// Hence ips[0 .. return_value-1] should all point to currently
+// 'active' (in the sense of a stack of unfinished function calls)
+// instructions.  [0] points to the start of an arbitrary instruction.#
+// [1 ..] point to the last byte of a chain of call instructions.
+//
+// If sps and fps are non-NULL, the corresponding frame-pointer and
+// stack-pointer values for each frame are stored there.
+
+extern UInt VG_(get_StackTrace) ( ThreadId tid, 
+                                  /*OUT*/StackTrace ips, UInt n_ips,
+                                  /*OUT*/StackTrace sps,
+                                  /*OUT*/StackTrace fps,
+                                  Word first_ip_delta );
+
+// Apply a function to every element in the StackTrace.  The parameter
+// 'n' gives the index of the passed ip.  'opaque' is an arbitrary
+// pointer provided to each invokation of 'action' (a poor man's
+// closure).  Doesn't go below main() unless --show-below-main=yes is
+// set.
+extern void VG_(apply_StackTrace)(
+               void(*action)(UInt n, Addr ip, void* opaque),
+               void* opaque,
+               StackTrace ips, UInt n_ips
+            );
+
+// Print a StackTrace.
+extern void VG_(pp_StackTrace) ( StackTrace ips, UInt n_ips );
+
+// Gets and immediately prints a StackTrace.  Just a bit simpler than
+// calling VG_(get_StackTrace)() then VG_(pp_StackTrace)().
+extern void VG_(get_and_pp_StackTrace) ( ThreadId tid, UInt n_ips );
+
+#endif   // __PUB_TOOL_STACKTRACE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_threadstate.h b/include/pub_tool_threadstate.h
new file mode 100644
index 0000000..993abfd
--- /dev/null
+++ b/include/pub_tool_threadstate.h
@@ -0,0 +1,53 @@
+
+/*--------------------------------------------------------------------*/
+/*--- The thread state.                     pub_tool_threadstate.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_THREADSTATE_H
+#define __PUB_TOOL_THREADSTATE_H
+
+/* The maximum number of pthreads that we support.  This is
+   deliberately not very high since our implementation of some of the
+   scheduler algorithms is surely O(N) in the number of threads, since
+   that's simple, at least.  And (in practice) we hope that most
+   programs do not need many threads. */
+#define VG_N_THREADS 500
+
+/* Special magic value for an invalid ThreadId.  It corresponds to
+   LinuxThreads using zero as the initial value for
+   pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */
+#define VG_INVALID_THREADID ((ThreadId)(0))
+
+/* Get the TID of the thread which currently has the CPU. */
+extern ThreadId VG_(get_running_tid) ( void );
+
+#endif   // __PUB_TOOL_THREADSTATE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
new file mode 100644
index 0000000..ac346b9
--- /dev/null
+++ b/include/pub_tool_tooliface.h
@@ -0,0 +1,686 @@
+
+/*--------------------------------------------------------------------*/
+/*--- The core/tool interface.                pub_tool_tooliface.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __PUB_TOOL_TOOLIFACE_H
+#define __PUB_TOOL_TOOLIFACE_H
+
+#include "pub_tool_errormgr.h"   // for Error, Supp
+#include "libvex.h"              // for all Vex stuff
+
+/* ------------------------------------------------------------------ */
+/* The interface version */
+
+/* Initialise tool.   Must do the following:
+   - initialise the `details' struct, via the VG_(details_*)() functions
+   - register the basic tool functions, via VG_(basic_tool_funcs)().
+   May do the following:
+   - initialise the `needs' struct to indicate certain requirements, via
+     the VG_(needs_*)() functions
+   - any other tool-specific initialisation
+*/
+extern void (*VG_(tl_pre_clo_init)) ( void );
+
+/* Every tool must include this macro somewhere, exactly once.  The
+   interface version is no longer relevant, but we kept the same name
+   to avoid requiring changes to tools.
+*/
+#define VG_DETERMINE_INTERFACE_VERSION(pre_clo_init) \
+   void (*VG_(tl_pre_clo_init)) ( void ) = pre_clo_init;
+
+/* ------------------------------------------------------------------ */
+/* Basic tool functions */
+
+/* The tool_instrument function is passed as a callback to
+   LibVEX_Translate.  VgCallbackClosure carries additional info
+   which the instrumenter might like to know, but which is opaque to
+   Vex.
+*/
+typedef 
+   struct {
+      Addr64   nraddr; /* non-redirected guest address */
+      Addr64   readdr; /* redirected guest address */
+      ThreadId tid;    /* tid requesting translation */
+   }
+   VgCallbackClosure;
+
+extern void VG_(basic_tool_funcs)(
+   // Do any initialisation that can only be done after command line
+   // processing.
+   void  (*post_clo_init)(void),
+
+   // Instrument a basic block.  Must be a true function, ie. the same
+   // input always results in the same output, because basic blocks
+   // can be retranslated, unless you're doing something really
+   // strange.  Anyway, the arguments.  Mostly they are straightforward
+   // except for the distinction between redirected and non-redirected
+   // guest code addresses, which is important to understand.
+   //
+   // VgCallBackClosure* closure contains extra arguments passed
+   // from Valgrind to the instrumenter, which Vex doesn't know about.
+   // You are free to look inside this structure.
+   //
+   // * closure->tid is the ThreadId of the thread requesting the
+   //   translation.  Not sure why this is here; perhaps callgrind
+   //   uses it.
+   //
+   // * closure->nraddr is the non-redirected guest address of the
+   //   start of the translation.  In other words, the translation is
+   //   being constructed because the guest program jumped to 
+   //   closure->nraddr but no translation of it was found.
+   //
+   // * closure->readdr is the redirected guest address, from which
+   //   the translation was really made.
+   //
+   //   To clarify this, consider what happens when, in Memcheck, the
+   //   first call to malloc() happens.  The guest program will be
+   //   trying to jump to malloc() in libc; hence ->nraddr will contain
+   //   that address.  However, Memcheck intercepts and replaces
+   //   malloc, hence ->readdr will be the address of Memcheck's
+   //   malloc replacement in
+   //   coregrind/m_replacemalloc/vg_replacemalloc.c.  It follows
+   //   that the first IMark in the translation will be labelled as
+   //   from ->readdr rather than ->nraddr.
+   //
+   //   Since most functions are not redirected, the majority of the
+   //   time ->nraddr will be the same as ->readdr.  However, you
+   //   cannot assume this: if your tool has metadata associated
+   //   with code addresses it will get into deep trouble if it does
+   //   make this assumption.
+   //
+   // IRSB* sb_in is the incoming superblock to be instrumented,
+   // in flat IR form.
+   //
+   // VexGuestLayout* layout contains limited info on the layout of
+   // the guest state: where the stack pointer and program counter
+   // are, and which fields should be regarded as 'always defined'.
+   // Memcheck uses this.
+   //
+   // VexGuestExtents* vge points to a structure which states the
+   // precise byte ranges of original code from which this translation
+   // was made (there may be up to three different ranges involved).
+   // Note again that these are the real addresses from which the code
+   // came.  And so it should be the case that closure->readdr is the
+   // same as vge->base[0]; indeed Cachegrind contains this assertion.
+   //
+   // Tools which associate shadow data with code addresses
+   // (cachegrind, callgrind) need to be particularly clear about
+   // whether they are making the association with redirected or
+   // non-redirected code addresses.  Both approaches are viable
+   // but you do need to understand what's going on.  See comments
+   // below on discard_basic_block_info().
+   //
+   // IRType gWordTy and IRType hWordTy contain the types of native
+   // words on the guest (simulated) and host (real) CPUs.  They will
+   // by either Ity_I32 or Ity_I64.  So far we have never built a
+   // cross-architecture Valgrind so they should always be the same.
+   //
+   /* --- Further comments about the IR that your --- */
+   /* --- instrumentation function will receive. --- */
+   /*
+      In the incoming IRSB, the IR for each instruction begins with an
+      IRStmt_IMark, which states the address and length of the
+      instruction from which this IR came.  This makes it easy for
+      profiling-style tools to know precisely which guest code
+      addresses are being executed.
+
+      However, before the first IRStmt_IMark, there may be other IR
+      statements -- a preamble.  In most cases this preamble is empty,
+      but when it isn't, what it contains is some supporting IR that
+      the JIT uses to ensure control flow works correctly.  This
+      preamble does not modify any architecturally defined guest state
+      (registers or memory) and so does not contain anything that will
+      be of interest to your tool.
+
+      You should therefore 
+
+      (1) copy any IR preceding the first IMark verbatim to the start
+          of the output IRSB.
+
+      (2) not try to instrument it or modify it in any way.
+
+      For the record, stuff that may be in the preamble at
+      present is:
+
+      - A self-modifying-code check has been requested for this block.
+        The preamble will contain instructions to checksum the block,
+        compare against the expected value, and exit the dispatcher
+        requesting a discard (hence forcing a retranslation) if they
+        don't match.
+
+      - This block is known to be the entry point of a wrapper of some
+        function F.  In this case the preamble contains code to write
+        the address of the original F (the fn being wrapped) into a
+        'hidden' guest state register _NRADDR.  The wrapper can later
+        read this register using a client request and make a
+        non-redirected call to it using another client-request-like
+        magic macro.
+
+      - For platforms that use the AIX ABI (including ppc64-linux), it
+        is necessary to have a preamble even for replacement functions
+        (not just for wrappers), because it is necessary to switch the
+        R2 register (constant-pool pointer) to a different value when
+        swizzling the program counter.
+
+        Hence the preamble pushes both R2 and LR (the return address)
+        on a small 16-entry stack in the guest state and sets R2 to an
+        appropriate value for the wrapper/replacement fn.  LR is then
+        set so that the wrapper/replacement fn returns to a magic IR
+        stub which restores R2 and LR and returns.
+
+        It's all hugely ugly and fragile.  And it places a stringent
+        requirement on m_debuginfo to find out the correct R2 (toc
+        pointer) value for the wrapper/replacement function.  So much
+        so that m_redir will refuse to honour a redirect-to-me request
+        if it cannot find (by asking m_debuginfo) a plausible R2 value
+        for 'me'.
+
+        Because this mechanism maintains a shadow stack of (R2,LR)
+        pairs in the guest state, it will fail if the
+        wrapper/redirection function, or anything it calls, longjumps
+        out past the wrapper, because then the magic return stub will
+        not be run and so the shadow stack will not be popped.  So it
+        will quickly fill up.  Fortunately none of this applies to
+        {x86,amd64,ppc32}-linux; on those platforms, wrappers can
+        longjump and recurse arbitrarily and everything should work
+        fine.
+
+      Note that copying the preamble verbatim may cause complications
+      for your instrumenter if you shadow IR temporaries.  See big
+      comment in MC_(instrument) in memcheck/mc_translate.c for
+      details.
+   */
+   IRSB*(*instrument)(VgCallbackClosure* closure, 
+                      IRSB*              sb_in, 
+                      VexGuestLayout*    layout, 
+                      VexGuestExtents*   vge, 
+                      IRType             gWordTy, 
+                      IRType             hWordTy),
+
+   // Finish up, print out any results, etc.  `exitcode' is program's exit
+   // code.  The shadow can be found with VG_(get_exit_status_shadow)().
+   void  (*fini)(Int)
+);
+
+/* ------------------------------------------------------------------ */
+/* Details */
+
+/* Default value for avg_translations_sizeB (in bytes), indicating typical
+   code expansion of about 6:1. */
+#define VG_DEFAULT_TRANS_SIZEB   172
+
+/* Information used in the startup message.  `name' also determines the
+   string used for identifying suppressions in a suppression file as
+   belonging to this tool.  `version' can be NULL, in which case (not
+   surprisingly) no version info is printed; this mechanism is designed for
+   tools distributed with Valgrind that share a version number with
+   Valgrind.  Other tools not distributed as part of Valgrind should
+   probably have their own version number.  */
+extern void VG_(details_name)                  ( Char* name );
+extern void VG_(details_version)               ( Char* version );
+extern void VG_(details_description)           ( Char* description );
+extern void VG_(details_copyright_author)      ( Char* copyright_author );
+
+/* Average size of a translation, in bytes, so that the translation
+   storage machinery can allocate memory appropriately.  Not critical,
+   setting is optional. */
+extern void VG_(details_avg_translation_sizeB) ( UInt size );
+
+/* String printed if an `tl_assert' assertion fails or VG_(tool_panic)
+   is called.  Should probably be an email address. */
+extern void VG_(details_bug_reports_to)   ( Char* bug_reports_to );
+
+/* ------------------------------------------------------------------ */
+/* Needs */
+
+/* Should __libc_freeres() be run?  Bugs in it can crash the tool. */
+extern void VG_(needs_libc_freeres) ( void );
+
+/* Want to have errors detected by Valgrind's core reported?  Includes:
+   - pthread API errors (many;  eg. unlocking a non-locked mutex) 
+     [currently disabled]
+   - invalid file descriptors to syscalls like read() and write()
+   - bad signal numbers passed to sigaction()
+   - attempt to install signal handler for SIGKILL or SIGSTOP */
+extern void VG_(needs_core_errors) ( void );
+
+/* Booleans that indicate extra operations are defined;  if these are True,
+   the corresponding template functions (given below) must be defined.  A
+   lot like being a member of a type class. */
+
+/* Want to report errors from tool?  This implies use of suppressions, too. */
+extern void VG_(needs_tool_errors) (
+   // Identify if two errors are equal, or close enough.  This function is
+   // only called if e1 and e2 will have the same error kind.  `res' indicates
+   // how close is "close enough".  `res' should be passed on as necessary,
+   // eg. if the Error's `extra' part contains an ExeContext, `res' should be
+   // passed to VG_(eq_ExeContext)() if the ExeContexts are considered.  Other
+   // than that, probably don't worry about it unless you have lots of very
+   // similar errors occurring.
+   Bool (*eq_Error)(VgRes res, Error* e1, Error* e2),
+
+   // We give tools a chance to have a look at errors
+   // just before they are printed.  That is, before_pp_Error is 
+   // called just before pp_Error itself.  This gives the tool a
+   // chance to look at the just-about-to-be-printed error, so as to 
+   // emit any arbitrary output if wants to, before the error itself
+   // is printed.  This functionality was added to allow Helgrind to
+   // print thread-announcement messages immediately before the 
+   // errors that refer to them.
+   void (*before_pp_Error)(Error* err),
+
+   // Print error context.
+   void (*pp_Error)(Error* err),
+
+   // Should the core indicate which ThreadId each error comes from?
+   Bool show_ThreadIDs_for_errors,
+
+   // Should fill in any details that could be postponed until after the
+   // decision whether to ignore the error (ie. details not affecting the
+   // result of VG_(tdict).tool_eq_Error()).  This saves time when errors
+   // are ignored.
+   // Yuk.
+   // Return value: must be the size of the `extra' part in bytes -- used by
+   // the core to make a copy.
+   UInt (*update_extra)(Error* err),
+
+   // Return value indicates recognition.  If recognised, must set skind using
+   // VG_(set_supp_kind)().
+   Bool (*recognised_suppression)(Char* name, Supp* su),
+
+   // Read any extra info for this suppression kind.  Most likely for filling
+   // in the `extra' and `string' parts (with VG_(set_supp_{extra, string})())
+   // of a suppression if necessary.  Should return False if a syntax error
+   // occurred, True otherwise.  bufpp and nBufp are the same as for
+   // VG_(get_line).
+   Bool (*read_extra_suppression_info)(Int fd, Char** bufpp, SizeT* nBufp,
+                                       Supp* su),
+
+   // This should just check the kinds match and maybe some stuff in the
+   // `string' and `extra' field if appropriate (using VG_(get_supp_*)() to
+   // get the relevant suppression parts).
+   Bool (*error_matches_suppression)(Error* err, Supp* su),
+
+   // This should return the suppression name, for --gen-suppressions, or NULL
+   // if that error type cannot be suppressed.  This is the inverse of
+   // VG_(tdict).tool_recognised_suppression().
+   Char* (*get_error_name)(Error* err),
+
+   // This should print into buf[0..nBuf-1] any extra info for the
+   // error, for --gen-suppressions, but not including any leading
+   // spaces nor a trailing newline.  When called, buf[0 .. nBuf-1]
+   // will be zero filled, and it is expected and checked that the
+   // last element is still zero after the call.  In other words the
+   // tool may not overrun the buffer, and this is checked for.  If
+   // there is any info printed in the buffer, return True, otherwise
+   // do nothing, and return False.  This function is the inverse of
+   // VG_(tdict).tool_read_extra_suppression_info().
+   Bool (*print_extra_suppression_info)(Error* err,
+                                        /*OUT*/Char* buf, Int nBuf)
+);
+
+/* Is information kept by the tool about specific instructions or
+   translations?  (Eg. for cachegrind there are cost-centres for every
+   instruction, stored in a per-translation fashion.)  If so, the info
+   may have to be discarded when translations are unloaded (eg. due to
+   .so unloading, or otherwise at the discretion of m_transtab, eg
+   when the table becomes too full) to avoid stale information being
+   reused for new translations. */
+extern void VG_(needs_superblock_discards) (
+   // Discard any information that pertains to specific translations
+   // or instructions within the address range given.  There are two
+   // possible approaches.
+   // - If info is being stored at a per-translation level, use orig_addr
+   //   to identify which translation is being discarded.  Each translation
+   //   will be discarded exactly once.
+   //   This orig_addr will match the closure->nraddr which was passed to
+   //   to instrument() (see extensive comments above) when this 
+   //   translation was made.  Note that orig_addr won't necessarily be 
+   //   the same as the first address in "extents".
+   // - If info is being stored at a per-instruction level, you can get
+   //   the address range(s) being discarded by stepping through "extents".
+   //   Note that any single instruction may belong to more than one
+   //   translation, and so could be covered by the "extents" of more than
+   //   one call to this function.
+   // Doing it the first way (as eg. Cachegrind does) is probably easier.
+   void (*discard_superblock_info)(Addr64 orig_addr, VexGuestExtents extents)
+);
+
+/* Tool defines its own command line options? */
+extern void VG_(needs_command_line_options) (
+   // Return True if option was recognised, False if it wasn't (but also see
+   // below).  Presumably sets some state to record the option as well.  
+   //
+   // Nb: tools can assume that the argv will never disappear.  So they can,
+   // for example, store a pointer to a string within an option, rather than
+   // having to make a copy.
+   //
+   // Options (and combinations of options) should be checked in this function
+   // if possible rather than in post_clo_init(), and if they are bad then
+   // VG_(fmsg_bad_option)() should be called.  This ensures that the
+   // messaging is consistent with command line option errors from the core.
+   Bool (*process_cmd_line_option)(Char* argv),
+
+   // Print out command line usage for options for normal tool operation.
+   void (*print_usage)(void),
+
+   // Print out command line usage for options for debugging the tool.
+   void (*print_debug_usage)(void)
+);
+
+/* Tool defines its own client requests? */
+extern void VG_(needs_client_requests) (
+   // If using client requests, the number of the first request should be equal
+   // to VG_USERREQ_TOOL_BASE('X', 'Y'), where 'X' and 'Y' form a suitable two
+   // character identification for the string.  The second and subsequent
+   // requests should follow.
+   //
+   // This function should use the VG_IS_TOOL_USERREQ macro (in
+   // include/valgrind.h) to first check if it's a request for this tool.  Then
+   // should handle it if it's recognised (and return True), or return False if
+   // not recognised.  arg_block[0] holds the request number, any further args
+   // from the request are in arg_block[1..].  'ret' is for the return value...
+   // it should probably be filled, if only with 0.
+   Bool (*handle_client_request)(ThreadId tid, UWord* arg_block, UWord* ret)
+);
+
+/* Tool does stuff before and/or after system calls? */
+// Nb: If either of the pre_ functions malloc() something to return, the
+// corresponding post_ function had better free() it!
+// Also, the args are the 'original args' -- that is, it may be
+// that the syscall pre-wrapper will modify the args before the
+// syscall happens.  So these args are the original, un-modified
+// args.  Finally, nArgs merely indicates the length of args[..],
+// it does not indicate how many of those values are actually
+// relevant to the syscall.  args[0 .. nArgs-1] is guaranteed
+// to be defined and to contain all the args for this syscall,
+// possibly including some trailing zeroes.
+extern void VG_(needs_syscall_wrapper) (
+               void (* pre_syscall)(ThreadId tid, UInt syscallno,
+                                    UWord* args, UInt nArgs),
+               void (*post_syscall)(ThreadId tid, UInt syscallno,
+                                    UWord* args, UInt nArgs, SysRes res)
+);
+
+/* Are tool-state sanity checks performed? */
+// Can be useful for ensuring a tool's correctness.  cheap_sanity_check()
+// is called very frequently;  expensive_sanity_check() is called less
+// frequently and can be more involved.
+extern void VG_(needs_sanity_checks) (
+   Bool(*cheap_sanity_check)(void),
+   Bool(*expensive_sanity_check)(void)
+);
+
+/* Do we need to see variable type and location information? */
+extern void VG_(needs_var_info) ( void );
+
+/* Does the tool replace malloc() and friends with its own versions?
+   This has to be combined with the use of a vgpreload_<tool>.so module
+   or it won't work.  See massif/Makefile.am for how to build it. */
+// The 'p' prefix avoids GCC complaints about overshadowing global names.
+extern void VG_(needs_malloc_replacement)(
+   void* (*pmalloc)               ( ThreadId tid, SizeT n ),
+   void* (*p__builtin_new)        ( ThreadId tid, SizeT n ),
+   void* (*p__builtin_vec_new)    ( ThreadId tid, SizeT n ),
+   void* (*pmemalign)             ( ThreadId tid, SizeT align, SizeT n ),
+   void* (*pcalloc)               ( ThreadId tid, SizeT nmemb, SizeT size1 ),
+   void  (*pfree)                 ( ThreadId tid, void* p ),
+   void  (*p__builtin_delete)     ( ThreadId tid, void* p ),
+   void  (*p__builtin_vec_delete) ( ThreadId tid, void* p ),
+   void* (*prealloc)              ( ThreadId tid, void* p, SizeT new_size ),
+   SizeT (*pmalloc_usable_size)   ( ThreadId tid, void* p), 
+   SizeT client_malloc_redzone_szB
+);
+
+/* Can the tool do XML output?  This is a slight misnomer, because the tool
+ * is not requesting the core to do anything, rather saying "I can handle
+ * it". */
+extern void VG_(needs_xml_output) ( void );
+
+/* Does the tool want to have one final pass over the IR after tree
+   building but before instruction selection?  If so specify the
+   function here. */
+extern void VG_(needs_final_IR_tidy_pass) ( IRSB*(*final_tidy)(IRSB*) );
+
+
+/* ------------------------------------------------------------------ */
+/* Core events to track */
+
+/* Part of the core from which this call was made.  Useful for determining
+   what kind of error message should be emitted. */
+typedef
+   enum { Vg_CoreStartup=1, Vg_CoreSignal, Vg_CoreSysCall,
+          // This is for platforms where syscall args are passed on the
+          // stack; although pre_mem_read is the callback that will be
+          // called, such an arg should be treated (with respect to
+          // presenting information to the user) as if it was passed in a
+          // register, ie. like pre_reg_read.
+          Vg_CoreSysCallArgInMem,  
+          Vg_CoreTranslate, Vg_CoreClientReq
+   } CorePart;
+
+/* Events happening in core to track.  To be notified, pass a callback
+   function to the appropriate function.  To ignore an event, don't do
+   anything (the default is for events to be ignored).
+
+   Note that most events aren't passed a ThreadId.  If the event is one called
+   from generated code (eg. new_mem_stack_*), you can use
+   VG_(get_running_tid)() to find it.  Otherwise, it has to be passed in,
+   as in pre_mem_read, and so the event signature will require changing.
+
+   Memory events (Nb: to track heap allocation/freeing, a tool must replace
+   malloc() et al.  See above how to do this.)
+
+   These ones occur at startup, upon some signals, and upon some syscalls.
+
+   For new_mem_brk and new_mem_stack_signal, the supplied ThreadId
+   indicates the thread for whom the new memory is being allocated.
+
+   For new_mem_startup and new_mem_mmap, the di_handle argument is a
+   handle which can be used to retrieve debug info associated with the
+   mapping or allocation (because it is of a file that Valgrind has
+   decided to read debug info from).  If the value is zero, there is
+   no associated debug info.  If the value exceeds zero, it can be
+   supplied as an argument to selected queries in m_debuginfo.
+*/
+void VG_(track_new_mem_startup)     (void(*f)(Addr a, SizeT len,
+                                              Bool rr, Bool ww, Bool xx,
+                                              ULong di_handle));
+void VG_(track_new_mem_stack_signal)(void(*f)(Addr a, SizeT len, ThreadId tid));
+void VG_(track_new_mem_brk)         (void(*f)(Addr a, SizeT len, ThreadId tid));
+void VG_(track_new_mem_mmap)        (void(*f)(Addr a, SizeT len,
+                                              Bool rr, Bool ww, Bool xx,
+                                              ULong di_handle));
+
+void VG_(track_copy_mem_remap)      (void(*f)(Addr from, Addr to, SizeT len));
+void VG_(track_change_mem_mprotect) (void(*f)(Addr a, SizeT len,
+                                              Bool rr, Bool ww, Bool xx));
+void VG_(track_die_mem_stack_signal)(void(*f)(Addr a, SizeT len));
+void VG_(track_die_mem_brk)         (void(*f)(Addr a, SizeT len));
+void VG_(track_die_mem_munmap)      (void(*f)(Addr a, SizeT len));
+
+/* These ones are called when SP changes.  A tool could track these itself
+   (except for ban_mem_stack) but it's much easier to use the core's help.
+
+   The specialised ones are called in preference to the general one, if they
+   are defined.  These functions are called a lot if they are used, so
+   specialising can optimise things significantly.  If any of the
+   specialised cases are defined, the general case must be defined too.
+
+   Nb: all the specialised ones must use the VG_REGPARM(n) attribute.
+
+   For the _new functions, a tool may specify with with-ECU
+   (ExeContext Unique) or without-ECU version for each size, but not
+   both.  If the with-ECU version is supplied, then the core will
+   arrange to pass, as the ecu argument, a 32-bit int which uniquely
+   identifies the instruction moving the stack pointer down.  This
+   32-bit value is as obtained from VG_(get_ECU_from_ExeContext).
+   VG_(get_ExeContext_from_ECU) can then be used to retrieve the
+   associated depth-1 ExeContext for the location.  All this
+   complexity is provided to support origin tracking in Memcheck.
+*/
+void VG_(track_new_mem_stack_4_w_ECU)  (VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_8_w_ECU)  (VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_12_w_ECU) (VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_16_w_ECU) (VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_32_w_ECU) (VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_112_w_ECU)(VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_128_w_ECU)(VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_144_w_ECU)(VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_160_w_ECU)(VG_REGPARM(2) void(*f)(Addr new_ESP, UInt ecu));
+void VG_(track_new_mem_stack_w_ECU)                  (void(*f)(Addr a, SizeT len,
+                                                                       UInt ecu));
+
+void VG_(track_new_mem_stack_4)  (VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_8)  (VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_12) (VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_16) (VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_32) (VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_112)(VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_128)(VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_144)(VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack_160)(VG_REGPARM(1) void(*f)(Addr new_ESP));
+void VG_(track_new_mem_stack)                  (void(*f)(Addr a, SizeT len));
+
+void VG_(track_die_mem_stack_4)  (VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_8)  (VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_12) (VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_16) (VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_32) (VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_112)(VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_128)(VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_144)(VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack_160)(VG_REGPARM(1) void(*f)(Addr die_ESP));
+void VG_(track_die_mem_stack)                  (void(*f)(Addr a, SizeT len));
+
+/* Used for redzone at end of thread stacks */
+void VG_(track_ban_mem_stack)      (void(*f)(Addr a, SizeT len));
+
+/* These ones occur around syscalls, signal handling, etc */
+void VG_(track_pre_mem_read)       (void(*f)(CorePart part, ThreadId tid,
+                                             Char* s, Addr a, SizeT size));
+void VG_(track_pre_mem_read_asciiz)(void(*f)(CorePart part, ThreadId tid,
+                                             Char* s, Addr a));
+void VG_(track_pre_mem_write)      (void(*f)(CorePart part, ThreadId tid,
+                                             Char* s, Addr a, SizeT size));
+void VG_(track_post_mem_write)     (void(*f)(CorePart part, ThreadId tid,
+                                             Addr a, SizeT size));
+
+/* Register events.  Use VG_(set_shadow_state_area)() to set the shadow regs
+   for these events.  */
+void VG_(track_pre_reg_read)  (void(*f)(CorePart part, ThreadId tid,
+                                        Char* s, PtrdiffT guest_state_offset,
+                                        SizeT size));
+void VG_(track_post_reg_write)(void(*f)(CorePart part, ThreadId tid,
+                                        PtrdiffT guest_state_offset,
+                                        SizeT size));
+
+/* This one is called for malloc() et al if they are replaced by a tool. */
+void VG_(track_post_reg_write_clientcall_return)(
+      void(*f)(ThreadId tid, PtrdiffT guest_state_offset, SizeT size, Addr f));
+
+
+/* Scheduler events (not exhaustive) */
+
+/* Called when 'tid' starts or stops running client code blocks.
+   Gives the total dispatched block count at that event.  Note, this
+   is not the same as 'tid' holding the BigLock (the lock that ensures
+   that only one thread runs at a time): a thread can hold the lock
+   for other purposes (making translations, etc) yet not be running
+   client blocks.  Obviously though, a thread must hold the lock in
+   order to run client code blocks, so the times bracketed by
+   'start_client_code'..'stop_client_code' are a subset of the times
+   when thread 'tid' holds the cpu lock.
+*/
+void VG_(track_start_client_code)(
+        void(*f)(ThreadId tid, ULong blocks_dispatched)
+     );
+void VG_(track_stop_client_code)(
+        void(*f)(ThreadId tid, ULong blocks_dispatched)
+     );
+
+
+/* Thread events (not exhaustive)
+
+   ll_create: low level thread creation.  Called before the new thread
+   has run any instructions (or touched any memory).  In fact, called
+   immediately before the new thread has come into existence; the new
+   thread can be assumed to exist when notified by this call.
+
+   ll_exit: low level thread exit.  Called after the exiting thread
+   has run its last instruction.
+
+   The _ll_ part makes it clear these events are not to do with
+   pthread_create or pthread_exit/pthread_join (etc), which are a
+   higher level abstraction synthesised by libpthread.  What you can
+   be sure of from _ll_create/_ll_exit is the absolute limits of each
+   thread's lifetime, and hence be assured that all memory references
+   made by the thread fall inside the _ll_create/_ll_exit pair.  This
+   is important for tools that need a 100% accurate account of which
+   thread is responsible for every memory reference in the process.
+
+   pthread_create/join/exit do not give this property.  Calls/returns
+   to/from them happen arbitrarily far away from the relevant
+   low-level thread create/quit event.  In general a few hundred
+   instructions; hence a few hundred(ish) memory references could get
+   misclassified each time.
+
+   pre_thread_first_insn: is called when the thread is all set up and
+   ready to go (stack in place, etc) but has not executed its first
+   instruction yet.  Gives threading tools a chance to ask questions
+   about the thread (eg, what is its initial client stack pointer)
+   that are not easily answered at pre_thread_ll_create time.
+
+   For a given thread, the call sequence is:
+      ll_create (in the parent's context)
+      first_insn (in the child's context)
+      ll_exit (in the child's context)
+*/
+void VG_(track_pre_thread_ll_create) (void(*f)(ThreadId tid, ThreadId child));
+void VG_(track_pre_thread_first_insn)(void(*f)(ThreadId tid));
+void VG_(track_pre_thread_ll_exit)   (void(*f)(ThreadId tid));
+
+
+/* Signal events (not exhaustive)
+
+   ... pre_send_signal, post_send_signal ...
+
+   Called before a signal is delivered;  `alt_stack' indicates if it is
+   delivered on an alternative stack.  */
+void VG_(track_pre_deliver_signal) (void(*f)(ThreadId tid, Int sigNo,
+                                             Bool alt_stack));
+/* Called after a signal is delivered.  Nb: unfortunately, if the signal
+   handler longjmps, this won't be called.  */
+void VG_(track_post_deliver_signal)(void(*f)(ThreadId tid, Int sigNo));
+
+#endif   // __PUB_TOOL_TOOLIFACE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_vki.h b/include/pub_tool_vki.h
new file mode 100644
index 0000000..73a4174
--- /dev/null
+++ b/include/pub_tool_vki.h
@@ -0,0 +1,64 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Top level for kernel interface declarations.                 ---*/
+/*---                                               pub_tool_vki.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 Julian Seward
+      jseward@acm.org
+   Copyright (C) 2005-2010 Nicholas Nethercote
+      njn@valgrind.org
+   Copyright (C) 2006-2010 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.
+*/
+
+/* This file defines types and constants for the kernel interface, and to
+   make that clear everything is prefixed VKI_/vki_.
+
+   This file is merely a top-level "steering" file, which pulls in the
+   correct bits for the relevant platform.  You should not directly
+   #include any file in include/vki; instead #include only this one or
+   pub_core_vki.h.
+*/
+
+#ifndef __PUB_TOOL_VKI_H
+#define __PUB_TOOL_VKI_H
+
+#if defined(VGO_linux)
+#  include "vki/vki-linux.h"
+#elif defined(VGP_ppc32_aix5)
+#  include "vki/vki-ppc32-aix5.h"
+#elif defined(VGP_ppc64_aix5)
+#  include "vki/vki-ppc64-aix5.h"
+#elif defined(VGO_darwin)
+#  include "vki/vki-darwin.h"
+#else
+#  error Unknown Plat/OS
+#endif
+
+#endif // __PUB_TOOL_VKI_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                           pub_tool_vki.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_vkiscnums.h b/include/pub_tool_vkiscnums.h
new file mode 100644
index 0000000..b8b5e88
--- /dev/null
+++ b/include/pub_tool_vkiscnums.h
@@ -0,0 +1,75 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Syscall numbers and related operations. pub_tool_vkiscnums.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 Nicholas Nethercote
+      njn@valgrind.org
+   Copyright (C) 2006-2010 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_TOOL_VKISCNUMS_H
+#define __PUB_TOOL_VKISCNUMS_H
+
+#include "pub_tool_vkiscnums_asm.h"
+
+
+// This converts a syscall number into a string, suitable for printing.  It is
+// needed because some platforms (AIX, Darwin) munge sysnums in various ways.
+// It is used in places where the sycall name will be printed alongside.
+extern Char* VG_(sysnum_string)      (Word sysnum, SizeT n_buf, Char* buf);
+
+// This is like VG_(sysnum_string), but prints extra info if needed.  It is
+// called in places where the syscall name will *not* be printed alongside.
+extern Char* VG_(sysnum_string_extra)(Word sysnum, SizeT n_buf, Char* buf);
+
+// Macros that make the above functions easier to use by declaring a local
+// buffer.
+#define VG_SYSNUM_STRING(sysnum) \
+   ({ Char qq_zz_buf[32]; VG_(sysnum_string)(sysnum, 32, qq_zz_buf); })
+#define VG_SYSNUM_STRING_EXTRA(sysnum) \
+   ({ Char qq_zz_buf[64]; VG_(sysnum_string_extra)(sysnum, 64, qq_zz_buf); })
+
+
+#if defined(VGO_linux)
+   // Nothing.
+
+#elif defined(VGO_aix5)
+   // See the AIX5-specific case in pub_tool_vkiscnums_asm.h for an
+   // explanation of why we include this here rather than there.
+#  include "vki/vki-scnums-aix5.h"
+
+#elif defined(VGO_darwin)
+   // Nothing.
+
+#else
+#  error Unknown OS
+#endif
+
+#endif   // __PUB_TOOL_VKISCNUMS_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_vkiscnums_asm.h b/include/pub_tool_vkiscnums_asm.h
new file mode 100644
index 0000000..bd8d497
--- /dev/null
+++ b/include/pub_tool_vkiscnums_asm.h
@@ -0,0 +1,68 @@
+
+/*--------------------------------------------------------------------*/
+/*--- asm-only vkiscnums stuff.           pub_tool_vkiscnums_asm.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 Nicholas Nethercote
+      njn@valgrind.org
+   Copyright (C) 2006-2010 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_TOOL_VKISCNUMS_ASM_H
+#define __PUB_TOOL_VKISCNUMS_ASM_H
+
+#if defined(VGP_x86_linux)
+#  include "vki/vki-scnums-x86-linux.h"
+
+#elif defined(VGP_amd64_linux)
+#  include "vki/vki-scnums-amd64-linux.h"
+
+#elif defined(VGP_ppc32_linux)
+#  include "vki/vki-scnums-ppc32-linux.h"
+
+#elif defined(VGP_ppc64_linux)
+#  include "vki/vki-scnums-ppc64-linux.h"
+
+#elif defined(VGP_arm_linux)
+#  include "vki/vki-scnums-arm-linux.h"
+
+#elif defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+   // Nothing:  vki-scnums-aix5.h only contains stuff suitable for inclusion
+   // in C files, not asm files.  So unlike all the other
+   // vki-scnums-PLATFORM.h files, we include it in pub_tool_vkiscnums.h
+   // rather than in include/pub_tool_vkiscnums_asm.h.
+
+#elif defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
+#  include "vki/vki-scnums-darwin.h"
+
+#else
+#  error Unknown platform
+#endif
+
+#endif   // __PUB_TOOL_VKISCNUMS_ASM_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_wordfm.h b/include/pub_tool_wordfm.h
new file mode 100644
index 0000000..77027ad
--- /dev/null
+++ b/include/pub_tool_wordfm.h
@@ -0,0 +1,220 @@
+
+/*--------------------------------------------------------------------*/
+/*--- An AVL tree based finite map for word keys and word values.  ---*/
+/*--- Inspired by Haskell's "FiniteMap" library.                   ---*/
+/*---                                            pub_tool_wordfm.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2007-2010 Julian Seward
+      jseward@acm.org
+
+   This code is based on previous work by Nicholas Nethercote
+   (coregrind/m_oset.c) which is
+
+   Copyright (C) 2005-2010 Nicholas Nethercote
+       njn@valgrind.org
+
+   which in turn was derived partially from:
+
+      AVL C library
+      Copyright (C) 2000,2002  Daniel Nagy
+
+      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.
+      [...]
+
+      (taken from libavl-0.4/debian/copyright)
+
+   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_TOOL_WORDFM_H
+#define __PUB_TOOL_WORDFM_H
+
+//------------------------------------------------------------------//
+//---                           WordFM                           ---//
+//---                      Public interface                      ---//
+//------------------------------------------------------------------//
+
+/* As of r7409 (15 Feb 08), all these word-based abstractions (WordFM,
+   WordSet, WordBag) now operate on unsigned words (UWord), whereas
+   they previously operated on signed words (Word).  This became a
+   problem, when using unboxed comparisons (when kCmp == NULL), with
+   the introduction of VG_(initIterAtFM), which allows iteration over
+   parts of mappings.  Iterating over a mapping in increasing order of
+   signed Word keys is not what callers expect when iterating through
+   maps whose keys represent addresses (Addr) since Addr is unsigned,
+   and causes logical problems and assertion failures. */
+
+typedef  struct _WordFM  WordFM; /* opaque */
+
+/* Allocate and initialise a WordFM.  If kCmp is non-NULL, elements in
+   the set are ordered according to the ordering specified by kCmp,
+   which becomes obvious if you use VG_(initIterFM),
+   VG_(initIterAtFM), VG_(nextIterFM), VG_(doneIterFM) to iterate over
+   sections of the map, or the whole thing.  If kCmp is NULL then the
+   ordering used is unsigned word ordering (UWord) on the key
+   values. */
+WordFM* VG_(newFM) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
+                     HChar* cc,
+                     void  (*dealloc)(void*),
+                     Word  (*kCmp)(UWord,UWord) );
+
+/* Free up the FM.  If kFin is non-NULL, it is applied to keys
+   before the FM is deleted; ditto with vFin for vals. */
+void VG_(deleteFM) ( WordFM*, void(*kFin)(UWord), void(*vFin)(UWord) );
+
+/* Add (k,v) to fm.  If a binding for k already exists, it is updated
+   to map to this new v.  In that case we should really return the
+   previous v so that caller can finalise it.  Oh well.  Returns
+   True if a binding for k already exists. */
+Bool VG_(addToFM) ( WordFM* fm, UWord k, UWord v );
+
+// Delete key from fm, returning associated key and val if found
+Bool VG_(delFromFM) ( WordFM* fm,
+                      /*OUT*/UWord* oldK, /*OUT*/UWord* oldV, UWord key );
+
+// Look up in fm, assigning found key & val at spec'd addresses
+Bool VG_(lookupFM) ( WordFM* fm, 
+                     /*OUT*/UWord* keyP, /*OUT*/UWord* valP, UWord key );
+
+// Find the closest key values bracketing the given key, assuming the 
+// given key is not present in the map.  minKey and maxKey are the 
+// minimum and maximum possible key values.  The resulting bracket
+// values are returned in *kMinP and *kMaxP.  It follows that if fm is
+// empty then the returned values are simply minKey and maxKey.
+//
+// For convenience the associated value fields are also returned
+// through *vMinP and *vMaxP.  To make that possible in the general
+// case, the caller must supply via minVal and maxVal, the value
+// fields associated with minKey and maxKey.
+//
+// If the operation was successful (that is, the given key is not
+// present), True is returned.  If the given key is in fact present,
+// False is returned, and *kMinP, *vMinP, *kMaxP and *vMaxP are
+// undefined.  Any of kMinP, vMinP, kMaxP and vMaxP may be safely
+// supplied as NULL.
+Bool VG_(findBoundsFM)( WordFM* fm,
+                        /*OUT*/UWord* kMinP, /*OUT*/UWord* vMinP,
+                        /*OUT*/UWord* kMaxP, /*OUT*/UWord* vMaxP,
+                        UWord minKey, UWord minVal,
+                        UWord maxKey, UWord maxVal,
+                        UWord key );
+
+// How many elements are there in fm?  NOTE: dangerous in the
+// sense that this is not an O(1) operation but rather O(N),
+// since it involves walking the whole tree.
+UWord VG_(sizeFM) ( WordFM* fm );
+
+// Is fm empty?  This at least is an O(1) operation.
+// Code is present in m_wordfm.c but commented out due to no
+// current usage.  Un-comment (and TEST IT) if required.
+//Bool VG_(isEmptyFM)( WordFM* fm );
+
+// set up FM for iteration
+void VG_(initIterFM) ( WordFM* fm );
+
+// set up FM for iteration so that the first key subsequently produced
+// by VG_(nextIterFM) is the smallest key in the map >= start_at.
+// Naturally ">=" is defined by the comparison function supplied to
+// VG_(newFM), as documented above.
+void VG_(initIterAtFM) ( WordFM* fm, UWord start_at );
+
+// get next key/val pair.  Will assert if fm has been modified
+// or looked up in since initIterFM/initIterWithStartFM was called.
+Bool VG_(nextIterFM) ( WordFM* fm,
+                       /*OUT*/UWord* pKey, /*OUT*/UWord* pVal );
+
+// clear the I'm iterating flag
+void VG_(doneIterFM) ( WordFM* fm );
+
+// Deep copy a FM.  If dopyK is NULL, keys are copied verbatim.
+// If non-null, dopyK is applied to each key to generate the
+// version in the new copy.  In that case, if the argument to dopyK
+// is non-NULL but the result is NULL, it is assumed that dopyK
+// could not allocate memory, in which case the copy is abandoned
+// and NULL is returned.  Ditto with dopyV for values.
+WordFM* VG_(dopyFM) ( WordFM* fm,
+                      UWord(*dopyK)(UWord), UWord(*dopyV)(UWord) );
+
+// admin: what's the 'common' allocation size (for tree nodes?)
+SizeT VG_(getNodeSizeFM)( void );
+
+//------------------------------------------------------------------//
+//---                         end WordFM                         ---//
+//---                      Public interface                      ---//
+//------------------------------------------------------------------//
+
+//------------------------------------------------------------------//
+//---                WordBag (unboxed words only)                ---//
+//---                      Public interface                      ---//
+//------------------------------------------------------------------//
+
+typedef  struct _WordBag  WordBag; /* opaque */
+
+/* Allocate and initialise a WordBag */
+WordBag* VG_(newBag) ( void* (*alloc_nofail)( HChar* cc, SizeT ),
+                       HChar* cc,
+                       void  (*dealloc)(void*) );
+
+/* Free up the Bag. */
+void VG_(deleteBag) ( WordBag* );
+
+/* Add a word. */
+void VG_(addToBag)( WordBag*, UWord );
+
+/* Find out how many times the given word exists in the bag. */
+UWord VG_(elemBag) ( WordBag*, UWord );
+
+/* Delete a word from the bag. */
+Bool VG_(delFromBag)( WordBag*, UWord );
+
+/* Is the bag empty? */
+Bool VG_(isEmptyBag)( WordBag* );
+
+/* Does the bag have exactly one element? */
+Bool VG_(isSingletonTotalBag)( WordBag* );
+
+/* Return an arbitrary element from the bag. */
+UWord VG_(anyElementOfBag)( WordBag* );
+
+/* How many different / total elements are in the bag? */
+UWord VG_(sizeUniqueBag)( WordBag* ); /* fast */
+UWord VG_(sizeTotalBag)( WordBag* );  /* warning: slow */
+
+/* Iterating over the elements of a bag. */
+void VG_(initIterBag)( WordBag* );
+Bool VG_(nextIterBag)( WordBag*, /*OUT*/UWord* pVal, /*OUT*/UWord* pCount );
+void VG_(doneIterBag)( WordBag* );
+
+//------------------------------------------------------------------//
+//---             end WordBag (unboxed words only)               ---//
+//---                      Public interface                      ---//
+//------------------------------------------------------------------//
+
+#endif /* ! __PUB_TOOL_WORDFM_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                        pub_tool_wordfm.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_xarray.h b/include/pub_tool_xarray.h
new file mode 100644
index 0000000..cd1b02e
--- /dev/null
+++ b/include/pub_tool_xarray.h
@@ -0,0 +1,154 @@
+
+/*--------------------------------------------------------------------*/
+/*--- An expandable array implementation.        pub_tool_xarray.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2007-2010 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_TOOL_XARRAY_H
+#define __PUB_TOOL_XARRAY_H
+
+//--------------------------------------------------------------------
+// PURPOSE: Provides a simple but useful structure, which is an array
+// in which elements can be added at the end.  The array is expanded
+// as needed by multiplying its size by a constant factor (usually 2).
+// This gives amortised O(1) insertion cost, and, following sorting,
+// the usual O(log N) binary search cost.  Arbitrary element sizes
+// are allowed; the comparison function for sort/lookup can be changed
+// at any time, and duplicates (modulo the comparison function) are
+// allowed.
+//--------------------------------------------------------------------
+
+
+/* It's an abstract type.  Bwaha. */
+typedef  struct _XArray  XArray;
+
+/* Create new XArray, using given allocation and free function, and
+   for elements of the specified size.  Alloc fn must not fail (that
+   is, if it returns it must have succeeded.) */
+extern XArray* VG_(newXA) ( void*(*alloc_fn)(HChar*,SizeT), 
+                            HChar* cc,
+                            void(*free_fn)(void*),
+                            Word elemSzB );
+
+/* Free all memory associated with an XArray. */
+extern void VG_(deleteXA) ( XArray* );
+
+/* Set the comparison function for this XArray.  This clears an
+   internal 'array is sorted' flag, which means you must call sortXA
+   before making further queries with lookupXA. */
+extern void VG_(setCmpFnXA) ( XArray*, Int (*compar)(void*,void*) );
+
+/* Add an element to an XArray.  Element is copied into the XArray.
+   Index at which it was added is returned.  Note this will be
+   invalidated if the array is later sortXA'd. */
+extern Word VG_(addToXA) ( XArray*, void* elem );
+
+/* Add a sequence of bytes to an XArray of bytes.  Asserts if nbytes
+   is negative or the array's element size is not 1.  Returns the
+   index at which the first byte was added. */
+extern Word VG_(addBytesToXA) ( XArray* xao, void* bytesV, Word nbytes );
+
+/* Sort an XArray using its comparison function, if set; else bomb.
+   Probably not a stable sort w.r.t. equal elements module cmpFn. */
+extern void VG_(sortXA) ( XArray* );
+
+/* Lookup (by binary search) 'key' in the array.  Set *first to be the
+   index of the first, and *last to be the index of the last matching
+   value found.  If any values are found, return True, else return
+   False, and don't change *first or *last.  Bomb if the array is not
+   sorted. */
+extern Bool VG_(lookupXA) ( XArray*, void* key, 
+                            /*OUT*/Word* first, /*OUT*/Word* last );
+
+/* A version of VG_(lookupXA) in which you can specify your own
+   comparison function.  This is unsafe in the sense that if the array
+   is not totally ordered as defined by your comparison function, then
+   this function may loop indefinitely, so it is up to you to ensure
+   that the array is suitably ordered.  This is in comparison to
+   VG_(lookupXA), which refuses to do anything (asserts) unless the
+   array has first been sorted using the same comparison function as
+   is being used for the lookup. */
+extern Bool VG_(lookupXA_UNSAFE) ( XArray* xao, void* key,
+                                   /*OUT*/Word* first, /*OUT*/Word* last,
+                                   Int(*cmpFn)(void*,void*) );
+
+/* How elements are there in this XArray now? */
+extern Word VG_(sizeXA) ( XArray* );
+
+/* Index into the XArray.  Checks bounds and bombs if the index is
+   invalid.  What this returns is the address of the specified element
+   in the array, not (of course) the element itself.  Note that the
+   element may get moved by subsequent addToXAs/sortXAs, so you should
+   copy it out immediately and not regard its address as unchanging.
+   Note also that indexXA will of course not return NULL if it
+   succeeds. */
+extern void* VG_(indexXA) ( XArray*, Word );
+
+/* Drop the last n elements of an XArray.  Bombs if there are less
+   than n elements in the array.  This is an O(1) operation. */
+extern void VG_(dropTailXA) ( XArray*, Word );
+
+/* Drop the first n elements of an XArray.  Bombs if there are less
+   than n elements in the array.  This is an O(N) operation, where N
+   is the number of elements remaining in the XArray. */
+extern void VG_(dropHeadXA) ( XArray*, Word );
+
+/* Make a new, completely independent copy of the given XArray, using
+   the existing allocation function to allocate the new space.
+   Returns NULL if the allocation function didn't manage to allocate
+   space (but did return NULL rather than merely abort.)  Space for
+   the clone (and all additions to it) is billed to 'cc' unless that
+   is NULL, in which case the parent's cost-center is used. */
+extern XArray* VG_(cloneXA)( HChar* cc, XArray* xa );
+
+/* Get the raw array and size so callers can index it really fast.
+   This is dangerous in the sense that there's no range or
+   anything-else checking.  It's also dangerous in that if
+   VG_(addToXA) is used, the contents may be re-located without
+   warning, hence making the contents address returned here
+   invalid. */
+extern void VG_(getContentsXA_UNSAFE)( XArray* sr,
+                                       /*OUT*/void** ctsP,
+                                       /*OUT*/Word*  usedP );
+
+/* Convenience function: printf into an XArray of HChar, adding stuff
+   at the end.  This is very convenient for concocting arbitrary
+   length printf output in an XArray.  Note that the resulting string
+   is NOT zero-terminated.  Versions are provided with and without a
+   format check, the latter so the unknown (to gcc) "%t" can be used
+   without gcc complaining. */
+extern void VG_(xaprintf)( XArray* dst, const HChar* format, ... )
+                         PRINTF_CHECK(2, 3);
+
+extern void VG_(xaprintf_no_f_c)
+                         ( XArray* dst, const HChar* format, ... );
+
+#endif   // __PUB_TOOL_XARRAY_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                        pub_tool_xarray.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/valgrind.h b/include/valgrind.h
new file mode 100644
index 0000000..0bae0aa
--- /dev/null
+++ b/include/valgrind.h
@@ -0,0 +1,4792 @@
+/* -*- c -*-
+   ----------------------------------------------------------------
+
+   Notice that the following BSD-style license applies to this one
+   file (valgrind.h) only.  The rest of Valgrind is licensed under the
+   terms of the GNU General Public License, version 2, unless
+   otherwise indicated.  See the COPYING file in the source
+   distribution for details.
+
+   ----------------------------------------------------------------
+
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 Julian Seward.  All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+   2. The origin of this software must not be misrepresented; you must 
+      not claim that you wrote the original software.  If you use this 
+      software in a product, an acknowledgment in the product 
+      documentation would be appreciated but is not required.
+
+   3. Altered source versions must be plainly marked as such, and must
+      not be misrepresented as being the original software.
+
+   4. The name of the author may not be used to endorse or promote 
+      products derived from this software without specific prior written 
+      permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+   ----------------------------------------------------------------
+
+   Notice that the above BSD-style license applies to this one file
+   (valgrind.h) only.  The entire rest of Valgrind is licensed under
+   the terms of the GNU General Public License, version 2.  See the
+   COPYING file in the source distribution for details.
+
+   ---------------------------------------------------------------- 
+*/
+
+
+/* This file is for inclusion into client (your!) code.
+
+   You can use these macros to manipulate and query Valgrind's 
+   execution inside your own programs.
+
+   The resulting executables will still run without Valgrind, just a
+   little bit more slowly than they otherwise would, but otherwise
+   unchanged.  When not running on valgrind, each client request
+   consumes very few (eg. 7) instructions, so the resulting performance
+   loss is negligible unless you plan to execute client requests
+   millions of times per second.  Nevertheless, if that is still a
+   problem, you can compile with the NVALGRIND symbol defined (gcc
+   -DNVALGRIND) so that client requests are not even compiled in.  */
+
+#ifndef __VALGRIND_H
+#define __VALGRIND_H
+
+
+/* ------------------------------------------------------------------ */
+/* VERSION NUMBER OF VALGRIND                                         */
+/* ------------------------------------------------------------------ */
+
+/* Specify Valgrind's version number, so that user code can
+   conditionally compile based on our version number.  Note that these
+   were introduced at version 3.6 and so do not exist in version 3.5
+   or earlier.  The recommended way to use them to check for "version
+   X.Y or later" is (eg)
+
+#if defined(__VALGRIND_MAJOR__) && defined(__VALGRIND_MINOR__)   \
+    && (__VALGRIND_MAJOR__ > 3                                   \
+        || (__VALGRIND_MAJOR__ == 3 && __VALGRIND_MINOR__ >= 6))
+*/
+#define __VALGRIND_MAJOR__    3
+#define __VALGRIND_MINOR__    6
+
+
+#include <stdarg.h>
+
+/* Nb: this file might be included in a file compiled with -ansi.  So
+   we can't use C++ style "//" comments nor the "asm" keyword (instead
+   use "__asm__"). */
+
+/* Derive some tags indicating what the target platform is.  Note
+   that in this file we're using the compiler's CPP symbols for
+   identifying architectures, which are different to the ones we use
+   within the rest of Valgrind.  Note, __powerpc__ is active for both
+   32 and 64-bit PPC, whereas __powerpc64__ is only active for the
+   latter (on Linux, that is).
+
+   Misc note: how to find out what's predefined in gcc by default:
+   gcc -Wp,-dM somefile.c
+*/
+#undef PLAT_ppc64_aix5
+#undef PLAT_ppc32_aix5
+#undef PLAT_x86_darwin
+#undef PLAT_amd64_darwin
+#undef PLAT_x86_win32
+#undef PLAT_x86_linux
+#undef PLAT_amd64_linux
+#undef PLAT_ppc32_linux
+#undef PLAT_ppc64_linux
+#undef PLAT_arm_linux
+
+#if defined(_AIX) && defined(__64BIT__)
+#  define PLAT_ppc64_aix5 1
+#elif defined(_AIX) && !defined(__64BIT__)
+#  define PLAT_ppc32_aix5 1
+#elif defined(__APPLE__) && defined(__i386__)
+#  define PLAT_x86_darwin 1
+#elif defined(__APPLE__) && defined(__x86_64__)
+#  define PLAT_amd64_darwin 1
+#elif defined(__MINGW32__) || defined(__CYGWIN32__) || defined(_WIN32) && defined(_M_IX86)
+#  define PLAT_x86_win32 1
+#elif defined(__linux__) && defined(__i386__)
+#  define PLAT_x86_linux 1
+#elif defined(__linux__) && defined(__x86_64__)
+#  define PLAT_amd64_linux 1
+#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
+#  define PLAT_ppc32_linux 1
+#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__)
+#  define PLAT_ppc64_linux 1
+#elif defined(__linux__) && defined(__arm__)
+#  define PLAT_arm_linux 1
+#else
+/* If we're not compiling for our target platform, don't generate
+   any inline asms.  */
+#  if !defined(NVALGRIND)
+#    define NVALGRIND 1
+#  endif
+#endif
+
+
+/* ------------------------------------------------------------------ */
+/* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS.  There is nothing */
+/* in here of use to end-users -- skip to the next section.           */
+/* ------------------------------------------------------------------ */
+
+#if defined(NVALGRIND)
+
+/* Define NVALGRIND to completely remove the Valgrind magic sequence
+   from the compiled code (analogous to NDEBUG's effects on
+   assert()) */
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+   {                                                              \
+      (_zzq_rlval) = (_zzq_default);                              \
+   }
+
+#else  /* ! NVALGRIND */
+
+/* The following defines the magic code sequences which the JITter
+   spots and handles magically.  Don't look too closely at them as
+   they will rot your brain.
+
+   The assembly code sequences for all architectures is in this one
+   file.  This is because this file must be stand-alone, and we don't
+   want to have multiple files.
+
+   For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default
+   value gets put in the return slot, so that everything works when
+   this is executed not under Valgrind.  Args are passed in a memory
+   block, and so there's no intrinsic limit to the number that could
+   be passed, but it's currently five.
+   
+   The macro args are: 
+      _zzq_rlval    result lvalue
+      _zzq_default  default value (result returned when running on real CPU)
+      _zzq_request  request code
+      _zzq_arg1..5  request params
+
+   The other two macros are used to support function wrapping, and are
+   a lot simpler.  VALGRIND_GET_NR_CONTEXT returns the value of the
+   guest's NRADDR pseudo-register and whatever other information is
+   needed to safely run the call original from the wrapper: on
+   ppc64-linux, the R2 value at the divert point is also needed.  This
+   information is abstracted into a user-visible type, OrigFn.
+
+   VALGRIND_CALL_NOREDIR_* behaves the same as the following on the
+   guest, but guarantees that the branch instruction will not be
+   redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64:
+   branch-and-link-to-r11.  VALGRIND_CALL_NOREDIR is just text, not a
+   complete inline asm, since it needs to be combined with more magic
+   inline asm stuff to be useful.
+*/
+
+/* ------------------------- x86-{linux,darwin} ---------------- */
+
+#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin)  \
+    ||  (defined(PLAT_x86_win32) && defined(__GNUC__))
+
+typedef
+   struct { 
+      unsigned int nraddr; /* where's the code? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "roll $3,  %%edi ; roll $13, %%edi\n\t"      \
+                     "roll $29, %%edi ; roll $19, %%edi\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+  { volatile unsigned int _zzq_args[6];                           \
+    volatile unsigned int _zzq_result;                            \
+    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
+    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
+    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
+    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
+    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
+    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %EDX = client_request ( %EAX ) */         \
+                     "xchgl %%ebx,%%ebx"                          \
+                     : "=d" (_zzq_result)                         \
+                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    volatile unsigned int __addr;                                 \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %EAX = guest_NRADDR */                    \
+                     "xchgl %%ecx,%%ecx"                          \
+                     : "=a" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+  }
+
+#define VALGRIND_CALL_NOREDIR_EAX                                 \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* call-noredir *%EAX */                     \
+                     "xchgl %%edx,%%edx\n\t"
+#endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__) */
+
+/* ------------------------- x86-Win32 ------------------------- */
+
+#if defined(PLAT_x86_win32) && !defined(__GNUC__)
+
+typedef
+   struct { 
+      unsigned int nraddr; /* where's the code? */
+   }
+   OrigFn;
+
+#if defined(_MSC_VER)
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     __asm rol edi, 3  __asm rol edi, 13          \
+                     __asm rol edi, 29 __asm rol edi, 19
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+  { volatile uintptr_t _zzq_args[6];                              \
+    volatile unsigned int _zzq_result;                            \
+    _zzq_args[0] = (uintptr_t)(_zzq_request);                     \
+    _zzq_args[1] = (uintptr_t)(_zzq_arg1);                        \
+    _zzq_args[2] = (uintptr_t)(_zzq_arg2);                        \
+    _zzq_args[3] = (uintptr_t)(_zzq_arg3);                        \
+    _zzq_args[4] = (uintptr_t)(_zzq_arg4);                        \
+    _zzq_args[5] = (uintptr_t)(_zzq_arg5);                        \
+    __asm { __asm lea eax, _zzq_args __asm mov edx, _zzq_default  \
+            __SPECIAL_INSTRUCTION_PREAMBLE                        \
+            /* %EDX = client_request ( %EAX ) */                  \
+            __asm xchg ebx,ebx                                    \
+            __asm mov _zzq_result, edx                            \
+    }                                                             \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    volatile unsigned int __addr;                                 \
+    __asm { __SPECIAL_INSTRUCTION_PREAMBLE                        \
+            /* %EAX = guest_NRADDR */                             \
+            __asm xchg ecx,ecx                                    \
+            __asm mov __addr, eax                                 \
+    }                                                             \
+    _zzq_orig->nraddr = __addr;                                   \
+  }
+
+#define VALGRIND_CALL_NOREDIR_EAX ERROR
+
+#else
+#error Unsupported compiler.
+#endif
+
+#endif /* PLAT_x86_win32 */
+
+/* ------------------------ amd64-{linux,darwin} --------------- */
+
+#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin)
+
+typedef
+   struct { 
+      unsigned long long int nraddr; /* where's the code? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "rolq $3,  %%rdi ; rolq $13, %%rdi\n\t"      \
+                     "rolq $61, %%rdi ; rolq $51, %%rdi\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+  { volatile unsigned long long int _zzq_args[6];                 \
+    volatile unsigned long long int _zzq_result;                  \
+    _zzq_args[0] = (unsigned long long int)(_zzq_request);        \
+    _zzq_args[1] = (unsigned long long int)(_zzq_arg1);           \
+    _zzq_args[2] = (unsigned long long int)(_zzq_arg2);           \
+    _zzq_args[3] = (unsigned long long int)(_zzq_arg3);           \
+    _zzq_args[4] = (unsigned long long int)(_zzq_arg4);           \
+    _zzq_args[5] = (unsigned long long int)(_zzq_arg5);           \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %RDX = client_request ( %RAX ) */         \
+                     "xchgq %%rbx,%%rbx"                          \
+                     : "=d" (_zzq_result)                         \
+                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    volatile unsigned long long int __addr;                       \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %RAX = guest_NRADDR */                    \
+                     "xchgq %%rcx,%%rcx"                          \
+                     : "=a" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+  }
+
+#define VALGRIND_CALL_NOREDIR_RAX                                 \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* call-noredir *%RAX */                     \
+                     "xchgq %%rdx,%%rdx\n\t"
+#endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
+
+/* ------------------------ ppc32-linux ------------------------ */
+
+#if defined(PLAT_ppc32_linux)
+
+typedef
+   struct { 
+      unsigned int nraddr; /* where's the code? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "rlwinm 0,0,3,0,0  ; rlwinm 0,0,13,0,0\n\t"  \
+                     "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+                                                                  \
+  {          unsigned int  _zzq_args[6];                          \
+             unsigned int  _zzq_result;                           \
+             unsigned int* _zzq_ptr;                              \
+    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
+    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
+    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
+    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
+    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
+    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
+    _zzq_ptr = _zzq_args;                                         \
+    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
+                     "mr 4,%2\n\t" /*ptr*/                        \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = client_request ( %R4 ) */           \
+                     "or 1,1,1\n\t"                               \
+                     "mr %0,3"     /*result*/                     \
+                     : "=b" (_zzq_result)                         \
+                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
+                     : "cc", "memory", "r3", "r4");               \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    unsigned int __addr;                                          \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR */                     \
+                     "or 2,2,2\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory", "r3"                       \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+  }
+
+#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* branch-and-link-to-noredir *%R11 */       \
+                     "or 3,3,3\n\t"
+#endif /* PLAT_ppc32_linux */
+
+/* ------------------------ ppc64-linux ------------------------ */
+
+#if defined(PLAT_ppc64_linux)
+
+typedef
+   struct { 
+      unsigned long long int nraddr; /* where's the code? */
+      unsigned long long int r2;  /* what tocptr do we need? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
+                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+                                                                  \
+  {          unsigned long long int  _zzq_args[6];                \
+    register unsigned long long int  _zzq_result __asm__("r3");   \
+    register unsigned long long int* _zzq_ptr __asm__("r4");      \
+    _zzq_args[0] = (unsigned long long int)(_zzq_request);        \
+    _zzq_args[1] = (unsigned long long int)(_zzq_arg1);           \
+    _zzq_args[2] = (unsigned long long int)(_zzq_arg2);           \
+    _zzq_args[3] = (unsigned long long int)(_zzq_arg3);           \
+    _zzq_args[4] = (unsigned long long int)(_zzq_arg4);           \
+    _zzq_args[5] = (unsigned long long int)(_zzq_arg5);           \
+    _zzq_ptr = _zzq_args;                                         \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = client_request ( %R4 ) */           \
+                     "or 1,1,1"                                   \
+                     : "=r" (_zzq_result)                         \
+                     : "0" (_zzq_default), "r" (_zzq_ptr)         \
+                     : "cc", "memory");                           \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    register unsigned long long int __addr __asm__("r3");         \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR */                     \
+                     "or 2,2,2"                                   \
+                     : "=r" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR_GPR2 */                \
+                     "or 4,4,4"                                   \
+                     : "=r" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory"                             \
+                    );                                            \
+    _zzq_orig->r2 = __addr;                                       \
+  }
+
+#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* branch-and-link-to-noredir *%R11 */       \
+                     "or 3,3,3\n\t"
+
+#endif /* PLAT_ppc64_linux */
+
+/* ------------------------- arm-linux ------------------------- */
+
+#if defined(PLAT_arm_linux)
+
+typedef
+   struct { 
+      unsigned int nraddr; /* where's the code? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+            "mov r12, r12, ror #3  ; mov r12, r12, ror #13 \n\t"  \
+            "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+                                                                  \
+  { volatile unsigned int  _zzq_args[6];                          \
+    volatile unsigned int  _zzq_result;                           \
+    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
+    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
+    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
+    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
+    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
+    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
+    __asm__ volatile("mov r3, %1\n\t" /*default*/                 \
+                     "mov r4, %2\n\t" /*ptr*/                     \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* R3 = client_request ( R4 ) */             \
+                     "orr r10, r10, r10\n\t"                      \
+                     "mov %0, r3"     /*result*/                  \
+                     : "=r" (_zzq_result)                         \
+                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
+                     : "cc","memory", "r3", "r4");                \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    unsigned int __addr;                                          \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* R3 = guest_NRADDR */                      \
+                     "orr r11, r11, r11\n\t"                      \
+                     "mov %0, r3"                                 \
+                     : "=r" (__addr)                              \
+                     :                                            \
+                     : "cc", "memory", "r3"                       \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+  }
+
+#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                    \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* branch-and-link-to-noredir *%R4 */        \
+                     "orr r12, r12, r12\n\t"
+
+#endif /* PLAT_arm_linux */
+
+/* ------------------------ ppc32-aix5 ------------------------- */
+
+#if defined(PLAT_ppc32_aix5)
+
+typedef
+   struct { 
+      unsigned int nraddr; /* where's the code? */
+      unsigned int r2;  /* what tocptr do we need? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "rlwinm 0,0,3,0,0  ; rlwinm 0,0,13,0,0\n\t"  \
+                     "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+                                                                  \
+  {          unsigned int  _zzq_args[7];                          \
+    register unsigned int  _zzq_result;                           \
+    register unsigned int* _zzq_ptr;                              \
+    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
+    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
+    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
+    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
+    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
+    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
+    _zzq_args[6] = (unsigned int)(_zzq_default);                  \
+    _zzq_ptr = _zzq_args;                                         \
+    __asm__ volatile("mr 4,%1\n\t"                                \
+                     "lwz 3, 24(4)\n\t"                           \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = client_request ( %R4 ) */           \
+                     "or 1,1,1\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (_zzq_result)                         \
+                     : "b" (_zzq_ptr)                             \
+                     : "r3", "r4", "cc", "memory");               \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    register unsigned int __addr;                                 \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR */                     \
+                     "or 2,2,2\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (__addr)                              \
+                     :                                            \
+                     : "r3", "cc", "memory"                       \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR_GPR2 */                \
+                     "or 4,4,4\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (__addr)                              \
+                     :                                            \
+                     : "r3", "cc", "memory"                       \
+                    );                                            \
+    _zzq_orig->r2 = __addr;                                       \
+  }
+
+#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* branch-and-link-to-noredir *%R11 */       \
+                     "or 3,3,3\n\t"
+
+#endif /* PLAT_ppc32_aix5 */
+
+/* ------------------------ ppc64-aix5 ------------------------- */
+
+#if defined(PLAT_ppc64_aix5)
+
+typedef
+   struct { 
+      unsigned long long int nraddr; /* where's the code? */
+      unsigned long long int r2;  /* what tocptr do we need? */
+   }
+   OrigFn;
+
+#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
+                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
+                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
+
+#define VALGRIND_DO_CLIENT_REQUEST(                               \
+        _zzq_rlval, _zzq_default, _zzq_request,                   \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
+                                                                  \
+  {          unsigned long long int  _zzq_args[7];                \
+    register unsigned long long int  _zzq_result;                 \
+    register unsigned long long int* _zzq_ptr;                    \
+    _zzq_args[0] = (unsigned int long long)(_zzq_request);        \
+    _zzq_args[1] = (unsigned int long long)(_zzq_arg1);           \
+    _zzq_args[2] = (unsigned int long long)(_zzq_arg2);           \
+    _zzq_args[3] = (unsigned int long long)(_zzq_arg3);           \
+    _zzq_args[4] = (unsigned int long long)(_zzq_arg4);           \
+    _zzq_args[5] = (unsigned int long long)(_zzq_arg5);           \
+    _zzq_args[6] = (unsigned int long long)(_zzq_default);        \
+    _zzq_ptr = _zzq_args;                                         \
+    __asm__ volatile("mr 4,%1\n\t"                                \
+                     "ld 3, 48(4)\n\t"                            \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = client_request ( %R4 ) */           \
+                     "or 1,1,1\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (_zzq_result)                         \
+                     : "b" (_zzq_ptr)                             \
+                     : "r3", "r4", "cc", "memory");               \
+    _zzq_rlval = _zzq_result;                                     \
+  }
+
+#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
+  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
+    register unsigned long long int __addr;                       \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR */                     \
+                     "or 2,2,2\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (__addr)                              \
+                     :                                            \
+                     : "r3", "cc", "memory"                       \
+                    );                                            \
+    _zzq_orig->nraddr = __addr;                                   \
+    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* %R3 = guest_NRADDR_GPR2 */                \
+                     "or 4,4,4\n\t"                               \
+                     "mr %0,3"                                    \
+                     : "=b" (__addr)                              \
+                     :                                            \
+                     : "r3", "cc", "memory"                       \
+                    );                                            \
+    _zzq_orig->r2 = __addr;                                       \
+  }
+
+#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
+                     __SPECIAL_INSTRUCTION_PREAMBLE               \
+                     /* branch-and-link-to-noredir *%R11 */       \
+                     "or 3,3,3\n\t"
+
+#endif /* PLAT_ppc64_aix5 */
+
+/* Insert assembly code for other platforms here... */
+
+#endif /* NVALGRIND */
+
+
+/* ------------------------------------------------------------------ */
+/* PLATFORM SPECIFICS for FUNCTION WRAPPING.  This is all very        */
+/* ugly.  It's the least-worst tradeoff I can think of.               */
+/* ------------------------------------------------------------------ */
+
+/* This section defines magic (a.k.a appalling-hack) macros for doing
+   guaranteed-no-redirection macros, so as to get from function
+   wrappers to the functions they are wrapping.  The whole point is to
+   construct standard call sequences, but to do the call itself with a
+   special no-redirect call pseudo-instruction that the JIT
+   understands and handles specially.  This section is long and
+   repetitious, and I can't see a way to make it shorter.
+
+   The naming scheme is as follows:
+
+      CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc}
+
+   'W' stands for "word" and 'v' for "void".  Hence there are
+   different macros for calling arity 0, 1, 2, 3, 4, etc, functions,
+   and for each, the possibility of returning a word-typed result, or
+   no result.
+*/
+
+/* Use these to write the name of your wrapper.  NOTE: duplicates
+   VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. */
+
+/* Use an extra level of macroisation so as to ensure the soname/fnname
+   args are fully macro-expanded before pasting them together. */
+#define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd
+
+#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname)                    \
+   VG_CONCAT4(_vgwZU_,soname,_,fnname)
+
+#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname)                    \
+   VG_CONCAT4(_vgwZZ_,soname,_,fnname)
+
+/* Use this macro from within a wrapper function to collect the
+   context (address and possibly other info) of the original function.
+   Once you have that you can then use it in one of the CALL_FN_
+   macros.  The type of the argument _lval is OrigFn. */
+#define VALGRIND_GET_ORIG_FN(_lval)  VALGRIND_GET_NR_CONTEXT(_lval)
+
+/* Derivatives of the main macros below, for calling functions
+   returning void. */
+
+#define CALL_FN_v_v(fnptr)                                        \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_v(_junk,fnptr); } while (0)
+
+#define CALL_FN_v_W(fnptr, arg1)                                  \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_W(_junk,fnptr,arg1); } while (0)
+
+#define CALL_FN_v_WW(fnptr, arg1,arg2)                            \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0)
+
+#define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3)                      \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0)
+
+#define CALL_FN_v_WWWW(fnptr, arg1,arg2,arg3,arg4)                \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_WWWW(_junk,fnptr,arg1,arg2,arg3,arg4); } while (0)
+
+#define CALL_FN_v_5W(fnptr, arg1,arg2,arg3,arg4,arg5)             \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_5W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5); } while (0)
+
+#define CALL_FN_v_6W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6)        \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_6W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6); } while (0)
+
+#define CALL_FN_v_7W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6,arg7)   \
+   do { volatile unsigned long _junk;                             \
+        CALL_FN_W_7W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6,arg7); } while (0)
+
+/* ------------------------- x86-{linux,darwin} ---------------- */
+
+#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin)
+
+/* These regs are trashed by the hidden call.  No need to mention eax
+   as gcc can already see that, plus causes gcc to bomb. */
+#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx"
+
+/* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned
+   long) == 4. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[1];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[2];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      __asm__ volatile(                                           \
+         "subl $12, %%esp\n\t"                                    \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $16, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      __asm__ volatile(                                           \
+         "subl $8, %%esp\n\t"                                     \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $16, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[4];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      __asm__ volatile(                                           \
+         "subl $4, %%esp\n\t"                                     \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $16, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[5];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      __asm__ volatile(                                           \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $16, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[6];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      __asm__ volatile(                                           \
+         "subl $12, %%esp\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $32, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[7];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      __asm__ volatile(                                           \
+         "subl $8, %%esp\n\t"                                     \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $32, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[8];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      __asm__ volatile(                                           \
+         "subl $4, %%esp\n\t"                                     \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $32, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[9];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      __asm__ volatile(                                           \
+         "pushl 32(%%eax)\n\t"                                    \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $32, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[10];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      __asm__ volatile(                                           \
+         "subl $12, %%esp\n\t"                                    \
+         "pushl 36(%%eax)\n\t"                                    \
+         "pushl 32(%%eax)\n\t"                                    \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $48, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[11];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      __asm__ volatile(                                           \
+         "subl $8, %%esp\n\t"                                     \
+         "pushl 40(%%eax)\n\t"                                    \
+         "pushl 36(%%eax)\n\t"                                    \
+         "pushl 32(%%eax)\n\t"                                    \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $48, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
+                                  arg6,arg7,arg8,arg9,arg10,      \
+                                  arg11)                          \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[12];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      __asm__ volatile(                                           \
+         "subl $4, %%esp\n\t"                                     \
+         "pushl 44(%%eax)\n\t"                                    \
+         "pushl 40(%%eax)\n\t"                                    \
+         "pushl 36(%%eax)\n\t"                                    \
+         "pushl 32(%%eax)\n\t"                                    \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $48, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
+                                  arg6,arg7,arg8,arg9,arg10,      \
+                                  arg11,arg12)                    \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[13];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      _argvec[12] = (unsigned long)(arg12);                       \
+      __asm__ volatile(                                           \
+         "pushl 48(%%eax)\n\t"                                    \
+         "pushl 44(%%eax)\n\t"                                    \
+         "pushl 40(%%eax)\n\t"                                    \
+         "pushl 36(%%eax)\n\t"                                    \
+         "pushl 32(%%eax)\n\t"                                    \
+         "pushl 28(%%eax)\n\t"                                    \
+         "pushl 24(%%eax)\n\t"                                    \
+         "pushl 20(%%eax)\n\t"                                    \
+         "pushl 16(%%eax)\n\t"                                    \
+         "pushl 12(%%eax)\n\t"                                    \
+         "pushl 8(%%eax)\n\t"                                     \
+         "pushl 4(%%eax)\n\t"                                     \
+         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
+         VALGRIND_CALL_NOREDIR_EAX                                \
+         "addl $48, %%esp\n"                                      \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_x86_linux || PLAT_x86_darwin */
+
+/* ------------------------ amd64-{linux,darwin} --------------- */
+
+#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin)
+
+/* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi",       \
+                            "rdi", "r8", "r9", "r10", "r11"
+
+/* This is all pretty complex.  It's so as to make stack unwinding
+   work reliably.  See bug 243270.  The basic problem is the sub and
+   add of 128 of %rsp in all of the following macros.  If gcc believes
+   the CFA is in %rsp, then unwinding may fail, because what's at the
+   CFA is not what gcc "expected" when it constructs the CFIs for the
+   places where the macros are instantiated.
+
+   But we can't just add a CFI annotation to increase the CFA offset
+   by 128, to match the sub of 128 from %rsp, because we don't know
+   whether gcc has chosen %rsp as the CFA at that point, or whether it
+   has chosen some other register (eg, %rbp).  In the latter case,
+   adding a CFI annotation to change the CFA offset is simply wrong.
+
+   So the solution is to get hold of the CFA using
+   __builtin_dwarf_cfa(), put it in a known register, and add a
+   CFI annotation to say what the register is.  We choose %rbp for
+   this (perhaps perversely), because:
+
+   (1) %rbp is already subject to unwinding.  If a new register was
+       chosen then the unwinder would have to unwind it in all stack
+       traces, which is expensive, and
+
+   (2) %rbp is already subject to precise exception updates in the
+       JIT.  If a new register was chosen, we'd have to have precise
+       exceptions for it too, which reduces performance of the
+       generated code.
+
+   However .. one extra complication.  We can't just whack the result
+   of __builtin_dwarf_cfa() into %rbp and then add %rbp to the
+   list of trashed registers at the end of the inline assembly
+   fragments; gcc won't allow %rbp to appear in that list.  Hence
+   instead we need to stash %rbp in %r15 for the duration of the asm,
+   and say that %r15 is trashed instead.  gcc seems happy to go with
+   that.
+
+   Oh .. and this all needs to be conditionalised so that it is
+   unchanged from before this commit, when compiled with older gccs
+   that don't support __builtin_dwarf_cfa.  Furthermore, since
+   this header file is freestanding, it has to be independent of
+   config.h, and so the following conditionalisation cannot depend on
+   configure time checks.
+
+   Although it's not clear from
+   'defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)',
+   this expression excludes Darwin.
+   .cfi directives in Darwin assembly appear to be completely
+   different and I haven't investigated how they work.
+
+   For even more entertainment value, note we have to use the
+   completely undocumented __builtin_dwarf_cfa(), which appears to
+   really compute the CFA, whereas __builtin_frame_address(0) claims
+   to but actually doesn't.  See
+   https://bugs.kde.org/show_bug.cgi?id=243270#c47
+*/
+#if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
+#  define __FRAME_POINTER                                         \
+      ,"r"(__builtin_dwarf_cfa())
+#  define VALGRIND_CFI_PROLOGUE                                   \
+      "movq %%rbp, %%r15\n\t"                                     \
+      "movq %2, %%rbp\n\t"                                        \
+      ".cfi_remember_state\n\t"                                   \
+      ".cfi_def_cfa rbp, 0\n\t"
+#  define VALGRIND_CFI_EPILOGUE                                   \
+      "movq %%r15, %%rbp\n\t"                                     \
+      ".cfi_restore_state\n\t"
+#else
+#  define __FRAME_POINTER
+#  define VALGRIND_CFI_PROLOGUE
+#  define VALGRIND_CFI_EPILOGUE
+#endif
+
+
+/* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned
+   long) == 8. */
+
+/* NB 9 Sept 07.  There is a nasty kludge here in all these CALL_FN_
+   macros.  In order not to trash the stack redzone, we need to drop
+   %rsp by 128 before the hidden call, and restore afterwards.  The
+   nastyness is that it is only by luck that the stack still appears
+   to be unwindable during the hidden call - since then the behaviour
+   of any routine using this macro does not match what the CFI data
+   says.  Sigh.
+
+   Why is this important?  Imagine that a wrapper has a stack
+   allocated local, and passes to the hidden call, a pointer to it.
+   Because gcc does not know about the hidden call, it may allocate
+   that local in the redzone.  Unfortunately the hidden call may then
+   trash it before it comes to use it.  So we must step clear of the
+   redzone, for the duration of the hidden call, to make it safe.
+
+   Probably the same problem afflicts the other redzone-style ABIs too
+   (ppc64-linux, ppc32-aix5, ppc64-aix5); but for those, the stack is
+   self describing (none of this CFI nonsense) so at least messing
+   with the stack pointer doesn't give a danger of non-unwindable
+   stack. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[1];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[2];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[4];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[5];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[6];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[7];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[8];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $136,%%rsp\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $8, %%rsp\n"                                       \
+         "addq $136,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[9];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "pushq 64(%%rax)\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $16, %%rsp\n"                                      \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[10];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $136,%%rsp\n\t"                                    \
+         "pushq 72(%%rax)\n\t"                                    \
+         "pushq 64(%%rax)\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $24, %%rsp\n"                                      \
+         "addq $136,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[11];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "pushq 80(%%rax)\n\t"                                    \
+         "pushq 72(%%rax)\n\t"                                    \
+         "pushq 64(%%rax)\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $32, %%rsp\n"                                      \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10,arg11)     \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[12];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $136,%%rsp\n\t"                                    \
+         "pushq 88(%%rax)\n\t"                                    \
+         "pushq 80(%%rax)\n\t"                                    \
+         "pushq 72(%%rax)\n\t"                                    \
+         "pushq 64(%%rax)\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $40, %%rsp\n"                                      \
+         "addq $136,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                arg7,arg8,arg9,arg10,arg11,arg12) \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[13];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      _argvec[12] = (unsigned long)(arg12);                       \
+      __asm__ volatile(                                           \
+         VALGRIND_CFI_PROLOGUE                                    \
+         "subq $128,%%rsp\n\t"                                    \
+         "pushq 96(%%rax)\n\t"                                    \
+         "pushq 88(%%rax)\n\t"                                    \
+         "pushq 80(%%rax)\n\t"                                    \
+         "pushq 72(%%rax)\n\t"                                    \
+         "pushq 64(%%rax)\n\t"                                    \
+         "pushq 56(%%rax)\n\t"                                    \
+         "movq 48(%%rax), %%r9\n\t"                               \
+         "movq 40(%%rax), %%r8\n\t"                               \
+         "movq 32(%%rax), %%rcx\n\t"                              \
+         "movq 24(%%rax), %%rdx\n\t"                              \
+         "movq 16(%%rax), %%rsi\n\t"                              \
+         "movq 8(%%rax), %%rdi\n\t"                               \
+         "movq (%%rax), %%rax\n\t"  /* target->%rax */            \
+         VALGRIND_CALL_NOREDIR_RAX                                \
+         "addq $48, %%rsp\n"                                      \
+         "addq $128,%%rsp\n\t"                                    \
+         VALGRIND_CFI_EPILOGUE                                    \
+         : /*out*/   "=a" (_res)                                  \
+         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15"   \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
+
+/* ------------------------ ppc32-linux ------------------------ */
+
+#if defined(PLAT_ppc32_linux)
+
+/* This is useful for finding out about the on-stack stuff:
+
+   extern int f9  ( int,int,int,int,int,int,int,int,int );
+   extern int f10 ( int,int,int,int,int,int,int,int,int,int );
+   extern int f11 ( int,int,int,int,int,int,int,int,int,int,int );
+   extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int );
+
+   int g9 ( void ) {
+      return f9(11,22,33,44,55,66,77,88,99);
+   }
+   int g10 ( void ) {
+      return f10(11,22,33,44,55,66,77,88,99,110);
+   }
+   int g11 ( void ) {
+      return f11(11,22,33,44,55,66,77,88,99,110,121);
+   }
+   int g12 ( void ) {
+      return f12(11,22,33,44,55,66,77,88,99,110,121,132);
+   }
+*/
+
+/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS                                       \
+   "lr", "ctr", "xer",                                            \
+   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
+   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
+   "r11", "r12", "r13"
+
+/* These CALL_FN_ macros assume that on ppc32-linux, 
+   sizeof(unsigned long) == 4. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[1];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[2];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[4];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[5];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[6];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[7];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[8];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[9];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      _argvec[8] = (unsigned long)arg8;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[10];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      _argvec[8] = (unsigned long)arg8;                           \
+      _argvec[9] = (unsigned long)arg9;                           \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "addi 1,1,-16\n\t"                                       \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,8(1)\n\t"                                         \
+         /* args1-8 */                                            \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "addi 1,1,16\n\t"                                        \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[11];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      _argvec[8] = (unsigned long)arg8;                           \
+      _argvec[9] = (unsigned long)arg9;                           \
+      _argvec[10] = (unsigned long)arg10;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "addi 1,1,-16\n\t"                                       \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,12(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,8(1)\n\t"                                         \
+         /* args1-8 */                                            \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "addi 1,1,16\n\t"                                        \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10,arg11)     \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[12];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      _argvec[8] = (unsigned long)arg8;                           \
+      _argvec[9] = (unsigned long)arg9;                           \
+      _argvec[10] = (unsigned long)arg10;                         \
+      _argvec[11] = (unsigned long)arg11;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "addi 1,1,-32\n\t"                                       \
+         /* arg11 */                                              \
+         "lwz 3,44(11)\n\t"                                       \
+         "stw 3,16(1)\n\t"                                        \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,12(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,8(1)\n\t"                                         \
+         /* args1-8 */                                            \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "addi 1,1,32\n\t"                                        \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                arg7,arg8,arg9,arg10,arg11,arg12) \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[13];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)arg1;                           \
+      _argvec[2] = (unsigned long)arg2;                           \
+      _argvec[3] = (unsigned long)arg3;                           \
+      _argvec[4] = (unsigned long)arg4;                           \
+      _argvec[5] = (unsigned long)arg5;                           \
+      _argvec[6] = (unsigned long)arg6;                           \
+      _argvec[7] = (unsigned long)arg7;                           \
+      _argvec[8] = (unsigned long)arg8;                           \
+      _argvec[9] = (unsigned long)arg9;                           \
+      _argvec[10] = (unsigned long)arg10;                         \
+      _argvec[11] = (unsigned long)arg11;                         \
+      _argvec[12] = (unsigned long)arg12;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "addi 1,1,-32\n\t"                                       \
+         /* arg12 */                                              \
+         "lwz 3,48(11)\n\t"                                       \
+         "stw 3,20(1)\n\t"                                        \
+         /* arg11 */                                              \
+         "lwz 3,44(11)\n\t"                                       \
+         "stw 3,16(1)\n\t"                                        \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,12(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,8(1)\n\t"                                         \
+         /* args1-8 */                                            \
+         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
+         "lwz 4,8(11)\n\t"                                        \
+         "lwz 5,12(11)\n\t"                                       \
+         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
+         "lwz 7,20(11)\n\t"                                       \
+         "lwz 8,24(11)\n\t"                                       \
+         "lwz 9,28(11)\n\t"                                       \
+         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
+         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "addi 1,1,32\n\t"                                        \
+         "mr %0,3"                                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_ppc32_linux */
+
+/* ------------------------ ppc64-linux ------------------------ */
+
+#if defined(PLAT_ppc64_linux)
+
+/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS                                       \
+   "lr", "ctr", "xer",                                            \
+   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
+   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
+   "r11", "r12", "r13"
+
+/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
+   long) == 8. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+0];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1] = (unsigned long)_orig.r2;                       \
+      _argvec[2] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+1];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+2];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+3];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+4];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+5];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+6];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+7];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+8];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)" /* restore tocptr */                      \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+9];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "addi 1,1,-128\n\t"  /* expand stack frame */            \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         "addi 1,1,128"     /* restore frame */                   \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+10];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "addi 1,1,-128\n\t"  /* expand stack frame */            \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         "addi 1,1,128"     /* restore frame */                   \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10,arg11)     \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+11];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "addi 1,1,-144\n\t"  /* expand stack frame */            \
+         /* arg11 */                                              \
+         "ld  3,88(11)\n\t"                                       \
+         "std 3,128(1)\n\t"                                       \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         "addi 1,1,144"     /* restore frame */                   \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                arg7,arg8,arg9,arg10,arg11,arg12) \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+12];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      _argvec[2+12] = (unsigned long)arg12;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         "std 2,-16(11)\n\t"  /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "addi 1,1,-144\n\t"  /* expand stack frame */            \
+         /* arg12 */                                              \
+         "ld  3,96(11)\n\t"                                       \
+         "std 3,136(1)\n\t"                                       \
+         /* arg11 */                                              \
+         "ld  3,88(11)\n\t"                                       \
+         "std 3,128(1)\n\t"                                       \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         "addi 1,1,144"     /* restore frame */                   \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_ppc64_linux */
+
+/* ------------------------- arm-linux ------------------------- */
+
+#if defined(PLAT_arm_linux)
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3","r4","r14"
+
+/* These CALL_FN_ macros assume that on arm-linux, sizeof(unsigned
+   long) == 4. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[1];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "mov %0, r0\n"                                           \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[2];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "mov %0, r0\n"                                           \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory",  __CALLER_SAVED_REGS         \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "mov %0, r0\n"                                           \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[4];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "mov %0, r0\n"                                           \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[5];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[6];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "push {r0} \n\t"                                         \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #4 \n\t"                                    \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[7];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "push {r0, r1} \n\t"                                     \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #8 \n\t"                                    \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[8];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "push {r0, r1, r2} \n\t"                                 \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #12 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[9];                          \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "ldr r3, [%1, #32] \n\t"                                 \
+         "push {r0, r1, r2, r3} \n\t"                             \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #16 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[10];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "ldr r3, [%1, #32] \n\t"                                 \
+         "ldr r4, [%1, #36] \n\t"                                 \
+         "push {r0, r1, r2, r3, r4} \n\t"                         \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #20 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[11];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #40] \n\t"                                 \
+         "push {r0} \n\t"                                         \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "ldr r3, [%1, #32] \n\t"                                 \
+         "ldr r4, [%1, #36] \n\t"                                 \
+         "push {r0, r1, r2, r3, r4} \n\t"                         \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #24 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
+                                  arg6,arg7,arg8,arg9,arg10,      \
+                                  arg11)                          \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[12];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #40] \n\t"                                 \
+         "ldr r1, [%1, #44] \n\t"                                 \
+         "push {r0, r1} \n\t"                                     \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "ldr r3, [%1, #32] \n\t"                                 \
+         "ldr r4, [%1, #36] \n\t"                                 \
+         "push {r0, r1, r2, r3, r4} \n\t"                         \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #28 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory",__CALLER_SAVED_REGS           \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
+                                  arg6,arg7,arg8,arg9,arg10,      \
+                                  arg11,arg12)                    \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[13];                         \
+      volatile unsigned long _res;                                \
+      _argvec[0] = (unsigned long)_orig.nraddr;                   \
+      _argvec[1] = (unsigned long)(arg1);                         \
+      _argvec[2] = (unsigned long)(arg2);                         \
+      _argvec[3] = (unsigned long)(arg3);                         \
+      _argvec[4] = (unsigned long)(arg4);                         \
+      _argvec[5] = (unsigned long)(arg5);                         \
+      _argvec[6] = (unsigned long)(arg6);                         \
+      _argvec[7] = (unsigned long)(arg7);                         \
+      _argvec[8] = (unsigned long)(arg8);                         \
+      _argvec[9] = (unsigned long)(arg9);                         \
+      _argvec[10] = (unsigned long)(arg10);                       \
+      _argvec[11] = (unsigned long)(arg11);                       \
+      _argvec[12] = (unsigned long)(arg12);                       \
+      __asm__ volatile(                                           \
+         "ldr r0, [%1, #40] \n\t"                                 \
+         "ldr r1, [%1, #44] \n\t"                                 \
+         "ldr r2, [%1, #48] \n\t"                                 \
+         "push {r0, r1, r2} \n\t"                                 \
+         "ldr r0, [%1, #20] \n\t"                                 \
+         "ldr r1, [%1, #24] \n\t"                                 \
+         "ldr r2, [%1, #28] \n\t"                                 \
+         "ldr r3, [%1, #32] \n\t"                                 \
+         "ldr r4, [%1, #36] \n\t"                                 \
+         "push {r0, r1, r2, r3, r4} \n\t"                         \
+         "ldr r0, [%1, #4] \n\t"                                  \
+         "ldr r1, [%1, #8] \n\t"                                  \
+         "ldr r2, [%1, #12] \n\t"                                 \
+         "ldr r3, [%1, #16] \n\t"                                 \
+         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
+         "add sp, sp, #32 \n\t"                                   \
+         "mov %0, r0"                                             \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "0" (&_argvec[0])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_arm_linux */
+
+/* ------------------------ ppc32-aix5 ------------------------- */
+
+#if defined(PLAT_ppc32_aix5)
+
+/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS                                       \
+   "lr", "ctr", "xer",                                            \
+   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
+   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
+   "r11", "r12", "r13"
+
+/* Expand the stack frame, copying enough info that unwinding
+   still works.  Trashes r3. */
+
+#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr)                      \
+         "addi 1,1,-" #_n_fr "\n\t"                               \
+         "lwz  3," #_n_fr "(1)\n\t"                               \
+         "stw  3,0(1)\n\t"
+
+#define VG_CONTRACT_FRAME_BY(_n_fr)                               \
+         "addi 1,1," #_n_fr "\n\t"
+
+/* These CALL_FN_ macros assume that on ppc32-aix5, sizeof(unsigned
+   long) == 4. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+0];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1] = (unsigned long)_orig.r2;                       \
+      _argvec[2] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+1];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+2];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+3];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+4];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+5];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t" /* arg2->r4 */                       \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+6];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+7];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+8];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 10, 32(11)\n\t" /* arg8->r10 */                     \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+9];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(64)                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,56(1)\n\t"                                        \
+         /* args1-8 */                                            \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 10, 32(11)\n\t" /* arg8->r10 */                     \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(64)                                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+10];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(64)                        \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,60(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,56(1)\n\t"                                        \
+         /* args1-8 */                                            \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 10, 32(11)\n\t" /* arg8->r10 */                     \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(64)                                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10,arg11)     \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+11];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(72)                        \
+         /* arg11 */                                              \
+         "lwz 3,44(11)\n\t"                                       \
+         "stw 3,64(1)\n\t"                                        \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,60(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,56(1)\n\t"                                        \
+         /* args1-8 */                                            \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 10, 32(11)\n\t" /* arg8->r10 */                     \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(72)                                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                arg7,arg8,arg9,arg10,arg11,arg12) \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+12];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      _argvec[2+12] = (unsigned long)arg12;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "stw  2,-8(11)\n\t"  /* save tocptr */                   \
+         "lwz  2,-4(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(72)                        \
+         /* arg12 */                                              \
+         "lwz 3,48(11)\n\t"                                       \
+         "stw 3,68(1)\n\t"                                        \
+         /* arg11 */                                              \
+         "lwz 3,44(11)\n\t"                                       \
+         "stw 3,64(1)\n\t"                                        \
+         /* arg10 */                                              \
+         "lwz 3,40(11)\n\t"                                       \
+         "stw 3,60(1)\n\t"                                        \
+         /* arg9 */                                               \
+         "lwz 3,36(11)\n\t"                                       \
+         "stw 3,56(1)\n\t"                                        \
+         /* args1-8 */                                            \
+         "lwz  3, 4(11)\n\t"  /* arg1->r3 */                      \
+         "lwz  4, 8(11)\n\t"  /* arg2->r4 */                      \
+         "lwz  5, 12(11)\n\t" /* arg3->r5 */                      \
+         "lwz  6, 16(11)\n\t" /* arg4->r6 */                      \
+         "lwz  7, 20(11)\n\t" /* arg5->r7 */                      \
+         "lwz  8, 24(11)\n\t" /* arg6->r8 */                      \
+         "lwz  9, 28(11)\n\t" /* arg7->r9 */                      \
+         "lwz 10, 32(11)\n\t" /* arg8->r10 */                     \
+         "lwz 11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "lwz 2,-8(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(72)                                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_ppc32_aix5 */
+
+/* ------------------------ ppc64-aix5 ------------------------- */
+
+#if defined(PLAT_ppc64_aix5)
+
+/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
+
+/* These regs are trashed by the hidden call. */
+#define __CALLER_SAVED_REGS                                       \
+   "lr", "ctr", "xer",                                            \
+   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
+   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
+   "r11", "r12", "r13"
+
+/* Expand the stack frame, copying enough info that unwinding
+   still works.  Trashes r3. */
+
+#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr)                      \
+         "addi 1,1,-" #_n_fr "\n\t"                               \
+         "ld   3," #_n_fr "(1)\n\t"                               \
+         "std  3,0(1)\n\t"
+
+#define VG_CONTRACT_FRAME_BY(_n_fr)                               \
+         "addi 1,1," #_n_fr "\n\t"
+
+/* These CALL_FN_ macros assume that on ppc64-aix5, sizeof(unsigned
+   long) == 8. */
+
+#define CALL_FN_W_v(lval, orig)                                   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+0];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1] = (unsigned long)_orig.r2;                       \
+      _argvec[2] = (unsigned long)_orig.nraddr;                   \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_W(lval, orig, arg1)                             \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+1];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+2];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+3];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+4];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+5];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+6];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7)                            \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+7];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8)                       \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+8];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
+                                 arg7,arg8,arg9)                  \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+9];                        \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(128)                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(128)                                \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10)           \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+10];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(128)                       \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(128)                                \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                  arg7,arg8,arg9,arg10,arg11)     \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+11];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(144)                       \
+         /* arg11 */                                              \
+         "ld  3,88(11)\n\t"                                       \
+         "std 3,128(1)\n\t"                                       \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(144)                                \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
+                                arg7,arg8,arg9,arg10,arg11,arg12) \
+   do {                                                           \
+      volatile OrigFn        _orig = (orig);                      \
+      volatile unsigned long _argvec[3+12];                       \
+      volatile unsigned long _res;                                \
+      /* _argvec[0] holds current r2 across the call */           \
+      _argvec[1]   = (unsigned long)_orig.r2;                     \
+      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
+      _argvec[2+1] = (unsigned long)arg1;                         \
+      _argvec[2+2] = (unsigned long)arg2;                         \
+      _argvec[2+3] = (unsigned long)arg3;                         \
+      _argvec[2+4] = (unsigned long)arg4;                         \
+      _argvec[2+5] = (unsigned long)arg5;                         \
+      _argvec[2+6] = (unsigned long)arg6;                         \
+      _argvec[2+7] = (unsigned long)arg7;                         \
+      _argvec[2+8] = (unsigned long)arg8;                         \
+      _argvec[2+9] = (unsigned long)arg9;                         \
+      _argvec[2+10] = (unsigned long)arg10;                       \
+      _argvec[2+11] = (unsigned long)arg11;                       \
+      _argvec[2+12] = (unsigned long)arg12;                       \
+      __asm__ volatile(                                           \
+         "mr 11,%1\n\t"                                           \
+         VG_EXPAND_FRAME_BY_trashes_r3(512)                       \
+         "std  2,-16(11)\n\t" /* save tocptr */                   \
+         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
+         VG_EXPAND_FRAME_BY_trashes_r3(144)                       \
+         /* arg12 */                                              \
+         "ld  3,96(11)\n\t"                                       \
+         "std 3,136(1)\n\t"                                       \
+         /* arg11 */                                              \
+         "ld  3,88(11)\n\t"                                       \
+         "std 3,128(1)\n\t"                                       \
+         /* arg10 */                                              \
+         "ld  3,80(11)\n\t"                                       \
+         "std 3,120(1)\n\t"                                       \
+         /* arg9 */                                               \
+         "ld  3,72(11)\n\t"                                       \
+         "std 3,112(1)\n\t"                                       \
+         /* args1-8 */                                            \
+         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
+         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
+         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
+         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
+         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
+         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
+         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
+         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
+         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
+         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
+         "mr 11,%1\n\t"                                           \
+         "mr %0,3\n\t"                                            \
+         "ld  2,-16(11)\n\t" /* restore tocptr */                 \
+         VG_CONTRACT_FRAME_BY(144)                                \
+         VG_CONTRACT_FRAME_BY(512)                                \
+         : /*out*/   "=r" (_res)                                  \
+         : /*in*/    "r" (&_argvec[2])                            \
+         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS          \
+      );                                                          \
+      lval = (__typeof__(lval)) _res;                             \
+   } while (0)
+
+#endif /* PLAT_ppc64_aix5 */
+
+
+/* ------------------------------------------------------------------ */
+/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS.               */
+/*                                                                    */
+/* ------------------------------------------------------------------ */
+
+/* Some request codes.  There are many more of these, but most are not
+   exposed to end-user view.  These are the public ones, all of the
+   form 0x1000 + small_number.
+
+   Core ones are in the range 0x00000000--0x0000ffff.  The non-public
+   ones start at 0x2000.
+*/
+
+/* These macros are used by tools -- they must be public, but don't
+   embed them into other programs. */
+#define VG_USERREQ_TOOL_BASE(a,b) \
+   ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
+#define VG_IS_TOOL_USERREQ(a, b, v) \
+   (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
+
+/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! 
+   This enum comprises an ABI exported by Valgrind to programs
+   which use client requests.  DO NOT CHANGE THE ORDER OF THESE
+   ENTRIES, NOR DELETE ANY -- add new ones at the end. */
+typedef
+   enum { VG_USERREQ__RUNNING_ON_VALGRIND  = 0x1001,
+          VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
+
+          /* These allow any function to be called from the simulated
+             CPU but run on the real CPU.  Nb: the first arg passed to
+             the function is always the ThreadId of the running
+             thread!  So CLIENT_CALL0 actually requires a 1 arg
+             function, etc. */
+          VG_USERREQ__CLIENT_CALL0 = 0x1101,
+          VG_USERREQ__CLIENT_CALL1 = 0x1102,
+          VG_USERREQ__CLIENT_CALL2 = 0x1103,
+          VG_USERREQ__CLIENT_CALL3 = 0x1104,
+
+          /* Can be useful in regression testing suites -- eg. can
+             send Valgrind's output to /dev/null and still count
+             errors. */
+          VG_USERREQ__COUNT_ERRORS = 0x1201,
+
+          /* These are useful and can be interpreted by any tool that
+             tracks malloc() et al, by using vg_replace_malloc.c. */
+          VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
+          VG_USERREQ__FREELIKE_BLOCK   = 0x1302,
+          /* Memory pool support. */
+          VG_USERREQ__CREATE_MEMPOOL   = 0x1303,
+          VG_USERREQ__DESTROY_MEMPOOL  = 0x1304,
+          VG_USERREQ__MEMPOOL_ALLOC    = 0x1305,
+          VG_USERREQ__MEMPOOL_FREE     = 0x1306,
+          VG_USERREQ__MEMPOOL_TRIM     = 0x1307,
+          VG_USERREQ__MOVE_MEMPOOL     = 0x1308,
+          VG_USERREQ__MEMPOOL_CHANGE   = 0x1309,
+          VG_USERREQ__MEMPOOL_EXISTS   = 0x130a,
+
+          /* Allow printfs to valgrind log. */
+          /* The first two pass the va_list argument by value, which
+             assumes it is the same size as or smaller than a UWord,
+             which generally isn't the case.  Hence are deprecated.
+             The second two pass the vargs by reference and so are
+             immune to this problem. */
+          /* both :: char* fmt, va_list vargs (DEPRECATED) */
+          VG_USERREQ__PRINTF           = 0x1401,
+          VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
+          /* both :: char* fmt, va_list* vargs */
+          VG_USERREQ__PRINTF_VALIST_BY_REF = 0x1403,
+          VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF = 0x1404,
+
+          /* Stack support. */
+          VG_USERREQ__STACK_REGISTER   = 0x1501,
+          VG_USERREQ__STACK_DEREGISTER = 0x1502,
+          VG_USERREQ__STACK_CHANGE     = 0x1503,
+
+          /* Wine support */
+          VG_USERREQ__LOAD_PDB_DEBUGINFO = 0x1601,
+
+          /* Querying of debug info. */
+          VG_USERREQ__MAP_IP_TO_SRCLOC = 0x1701
+   } Vg_ClientRequest;
+
+#if !defined(__GNUC__)
+#  define __extension__ /* */
+#endif
+
+
+/*
+ * VALGRIND_DO_CLIENT_REQUEST_EXPR(): a C expression that invokes a Valgrind
+ * client request and whose value equals the client request result.
+ */
+
+#if defined(NVALGRIND)
+
+#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                               \
+        _zzq_default, _zzq_request,                                    \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)         \
+   (_zzq_default)
+
+#else /*defined(NVALGRIND)*/
+
+#if defined(_MSC_VER)
+
+#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                                \
+        _zzq_default, _zzq_request,                                     \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)          \
+   (vg_VALGRIND_DO_CLIENT_REQUEST_EXPR((uintptr_t)(_zzq_default),       \
+        (_zzq_request), (uintptr_t)(_zzq_arg1), (uintptr_t)(_zzq_arg2), \
+        (uintptr_t)(_zzq_arg3), (uintptr_t)(_zzq_arg4),                 \
+        (uintptr_t)(_zzq_arg5)))
+
+static __inline unsigned
+vg_VALGRIND_DO_CLIENT_REQUEST_EXPR(uintptr_t _zzq_default,
+                                   unsigned _zzq_request, uintptr_t _zzq_arg1,
+                                   uintptr_t _zzq_arg2, uintptr_t _zzq_arg3,
+                                   uintptr_t _zzq_arg4, uintptr_t _zzq_arg5)
+{
+    unsigned _zzq_rlval;
+    VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval, _zzq_default, _zzq_request,
+                      _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5);
+    return _zzq_rlval;
+}
+
+#else /*defined(_MSC_VER)*/
+
+#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                               \
+        _zzq_default, _zzq_request,                                    \
+        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)         \
+   (__extension__({unsigned int _zzq_rlval;                            \
+    VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval, _zzq_default, _zzq_request, \
+                _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
+    _zzq_rlval;                                                        \
+   }))
+
+#endif /*defined(_MSC_VER)*/
+
+#endif /*defined(NVALGRIND)*/
+
+
+/* Returns the number of Valgrinds this code is running under.  That
+   is, 0 if running natively, 1 if running under Valgrind, 2 if
+   running under Valgrind which is running under another Valgrind,
+   etc. */
+#define RUNNING_ON_VALGRIND                                           \
+    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* if not */,                   \
+                                    VG_USERREQ__RUNNING_ON_VALGRIND,  \
+                                    0, 0, 0, 0, 0)                    \
+
+
+/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
+   _qzz_len - 1].  Useful if you are debugging a JITter or some such,
+   since it provides a way to make sure valgrind will retranslate the
+   invalidated area.  Returns no value. */
+#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len)         \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__DISCARD_TRANSLATIONS,  \
+                               _qzz_addr, _qzz_len, 0, 0, 0);     \
+   }
+
+
+/* These requests are for getting Valgrind itself to print something.
+   Possibly with a backtrace.  This is a really ugly hack.  The return value
+   is the number of characters printed, excluding the "**<pid>** " part at the
+   start and the backtrace (if present). */
+
+#if defined(NVALGRIND)
+
+#  define VALGRIND_PRINTF(...)
+#  define VALGRIND_PRINTF_BACKTRACE(...)
+
+#else /* NVALGRIND */
+
+#if !defined(_MSC_VER)
+/* Modern GCC will optimize the static routine out if unused,
+   and unused attribute will shut down warnings about it.  */
+static int VALGRIND_PRINTF(const char *format, ...)
+   __attribute__((format(__printf__, 1, 2), __unused__));
+#endif
+static int
+#if defined(_MSC_VER)
+__inline
+#endif
+VALGRIND_PRINTF(const char *format, ...)
+{
+   unsigned long _qzz_res;
+   va_list vargs;
+   va_start(vargs, format);
+#if defined(_MSC_VER)
+   VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,
+                              VG_USERREQ__PRINTF_VALIST_BY_REF,
+                              (uintptr_t)format,
+                              (uintptr_t)&vargs,
+                              0, 0, 0);
+#else
+   VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,
+                              VG_USERREQ__PRINTF_VALIST_BY_REF,
+                              (unsigned long)format,
+                              (unsigned long)&vargs, 
+                              0, 0, 0);
+#endif
+   va_end(vargs);
+   return (int)_qzz_res;
+}
+
+#if !defined(_MSC_VER)
+static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
+   __attribute__((format(__printf__, 1, 2), __unused__));
+#endif
+static int
+#if defined(_MSC_VER)
+__inline
+#endif
+VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
+{
+   unsigned long _qzz_res;
+   va_list vargs;
+   va_start(vargs, format);
+#if defined(_MSC_VER)
+   VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,
+                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
+                              (uintptr_t)format,
+                              (uintptr_t)&vargs,
+                              0, 0, 0);
+#else
+   VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,
+                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
+                              (unsigned long)format,
+                              (unsigned long)&vargs, 
+                              0, 0, 0);
+#endif
+   va_end(vargs);
+   return (int)_qzz_res;
+}
+
+#endif /* NVALGRIND */
+
+
+/* These requests allow control to move from the simulated CPU to the
+   real CPU, calling an arbitary function.
+   
+   Note that the current ThreadId is inserted as the first argument.
+   So this call:
+
+     VALGRIND_NON_SIMD_CALL2(f, arg1, arg2)
+
+   requires f to have this signature:
+
+     Word f(Word tid, Word arg1, Word arg2)
+
+   where "Word" is a word-sized type.
+
+   Note that these client requests are not entirely reliable.  For example,
+   if you call a function with them that subsequently calls printf(),
+   there's a high chance Valgrind will crash.  Generally, your prospects of
+   these working are made higher if the called function does not refer to
+   any global variables, and does not refer to any libc or other functions
+   (printf et al).  Any kind of entanglement with libc or dynamic linking is
+   likely to have a bad outcome, for tricky reasons which we've grappled
+   with a lot in the past.
+*/
+#define VALGRIND_NON_SIMD_CALL0(_qyy_fn)                          \
+   __extension__                                                  \
+   ({unsigned long _qyy_res;                                      \
+    VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */,  \
+                               VG_USERREQ__CLIENT_CALL0,          \
+                               _qyy_fn,                           \
+                               0, 0, 0, 0);                       \
+    _qyy_res;                                                     \
+   })
+
+#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1)               \
+   __extension__                                                  \
+   ({unsigned long _qyy_res;                                      \
+    VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */,  \
+                               VG_USERREQ__CLIENT_CALL1,          \
+                               _qyy_fn,                           \
+                               _qyy_arg1, 0, 0, 0);               \
+    _qyy_res;                                                     \
+   })
+
+#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2)    \
+   __extension__                                                  \
+   ({unsigned long _qyy_res;                                      \
+    VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */,  \
+                               VG_USERREQ__CLIENT_CALL2,          \
+                               _qyy_fn,                           \
+                               _qyy_arg1, _qyy_arg2, 0, 0);       \
+    _qyy_res;                                                     \
+   })
+
+#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
+   __extension__                                                  \
+   ({unsigned long _qyy_res;                                      \
+    VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */,  \
+                               VG_USERREQ__CLIENT_CALL3,          \
+                               _qyy_fn,                           \
+                               _qyy_arg1, _qyy_arg2,              \
+                               _qyy_arg3, 0);                     \
+    _qyy_res;                                                     \
+   })
+
+
+/* Counts the number of errors that have been recorded by a tool.  Nb:
+   the tool must record the errors with VG_(maybe_record_error)() or
+   VG_(unique_error)() for them to be counted. */
+#define VALGRIND_COUNT_ERRORS                                     \
+   __extension__                                                  \
+   ({unsigned int _qyy_res;                                       \
+    VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */,  \
+                               VG_USERREQ__COUNT_ERRORS,          \
+                               0, 0, 0, 0, 0);                    \
+    _qyy_res;                                                     \
+   })
+
+/* Several Valgrind tools (Memcheck, Massif, Helgrind, DRD) rely on knowing
+   when heap blocks are allocated in order to give accurate results.  This
+   happens automatically for the standard allocator functions such as
+   malloc(), calloc(), realloc(), memalign(), new, new[], free(), delete,
+   delete[], etc.
+
+   But if your program uses a custom allocator, this doesn't automatically
+   happen, and Valgrind will not do as well.  For example, if you allocate
+   superblocks with mmap() and then allocates chunks of the superblocks, all
+   Valgrind's observations will be at the mmap() level and it won't know that
+   the chunks should be considered separate entities.  In Memcheck's case,
+   that means you probably won't get heap block overrun detection (because
+   there won't be redzones marked as unaddressable) and you definitely won't
+   get any leak detection.
+
+   The following client requests allow a custom allocator to be annotated so
+   that it can be handled accurately by Valgrind.
+
+   VALGRIND_MALLOCLIKE_BLOCK marks a region of memory as having been allocated
+   by a malloc()-like function.  For Memcheck (an illustrative case), this
+   does two things:
+
+   - It records that the block has been allocated.  This means any addresses
+     within the block mentioned in error messages will be
+     identified as belonging to the block.  It also means that if the block
+     isn't freed it will be detected by the leak checker.
+
+   - It marks the block as being addressable and undefined (if 'is_zeroed' is
+     not set), or addressable and defined (if 'is_zeroed' is set).  This
+     controls how accesses to the block by the program are handled.
+   
+   'addr' is the start of the usable block (ie. after any
+   redzone), 'sizeB' is its size.  'rzB' is the redzone size if the allocator
+   can apply redzones -- these are blocks of padding at the start and end of
+   each block.  Adding redzones is recommended as it makes it much more likely
+   Valgrind will spot block overruns.  `is_zeroed' indicates if the memory is
+   zeroed (or filled with another predictable value), as is the case for
+   calloc().
+   
+   VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a
+   heap block -- that will be used by the client program -- is allocated.
+   It's best to put it at the outermost level of the allocator if possible;
+   for example, if you have a function my_alloc() which calls
+   internal_alloc(), and the client request is put inside internal_alloc(),
+   stack traces relating to the heap block will contain entries for both
+   my_alloc() and internal_alloc(), which is probably not what you want.
+
+   For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out
+   custom blocks from within a heap block, B, that has been allocated with
+   malloc/calloc/new/etc, then block B will be *ignored* during leak-checking
+   -- the custom blocks will take precedence.
+
+   VALGRIND_FREELIKE_BLOCK is the partner to VALGRIND_MALLOCLIKE_BLOCK.  For
+   Memcheck, it does two things:
+
+   - It records that the block has been deallocated.  This assumes that the
+     block was annotated as having been allocated via
+     VALGRIND_MALLOCLIKE_BLOCK.  Otherwise, an error will be issued.
+
+   - It marks the block as being unaddressable.
+
+   VALGRIND_FREELIKE_BLOCK should be put immediately after the point where a
+   heap block is deallocated.
+
+   In many cases, these two client requests will not be enough to get your
+   allocator working well with Memcheck.  More specifically, if your allocator
+   writes to freed blocks in any way then a VALGRIND_MAKE_MEM_UNDEFINED call
+   will be necessary to mark the memory as addressable just before the zeroing
+   occurs, otherwise you'll get a lot of invalid write errors.  For example,
+   you'll need to do this if your allocator recycles freed blocks, but it
+   zeroes them before handing them back out (via VALGRIND_MALLOCLIKE_BLOCK).
+   Alternatively, if your allocator reuses freed blocks for allocator-internal
+   data structures, VALGRIND_MAKE_MEM_UNDEFINED calls will also be necessary.
+
+   Really, what's happening is a blurring of the lines between the client
+   program and the allocator... after VALGRIND_FREELIKE_BLOCK is called, the
+   memory should be considered unaddressable to the client program, but the
+   allocator knows more than the rest of the client program and so may be able
+   to safely access it.  Extra client requests are necessary for Valgrind to
+   understand the distinction between the allocator and the rest of the
+   program.
+
+   Note: there is currently no VALGRIND_REALLOCLIKE_BLOCK client request;  it
+   has to be emulated with MALLOCLIKE/FREELIKE and memory copying.
+   
+   Ignored if addr == 0.
+*/
+#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)    \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MALLOCLIKE_BLOCK,      \
+                               addr, sizeB, rzB, is_zeroed, 0);   \
+   }
+
+/* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
+   Ignored if addr == 0.
+*/
+#define VALGRIND_FREELIKE_BLOCK(addr, rzB)                        \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__FREELIKE_BLOCK,        \
+                               addr, rzB, 0, 0, 0);               \
+   }
+
+/* Create a memory pool. */
+#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)             \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__CREATE_MEMPOOL,        \
+                               pool, rzB, is_zeroed, 0, 0);       \
+   }
+
+/* Destroy a memory pool. */
+#define VALGRIND_DESTROY_MEMPOOL(pool)                            \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__DESTROY_MEMPOOL,       \
+                               pool, 0, 0, 0, 0);                 \
+   }
+
+/* Associate a piece of memory with a memory pool. */
+#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size)                  \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MEMPOOL_ALLOC,         \
+                               pool, addr, size, 0, 0);           \
+   }
+
+/* Disassociate a piece of memory from a memory pool. */
+#define VALGRIND_MEMPOOL_FREE(pool, addr)                         \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MEMPOOL_FREE,          \
+                               pool, addr, 0, 0, 0);              \
+   }
+
+/* Disassociate any pieces outside a particular range. */
+#define VALGRIND_MEMPOOL_TRIM(pool, addr, size)                   \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MEMPOOL_TRIM,          \
+                               pool, addr, size, 0, 0);           \
+   }
+
+/* Resize and/or move a piece associated with a memory pool. */
+#define VALGRIND_MOVE_MEMPOOL(poolA, poolB)                       \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MOVE_MEMPOOL,          \
+                               poolA, poolB, 0, 0, 0);            \
+   }
+
+/* Resize and/or move a piece associated with a memory pool. */
+#define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size)         \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MEMPOOL_CHANGE,        \
+                               pool, addrA, addrB, size, 0);      \
+   }
+
+/* Return 1 if a mempool exists, else 0. */
+#define VALGRIND_MEMPOOL_EXISTS(pool)                             \
+   __extension__                                                  \
+   ({unsigned int _qzz_res;                                       \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MEMPOOL_EXISTS,        \
+                               pool, 0, 0, 0, 0);                 \
+    _qzz_res;                                                     \
+   })
+
+/* Mark a piece of memory as being a stack. Returns a stack id. */
+#define VALGRIND_STACK_REGISTER(start, end)                       \
+   __extension__                                                  \
+   ({unsigned int _qzz_res;                                       \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__STACK_REGISTER,        \
+                               start, end, 0, 0, 0);              \
+    _qzz_res;                                                     \
+   })
+
+/* Unmark the piece of memory associated with a stack id as being a
+   stack. */
+#define VALGRIND_STACK_DEREGISTER(id)                             \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__STACK_DEREGISTER,      \
+                               id, 0, 0, 0, 0);                   \
+   }
+
+/* Change the start and end address of the stack id. */
+#define VALGRIND_STACK_CHANGE(id, start, end)                     \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__STACK_CHANGE,          \
+                               id, start, end, 0, 0);             \
+   }
+
+/* Load PDB debug info for Wine PE image_map. */
+#define VALGRIND_LOAD_PDB_DEBUGINFO(fd, ptr, total_size, delta)   \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__LOAD_PDB_DEBUGINFO,    \
+                               fd, ptr, total_size, delta, 0);    \
+   }
+
+/* Map a code address to a source file name and line number.  buf64
+   must point to a 64-byte buffer in the caller's address space.  The
+   result will be dumped in there and is guaranteed to be zero
+   terminated.  If no info is found, the first byte is set to zero. */
+#define VALGRIND_MAP_IP_TO_SRCLOC(addr, buf64)                    \
+   {unsigned int _qzz_res;                                        \
+    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                       \
+                               VG_USERREQ__MAP_IP_TO_SRCLOC,      \
+                               addr, buf64, 0, 0, 0);             \
+   }
+
+
+#undef PLAT_x86_linux
+#undef PLAT_amd64_linux
+#undef PLAT_ppc32_linux
+#undef PLAT_ppc64_linux
+#undef PLAT_arm_linux
+#undef PLAT_ppc32_aix5
+#undef PLAT_ppc64_aix5
+
+#endif   /* __VALGRIND_H */
diff --git a/include/vki/vki-amd64-linux.h b/include/vki/vki-amd64-linux.h
new file mode 100644
index 0000000..de3fd41
--- /dev/null
+++ b/include/vki/vki-amd64-linux.h
@@ -0,0 +1,671 @@
+
+/*--------------------------------------------------------------------*/
+/*--- AMD64/Linux-specific kernel interface.     vki-amd64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_AMD64_LINUX_H
+#define __VKI_AMD64_LINUX_H
+
+// AMD64 is little-endian.
+#define VKI_LITTLE_ENDIAN  1
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/types.h
+//----------------------------------------------------------------------
+
+typedef unsigned char __vki_u8;
+
+typedef __signed__ short __vki_s16;
+typedef unsigned short __vki_u16;
+
+typedef __signed__ int __vki_s32;
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long long __vki_s64;
+typedef unsigned long long __vki_u64;
+
+typedef unsigned short vki_u16;
+
+typedef unsigned int vki_u32;
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/page.h
+//----------------------------------------------------------------------
+
+#define VKI_PAGE_SHIFT	12
+#define VKI_PAGE_SIZE	(1UL << VKI_PAGE_SHIFT)
+#define VKI_MAX_PAGE_SHIFT	VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE	VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
+//----------------------------------------------------------------------
+
+#define VKI_SHMLBA  VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/signal.h
+//----------------------------------------------------------------------
+
+#define _VKI_NSIG	64
+#define _VKI_NSIG_BPW	64
+#define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
+
+typedef struct {
+	unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#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_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
+
+#define VKI_SIGRTMIN		32
+#define VKI_SIGRTMAX		_VKI_NSIG
+
+#define VKI_SA_NOCLDSTOP	0x00000001
+#define VKI_SA_NOCLDWAIT	0x00000002
+#define VKI_SA_SIGINFO		0x00000004
+#define VKI_SA_ONSTACK		0x08000000
+#define VKI_SA_RESTART		0x10000000
+#define VKI_SA_NODEFER		0x40000000
+#define VKI_SA_RESETHAND	0x80000000
+
+#define VKI_SA_NOMASK	VKI_SA_NODEFER
+#define VKI_SA_ONESHOT	VKI_SA_RESETHAND
+
+#define VKI_SA_RESTORER	0x04000000
+
+#define VKI_SS_ONSTACK	1
+#define VKI_SS_DISABLE	2
+
+#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 */
+
+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 */
+
+struct vki_sigaction_base {
+        // [[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 */
+};
+
+/* On Linux we use the same type for passing sigactions to
+   and from the kernel.  Hence: */
+typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
+typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
+
+
+typedef struct vki_sigaltstack {
+	void __user *ss_sp;
+	int ss_flags;
+	vki_size_t ss_size;
+} vki_stack_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/sigcontext.h
+//----------------------------------------------------------------------
+
+struct _vki_fpstate {
+	__vki_u16	cwd;
+	__vki_u16	swd;
+	__vki_u16	twd;	/* Note this is not the same as the 32bit/x87/FSAVE twd */
+	__vki_u16	fop;
+	__vki_u64	rip;
+	__vki_u64	rdp; 
+	__vki_u32	mxcsr;
+	__vki_u32	mxcsr_mask;
+	__vki_u32	st_space[32];	/* 8*16 bytes for each FP-reg */
+	__vki_u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg  */
+	__vki_u32	reserved2[24];
+};
+
+struct vki_sigcontext { 
+	unsigned long r8;
+	unsigned long r9;
+	unsigned long r10;
+	unsigned long r11;
+	unsigned long r12;
+	unsigned long r13;
+	unsigned long r14;
+	unsigned long r15;
+	unsigned long rdi;
+	unsigned long rsi;
+	unsigned long rbp;
+	unsigned long rbx;
+	unsigned long rdx;
+	unsigned long rax;
+	unsigned long rcx;
+	unsigned long rsp;
+	unsigned long rip;
+	unsigned long eflags;		/* RFLAGS */
+	unsigned short cs;
+	unsigned short gs;
+	unsigned short fs;
+	unsigned short __pad0; 
+	unsigned long err;
+	unsigned long trapno;
+	unsigned long oldmask;
+	unsigned long cr2;
+	struct _vki_fpstate __user *fpstate;	/* zero when no FPU context */
+	unsigned long reserved1[8];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/mman.h
+//----------------------------------------------------------------------
+
+#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_PROT_NONE	0x0		/* page can not be accessed */
+#define VKI_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
+#define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
+
+#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_ANONYMOUS	0x20	/* don't use a file */
+#define VKI_MAP_NORESERVE       0x4000  /* don't check for reservations */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/fcntl.h
+//----------------------------------------------------------------------
+
+#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_LARGEFILE	0100000
+
+#define VKI_AT_FDCWD            -100
+
+#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_SETOWN		8	/*  for sockets. */
+#define VKI_F_GETOWN		9	/*  for sockets. */
+#define VKI_F_SETSIG		10	/*  for sockets. */
+#define VKI_F_GETSIG		11	/*  for sockets. */
+
+#define VKI_FD_CLOEXEC	1	/* actually anything with low bit set goes */
+
+#define VKI_F_LINUX_SPECIFIC_BASE	1024
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/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.9/include/asm-x86_64/socket.h
+//----------------------------------------------------------------------
+
+#define VKI_SOL_SOCKET	1
+
+#define VKI_SO_TYPE	3
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/sockios.h
+//----------------------------------------------------------------------
+
+#define VKI_SIOCSPGRP		0x8902
+#define VKI_SIOCGPGRP		0x8904
+#define VKI_SIOCGSTAMP		0x8906		/* Get stamp (timeval) */
+#define VKI_SIOCGSTAMPNS	0x8907		/* Get stamp (timespec) */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/stat.h
+//----------------------------------------------------------------------
+
+struct vki_stat {
+	unsigned long	st_dev;
+	unsigned long	st_ino;
+	unsigned long	st_nlink;
+
+	unsigned int	st_mode;
+	unsigned int	st_uid;
+	unsigned int	st_gid;
+	unsigned int	__pad0;
+	unsigned long	st_rdev;
+	long		st_size;
+	long		st_blksize;
+	long		st_blocks;	/* Number 512-byte blocks allocated. */
+
+	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;
+  	long		__unused[3];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/statfs.h
+//----------------------------------------------------------------------
+
+struct vki_statfs {
+	long f_type;
+	long f_bsize;
+	long f_blocks;
+	long f_bfree;
+	long f_bavail;
+	long f_files;
+	long f_ffree;
+	__vki_kernel_fsid_t f_fsid;
+	long f_namelen;
+	long f_frsize;
+	long f_spare[5];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/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.9/include/asm-x86_64/termbits.h
+//----------------------------------------------------------------------
+
+typedef unsigned char	vki_cc_t;
+typedef unsigned int	vki_tcflag_t;
+
+#define VKI_NCCS 19
+struct vki_termios {
+	vki_tcflag_t c_iflag;		/* input mode flags */
+	vki_tcflag_t c_oflag;		/* output mode flags */
+	vki_tcflag_t c_cflag;		/* control mode flags */
+	vki_tcflag_t c_lflag;		/* local mode flags */
+	vki_cc_t c_line;		/* line discipline */
+	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
+};
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/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))
+
+#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),sizeof(size))
+#define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size))
+#define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size))
+
+#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.9/include/asm-x86_64/ioctls.h
+//----------------------------------------------------------------------
+
+#define VKI_TCGETS	0x5401
+#define VKI_TCSETS	0x5402
+#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_TIOCMGET	0x5415
+#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
+#define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
+
+#define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/poll.h
+//----------------------------------------------------------------------
+
+#define VKI_POLLIN		0x0001
+
+struct vki_pollfd {
+	int fd;
+	short events;
+	short revents;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/user.h
+//----------------------------------------------------------------------
+
+struct vki_user_i387_struct {
+	unsigned short	cwd;
+	unsigned short	swd;
+	unsigned short	twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
+	unsigned short	fop;
+	__vki_u64	rip;
+	__vki_u64	rdp;
+	__vki_u32	mxcsr;
+	__vki_u32	mxcsr_mask;
+	__vki_u32	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
+	__vki_u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg = 256 bytes */
+	__vki_u32	padding[24];
+};
+
+struct vki_user_regs_struct {
+	unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10;
+	unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax;
+	unsigned long rip,cs,eflags;
+	unsigned long rsp,ss;
+  	unsigned long fs_base, gs_base;
+	unsigned long ds,es,fs,gs; 
+}; 
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/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;
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/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.9/include/asm-x86_64/segment.h
+//----------------------------------------------------------------------
+
+#define VKI_GDT_ENTRY_TLS_ENTRIES 3
+
+#define VKI_GDT_ENTRY_TLS_MIN 11
+#define VKI_GDT_ENTRY_TLS_MAX 13
+
+//----------------------------------------------------------------------
+// From linux-2.6.11.9/include/asm-x86_64/prctl.h
+//----------------------------------------------------------------------
+
+#define VKI_ARCH_SET_GS 0x1001
+#define VKI_ARCH_SET_FS 0x1002
+#define VKI_ARCH_GET_FS 0x1003
+#define VKI_ARCH_GET_GS 0x1004
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/ldt.h
+//----------------------------------------------------------------------
+
+// I think this LDT stuff will have to be reinstated for amd64, but I'm not
+// certain.  (Nb: The sys_arch_prctl seems to have replaced
+// [gs]et_thread_area syscalls.)
+//
+// Note that the type here is very slightly different to the
+// type for x86 (the final 'lm' field is added);  I'm not sure about the
+// significance of that... --njn
+
+#if 0
+/* [[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;
+        unsigned int  lm:1;
+};
+
+// [[Nb: for our convenience within Valgrind, use a more specific name]]
+typedef struct vki_user_desc vki_modify_ldt_t;
+#endif
+
+typedef void vki_modify_ldt_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.11.2/include/asm-x86_64/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.11.2/include/asm-x86_64/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.11.2/include/asm-x86_64/msgbuf.h
+//----------------------------------------------------------------------
+
+struct vki_msqid64_ds {
+	struct vki_ipc64_perm msg_perm;
+	__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_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.11.2/include/asm-x86_64/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 */
+	__vki_kernel_time_t	shm_dtime;	/* last detach time */
+	__vki_kernel_time_t	shm_ctime;	/* last change time */
+	__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.12.2/include/asm-x86_64/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PTRACE_GETREGS            12
+#define VKI_PTRACE_SETREGS            13
+#define VKI_PTRACE_GETFPREGS          14
+#define VKI_PTRACE_SETFPREGS          15
+
+//----------------------------------------------------------------------
+// And that's it!
+//----------------------------------------------------------------------
+
+#endif // __VKI_AMD64_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-arm-linux.h b/include/vki/vki-arm-linux.h
new file mode 100644
index 0000000..678e268
--- /dev/null
+++ b/include/vki/vki-arm-linux.h
@@ -0,0 +1,893 @@
+
+/*--------------------------------------------------------------------*/
+/*--- arm/Linux-specific kernel interface.         vki-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2008 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 __VKI_ARM_LINUX_H
+#define __VKI_ARM_LINUX_H
+
+// arm 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 __signed__ int __vki_s32;
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long long __vki_s64;
+typedef unsigned long long __vki_u64;
+
+typedef unsigned short vki_u16;
+
+typedef unsigned int vki_u32;
+
+//----------------------------------------------------------------------
+// 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)
+#define VKI_MAX_PAGE_SHIFT	VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE	VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/arm/include/asm/shmparam.h
+//----------------------------------------------------------------------
+
+#define VKI_SHMLBA  (4 * VKI_PAGE_SIZE)
+
+//----------------------------------------------------------------------
+// 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 */
+
+#define _VKI_NSIG	64
+#define _VKI_NSIG_BPW	32
+#define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
+
+typedef struct {
+	unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#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_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_old_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;
+        vki_old_sigset_t sa_mask;
+        unsigned long sa_flags;
+        __vki_sigrestore_t sa_restorer;
+};
+
+struct vki_sigaction_base {
+        // [[See comment about extra 'k' above]]
+	__vki_sighandler_t ksa_handler;
+	unsigned long sa_flags;
+	__vki_sigrestore_t sa_restorer;
+	vki_sigset_t sa_mask;		/* mask last for extensibility */
+};
+
+/* On Linux we use the same type for passing sigactions to
+   and from the kernel.  Hence: */
+typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
+typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
+
+
+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 long trap_no;
+		unsigned long error_code;
+		unsigned long oldmask;
+		unsigned long arm_r0;
+		unsigned long arm_r1;
+		unsigned long arm_r2;
+		unsigned long arm_r3;
+		unsigned long arm_r4;
+		unsigned long arm_r5;
+		unsigned long arm_r6;
+		unsigned long arm_r7;
+		unsigned long arm_r8;
+		unsigned long arm_r9;
+		unsigned long arm_r10;
+		unsigned long arm_fp;
+		unsigned long arm_ip;
+		unsigned long arm_sp;
+		unsigned long arm_lr;
+		unsigned long arm_pc;
+		unsigned long arm_cpsr;
+		unsigned long fault_address;
+};
+
+//----------------------------------------------------------------------
+// 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_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
+#define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
+
+#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 */
+#define VKI_MAP_NORESERVE	0x4000		/* don't check for reservations */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/fcntl.h
+//----------------------------------------------------------------------
+
+#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_LARGEFILE	0100000
+
+#define VKI_AT_FDCWD            -100
+
+#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_SETOWN		8	/*  for sockets. */
+#define VKI_F_GETOWN		9	/*  for sockets. */
+#define VKI_F_SETSIG		10	/*  for sockets. */
+#define VKI_F_GETSIG		11	/*  for sockets. */
+
+#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_F_LINUX_SPECIFIC_BASE	1024
+
+//----------------------------------------------------------------------
+// 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
+
+//----------------------------------------------------------------------
+// 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 (timeval) */
+#define VKI_SIOCGSTAMPNS        0x8907      /* Get stamp (timespec) */
+
+//----------------------------------------------------------------------
+// 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
+//----------------------------------------------------------------------
+
+// [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
+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
+//----------------------------------------------------------------------
+
+typedef unsigned char   vki_cc_t;
+typedef unsigned int    vki_tcflag_t;
+
+#define VKI_NCCS 19
+struct vki_termios {
+	vki_tcflag_t c_iflag;		/* input mode flags */
+	vki_tcflag_t c_oflag;		/* output mode flags */
+	vki_tcflag_t c_cflag;		/* control mode flags */
+	vki_tcflag_t c_lflag;		/* local mode flags */
+	vki_cc_t c_line;		/* line discipline */
+	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
+};
+
+//----------------------------------------------------------------------
+// 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_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
+#define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
+#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))
+
+/* 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_TYPE(nr)	(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
+#define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
+#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_TIOCMGET	0x5415
+#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
+#define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
+
+#define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
+
+//----------------------------------------------------------------------
+// From asm-generic/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];
+};
+
+struct vki_user_regs_struct {
+    long uregs[18];
+};
+#define ARM_cpsr	uregs[16]
+#define ARM_pc		uregs[15]
+#define ARM_lr		uregs[14]
+#define ARM_sp		uregs[13]
+#define ARM_ip		uregs[12]
+#define ARM_fp		uregs[11]
+#define ARM_r10		uregs[10]
+#define ARM_r9		uregs[9]
+#define ARM_r8		uregs[8]
+#define ARM_r7		uregs[7]
+#define ARM_r6		uregs[6]
+#define ARM_r5		uregs[5]
+#define ARM_r4		uregs[4]
+#define ARM_r3		uregs[3]
+#define ARM_r2		uregs[2]
+#define ARM_r1		uregs[1]
+#define ARM_r0		uregs[0]
+#define ARM_ORIG_r0	uregs[17]
+//----------------------------------------------------------------------
+// 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 */
+	int               __unused[32 - (sizeof (vki_sigset_t) / sizeof (int))];
+	unsigned long     uc_regspace[128] __attribute__((__aligned__(8)));
+
+};
+
+//----------------------------------------------------------------------
+// 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;
+};
+
+#define VKI_SEMOP		 1
+#define VKI_SEMGET		 2
+#define VKI_SEMCTL		 3
+#define VKI_SEMTIMEDOP	 	 4
+#define VKI_MSGSND		11
+#define VKI_MSGRCV		12
+#define VKI_MSGGET		13
+#define VKI_MSGCTL		14
+#define VKI_SHMAT		21
+#define VKI_SHMDT		22
+#define VKI_SHMGET		23
+#define VKI_SHMCTL		24
+
+//----------------------------------------------------------------------
+// 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;
+};
+
+//----------------------------------------------------------------------
+// DRM ioctls
+//----------------------------------------------------------------------
+
+// jrs 20050207: where did all this stuff come from?  Is it really
+// i386 specific, or should it go into the linux-generic category?
+//struct vki_drm_buf_pub {
+//	Int		  idx;	       /**< Index into the master buffer list */
+//	Int		  total;       /**< Buffer size */
+//	Int		  used;	       /**< Amount of buffer in use (for DMA) */
+//	void	  __user *address;     /**< Address of buffer */
+//};
+//
+//struct vki_drm_buf_map {
+//	Int	      count;		/**< Length of the buffer list */
+//	void	      __user *virtual;	/**< Mmap'd area in user-virtual */
+//	struct vki_drm_buf_pub __user *list;	/**< Buffer information */
+//};
+//
+///* We need to pay attention to this, because it mmaps memory */
+//#define VKI_DRM_IOCTL_MAP_BUFS		_VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-i386/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PTRACE_GETREGS            12
+#define VKI_PTRACE_SETREGS            13
+#define VKI_PTRACE_GETFPREGS          14
+#define VKI_PTRACE_SETFPREGS          15
+#define VKI_PTRACE_GETFPXREGS         18
+#define VKI_PTRACE_SETFPXREGS         19
+
+//----------------------------------------------------------------------
+// From linux-2.6.15.4/include/asm-i386/vm86.h
+//----------------------------------------------------------------------
+
+#define VKI_VM86_PLUS_INSTALL_CHECK	0
+#define VKI_VM86_ENTER			1
+#define VKI_VM86_ENTER_NO_BYPASS	2
+#define	VKI_VM86_REQUEST_IRQ		3
+#define VKI_VM86_FREE_IRQ		4
+#define VKI_VM86_GET_IRQ_BITS		5
+#define VKI_VM86_GET_AND_RESET_IRQ	6
+
+struct vki_vm86_regs {
+/*
+ * normal regs, with special meaning for the segment descriptors..
+ */
+	long ebx;
+	long ecx;
+	long edx;
+	long esi;
+	long edi;
+	long ebp;
+	long eax;
+	long __null_ds;
+	long __null_es;
+	long __null_fs;
+	long __null_gs;
+	long orig_eax;
+	long eip;
+	unsigned short cs, __csh;
+	long eflags;
+	long esp;
+	unsigned short ss, __ssh;
+/*
+ * these are specific to v86 mode:
+ */
+	unsigned short es, __esh;
+	unsigned short ds, __dsh;
+	unsigned short fs, __fsh;
+	unsigned short gs, __gsh;
+};
+
+struct vki_revectored_struct {
+	unsigned long __map[8];			/* 256 bits */
+};
+
+struct vki_vm86_struct {
+	struct vki_vm86_regs regs;
+	unsigned long flags;
+	unsigned long screen_bitmap;
+	unsigned long cpu_type;
+	struct vki_revectored_struct int_revectored;
+	struct vki_revectored_struct int21_revectored;
+};
+
+struct vki_vm86plus_info_struct {
+	unsigned long force_return_for_pic:1;
+	unsigned long vm86dbg_active:1;       /* for debugger */
+	unsigned long vm86dbg_TFpendig:1;     /* for debugger */
+	unsigned long unused:28;
+	unsigned long is_vm86pus:1;	      /* for vm86 internal use */
+	unsigned char vm86dbg_intxxtab[32];   /* for debugger */
+};
+
+struct vki_vm86plus_struct {
+	struct vki_vm86_regs regs;
+	unsigned long flags;
+	unsigned long screen_bitmap;
+	unsigned long cpu_type;
+	struct vki_revectored_struct int_revectored;
+	struct vki_revectored_struct int21_revectored;
+	struct vki_vm86plus_info_struct vm86plus;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/arm/include/asm/hwcap.h
+//----------------------------------------------------------------------
+
+#define VKI_HWCAP_NEON      4096
+
+//----------------------------------------------------------------------
+// And that's it!
+//----------------------------------------------------------------------
+
+#endif // __VKI_ARM_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                          vki-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h
new file mode 100644
index 0000000..e4d28d7
--- /dev/null
+++ b/include/vki/vki-darwin.h
@@ -0,0 +1,1048 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Darwin-specific kernel interface.               vki-darwin.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2007-2010 Apple Inc.
+      Greg Parker  gparker@apple.com
+
+   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.
+*/
+
+/* Unlike vki-linux, this Darwin kernel interface includes system headers
+   directly, to avoid copyright complexity. */
+
+#ifndef __VKI_DARWIN_H
+#define __VKI_DARWIN_H
+
+#include <stdint.h>
+
+#define vki_int8_t int8_t
+#define vki_uint8_t uint8_t
+#define vki_int16_t int16_t
+#define vki_uint16_t uint16_t
+#define vki_int32_t int32_t
+#define vki_uint32_t uint32_t
+#define vki_int64_t int64_t
+#define vki_uint64_t uint64_t
+#define vki_intptr_t intptr_t
+#define vki_uintptr_t uintptr_t
+
+#include <sys/types.h>
+
+#define vki_dev_t dev_t
+#define vki_mode_t mode_t
+#define vki_ino_t ino_t
+#define vki_ino64_t ino64_t
+#define vki_nlink_t nlink_t
+#define vki_uid_t uid_t
+#define vki_gid_t gid_t
+#define vki_time_t time_t
+#define vki_off_t off_t
+#define vki_blkcnt_t blkcnt_t
+#define vki_blksize_t blksize_t
+#define vki_size_t size_t
+#define vki_ssize_t ssize_t
+#define vki_pid_t pid_t
+#define vki_socklen_t socklen_t
+#define vki_suseconds_t suseconds_t
+#define vki_caddr_t caddr_t
+#define vki_u_long u_long
+#define vki_u_short u_short
+#define vki_clock_t clock_t
+#define vki_u_int32_t u_int32_t
+#define vki_u_int16_t u_int16_t
+#define vki_pthread_t pthread_t
+
+
+// valgrind special
+
+// magic mmap() flags
+#define	VKI_MAP_ANONYMOUS MAP_ANON	// linux synonym
+
+// fds for mmap(MAP_ANON), displayed by vmmap
+#define VM_TAG_VALGRIND VM_MAKE_TAG(239)  // SkAnonV
+
+// page sizes
+#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
+
+// types
+typedef uint32_t vki_u32;
+
+// linux-like ioctl flags
+#define _VKI_IOC_DIR(x)		((x) & IOC_DIRMASK)
+#define _VKI_IOC_SIZE(x)	IOCPARM_LEN(x)
+#define _VKI_IOC_NONE		IOC_VOID  /* GrP fixme correct? */
+#define _VKI_IOC_READ		IOC_OUT
+#define _VKI_IOC_WRITE		IOC_IN
+
+
+#include <malloc/malloc.h>
+
+#define vki_malloc_zone_t malloc_zone_t
+
+
+#include <sys/time.h>
+
+#define vki_timeval timeval
+#define vki_timeval32 timeval32
+#define vki_timespec timespec
+#define vki_itimerval itimerval
+#define vki_timezone timezone
+
+
+#include <sys/stat.h>
+
+#define	VKI_S_ISBLK(m)	S_ISBLK(m)
+#define	VKI_S_ISCHR(m)	S_ISCHR(m)
+#define	VKI_S_ISDIR(m)	S_ISDIR(m)
+#define	VKI_S_ISFIFO(m)	S_ISFIFO(m)
+#define	VKI_S_ISREG(m)	S_ISREG(m)
+#define	VKI_S_ISLNK(m)	S_ISLNK(m)
+#define	VKI_S_ISSOCK(m)	S_ISSOCK(m)
+#define	VKI_S_ISWHT(m)	S_ISWHT(m)
+#define VKI_S_ISXATTR(m) S_ISXATTR(m)
+
+#define	VKI_S_IRWXU	S_IRWXU
+#define	VKI_S_IRUSR	S_IRUSR
+#define	VKI_S_IWUSR	S_IWUSR
+#define	VKI_S_IXUSR	S_IXUSR
+#define	VKI_S_IRWXG	S_IRWXG
+#define	VKI_S_IRGRP	S_IRGRP
+#define	VKI_S_IWGRP	S_IWGRP
+#define	VKI_S_IXGRP	S_IXGRP
+#define	VKI_S_IRWXO	S_IRWXO
+#define	VKI_S_IROTH	S_IROTH
+#define	VKI_S_IWOTH	S_IWOTH
+#define	VKI_S_IXOTH	S_IXOTH
+#define	VKI_S_ISUID	S_ISUID
+#define	VKI_S_ISGID	S_ISGID
+#define	VKI_S_ISVTX	S_ISVTX
+
+#define vki_stat stat
+#define vki_stat64 stat64
+
+#define st_atime      st_atimespec.tv_sec
+#define st_atime_nsec st_atimespec.tv_nsec
+#define st_mtime      st_mtimespec.tv_sec
+#define st_mtime_nsec st_mtimespec.tv_nsec
+#define st_ctime      st_ctimespec.tv_sec
+#define st_ctime_nsec st_ctimespec.tv_nsec
+
+
+#include <sys/dirent.h>
+
+#define VKI_MAXNAMLEN MAXNAMLEN
+#define vki_dirent dirent
+
+
+#include <sys/socket.h>
+#define	VKI_SOCK_STREAM	SOCK_STREAM
+#define	VKI_SOCK_DGRAM	SOCK_DGRAM
+#define	VKI_SOCK_RAW	SOCK_RAW
+
+#define	VKI_AF_UNIX	AF_UNIX
+#define	VKI_AF_INET	AF_INET
+#define	VKI_AF_INET6	AF_INET6
+
+#define	VKI_SOL_SOCKET	SOL_SOCKET
+
+#define	VKI_SO_REUSEADDR SO_REUSEADDR
+
+#define VKI_SO_SNDBUF	SO_SNDBUF
+#define VKI_SO_RCVBUF	SO_RCVBUF
+#define VKI_SO_SNDLOWAT	SO_SNDLOWAT
+#define VKI_SO_RCVLOWAT	SO_RCVLOWAT
+#define VKI_SO_SNDTIMEO	SO_SNDTIMEO
+#define VKI_SO_RCVTIMEO	SO_RCVTIMEO
+#define	VKI_SO_ERROR	SO_ERROR
+#define	VKI_SO_TYPE	SO_TYPE
+#define VKI_SO_NREAD	SO_NREAD
+#define VKI_SO_NKE	SO_NKE
+#define VKI_SO_NOSIGPIPE	SO_NOSIGPIPE
+#define VKI_SO_NOADDRERR	SO_NOADDRERR
+#define VKI_SO_NWRITE	SO_NWRITE
+#define VKI_SO_LINGER_SEC	SO_LINGER_SEC
+
+#define vki_sa_family_t sa_family_t
+#define vki_sockaddr sockaddr
+#define vki_iovec iovec
+#define vki_msghdr msghdr
+#define vki_cmsghdr cmsghdr
+
+
+#define VKI_CMSG_ALIGN(a) 	ALIGN(a)
+#define	VKI_CMSG_DATA(cmsg)	CMSG_DATA(cmsg)
+#define	VKI_CMSG_FIRSTHDR(mhdr)	CMSG_FIRSTHDR(mhdr)
+#define	VKI_CMSG_NXTHDR(mhdr, cmsg)	CMSG_NXTHDR(mhdr, cmsg)
+
+#define	VKI_SCM_RIGHTS		SCM_RIGHTS
+#define	VKI_SCM_TIMESTAMP	SCM_TIMESTAMP
+#define	VKI_SCM_CREDS		SCM_CREDS
+
+
+#include <sys/un.h>
+
+#define vki_sockaddr_un sockaddr_un
+
+
+#include <netinet/in.h>
+
+#define vki_in_addr_t in_addr_t
+#define vki_in_port_t in_port_t
+#define vki_in_addr in_addr
+#define vki_sockaddr_in sockaddr_in
+
+#define	VKI_INADDR_LOOPBACK	INADDR_LOOPBACK
+
+
+// #include <netinet6/in6.h>
+
+#define vki_in6_addr in6_addr
+#define vki_sockaddr_in6 sockaddr_in6
+
+
+#include <net/if.h>
+
+#define	VKI_IFNAMSIZ	IFNAMSIZ
+
+#define vki_ifdevmtu ifdevmtu
+#define vki_ifreq ifreq
+#define vki_ifr_name 	ifr_name
+#define	vki_ifr_addr	ifr_addr
+#define	vki_ifr_dstaddr	ifr_dstaddr
+#define	vki_ifr_broadaddr	ifr_broadaddr
+#define	vki_ifr_flags	ifr_flags
+#define	vki_ifr_metric	ifr_metric
+#define	vki_ifr_mtu	ifr_mtu
+#define vki_ifr_phys	ifr_phys
+#define vki_ifr_media	ifr_media
+#define	vki_ifr_data	ifr_data
+#define vki_ifr_devmtu	ifr_devmtu
+#define vki_ifr_intval	ifr_intval
+
+#define vki_ifconf ifconf
+#define vki_ifc_buf 	ifc_buf
+#define vki_ifc_req 	ifc_req
+
+
+#include <sys/fcntl.h>
+
+#define	VKI_SEEK_SET	SEEK_SET
+#define	VKI_SEEK_CUR	SEEK_CUR
+#define	VKI_SEEK_END	SEEK_END
+
+#define	VKI_O_RDONLY	O_RDONLY
+#define	VKI_O_WRONLY	O_WRONLY
+#define	VKI_O_RDWR	O_RDWR
+#define	VKI_O_ACCMODE	O_ACCMODE
+#define	VKI_O_NONBLOCK	O_NONBLOCK
+#define	VKI_O_APPEND	O_APPEND
+#define	VKI_O_SYNC	O_SYN
+#define	VKI_O_SHLOCK	O_SHLOCK
+#define	VKI_O_EXLOCK	O_EXLOCK
+#define	VKI_O_ASYNC	O_ASYNC
+#define VKI_O_NOFOLLOW  O_NOFOLLOW
+#define	VKI_O_CREAT	O_CREAT
+#define	VKI_O_TRUNC	O_TRUNC
+#define	VKI_O_EXCL	O_EXCL
+#define	VKI_O_EVTONLY	O_EVTONLY
+
+#define	VKI_F_DUPFD	F_DUPFD
+#define	VKI_F_GETFD	F_GETFD
+#define	VKI_F_SETFD	F_SETFD
+#define	VKI_F_GETFL	F_GETFL
+#define	VKI_F_SETFL	F_SETFL
+#define	VKI_F_GETOWN	F_GETOWN
+#define VKI_F_SETOWN	F_SETOWN
+#define	VKI_F_GETLK	F_GETLK
+#define	VKI_F_SETLK	F_SETLK
+#define	VKI_F_SETLKW	F_SETLKW
+
+#define VKI_F_CHKCLEAN	F_CHKCLEAN
+#define VKI_F_PREALLOCATE	F_PREALLOCATE
+#define VKI_F_SETSIZE	F_SETSIZE
+#define VKI_F_RDADVISE	F_RDADVISE
+#define VKI_F_RDAHEAD	F_RDAHEAD
+#define VKI_F_READBOOTSTRAP	F_READBOOTSTRAP
+#define VKI_F_WRITEBOOTSTRAP	F_WRITEBOOTSTRAP
+#define VKI_F_NOCACHE	F_NOCACHE
+#define VKI_F_LOG2PHYS	F_LOG2PHYS
+#define VKI_F_GETPATH	F_GETPATH
+#define VKI_F_ADDSIGS	F_ADDSIGS
+#define VKI_F_FULLFSYNC	F_FULLFSYNC
+#define VKI_F_PATHPKG_CHECK	F_PATHPKG_CHECK
+#define VKI_F_FREEZE_FS	F_FREEZE_FS
+#define VKI_F_THAW_FS	F_THAW_FS
+#define	VKI_F_GLOBAL_NOCACHE	F_GLOBAL_NOCACHE
+
+#define VKI_FD_CLOEXEC	FD_CLOEXEC
+
+#define vki_radvisory radvisory
+#define vki_fstore fstore
+#define vki_fbootstraptransfer fbootstraptransfer
+#define vki_log2phys log2phys
+#define vki_fsignatures_t fsignatures_t
+
+// These constants aren't in a standard header, they are from the kernel code:
+// xnu-1228.3.13/bsd/sys/codesign.h
+// Mac OS X 10.5.6 - Darwin 9.6
+#define VKI_CS_OPS_STATUS           0       /* return status */
+#define VKI_CS_OPS_MARKINVALID      1       /* invalidate process */
+#define VKI_CS_OPS_MARKHARD         2       /* set HARD flag */
+#define VKI_CS_OPS_MARKKILL         3       /* set KILL flag (sticky) */
+#define VKI_CS_OPS_PIDPATH          4       /* get executable's pathname */
+#define VKI_CS_OPS_CDHASH           5       /* get code directory hash */
+
+#include <sys/mman.h>
+
+#define	VKI_PROT_NONE	PROT_NONE
+#define	VKI_PROT_READ	PROT_READ
+#define	VKI_PROT_WRITE	PROT_WRITE
+#define	VKI_PROT_EXEC	PROT_EXEC
+
+#define	VKI_MAP_SHARED	MAP_SHARED
+#define	VKI_MAP_PRIVATE	MAP_PRIVATE
+#define	VKI_MAP_FIXED	MAP_FIXED
+#define	VKI_MAP_RENAME	MAP_RENAME
+#define	VKI_MAP_NORESERVE	MAP_NORESERVE
+#define	VKI_MAP_RESERVED0080	MAP_RESERVED0080
+#define	VKI_MAP_NOEXTEND	MAP_NOEXTEND
+#define	VKI_MAP_HASSEMAPHORE	MAP_HASSEMAPHORE
+#define	VKI_MAP_FILE	MAP_FILE
+#define	VKI_MAP_ANON	MAP_ANON
+#define VKI_MAP_FAILED	MAP_FAILED
+
+
+#include <mach/vm_param.h>
+
+#define VKI_PAGE_SHIFT PAGE_SHIFT
+#define VKI_PAGE_SIZE PAGE_SIZE
+#define VKI_PAGE_MASK PAGE_MASK
+
+
+#include <sys/vmparam.h>
+
+#define VKI_USRSTACK USRSTACK
+#define VKI_USRSTACK64 USRSTACK64
+
+
+#include <mach/mach_time.h>
+
+#define vki_mach_timebase_info mach_timebase_info
+
+
+#include <sys/syslimits.h>
+
+#define VKI_PATH_MAX PATH_MAX
+
+
+#include <sys/param.h>
+
+#define VKI_MAXPATHLEN MAXPATHLEN
+
+
+#include <sys/signal.h>
+
+/* While we fully intend to make 'vki_sigset_t' match the native
+   Darwin 'sigset_t', we can't just clone the Darwin sigset_t type,
+   because it isn't an array, and the VG_(sigfillset) etc functions
+   assume it is.  So instead define another isomorphic type, and check
+   in VG_(vki_do_initial_consistency_checks) that it really is
+   correct. */
+/* #define vki_sigset_t sigset_t */
+#define _VKI_NSIG_BPW   32
+#define _VKI_NSIG       32
+#define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
+typedef struct {
+   UInt sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+/* and now let VG_(vki_do_initial_consistency_checks) make sure it
+   matches 'sigset_t'. */
+
+
+#define VKI_SS_ONSTACK	SS_ONSTACK
+#define	VKI_SS_DISABLE	SS_DISABLE
+#define	VKI_MINSIGSTKSZ	MINSIGSTKSZ
+#define	VKI_SIGSTKSZ	SIGSTKSZ
+
+#define vki_stack_t        stack_t
+#define vki_siginfo_t      siginfo_t
+
+/* There are two versions of this.  'struct __sigaction' is used for
+   passing sigactions to the kernel interface, and has the added
+   complexity of requiring an extra pointer to a new demultiplexing
+   function to be run in user space.  'struct sigaction' is used for
+   receiving old sigactions from the kernel, and lacks this
+   demux-function pointer.  So the type of the second and third
+   parameters in Darwin's sys_sigaction appear to be different,
+   respectively 'struct __sigaction*' and 'struct sigaction*'.
+*/
+//#define vki_sigaction      __sigaction
+//#define vki_user_sigaction sigaction
+//#define vki_sigaltstack    sigaltstack
+//#define vki_sigval         sigval
+//#define vki_sigaction_u    sigaction_u
+//#define vki_sigaction     sigaction
+
+//typedef  struct __sigaction  vki_sigaction_toK_t;
+//typedef  struct sigaction    vki_sigaction_fromK_t;
+
+typedef
+   struct {
+      void* ksa_handler;
+      void (*sa_tramp)(void*,UWord,UWord,void*,void*);
+      vki_sigset_t sa_mask;
+      int sa_flags;
+   }
+   vki_sigaction_toK_t;
+
+typedef
+   struct {
+      void* ksa_handler;
+      vki_sigset_t sa_mask;
+      int sa_flags;
+   }
+   vki_sigaction_fromK_t;
+
+
+
+/* and /usr/include/sys/signal.c in turn defines 'sa_handler' to
+   be '__sigaction_u.__sa_handler' */
+//#define	ksa_handler      sa_handler
+
+//#define	vki_sa_sigaction sa_sigaction
+
+#define VKI_SA_ONSTACK	SA_ONSTACK
+#define VKI_SA_RESTART	SA_RESTART
+#define	VKI_SA_DISABLE	SA_DISABLE
+#define	VKI_SA_RESETHAND	SA_RESETHAND
+#define VKI_SA_NOCLDSTOP	SA_NOCLDSTOP
+#define	VKI_SA_NODEFER	SA_NODEFER
+#define	VKI_SA_NOCLDWAIT	SA_NOCLDWAIT
+#define	VKI_SA_SIGINFO	SA_SIGINFO
+#define	VKI_SA_USERTRAMP	SA_USERTRAMP
+#define	VKI_SA_64REGSET	SA_64REGSET
+#define VKI_SA_RESTORER  0 /* Darwin doesn't have this */
+
+#define	VKI_SIG_BLOCK	SIG_BLOCK
+#define	VKI_SIG_UNBLOCK	SIG_UNBLOCK
+#define	VKI_SIG_SETMASK	SIG_SETMASK
+
+#define	VKI_SIGHUP	SIGHUP
+#define	VKI_SIGINT	SIGINT
+#define	VKI_SIGQUIT	SIGQUIT
+#define	VKI_SIGILL	SIGILL
+#define	VKI_SIGTRAP	SIGTRAP
+#define	VKI_SIGABRT	SIGABRT
+#define	VKI_SIGPOLL	SIGPOLL
+#define	VKI_SIGFPE	SIGFPE
+#define	VKI_SIGKILL	SIGKILL
+#define	VKI_SIGBUS	SIGBUS
+#define	VKI_SIGSEGV	SIGSEGV
+#define	VKI_SIGSYS	SIGSYS
+#define	VKI_SIGPIPE	SIGPIPE
+#define	VKI_SIGALRM	SIGALRM
+#define	VKI_SIGTERM	SIGTERM
+#define	VKI_SIGURG	SIGURG
+#define	VKI_SIGSTOP	SIGSTOP
+#define	VKI_SIGTSTP	SIGTSTP
+#define	VKI_SIGCONT	SIGCONT
+#define	VKI_SIGCHLD	SIGCHLD
+#define	VKI_SIGTTIN	SIGTTIN
+#define	VKI_SIGTTOU	SIGTTOU
+#define	VKI_SIGIO	SIGIO
+#define	VKI_SIGXCPU	SIGXCPU
+#define	VKI_SIGXFSZ	SIGXFSZ
+#define	VKI_SIGVTALRM	SIGVTALRM
+#define	VKI_SIGPROF	SIGPROF
+#define VKI_SIGWINCH	SIGWINCH
+#define VKI_SIGINFO	SIGINFO
+#define VKI_SIGUSR1	SIGUSR1
+#define VKI_SIGUSR2	SIGUSR2
+
+#define VKI_SIG_DFL     SIG_DFL
+#define VKI_SIG_IGN     SIG_IGN
+
+
+#define VKI_SI_USER      SI_USER
+#define VKI_SEGV_MAPERR  SEGV_MAPERR
+#define VKI_SEGV_ACCERR  SEGV_ACCERR
+#define VKI_ILL_ILLOPC   ILL_ILLOPC
+#define VKI_ILL_ILLOPN   ILL_ILLOPN
+#define VKI_ILL_ILLADR   ILL_ILLADR
+#define VKI_ILL_ILLTRP   ILL_ILLTRP
+#define VKI_ILL_PRVOPC   ILL_PRVOPC
+#define VKI_ILL_PRVREG   ILL_PRVREG
+#define VKI_ILL_COPROC   ILL_COPROC
+#define VKI_ILL_BADSTK   ILL_BADSTK
+#define VKI_FPE_INTDIV   FPE_INTDIV
+#define VKI_FPE_INTOVF   FPE_INTOVF
+#define VKI_FPE_FLTDIV   FPE_FLTDIV
+#define VKI_FPE_FLTOVF   FPE_FLTOVF
+#define VKI_FPE_FLTUND   FPE_FLTUND
+#define VKI_FPE_FLTRES   FPE_FLTRES
+#define VKI_FPE_FLTINV   FPE_FLTINV
+#define VKI_FPE_FLTSUB   FPE_FLTSUB
+#define VKI_BUS_ADRALN   BUS_ADRALN
+#define VKI_BUS_ADRERR   BUS_ADRERR
+#define VKI_BUS_OBJERR   BUS_OBJERR
+#define VKI_TRAP_BRKPT   TRAP_BRKPT
+
+/* JRS: not 100% sure, but I think these two are correct */
+#define VKI_SA_ONESHOT   SA_RESETHAND
+#define VKI_SA_NOMASK    SA_NODEFER
+
+#define VKI_UC_SET_ALT_STACK   0x40000000
+#define VKI_UC_RESET_ALT_STACK 0x80000000
+
+
+#include <sys/errno.h>
+
+#define VKI_EPERM		EPERM
+#define VKI_ENOENT		ENOENT
+#define VKI_ESRCH		ESRCH
+#define VKI_EINTR		EINTR
+#define VKI_EIO			EIO
+#define VKI_ENXIO		ENXIO
+#define VKI_E2BIG		E2BIG
+#define VKI_ENOEXEC		ENOEXEC
+#define VKI_EBADF		EBADF
+#define VKI_ECHILD		ECHILD
+#define VKI_EDEADLK		EDEADLK
+#define VKI_ENOMEM		ENOMEM
+#define VKI_EACCES		EACCES
+#define VKI_EFAULT		EFAULT
+#define VKI_ENOTBLK		ENOTBLK
+#define VKI_EBUSY		EBUSY
+#define VKI_EEXIST		EEXIST
+#define VKI_EXDEV		EXDEV
+#define VKI_ENODEV		ENODEV
+#define VKI_ENOTDIR		ENOTDIR
+#define VKI_EISDIR		EISDIR
+#define VKI_EINVAL		EINVAL
+#define VKI_ENFILE		ENFILE
+#define VKI_EMFILE		EMFILE
+#define VKI_ENOTTY		ENOTTY
+#define VKI_ETXTBSY		ETXTBSY
+#define VKI_EFBIG		EFBIG
+#define VKI_ENOSPC		ENOSPC
+#define VKI_ESPIPE		ESPIPE
+#define VKI_EROFS		EROFS
+#define VKI_EMLINK		EMLINK
+#define VKI_EPIPE		EPIPE
+#define VKI_EDOM		EDOM
+#define VKI_ERANGE		ERANGE
+#define VKI_EAGAIN		EAGAIN
+#define VKI_EWOULDBLOCK		EAGAIN
+#define VKI_EINPROGRESS		EINPROGRESS
+#define VKI_EALREADY		EALREADY
+#define VKI_ENOTSOCK		ENOTSOCK
+#define VKI_EDESTADDRREQ	EDESTADDRREQ
+#define VKI_EMSGSIZE		EMSGSIZE
+#define VKI_EPROTOTYPE		EPROTOTYPE
+#define VKI_ENOPROTOOPT		ENOPROTOOPT
+#define VKI_EPROTONOSUPPORT	EPROTONOSUPPORT
+#define VKI_ESOCKTNOSUPPORT	ESOCKTNOSUPPORT
+#define VKI_ENOTSUP		ENOTSUP
+#define VKI_EPFNOSUPPORT	EPFNOSUPPORT
+#define VKI_EAFNOSUPPORT	EAFNOSUPPORT
+#define VKI_EADDRINUSE		EADDRINUSE
+#define VKI_EADDRNOTAVAIL	EADDRNOTAVAIL
+#define VKI_ENETDOWN		ENETDOWN
+#define VKI_ENETUNREACH		ENETUNREACH
+#define VKI_ENETRESET		ENETRESET
+#define VKI_ECONNABORTED	ECONNABORTED
+#define VKI_ECONNRESET		ECONNRESET
+#define VKI_ENOBUFS		ENOBUFS
+#define VKI_EISCONN		EISCONN
+#define VKI_ENOTCONN		ENOTCONN
+#define VKI_ESHUTDOWN		ESHUTDOWN
+#define VKI_ETOOMANYREFS	ETOOMANYREFS
+#define VKI_ETIMEDOUT		ETIMEDOUT
+#define VKI_ECONNREFUSED	ECONNREFUSED
+#define VKI_ELOOP		ELOOP
+#define VKI_ENAMETOOLONG	ENAMETOOLONG
+#define VKI_EHOSTDOWN		EHOSTDOWN
+#define VKI_EHOSTUNREACH	EHOSTUNREACH
+#define VKI_ENOTEMPTY		ENOTEMPTY
+#define VKI_EPROCLIM		EPROCLIM
+#define VKI_EUSERS		EUSERS
+#define VKI_EDQUOT		EDQUOT
+#define VKI_ESTALE		ESTALE
+#define VKI_EREMOTE		EREMOTE
+#define VKI_EBADRPC		EBADRPC
+#define VKI_ERPCMISMATCH	ERPCMISMATCH
+#define VKI_EPROGUNAVAIL	EPROGUNAVAIL
+#define VKI_EPROGMISMATCH	EPROGMISMATCH
+#define VKI_EPROCUNAVAIL	EPROCUNAVAIL
+#define VKI_ENOLCK		ENOLCK
+#define VKI_ENOSYS		ENOSYS
+#define VKI_EFTYPE		EFTYPE
+#define VKI_EAUTH		EAUTH
+#define VKI_ENEEDAUTH		ENEEDAUTH
+#define VKI_EPWROFF		EPWROFF
+#define VKI_EDEVERR		EDEVERR
+#define VKI_EOVERFLOW		EOVERFLOW
+#define VKI_EBADEXEC		EBADEXEC
+#define VKI_EBADARCH		EBADARCH
+#define VKI_ESHLIBVERS		ESHLIBVERS
+#define VKI_EBADMACHO		EBADMACHO
+#define VKI_ECANCELED		ECANCELED
+#define VKI_EIDRM		EIDRM
+#define VKI_ENOMSG		ENOMSG
+#define VKI_EILSEQ		EILSEQ
+#define VKI_ENOATTR		ENOATTR
+#define VKI_EBADMSG		EBADMSG
+#define VKI_EMULTIHOP		EMULTIHOP
+#define VKI_ENODATA		ENODATA
+#define VKI_ENOLINK		ENOLINK
+#define VKI_ENOSR		ENOSR
+#define VKI_ENOSTR		ENOSTR
+#define VKI_EPROTO		EPROTO
+#define VKI_ETIME		ETIME
+#define VKI_EOPNOTSUPP		EOPNOTSUPP
+#define VKI_ELAST		ELAST
+
+
+#include <sys/resource.h>
+
+#define	VKI_RLIMIT_CPU		RLIMIT_CPU
+#define	VKI_RLIMIT_FSIZE	RLIMIT_FSIZE
+#define	VKI_RLIMIT_DATA		RLIMIT_DATA
+#define	VKI_RLIMIT_STACK	RLIMIT_STACK
+#define	VKI_RLIMIT_CORE		RLIMIT_CORE
+#define	VKI_RLIMIT_AS		RLIMIT_AD
+#define	VKI_RLIMIT_RSS		RLIMIT_AS
+#define	VKI_RLIMIT_MEMLOCK	RLIMIT_MEMLOCK
+#define	VKI_RLIMIT_NPROC	RLIMIT_NPROC
+#define	VKI_RLIMIT_NOFILE	RLIMIT_NOFILE
+#define	VKI_RLIM_NLIMITS	RLIM_NLIMITS
+
+#define vki_rlim_t rlim_t
+#define vki_rlimit rlimit
+#define vki_rusage rusage
+
+
+#include <sys/poll.h>
+
+#define vki_pollfd pollfd
+
+
+#include <sys/ipc.h>
+
+#define	VKI_IPC_RMID	IPC_RMID
+#define	VKI_IPC_SET	IPC_SET
+#define	VKI_IPC_STAT	IPC_STAT
+
+#define vki_key_t key_t
+#define vki_ipc_perm ipc_perm
+
+
+#include <sys/sem.h>
+
+#define VKI_GETNCNT	GETNCNT
+#define VKI_GETPID	GETPID
+#define VKI_GETVAL	GETVAL
+#define VKI_GETALL	GETALL
+#define VKI_GETZCNT	GETZCNT
+#define VKI_SETVAL	SETVAL
+#define VKI_SETALL	SETALL
+
+#define vki_sembuf sembuf
+#define vki_semid_ds semid_ds
+#define vki_semun semun
+
+
+#include <sys/semaphore.h>
+
+#define vki_sem_t sem_t
+
+
+#include <sys/mount.h>
+
+#define	VKI_MFSNAMELEN	MFSNAMELEN
+#define	VKI_MNAMELEN	MNAMELEN
+
+#define vki_fsid fsid
+#define vki_fsid_t fsid_t
+#define vki_statfs statfs
+#define vki_statfs64 statfs64
+
+
+#include <sys/select.h>
+
+#define vki_fd_set fd_set
+
+
+#include <sys/msgbuf.h>
+
+#define	VKI_MSG_BSIZE	MSG_BSIZE
+#define VKI_MSG_MAGIC	MSG_MAGIC
+#define vki_msgbuf msgbuf
+
+
+#include <sys/shm.h>
+
+#define VKI_SHM_RDONLY	SHM_RDONLY
+#define VKI_SHM_RND	SHM_RND
+#define VKI_SHMLBA	SHMLBA
+
+#define vki_shmid_ds shmid_ds
+
+
+#include <sys/times.h>
+
+#define vki_tms tms
+
+
+#include <sys/utsname.h>
+
+#define	_VKI_SYS_NAMELEN	_SYS_NAMELEN
+#define vki_new_utsname utsname
+
+
+#include <sys/unistd.h>
+
+#define	VKI_F_OK	F_OK
+#define	VKI_X_OK	X_OK
+#define	VKI_W_OK	W_OK
+#define	VKI_R_OK	R_OK
+
+#define vki_accessx_descriptor         accessx_descriptor
+#define VKI_ACCESSX_MAX_DESCRIPTORS    ACCESSX_MAX_DESCRIPTORS
+
+#include <sys/sysctl.h>
+
+#define VKI_CTL_MAXNAME		CTL_MAXNAME
+
+#define	VKI_CTL_UNSPEC		CTL_UNSPEC
+#define	VKI_CTL_KERN		CTL_KERN
+#define	VKI_CTL_VM		CTL_VM
+#define	VKI_CTL_VFS		CTL_VFS
+#define	VKI_CTL_NET		CTL_NET
+#define	VKI_CTL_DEBUG		CTL_DEBUG
+#define	VKI_CTL_HW		CTL_HW
+#define	VKI_CTL_MACHDEP		CTL_MACHDEP
+#define	VKI_CTL_USER		CTL_USER
+#define	VKI_CTL_MAXID		CTL_MAXID
+
+#define	VKI_HW_MACHINE		HW_MACHINE
+#define	VKI_HW_MODEL		HW_MODEL
+#define	VKI_HW_NCPU		HW_NCPU
+#define	VKI_HW_BYTEORDER	HW_BYTEORDER
+#define	VKI_HW_PHYSMEM		HW_PHYSMEM
+#define	VKI_HW_USERMEM		HW_USERMEM
+#define	VKI_HW_PAGESIZE		HW_PAGESIZE
+#define	VKI_HW_DISKNAMES	HW_DISKNAMES
+#define	VKI_HW_DISKSTATS	HW_DISKSTATS
+#define	VKI_HW_EPOCH  		HW_EPOCH
+#define VKI_HW_FLOATINGPT	HW_FLOATINGPT
+#define VKI_HW_MACHINE_ARCH	HW_MACHINE_ARCH
+#define VKI_HW_VECTORUNIT	HW_VECTORUNIT
+#define VKI_HW_BUS_FREQ		HW_BUS_FREQ
+#define VKI_HW_CPU_FREQ		HW_CPU_FREQ
+#define VKI_HW_CACHELINE	HW_CACHELINE
+#define VKI_HW_L1ICACHESIZE	HW_L1ICACHESIZE
+#define VKI_HW_L1DCACHESIZE	HW_L1DCACHESIZE
+#define VKI_HW_L2SETTINGS	HW_L2SETTINGS
+#define VKI_HW_L2CACHESIZE	HW_L2CACHESIZE
+#define VKI_HW_L3SETTINGS	HW_L3SETTINGS
+#define VKI_HW_L3CACHESIZE	HW_L3CACHESIZE
+#define VKI_HW_TB_FREQ		HW_TB_FREQ
+#define VKI_HW_MEMSIZE		HW_MEMSIZE
+#define VKI_HW_AVAILCPU		MW_AVAILCPU
+#define	VKI_HW_MAXID		MW_MAXID
+
+#define	VKI_KERN_USRSTACK32	KERN_USRSTACK32
+#define	VKI_KERN_USRSTACK64	KERN_USRSTACK64
+
+
+#include <sys/attr.h>
+
+#define vki_attrlist attrlist
+
+
+#include <sys/event.h>
+
+#define vki_kevent kevent
+
+
+#include <sys/ev.h>
+
+typedef struct eventreq vki_eventreq;
+
+
+#include <sys/acl.h>
+
+#define vki_kauth_filesec kauth_filesec
+
+
+#include <sys/ptrace.h>
+
+#define VKI_PTRACE_TRACEME   PT_TRACE_ME
+#define VKI_PTRACE_DETACH    PT_DETACH
+
+
+// sqlite/src/os_unix.c
+
+struct ByteRangeLockPB2
+{
+    unsigned long long offset;        /* offset to first byte to lock */
+    unsigned long long length;        /* nbr of bytes to lock */
+    unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */
+    unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */
+    unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */
+    int fd;                           /* file desc to assoc this lock with */
+};
+
+#define afpfsByteRangeLock2FSCTL _IOWR('z', 23, struct ByteRangeLockPB2)
+
+#define vki_ByteRangeLockPB2 ByteRangeLockPB2
+#define VKI_afpfsByteRangeLock2FSCTL afpfsByteRangeLock2FSCTL
+
+
+// xnu/bsd/sys/fsctl.h
+
+#define VKI_FSIOC_SYNC_VOLUME        _IOW('A', 1, uint32_t)
+
+
+// Libc/pthreads/pthread.c
+
+#define VKI_WQOPS_QUEUE_ADD      1
+#define VKI_WQOPS_QUEUE_REMOVE   2
+#define VKI_WQOPS_THREAD_RETURN  4
+
+
+#include <sys/ttycom.h>
+
+#define vki_winsize winsize
+
+#define	VKI_TIOCMODG	TIOCMODG
+#define	VKI_TIOCMODS	TIOCMODS
+#define	VKI_TIOCEXCL	TIOCEXCL
+#define	VKI_TIOCNXCL	TIOCNXCL
+#define	VKI_TIOCFLUSH	TIOCFLUSH
+#define	VKI_TIOCGETA	TIOCGETA
+#define	VKI_TIOCSETA	TIOCSETA
+#define	VKI_TIOCSETAW	TIOCSETAW
+#define	VKI_TIOCSETAF	TIOCSETAF
+#define	VKI_TIOCGETD	TIOCGETD
+#define	VKI_TIOCSETD	TIOCSETD
+#define	VKI_TIOCSBRK	TIOCSBRK
+#define	VKI_TIOCCBRK	TIOCCBRK
+#define	VKI_TIOCSDTR	TIOCSDTR
+#define	VKI_TIOCCDTR	TIOCCDTR
+#define	VKI_TIOCGPGRP	TIOCGPGRP
+#define	VKI_TIOCSPGRP	TIOCSPGRP
+#define	VKI_TIOCOUTQ	TIOCOUTQ
+#define	VKI_TIOCSTI	TIOCSTI
+#define	VKI_TIOCNOTTY	TIOCNOTTY
+#define	VKI_TIOCPKT	TIOCPKT
+#define	VKI_TIOCSTOP	TIOCSTOP
+#define	VKI_TIOCSTART	TIOCSTART
+#define	VKI_TIOCMSET	TIOCMSET
+#define	VKI_TIOCMBIS	TIOCMBIS
+#define	VKI_TIOCMBIC	TIOCMBIC
+#define	VKI_TIOCMGET	TIOCMGET
+#define	VKI_TIOCREMOTE	TIOCREMOTE
+#define	VKI_TIOCGWINSZ	TIOCGWINSZ
+#define	VKI_TIOCSWINSZ	TIOCSWINSZ
+#define	VKI_TIOCUCNTL	TIOCUCNTL
+#define	VKI_TIOCSTAT	TIOCSTAT
+#define	VKI_UIOCCMD(n)	UIOCCMD(n)
+#define	VKI_TIOCSCONS	TIOCSCONS
+#define	VKI_TIOCCONS	TIOCCONS
+#define	VKI_TIOCSCTTY	TIOCSCTTY
+#define	VKI_TIOCEXT	TIOCEXT
+#define	VKI_TIOCSIG	TIOCSIG
+#define	VKI_TIOCDRAIN	TIOCDRAIN
+#define	VKI_TIOCMSDTRWAIT	TIOCMSDTRWAIT
+#define	VKI_TIOCMGDTRWAIT	TIOCMGDTRWAIT
+#define	VKI_TIOCTIMESTAMP	TIOCTIMESTAMP
+#define	VKI_TIOCDCDTIMESTAMP	TIOCDCDTIMESTAMP
+#define	VKI_TIOCSDRAINWAIT	TIOCSDRAINWAIT
+#define	VKI_TIOCGDRAINWAIT	TIOCGDRAINWAIT
+#define	VKI_TIOCDSIMICROCODE	TIOCDSIMICROCODE
+#define VKI_TIOCPTYGRANT	TIOCPTYGRANT
+#define VKI_TIOCPTYGNAME	TIOCPTYGNAME
+#define VKI_TIOCPTYUNLK	TIOCPTYUNLK
+
+
+#include <sys/filio.h>
+
+#define	VKI_FIOCLEX	FIOCLEX
+#define	VKI_FIONCLEX	FIONCLEX
+#define	VKI_FIONREAD	FIONREAD
+#define	VKI_FIONBIO	FIONBIO
+#define	VKI_FIOASYNC	FIOASYNC
+#define	VKI_FIOSETOWN	FIOSETOWN
+#define	VKI_FIOGETOWN	FIOGETOWN
+#define	VKI_FIODTYPE	FIODTYPE
+
+
+#include <sys/sockio.h>
+
+#define	VKI_SIOCSHIWAT	SIOCSHIWAT
+#define	VKI_SIOCGHIWAT	SIOCGHIWAT
+#define	VKI_SIOCSLOWAT	SIOCSLOWAT
+#define	VKI_SIOCGLOWAT	SIOCGLOWAT
+#define	VKI_SIOCATMARK	SIOCATMARK
+#define	VKI_SIOCSPGRP	SIOCSPGRP
+#define	VKI_SIOCGPGRP	SIOCGPGRP
+
+#define	VKI_SIOCSIFADDR		SIOCSIFADDR
+#define	VKI_OSIOCGIFADDR	OSIOCGIFADDR
+#define	VKI_SIOCSIFDSTADDR	SIOCSIFDSTADDR
+#define	VKI_OSIOCGIFDSTADDR	OSIOCGIFDSTADDR
+#define	VKI_SIOCSIFFLAGS	SIOCSIFFLAGS
+#define	VKI_SIOCGIFFLAGS	SIOCGIFFLAGS
+#define	VKI_OSIOCGIFBRDADDR	OSIOCGIFBRDADDR
+#define	VKI_SIOCSIFBRDADDR	SIOCSIFBRDADDR
+#define	VKI_OSIOCGIFCONF	OSIOCGIFCONF
+#define	VKI_OSIOCGIFNETMASK	OSIOCGIFNETMASK
+#define	VKI_SIOCSIFNETMASK	SIOCSIFNETMASK
+#define	VKI_SIOCGIFMETRIC	SIOCGIFMETRIC
+#define	VKI_SIOCSIFMETRIC	SIOCSIFMETRIC
+#define	VKI_SIOCDIFADDR		SIOCDIFADDR
+#define	VKI_SIOCAIFADDR		SIOCAIFADDR
+#define	VKI_SIOCGETVIFCNT	SIOCGETVIFCNT
+#define	VKI_SIOCGETSGCNT	SIOCGETSGCNT
+#define VKI_SIOCALIFADDR	SIOCALIFADDR
+#define VKI_SIOCGLIFADDR	SIOCGLIFADDR
+#define VKI_SIOCDLIFADDR	SIOCDLIFADDR
+
+#define	VKI_SIOCGIFADDR		SIOCGIFADDR
+#define	VKI_SIOCGIFDSTADDR	SIOCGIFDSTADDR
+#define	VKI_SIOCGIFBRDADDR	SIOCGIFBRDADDR
+#define	VKI_SIOCGIFCONF		SIOCGIFCONF
+#define	VKI_SIOCGIFNETMASK	SIOCGIFNETMASK
+#define VKI_SIOCAUTOADDR	SIOCAUTOADDR
+#define VKI_SIOCAUTONETMASK	SIOCAUTONETMASK
+#define VKI_SIOCARPIPLL		SIOCARPIPLL
+
+#define	VKI_SIOCADDMULTI	SIOCADDMULTI
+#define	VKI_SIOCDELMULTI	SIOCDELMULTI
+#define	VKI_SIOCGIFMTU		SIOCGIFMTU
+#define	VKI_SIOCSIFMTU	 	SIOCSIFMTU
+#define	VKI_SIOCGIFPHYS		SIOCGIFPHYS
+#define	VKI_SIOCSIFPHYS	 	SIOCSIFPHYS
+#define	VKI_SIOCSIFMEDIA	SIOCSIFMEDIA
+#define	VKI_SIOCGIFMEDIA	SIOCGIFMEDIA
+#define	VKI_SIOCSIFGENERIC	SIOCSIFGENERIC
+#define	VKI_SIOCGIFGENERIC	SIOCGIFGENERIC
+#define VKI_SIOCRSLVMULTI   	SIOCRSLVMULTI
+
+#define	VKI_SIOCSIFLLADDR	SIOCSIFLLADDR
+#define	VKI_SIOCGIFSTATUS	SIOCGIFSTATUS
+#define	VKI_SIOCSIFPHYADDR   	SIOCSIFPHYADDR
+#define	VKI_SIOCGIFPSRCADDR	SIOCGIFPSRCADDR
+#define	VKI_SIOCGIFPDSTADDR	SIOCGIFPDSTADDR
+#define	VKI_SIOCDIFPHYADDR	SIOCDIFPHYADDR
+#define	VKI_SIOCSLIFPHYADDR	SIOCSLIFPHYADDR
+#define	VKI_SIOCGLIFPHYADDR	SIOCGLIFPHYADDR
+
+#define	VKI_SIOCGIFDEVMTU	SIOCGIFDEVMTU
+#define	VKI_SIOCSIFALTMTU	SIOCSIFALTMTU
+#define VKI_SIOCGIFALTMTU	SIOCGIFALTMTU
+#define VKI_SIOCSIFBOND	 	SIOCSIFBOND
+#define VKI_SIOCGIFBOND		SIOCGIFBOND
+#define	VKI_SIOCIFCREATE	SIOCIFCREATE
+#define	VKI_SIOCIFDESTROY	SIOCIFDESTROY
+#define	VKI_SIOCSIFVLAN	 	SIOCSIFVLAN
+#define	VKI_SIOCGIFVLAN		SIOCGIFVLAN
+
+#define	VKI_SIOCSETVLAN		SIOCSIFVLAN
+#define	VKI_SIOCGETVLAN		SIOCGIFVLAN
+
+#define	VKI_SIOCGIFASYNCMAP 	SIOCGIFASYNCMAP
+#define	VKI_SIOCSIFASYNCMAP 	SIOCSIGASYNCMAP
+
+
+#include <sys/dtrace.h>
+
+#define VKI_DTRACEHIOC_REMOVE   DTRACEHIOC_REMOVE
+#define VKI_DTRACEHIOC_ADDDOF   DTRACEHIOC_ADDDOF
+
+
+#include <sys/ucontext.h>
+
+/* quite why sys/ucontext.h provides a 'struct __darwin_ucontext'
+   but no 'struct ucontext' beats me. -- JRS */
+#define vki_ucontext __darwin_ucontext
+
+
+#include <sys/termios.h>
+
+#define vki_termios termios
+
+
+#include <uuid/uuid.h>
+
+#define vki_uuid_t uuid_t
+
+
+#include <bsm/audit.h>
+
+#define	VKI_A_GETPOLICY	A_GETPOLICY	
+#define	VKI_A_SETPOLICY	A_SETPOLICY	
+#define	VKI_A_GETKMASK	A_GETKMASK	
+#define	VKI_A_SETKMASK	A_SETKMASK	
+#define	VKI_A_GETQCTRL	A_GETQCTRL	
+#define	VKI_A_SETQCTRL	A_SETQCTRL	
+#define	VKI_A_GETCWD	A_GETCWD	
+#define	VKI_A_GETCAR	A_GETCAR	
+#define	VKI_A_GETSTAT	A_GETSTAT	
+#define	VKI_A_SETSTAT	A_SETSTAT	
+#define	VKI_A_SETUMASK	A_SETUMASK	
+#define	VKI_A_SETSMASK	A_SETSMASK	
+#define	VKI_A_GETCOND	A_GETCOND	
+#define	VKI_A_SETCOND	A_SETCOND	
+#define	VKI_A_GETCLASS	A_GETCLASS	
+#define	VKI_A_SETCLASS	A_SETCLASS	
+#define	VKI_A_GETPINFO	A_GETPINFO	
+#define	VKI_A_SETPMASK	A_SETPMASK	
+#define	VKI_A_SETFSIZE	A_SETFSIZE	
+#define	VKI_A_GETFSIZE	A_GETFSIZE	
+#define	VKI_A_GETPINFO_ADDR	A_GETPINFO_ADDR	
+#define	VKI_A_GETKAUDIT	A_GETKAUDIT	
+#define	VKI_A_SETKAUDIT	A_SETKAUDIT	
+#if DARWIN_VERS >= DARWIN_10_6
+#define VKI_A_SENDTRIGGER A_SENDTRIGGER
+#define VKI_A_GETSINFO_ADDR A_GETSINFO_ADDR
+#endif
+
+
+#include <sys/aio.h>
+
+#define vki_aiocb aiocb
+
+
+// XXX: for some reason when I #include <sys/kernel_types.h> I get a syntax
+// error.  Hmm.  So just define things ourselves.
+//#include <sys/kernel_types.h>
+
+//#define vki_errno_t
+typedef int vki_errno_t;
+
+#endif
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
new file mode 100644
index 0000000..537f0e0
--- /dev/null
+++ b/include/vki/vki-linux.h
@@ -0,0 +1,2724 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Linux-specific kernel interface.                 vki-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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
+   - 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 this file contains all the generic header info, ie. that
+   from linux/include/linux/ *.h.  The arch-specific header info, eg. that
+   from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and
+   vki_posixtypes-$PLATFORM.h.  (Two files are required to avoid
+   circular dependencies between the generic VKI header and the
+   arch-specific VKI header.  It's possible in the future, as more stuff
+   gets pulled in, that we might have to split files up some more to avoid
+   further circular dependencies.)
+   
+   Finally, note that it is assumed that __KERNEL__ is set for all these
+   definitions, which affects some of them.
+*/
+
+/* The structure is (aiui, jrs 20060504):
+
+     #include plat-specific posix types (vki-posixtypes-ARCH-linux.h)
+
+     Lots more types, structs, consts, in this file
+
+     #include other plat-specific stuff (vki-ARCH-linux.h)
+
+     Even more types, structs, consts, in this file
+
+   The system call numbers are dealt with by
+   pub_{core,tool}_vkiscnums.h, not via pub_{core,tool}_vki.h, which
+   is what this file is part of.
+*/
+
+#ifndef __VKI_LINUX_H
+#define __VKI_LINUX_H
+
+//----------------------------------------------------------------------
+// Arch-specific POSIX types
+//----------------------------------------------------------------------
+
+#if defined(VGA_x86)
+#  include "vki-posixtypes-x86-linux.h"
+#elif defined(VGA_amd64)
+#  include "vki-posixtypes-amd64-linux.h"
+#elif defined(VGA_ppc32)
+#  include "vki-posixtypes-ppc32-linux.h"
+#elif defined(VGA_ppc64)
+#  include "vki-posixtypes-ppc64-linux.h"
+#elif defined(VGA_arm)
+#  include "vki-posixtypes-arm-linux.h"
+#else
+#  error Unknown platform
+#endif
+
+//----------------------------------------------------------------------
+// VKI_STATIC_ASSERT(). Inspired by BUILD_BUG_ON() from
+// linux-2.6.34/include/linux/kernel.h
+//----------------------------------------------------------------------
+
+/*
+ * Evaluates to zero if 'expr' is true and forces a compilation error if
+ * 'expr' is false. Can be used in a context where no comma expressions
+ * are allowed.
+ */
+#ifdef __cplusplus
+template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
+#define VKI_STATIC_ASSERT(expr)                         \
+    (sizeof(vki_static_assert<(expr)>) - sizeof(int))
+#else
+#define VKI_STATIC_ASSERT(expr) (sizeof(struct { int:-!(expr); }))
+#endif
+
+//----------------------------------------------------------------------
+// Based on _IOC_TYPECHECK() from linux-2.6.34/asm-generic/ioctl.h
+//----------------------------------------------------------------------
+
+/* provoke compile error for invalid uses of size argument */
+#define _VKI_IOC_TYPECHECK(t)                                           \
+    (VKI_STATIC_ASSERT((sizeof(t) == sizeof(t[1])                       \
+                        && sizeof(t) < (1 << _VKI_IOC_SIZEBITS)))       \
+     + sizeof(t))
+
+//----------------------------------------------------------------------
+// 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
+//----------------------------------------------------------------------
+
+#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 fds_bits [__VKI_FDSET_LONGS];
+} __vki_kernel_fd_set;
+
+typedef int __vki_kernel_key_t;
+typedef int __vki_kernel_mqd_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/linux/types.h
+//----------------------------------------------------------------------
+
+typedef __vki_kernel_fd_set	vki_fd_set;
+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;
+typedef __vki_kernel_clockid_t	vki_clockid_t;
+typedef __vki_kernel_mqd_t	vki_mqd_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_old_uid_t	vki_old_uid_t;
+typedef __vki_kernel_old_gid_t	vki_old_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;
+
+typedef unsigned long           vki_u_long;
+
+typedef unsigned int	        vki_uint;
+
+//----------------------------------------------------------------------
+// Now the rest of the arch-specific stuff
+//----------------------------------------------------------------------
+
+#if defined(VGA_x86)
+#  include "vki-x86-linux.h"
+#elif defined(VGA_amd64)
+#  include "vki-amd64-linux.h"
+#elif defined(VGA_ppc32)
+#  include "vki-ppc32-linux.h"
+#elif defined(VGA_ppc64)
+#  include "vki-ppc64-linux.h"
+#elif defined(VGA_arm)
+#  include "vki-arm-linux.h"
+#else
+#  error Unknown platform
+#endif
+
+//----------------------------------------------------------------------
+// From linux-2.6.20.1/include/linux/types.h
+//----------------------------------------------------------------------
+
+typedef		__vki_s32	vki_int32_t;
+
+typedef		__vki_u8	vki_uint8_t;
+typedef		__vki_u16	vki_uint16_t;
+typedef		__vki_u32	vki_uint32_t;
+
+//----------------------------------------------------------------------
+// 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/time.h
+//----------------------------------------------------------------------
+
+#define VKI_CLOCK_REALTIME            0
+#define VKI_CLOCK_MONOTONIC           1
+#define VKI_CLOCK_PROCESS_CPUTIME_ID  2
+#define VKI_CLOCK_THREAD_CPUTIME_ID   3
+
+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 VKI_ADJ_OFFSET			0x0001	/* time offset */
+#define VKI_ADJ_FREQUENCY		0x0002	/* frequency offset */
+#define VKI_ADJ_MAXERROR		0x0004	/* maximum time error */
+#define VKI_ADJ_ESTERROR		0x0008	/* estimated time error */
+#define VKI_ADJ_STATUS			0x0010	/* clock status */
+#define VKI_ADJ_TIMECONST		0x0020	/* pll time constant */
+#define VKI_ADJ_TAI			0x0080	/* set TAI offset */
+#define VKI_ADJ_TICK			0x4000	/* tick value */
+#define VKI_ADJ_ADJTIME			0x8000	/* switch between adjtime/adjtimex modes */
+//#define VKI_ADJ_OFFSET_SINGLESHOT	0x8001	/* old-fashioned adjtime */
+#define VKI_ADJ_OFFSET_READONLY		0x2000	/* read-only 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_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_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_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	/* Unused, ignored */
+#define VKI_CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
+
+struct vki_sched_param {
+	int sched_priority;
+};
+
+#define VKI_TASK_COMM_LEN 16
+
+//----------------------------------------------------------------------
+// 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;
+
+#define __VKI_SI_FAULT	0
+
+/*
+ * 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 */
+
+/*
+ * SIGILL si_codes
+ */
+#define VKI_ILL_ILLOPC	(__VKI_SI_FAULT|1)	/* illegal opcode */
+#define VKI_ILL_ILLOPN	(__VKI_SI_FAULT|2)	/* illegal operand */
+#define VKI_ILL_ILLADR	(__VKI_SI_FAULT|3)	/* illegal addressing mode */
+#define VKI_ILL_ILLTRP	(__VKI_SI_FAULT|4)	/* illegal trap */
+#define VKI_ILL_PRVOPC	(__VKI_SI_FAULT|5)	/* privileged opcode */
+#define VKI_ILL_PRVREG	(__VKI_SI_FAULT|6)	/* privileged register */
+#define VKI_ILL_COPROC	(__VKI_SI_FAULT|7)	/* coprocessor error */
+#define VKI_ILL_BADSTK	(__VKI_SI_FAULT|8)	/* internal stack error */
+
+/*
+ * SIGFPE si_codes
+ */
+#define VKI_FPE_INTDIV	(__VKI_SI_FAULT|1)	/* integer divide by zero */
+#define VKI_FPE_INTOVF	(__VKI_SI_FAULT|2)	/* integer overflow */
+#define VKI_FPE_FLTDIV	(__VKI_SI_FAULT|3)	/* floating point divide by zero */
+#define VKI_FPE_FLTOVF	(__VKI_SI_FAULT|4)	/* floating point overflow */
+#define VKI_FPE_FLTUND	(__VKI_SI_FAULT|5)	/* floating point underflow */
+#define VKI_FPE_FLTRES	(__VKI_SI_FAULT|6)	/* floating point inexact result */
+#define VKI_FPE_FLTINV	(__VKI_SI_FAULT|7)	/* floating point invalid operation */
+#define VKI_FPE_FLTSUB	(__VKI_SI_FAULT|8)	/* subscript out of range */
+
+/*
+ * SIGSEGV si_codes
+ */
+#define VKI_SEGV_MAPERR	(__VKI_SI_FAULT|1)	/* address not mapped to object */
+#define VKI_SEGV_ACCERR	(__VKI_SI_FAULT|2)	/* invalid permissions for mapped object */
+
+/*
+ * SIGBUS si_codes
+ */
+#define VKI_BUS_ADRALN	(__VKI_SI_FAULT|1)	/* invalid address alignment */
+#define VKI_BUS_ADRERR	(__VKI_SI_FAULT|2)	/* non-existant physical address */
+#define VKI_BUS_OBJERR	(__VKI_SI_FAULT|3)	/* object specific hardware error */
+
+/*
+ * SIGTRAP si_codes
+ */
+#define VKI_TRAP_BRKPT      (__VKI_SI_FAULT|1)  /* process breakpoint */
+#define VKI_TRAP_TRACE      (__VKI_SI_FAULT|2)  /* process trace trap */
+
+/*
+ * This works because the alignment is ok on all current architectures
+ * but we leave open this being overridden in the future
+ */
+#ifndef VKI___ARCH_SIGEV_PREAMBLE_SIZE
+#define VKI___ARCH_SIGEV_PREAMBLE_SIZE	(sizeof(int) * 2 + sizeof(vki_sigval_t))
+#endif
+
+#define VKI_SIGEV_MAX_SIZE	64
+#define VKI_SIGEV_PAD_SIZE	((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
+		/ sizeof(int))
+
+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;
+
+//----------------------------------------------------------------------
+// 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
+
+//----------------------------------------------------------------------
+// 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)		*/
+#define VKI_SYS_ACCEPT4		18	/* sys_accept4(2)		*/
+
+enum vki_sock_type {
+	VKI_SOCK_STREAM	= 1,
+	// [[others omitted]]
+};
+
+//----------------------------------------------------------------------
+// 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 */
+
+#define VKI_SOL_SCTP	132
+
+//----------------------------------------------------------------------
+// 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.13-rc5/include/net/sctp/user.h
+//----------------------------------------------------------------------
+
+typedef __vki_s32 vki_sctp_assoc_t;
+
+enum vki_sctp_optname {
+	VKI_SCTP_RTOINFO,
+#define VKI_SCTP_RTOINFO VKI_SCTP_RTOINFO
+	VKI_SCTP_ASSOCINFO,
+#define VKI_SCTP_ASSOCINFO VKI_SCTP_ASSOCINFO
+	VKI_SCTP_INITMSG,
+#define VKI_SCTP_INITMSG VKI_SCTP_INITMSG
+	VKI_SCTP_NODELAY, 	/* Get/set nodelay option. */
+#define VKI_SCTP_NODELAY	VKI_SCTP_NODELAY
+	VKI_SCTP_AUTOCLOSE,
+#define VKI_SCTP_AUTOCLOSE VKI_SCTP_AUTOCLOSE
+	VKI_SCTP_SET_PEER_PRIMARY_ADDR, 
+#define VKI_SCTP_SET_PEER_PRIMARY_ADDR VKI_SCTP_SET_PEER_PRIMARY_ADDR
+	VKI_SCTP_PRIMARY_ADDR,
+#define VKI_SCTP_PRIMARY_ADDR VKI_SCTP_PRIMARY_ADDR
+	VKI_SCTP_ADAPTION_LAYER,      
+#define VKI_SCTP_ADAPTION_LAYER VKI_SCTP_ADAPTION_LAYER
+	VKI_SCTP_DISABLE_FRAGMENTS,
+#define VKI_SCTP_DISABLE_FRAGMENTS VKI_SCTP_DISABLE_FRAGMENTS
+	VKI_SCTP_PEER_ADDR_PARAMS,
+#define VKI_SCTP_PEER_ADDR_PARAMS VKI_SCTP_PEER_ADDR_PARAMS
+	VKI_SCTP_DEFAULT_SEND_PARAM,
+#define VKI_SCTP_DEFAULT_SEND_PARAM VKI_SCTP_DEFAULT_SEND_PARAM
+	VKI_SCTP_EVENTS,
+#define VKI_SCTP_EVENTS VKI_SCTP_EVENTS
+	VKI_SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
+#define VKI_SCTP_I_WANT_MAPPED_V4_ADDR VKI_SCTP_I_WANT_MAPPED_V4_ADDR
+	VKI_SCTP_MAXSEG, 	/* Get/set maximum fragment. */
+#define VKI_SCTP_MAXSEG 	VKI_SCTP_MAXSEG
+	VKI_SCTP_STATUS,
+#define VKI_SCTP_STATUS VKI_SCTP_STATUS
+	VKI_SCTP_GET_PEER_ADDR_INFO,
+#define VKI_SCTP_GET_PEER_ADDR_INFO VKI_SCTP_GET_PEER_ADDR_INFO
+
+	/* Internal Socket Options. Some of the sctp library functions are 
+	 * implemented using these socket options.
+	 */
+	VKI_SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
+#define VKI_SCTP_SOCKOPT_BINDX_ADD	VKI_SCTP_SOCKOPT_BINDX_ADD
+	VKI_SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
+#define VKI_SCTP_SOCKOPT_BINDX_REM	VKI_SCTP_SOCKOPT_BINDX_REM
+	VKI_SCTP_SOCKOPT_PEELOFF, 	/* peel off association. */
+#define VKI_SCTP_SOCKOPT_PEELOFF	VKI_SCTP_SOCKOPT_PEELOFF
+	VKI_SCTP_GET_PEER_ADDRS_NUM, 	/* Get number of peer addresss. */
+#define VKI_SCTP_GET_PEER_ADDRS_NUM	VKI_SCTP_GET_PEER_ADDRS_NUM
+	VKI_SCTP_GET_PEER_ADDRS, 	/* Get all peer addresss. */
+#define VKI_SCTP_GET_PEER_ADDRS	VKI_SCTP_GET_PEER_ADDRS
+	VKI_SCTP_GET_LOCAL_ADDRS_NUM, 	/* Get number of local addresss. */
+#define VKI_SCTP_GET_LOCAL_ADDRS_NUM	VKI_SCTP_GET_LOCAL_ADDRS_NUM
+	VKI_SCTP_GET_LOCAL_ADDRS, 	/* Get all local addresss. */
+#define VKI_SCTP_GET_LOCAL_ADDRS	VKI_SCTP_GET_LOCAL_ADDRS
+	VKI_SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
+#define VKI_SCTP_SOCKOPT_CONNECTX	VKI_SCTP_SOCKOPT_CONNECTX
+};
+
+struct vki_sctp_getaddrs {
+	vki_sctp_assoc_t        assoc_id;
+	int			addr_num;
+	struct vki_sockaddr	*addrs;
+};
+
+//----------------------------------------------------------------------
+// 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.12.1/include/linux/eventpoll.h
+//----------------------------------------------------------------------
+
+/* Valid opcodes to issue to sys_epoll_ctl() */
+#define VKI_EPOLL_CTL_ADD 1
+#define VKI_EPOLL_CTL_DEL 2
+#define VKI_EPOLL_CTL_MOD 3
+
+#ifdef __x86_64__
+#define VKI_EPOLL_PACKED __attribute__((packed))
+#else
+#define VKI_EPOLL_PACKED
+#endif
+
+struct vki_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
+//----------------------------------------------------------------------
+
+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_ENOENT		 2	/* No such file or directory */
+#define	VKI_ESRCH		 3	/* No such process */
+#define	VKI_EINTR		 4	/* Interrupted system call */
+#define VKI_ENOEXEC              8      /* Exec format error */
+#define	VKI_EBADF		 9	/* Bad file number */
+#define VKI_ECHILD              10      /* No child processes */
+#define VKI_EAGAIN		11	/* Try again */
+#define VKI_EWOULDBLOCK		VKI_EAGAIN
+#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 */
+#define	VKI_EOVERFLOW		75	/* Value too large for defined data type */
+
+//----------------------------------------------------------------------
+// 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.31-rc4/include/linux/futex.h
+//----------------------------------------------------------------------
+
+#define VKI_FUTEX_WAIT (0)
+#define VKI_FUTEX_WAKE (1)
+#define VKI_FUTEX_FD (2)
+#define VKI_FUTEX_REQUEUE (3)
+#define VKI_FUTEX_CMP_REQUEUE (4)
+#define VKI_FUTEX_WAKE_OP (5)
+#define VKI_FUTEX_LOCK_PI (6)
+#define VKI_FUTEX_UNLOCK_PI (7)
+#define VKI_FUTEX_TRYLOCK_PI (8)
+#define VKI_FUTEX_WAIT_BITSET (9)
+#define VKI_FUTEX_WAKE_BITSET (10)
+#define VKI_FUTEX_WAIT_REQUEUE_PI (11)
+#define VKI_FUTEX_CMP_REQUEUE_PI (12)
+#define VKI_FUTEX_PRIVATE_FLAG (128)
+#define VKI_FUTEX_CLOCK_REALTIME (256)
+
+struct vki_robust_list {
+	struct vki_robust_list __user *next;
+};
+
+struct vki_robust_list_head {
+	/*
+	 * The head of the list. Points back to itself if empty:
+	 */
+	struct vki_robust_list list;
+
+	/*
+	 * This relative offset is set by user-space, it gives the kernel
+	 * the relative position of the futex field to examine. This way
+	 * we keep userspace flexible, to freely shape its data-structure,
+	 * without hardcoding any particular offset into the kernel:
+	 */
+	long futex_offset;
+
+	/*
+	 * The death of the thread may race with userspace setting
+	 * up a lock's links. So to handle this race, userspace first
+	 * sets this field to the address of the to-be-taken lock,
+	 * then does the lock acquire, and then adds itself to the
+	 * list, and then clears this field. Hence the kernel will
+	 * always have full knowledge of all locks that the thread
+	 * _might_ have taken. We check the owner TID in any case,
+	 * so only truly owned locks will be handled.
+	 */
+	struct vki_robust_list __user *list_op_pending;
+};
+
+//----------------------------------------------------------------------
+// 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_IFMT  00170000
+#define VKI_S_IFSOCK 0140000
+#define VKI_S_IFLNK  0120000
+#define VKI_S_IFREG  0100000
+#define VKI_S_IFBLK  0060000
+#define VKI_S_IFDIR  0040000
+#define VKI_S_IFCHR  0020000
+#define VKI_S_IFIFO  0010000
+#define VKI_S_ISUID  0004000
+#define VKI_S_ISGID  0002000
+#define VKI_S_ISVTX  0001000
+
+#define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
+#define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
+#define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
+#define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
+#define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
+#define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
+#define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
+
+#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
+
+//----------------------------------------------------------------------
+// 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/fcntl.h
+//----------------------------------------------------------------------
+
+#define VKI_F_SETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 0)
+#define VKI_F_GETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 1)
+
+#define VKI_F_CANCELLK      (VKI_F_LINUX_SPECIFIC_BASE + 5)
+
+#define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6)
+
+#define VKI_F_NOTIFY        (VKI_F_LINUX_SPECIFIC_BASE + 2)
+
+#define VKI_F_SETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 7)
+#define VKI_F_GETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 8)
+
+//----------------------------------------------------------------------
+// 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,
+	VKI_IOCB_CMD_FSYNC = 2,
+	VKI_IOCB_CMD_FDSYNC = 3,
+	VKI_IOCB_CMD_PREADV = 7,
+	VKI_IOCB_CMD_PWRITEV = 8,
+};
+
+/* 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 */
+};
+
+#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_RDONLY  010000  /* read-only access */
+#define VKI_SHM_RND     020000  /* round attach address to SHMLBA boundary */
+
+#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
+//----------------------------------------------------------------------
+
+// [[Nb: Resolved this for the common case where CONFIG_COBALT_MICRO_SERVER
+//   is not defined]]
+#define VKI_ISDN_MAX_CHANNELS   64
+
+#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_BLKROSET   _VKI_IO(0x12,93)	/* set device read-only (0 = read-write) */
+#define VKI_BLKROGET   _VKI_IO(0x12,94)	/* get read-only status (0 = read_write) */
+#define VKI_BLKGETSIZE _VKI_IO(0x12,96) /* return device size /512 (long *arg) */
+#define VKI_BLKRASET   _VKI_IO(0x12,98)	/* set read ahead for block device */
+#define VKI_BLKRAGET   _VKI_IO(0x12,99)	/* get current read ahead setting */
+#define VKI_BLKFRASET  _VKI_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
+#define VKI_BLKFRAGET  _VKI_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
+#define VKI_BLKSECTGET _VKI_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
+#define VKI_BLKSSZGET  _VKI_IO(0x12,104)/* get block device sector size */
+#define VKI_BLKBSZGET  _VKI_IOR(0x12,112,vki_size_t)
+#define VKI_BLKBSZSET  _VKI_IOW(0x12,113,vki_size_t)
+#define VKI_BLKGETSIZE64 _VKI_IOR(0x12,114,vki_size_t) /* return device size in bytes (u64 *arg) */
+
+#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_CDROMREADRAW	0x5314	/* read data in raw mode (2352 Bytes)
+                                           (struct cdrom_read) */
+#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 */
+#define VKI_SNDCTL_DSP_SETFMT		_VKI_SIOWR('P', 5, int) /* Selects ONE fmt */
+
+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_GETCHANNELMASK	_VKI_SIOWR('P', 64, int)
+#define VKI_SNDCTL_DSP_BIND_CHANNEL	_VKI_SIOWR('P', 65, 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
+//----------------------------------------------------------------------
+
+struct vki_hd_geometry {
+      unsigned char heads;
+      unsigned char sectors;
+      unsigned short cylinders;
+      unsigned long start;
+};
+
+#define VKI_HDIO_GETGEO		0x0301	/* get device geometry */
+#define VKI_HDIO_GET_DMA	0x030b	/* get use-dma flag */
+#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 */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/linux/kd.h
+//----------------------------------------------------------------------
+
+#define VKI_GIO_FONT       0x4B60  /* gets font in expanded form */
+#define VKI_PIO_FONT       0x4B61  /* use font in expanded form */
+
+#define VKI_GIO_FONTX      0x4B6B  /* get font using struct consolefontdesc */
+#define VKI_PIO_FONTX      0x4B6C  /* set font using struct consolefontdesc */
+struct vki_consolefontdesc {
+	unsigned short charcount;	/* characters in font (256 or 512) */
+	unsigned short charheight;	/* scan lines per character (1-32) */
+	char __user *chardata;		/* font data in expanded form */
+};
+
+#define VKI_PIO_FONTRESET  0x4B6D  /* reset to default font */
+
+#define VKI_GIO_CMAP       0x4B70  /* gets colour palette on VGA+ */
+#define VKI_PIO_CMAP       0x4B71  /* sets colour palette on VGA+ */
+
+#define VKI_KIOCSOUND      0x4B2F  /* start sound generation (0 for off) */
+#define VKI_KDMKTONE       0x4B30  /* generate tone */
+
+#define VKI_KDGETLED       0x4B31  /* return current led state */
+#define VKI_KDSETLED       0x4B32  /* set led state [lights, not flags] */
+
+#define VKI_KDGKBTYPE      0x4B33  /* get keyboard type */
+
+#define VKI_KDADDIO        0x4B34  /* add i/o port as valid */
+#define VKI_KDDELIO        0x4B35  /* del i/o port as valid */
+#define VKI_KDENABIO       0x4B36  /* enable i/o to video board */
+#define VKI_KDDISABIO      0x4B37  /* disable i/o to video board */
+
+#define VKI_KDSETMODE      0x4B3A  /* set text/graphics mode */
+#define VKI_KDGETMODE      0x4B3B  /* get current mode */
+
+#define VKI_KDMAPDISP      0x4B3C  /* map display into address space */
+#define VKI_KDUNMAPDISP    0x4B3D  /* unmap display from address space */
+
+#define		VKI_E_TABSZ		256
+#define VKI_GIO_SCRNMAP    0x4B40  /* get screen mapping from kernel */
+#define VKI_PIO_SCRNMAP	   0x4B41  /* put screen mapping table in kernel */
+#define VKI_GIO_UNISCRNMAP 0x4B69  /* get full Unicode screen mapping */
+#define VKI_PIO_UNISCRNMAP 0x4B6A  /* set full Unicode screen mapping */
+
+#define VKI_GIO_UNIMAP     0x4B66  /* get unicode-to-font mapping from kernel */
+struct vki_unipair {
+	unsigned short unicode;
+	unsigned short fontpos;
+};
+struct vki_unimapdesc {
+	unsigned short entry_ct;
+	struct vki_unipair __user *entries;
+};
+#define VKI_PIO_UNIMAP     0x4B67  /* put unicode-to-font mapping in kernel */
+#define VKI_PIO_UNIMAPCLR  0x4B68  /* clear table, possibly advise hash algorithm */
+struct vki_unimapinit {
+	unsigned short advised_hashsize;  /* 0 if no opinion */
+	unsigned short advised_hashstep;  /* 0 if no opinion */
+	unsigned short advised_hashlevel; /* 0 if no opinion */
+};
+
+#define VKI_KDGKBMODE      0x4B44  /* gets current keyboard mode */
+#define VKI_KDSKBMODE      0x4B45  /* sets current keyboard mode */
+
+#define VKI_KDGKBMETA      0x4B62  /* gets meta key handling mode */
+#define VKI_KDSKBMETA      0x4B63  /* sets meta key handling mode */
+
+#define VKI_KDGKBLED       0x4B64  /* get led flags (not lights) */
+#define VKI_KDSKBLED       0x4B65  /* set led flags (not lights) */
+
+struct vki_kbentry {
+	unsigned char kb_table;
+	unsigned char kb_index;
+	unsigned short kb_value;
+};
+#define VKI_KDGKBENT       0x4B46  /* gets one entry in translation table */
+#define VKI_KDSKBENT       0x4B47  /* sets one entry in translation table */
+
+struct vki_kbsentry {
+	unsigned char kb_func;
+	unsigned char kb_string[512];
+};
+#define VKI_KDGKBSENT      0x4B48  /* gets one function key string entry */
+#define VKI_KDSKBSENT      0x4B49  /* sets one function key string entry */
+
+struct vki_kbdiacr {
+        unsigned char diacr, base, result;
+};
+struct vki_kbdiacrs {
+        unsigned int kb_cnt;    /* number of entries in following array */
+	struct vki_kbdiacr kbdiacr[256];    /* MAX_DIACR from keyboard.h */
+};
+#define VKI_KDGKBDIACR     0x4B4A  /* read kernel accent table */
+#define VKI_KDSKBDIACR     0x4B4B  /* write kernel accent table */
+
+struct vki_kbkeycode {
+	unsigned int scancode, keycode;
+};
+#define VKI_KDGETKEYCODE   0x4B4C  /* read kernel keycode table entry */
+#define VKI_KDSETKEYCODE   0x4B4D  /* write kernel keycode table entry */
+
+#define VKI_KDSIGACCEPT    0x4B4E  /* accept kbd generated signals */
+
+struct vki_kbd_repeat {
+	int delay;	/* in msec; <= 0: don't change */
+	int period;	/* in msec; <= 0: don't change */
+			/* earlier this field was misnamed "rate" */
+};
+#define VKI_KDKBDREP       0x4B52  /* set keyboard delay/repeat rate;
+                                    * actually used values are returned */
+
+#define VKI_KDFONTOP       0x4B72  /* font operations */
+
+struct vki_console_font_op {
+	unsigned int op;	/* operation code KD_FONT_OP_* */
+	unsigned int flags;	/* KD_FONT_FLAG_* */
+	unsigned int width, height;	/* font size */
+	unsigned int charcount;
+	unsigned char __user *data;	/* font data with height fixed to 32 */
+};
+
+#define VKI_KD_FONT_OP_SET		0	/* Set font */
+#define VKI_KD_FONT_OP_GET		1	/* Get font */
+#define VKI_KD_FONT_OP_SET_DEFAULT	2	/* Set font to default, data points to name / NULL */
+#define VKI_KD_FONT_OP_COPY		3	/* Copy from another console */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/linux/kb.h
+//----------------------------------------------------------------------
+
+typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
+
+//----------------------------------------------------------------------
+// From linux-2.6.20.1/include/linux/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PTRACE_TRACEME         0
+#define VKI_PTRACE_PEEKTEXT	   1
+#define VKI_PTRACE_PEEKDATA	   2
+#define VKI_PTRACE_PEEKUSR	   3
+#define VKI_PTRACE_POKEUSR	   6
+
+#define VKI_PTRACE_DETACH         17
+
+#define VKI_PTRACE_GETEVENTMSG	0x4201
+#define VKI_PTRACE_GETSIGINFO	0x4202
+#define VKI_PTRACE_SETSIGINFO	0x4203
+
+//----------------------------------------------------------------------
+// From linux-2.6.14/include/sound/asound.h
+//----------------------------------------------------------------------
+
+enum {
+	VKI_SNDRV_PCM_IOCTL_HW_FREE = _VKI_IO('A', 0x12),
+	VKI_SNDRV_PCM_IOCTL_HWSYNC = _VKI_IO('A', 0x22),
+	VKI_SNDRV_PCM_IOCTL_PREPARE = _VKI_IO('A', 0x40),
+	VKI_SNDRV_PCM_IOCTL_RESET = _VKI_IO('A', 0x41),
+	VKI_SNDRV_PCM_IOCTL_START = _VKI_IO('A', 0x42),
+	VKI_SNDRV_PCM_IOCTL_DROP = _VKI_IO('A', 0x43),
+	VKI_SNDRV_PCM_IOCTL_DRAIN = _VKI_IO('A', 0x44),
+	VKI_SNDRV_PCM_IOCTL_PAUSE = _VKI_IOW('A', 0x45, int),
+	VKI_SNDRV_PCM_IOCTL_RESUME = _VKI_IO('A', 0x47),
+	VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48),
+	VKI_SNDRV_PCM_IOCTL_LINK = _VKI_IOW('A', 0x60, int),
+	VKI_SNDRV_PCM_IOCTL_UNLINK = _VKI_IO('A', 0x61),
+};
+
+enum {
+	VKI_SNDRV_TIMER_IOCTL_START = _VKI_IO('T', 0xa0),
+	VKI_SNDRV_TIMER_IOCTL_STOP = _VKI_IO('T', 0xa1),
+	VKI_SNDRV_TIMER_IOCTL_CONTINUE = _VKI_IO('T', 0xa2),
+	VKI_SNDRV_TIMER_IOCTL_PAUSE = _VKI_IO('T', 0xa3),
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.15.4/include/linux/serial.h
+//----------------------------------------------------------------------
+
+struct vki_serial_icounter_struct {
+	int cts, dsr, rng, dcd;
+	int rx, tx;
+	int frame, overrun, parity, brk;
+	int buf_overrun;
+	int reserved[9];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.16/include/linux/vt.h
+//----------------------------------------------------------------------
+
+#define VKI_VT_OPENQRY	0x5600	/* find available vt */
+
+struct vki_vt_mode {
+	char mode;		/* vt mode */
+	char waitv;		/* if set, hang on writes if not active */
+	short relsig;		/* signal to raise on release req */
+	short acqsig;		/* signal to raise on acquisition */
+	short frsig;		/* unused (set to 0) */
+};
+#define VKI_VT_GETMODE	0x5601	/* get mode of active vt */
+#define VKI_VT_SETMODE	0x5602	/* set mode of active vt */
+
+struct vki_vt_stat {
+	unsigned short v_active;	/* active vt */
+	unsigned short v_signal;	/* signal to send */
+	unsigned short v_state;		/* vt bitmask */
+};
+#define VKI_VT_GETSTATE	0x5603	/* get global vt state info */
+#define VKI_VT_SENDSIG	0x5604	/* signal to send to bitmask of vts */
+
+#define VKI_VT_RELDISP	0x5605	/* release display */
+
+#define VKI_VT_ACTIVATE	0x5606	/* make vt active */
+#define VKI_VT_WAITACTIVE	0x5607	/* wait for vt active */
+#define VKI_VT_DISALLOCATE	0x5608  /* free memory associated to vt */
+
+struct vki_vt_sizes {
+	unsigned short v_rows;		/* number of rows */
+	unsigned short v_cols;		/* number of columns */
+	unsigned short v_scrollsize;	/* number of lines of scrollback */
+};
+#define VKI_VT_RESIZE	0x5609	/* set kernel's idea of screensize */
+
+struct vki_vt_consize {
+	unsigned short v_rows;	/* number of rows */
+	unsigned short v_cols;	/* number of columns */
+	unsigned short v_vlin;	/* number of pixel rows on screen */
+	unsigned short v_clin;	/* number of pixel rows per character */
+	unsigned short v_vcol;	/* number of pixel columns on screen */
+	unsigned short v_ccol;	/* number of pixel columns per character */
+};
+#define VKI_VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
+#define VKI_VT_LOCKSWITCH   0x560B  /* disallow vt switching */
+#define VKI_VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
+
+//----------------------------------------------------------------------
+// From linux-2.6.19/include/linux/prctl.h
+//----------------------------------------------------------------------
+
+#define VKI_PR_SET_PDEATHSIG  1  /* Second arg is a signal */
+#define VKI_PR_GET_PDEATHSIG  2  /* Second arg is a ptr to return the signal */
+
+#define VKI_PR_GET_DUMPABLE   3
+#define VKI_PR_SET_DUMPABLE   4
+
+#define VKI_PR_GET_UNALIGN	  5
+#define VKI_PR_SET_UNALIGN	  6
+# define VKI_PR_UNALIGN_NOPRINT	1	/* silently fix up unaligned user accesses */
+# define VKI_PR_UNALIGN_SIGBUS	2	/* generate SIGBUS on unaligned user access */
+
+#define VKI_PR_GET_KEEPCAPS   7
+#define VKI_PR_SET_KEEPCAPS   8
+
+#define VKI_PR_GET_FPEMU  9
+#define VKI_PR_SET_FPEMU 10
+# define VKI_PR_FPEMU_NOPRINT	1	/* silently emulate fp operations accesses */
+# define VKI_PR_FPEMU_SIGFPE	2	/* don't emulate fp operations, send SIGFPE instead */
+
+#define VKI_PR_GET_FPEXC	11
+#define VKI_PR_SET_FPEXC	12
+# define VKI_PR_FP_EXC_SW_ENABLE	0x80	/* Use FPEXC for FP exception enables */
+# define VKI_PR_FP_EXC_DIV		0x010000	/* floating point divide by zero */
+# define VKI_PR_FP_EXC_OVF		0x020000	/* floating point overflow */
+# define VKI_PR_FP_EXC_UND		0x040000	/* floating point underflow */
+# define VKI_PR_FP_EXC_RES		0x080000	/* floating point inexact result */
+# define VKI_PR_FP_EXC_INV		0x100000	/* floating point invalid operation */
+# define VKI_PR_FP_EXC_DISABLED	0	/* FP exceptions disabled */
+# define VKI_PR_FP_EXC_NONRECOV	1	/* async non-recoverable exc. mode */
+# define VKI_PR_FP_EXC_ASYNC	2	/* async recoverable exception mode */
+# define VKI_PR_FP_EXC_PRECISE	3	/* precise exception mode */
+
+#define VKI_PR_GET_TIMING   13
+#define VKI_PR_SET_TIMING   14
+# define VKI_PR_TIMING_STATISTICAL  0       /* Normal, traditional,
+                                                   statistical process timing */
+# define VKI_PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
+                                                   process timing */
+
+#define VKI_PR_SET_NAME    15		/* Set process name */
+#define VKI_PR_GET_NAME    16		/* Get process name */
+
+#define VKI_PR_GET_ENDIAN	19
+#define VKI_PR_SET_ENDIAN	20
+# define VKI_PR_ENDIAN_BIG		0
+# define VKI_PR_ENDIAN_LITTLE	1	/* True little endian mode */
+# define VKI_PR_ENDIAN_PPC_LITTLE	2	/* "PowerPC" pseudo little endian */
+
+//----------------------------------------------------------------------
+// From linux-2.6.19/include/linux/usbdevice_fs.h
+//----------------------------------------------------------------------
+
+struct vki_usbdevfs_ctrltransfer {
+	__vki_u8 bRequestType;
+	__vki_u8 bRequest;
+	__vki_u16 wValue;
+	__vki_u16 wIndex;
+	__vki_u16 wLength;
+	__vki_u32 timeout;  /* in milliseconds */
+ 	void __user *data;
+};
+
+struct vki_usbdevfs_bulktransfer {
+	unsigned int ep;
+	unsigned int len;
+	unsigned int timeout; /* in milliseconds */
+	void __user *data;
+};
+
+#define VKI_USBDEVFS_MAXDRIVERNAME 255
+
+struct vki_usbdevfs_getdriver {
+	unsigned int interface;
+	char driver[VKI_USBDEVFS_MAXDRIVERNAME + 1];
+};
+
+struct vki_usbdevfs_connectinfo {
+	unsigned int devnum;
+	unsigned char slow;
+};
+
+struct vki_usbdevfs_iso_packet_desc {
+	unsigned int length;
+	unsigned int actual_length;
+	unsigned int status;
+};
+
+struct vki_usbdevfs_urb {
+	unsigned char type;
+	unsigned char endpoint;
+	int status;
+	unsigned int flags;
+	void __user *buffer;
+	int buffer_length;
+	int actual_length;
+	int start_frame;
+	int number_of_packets;
+	int error_count;
+	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
+	void *usercontext;
+	struct vki_usbdevfs_iso_packet_desc iso_frame_desc[0];
+};
+
+struct vki_usbdevfs_ioctl {
+	int	ifno;		/* interface 0..N ; negative numbers reserved */
+	int	ioctl_code;	/* MUST encode size + direction of data so the
+				 * macros in <asm/ioctl.h> give correct values */
+	void __user *data;	/* param buffer (in, or out) */
+};
+
+#define VKI_USBDEVFS_CONTROL           _VKI_IOWR('U', 0, struct vki_usbdevfs_ctrltransfer)
+#define VKI_USBDEVFS_BULK              _VKI_IOWR('U', 2, struct vki_usbdevfs_bulktransfer)
+#define VKI_USBDEVFS_GETDRIVER         _VKI_IOW('U', 8, struct vki_usbdevfs_getdriver)
+#define VKI_USBDEVFS_SUBMITURB         _VKI_IOR('U', 10, struct vki_usbdevfs_urb)
+#define VKI_USBDEVFS_DISCARDURB        _VKI_IO('U', 11)
+#define VKI_USBDEVFS_REAPURB           _VKI_IOW('U', 12, void *)
+#define VKI_USBDEVFS_REAPURBNDELAY     _VKI_IOW('U', 13, void *)
+#define VKI_USBDEVFS_CONNECTINFO       _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo)
+#define VKI_USBDEVFS_IOCTL             _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl)
+
+#define VKI_USBDEVFS_URB_TYPE_ISO              0
+#define VKI_USBDEVFS_URB_TYPE_INTERRUPT        1
+#define VKI_USBDEVFS_URB_TYPE_CONTROL          2
+#define VKI_USBDEVFS_URB_TYPE_BULK             3
+
+// [[this is missing in usbdevice_fs.h]]
+struct vki_usbdevfs_setuppacket {
+       __vki_u8 bRequestType;
+       __vki_u8 bRequest;
+       __vki_u16 wValue;
+       __vki_u16 wIndex;
+       __vki_u16 wLength;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.20.1/include/linux/i2c.h
+//----------------------------------------------------------------------
+
+#define VKI_I2C_SLAVE		0x0703	/* Change slave address			*/
+					/* Attn.: Slave address is 7 or 10 bits */
+#define VKI_I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
+					/* Attn.: Slave address is 7 or 10 bits */
+					/* This changes the address, even if it */
+					/* is already taken!			*/
+#define VKI_I2C_TENBIT		0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit	*/
+#define VKI_I2C_FUNCS		0x0705	/* Get the adapter functionality */
+#define VKI_I2C_PEC		0x0708	/* != 0 for SMBus PEC                   */
+
+//----------------------------------------------------------------------
+// From linux-2.6.20.1/include/linux/keyctl.h
+//----------------------------------------------------------------------
+
+/* keyctl commands */
+#define VKI_KEYCTL_GET_KEYRING_ID	0	/* ask for a keyring's ID */
+#define VKI_KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
+#define VKI_KEYCTL_UPDATE		2	/* update a key */
+#define VKI_KEYCTL_REVOKE		3	/* revoke a key */
+#define VKI_KEYCTL_CHOWN		4	/* set ownership of a key */
+#define VKI_KEYCTL_SETPERM		5	/* set perms on a key */
+#define VKI_KEYCTL_DESCRIBE		6	/* describe a key */
+#define VKI_KEYCTL_CLEAR		7	/* clear contents of a keyring */
+#define VKI_KEYCTL_LINK			8	/* link a key into a keyring */
+#define VKI_KEYCTL_UNLINK		9	/* unlink a key from a keyring */
+#define VKI_KEYCTL_SEARCH		10	/* search for a key in a keyring */
+#define VKI_KEYCTL_READ			11	/* read a key or keyring's contents */
+#define VKI_KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
+#define VKI_KEYCTL_NEGATE		13	/* negate a partially constructed key */
+#define VKI_KEYCTL_SET_REQKEY_KEYRING	14	/* set default request-key keyring */
+#define VKI_KEYCTL_SET_TIMEOUT		15	/* set key timeout */
+#define VKI_KEYCTL_ASSUME_AUTHORITY	16	/* assume request_key() authorisation */
+
+/*--------------------------------------------------------------------*/
+// From linux-2.6.20.1/include/linux/key.h
+/*--------------------------------------------------------------------*/
+
+/* key handle serial number */
+typedef vki_int32_t vki_key_serial_t;
+
+/* key handle permissions mask */
+typedef vki_uint32_t vki_key_perm_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.24.7/include/linux/wireless.h
+// (wireless extensions version 22, 2007-03-16)
+//----------------------------------------------------------------------
+
+/*
+ * [[Wireless extensions ioctls.]]
+ */
+
+/* Wireless Identification */
+#define VKI_SIOCSIWCOMMIT	0x8B00	/* Commit pending changes to driver */
+#define VKI_SIOCGIWNAME		0x8B01	/* get name == wireless protocol */
+
+/* Basic operations */
+#define VKI_SIOCSIWNWID		0x8B02	/* set network id (pre-802.11) */
+#define VKI_SIOCGIWNWID		0x8B03	/* get network id (the cell) */
+#define VKI_SIOCSIWFREQ		0x8B04	/* set channel/frequency (Hz) */
+#define VKI_SIOCGIWFREQ		0x8B05	/* get channel/frequency (Hz) */
+#define VKI_SIOCSIWMODE		0x8B06	/* set operation mode */
+#define VKI_SIOCGIWMODE		0x8B07	/* get operation mode */
+#define VKI_SIOCSIWSENS		0x8B08	/* set sensitivity (dBm) */
+#define VKI_SIOCGIWSENS		0x8B09	/* get sensitivity (dBm) */
+
+/* Informative stuff */
+#define VKI_SIOCSIWRANGE	0x8B0A	/* Unused */
+#define VKI_SIOCGIWRANGE	0x8B0B	/* Get range of parameters */
+#define VKI_SIOCSIWPRIV		0x8B0C	/* Unused */
+#define VKI_SIOCGIWPRIV		0x8B0D	/* get private ioctl interface info */
+#define VKI_SIOCSIWSTATS	0x8B0E	/* Unused */
+#define VKI_SIOCGIWSTATS	0x8B0F	/* Get /proc/net/wireless stats */
+
+/* Spy support (statistics per MAC address - used for Mobile IP support) */
+#define VKI_SIOCSIWSPY		0x8B10	/* set spy addresses */
+#define VKI_SIOCGIWSPY		0x8B11	/* get spy info (quality of link) */
+#define VKI_SIOCSIWTHRSPY	0x8B12	/* set spy threshold (spy event) */
+#define VKI_SIOCGIWTHRSPY	0x8B13	/* get spy threshold */
+
+/* Access Point manipulation */
+#define VKI_SIOCSIWAP		0x8B14	/* set access point MAC addresses */
+#define VKI_SIOCGIWAP		0x8B15	/* get access point MAC addresses */
+#define VKI_SIOCGIWAPLIST	0x8B17	/* Deprecated in favor of scanning */
+#define VKI_SIOCSIWSCAN         0x8B18	/* trigger scanning (list cells) */
+#define VKI_SIOCGIWSCAN         0x8B19	/* get scanning results */
+
+/* 802.11 specific support */
+#define VKI_SIOCSIWESSID	0x8B1A	/* set ESSID (network name) */
+#define VKI_SIOCGIWESSID	0x8B1B	/* get ESSID */
+#define VKI_SIOCSIWNICKN	0x8B1C	/* set node name/nickname */
+#define VKI_SIOCGIWNICKN	0x8B1D	/* get node name/nickname */
+
+/* Other parameters useful in 802.11 and some other devices */
+#define VKI_SIOCSIWRATE		0x8B20	/* set default bit rate (bps) */
+#define VKI_SIOCGIWRATE		0x8B21	/* get default bit rate (bps) */
+#define VKI_SIOCSIWRTS		0x8B22	/* set RTS/CTS threshold (bytes) */
+#define VKI_SIOCGIWRTS		0x8B23	/* get RTS/CTS threshold (bytes) */
+#define VKI_SIOCSIWFRAG		0x8B24	/* set fragmentation thr (bytes) */
+#define VKI_SIOCGIWFRAG		0x8B25	/* get fragmentation thr (bytes) */
+#define VKI_SIOCSIWTXPOW	0x8B26	/* set transmit power (dBm) */
+#define VKI_SIOCGIWTXPOW	0x8B27	/* get transmit power (dBm) */
+#define VKI_SIOCSIWRETRY	0x8B28	/* set retry limits and lifetime */
+#define VKI_SIOCGIWRETRY	0x8B29	/* get retry limits and lifetime */
+
+/* Encoding stuff (scrambling, hardware security, WEP...) */
+#define VKI_SIOCSIWENCODE	0x8B2A	/* set encoding token & mode */
+#define VKI_SIOCGIWENCODE	0x8B2B	/* get encoding token & mode */
+
+/* Power saving stuff (power management, unicast and multicast) */
+#define VKI_SIOCSIWPOWER	0x8B2C	/* set Power Management settings */
+#define VKI_SIOCGIWPOWER	0x8B2D	/* get Power Management settings */
+
+/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
+#define VKI_SIOCSIWGENIE	0x8B30		/* set generic IE */
+#define VKI_SIOCGIWGENIE	0x8B31		/* get generic IE */
+
+/* WPA : IEEE 802.11 MLME requests */
+#define VKI_SIOCSIWMLME		0x8B16	/* request MLME operation; uses
+					 * struct iw_mlme */
+/* WPA : Authentication mode parameters */
+#define VKI_SIOCSIWAUTH		0x8B32	/* set authentication mode params */
+#define VKI_SIOCGIWAUTH		0x8B33	/* get authentication mode params */
+
+/* WPA : Extended version of encoding configuration */
+#define VKI_SIOCSIWENCODEEXT	0x8B34	/* set encoding token & mode */
+#define VKI_SIOCGIWENCODEEXT	0x8B35	/* get encoding token & mode */
+
+/* WPA2 : PMKSA cache management */
+#define VKI_SIOCSIWPMKSA	0x8B36	/* PMKSA cache operation */
+
+/*
+ * [[Payload for the wireless extensions ioctls.]]
+ */
+
+struct	vki_iw_param
+{
+  __vki_s32	value;		/* The value of the parameter itself */
+  __vki_u8	fixed;		/* Hardware should not use auto select */
+  __vki_u8	disabled;	/* Disable the feature */
+  __vki_u16	flags;		/* Various specifc flags (if any) */
+};
+
+struct	vki_iw_point
+{
+  void __user	*pointer;	/* Pointer to the data  (in user space) */
+  __vki_u16	length;		/* number of fields or size in bytes */
+  __vki_u16	flags;		/* Optional params */
+};
+
+struct	vki_iw_freq
+{
+	__vki_s32	m;		/* Mantissa */
+	__vki_s16	e;		/* Exponent */
+	__vki_u8	i;		/* List index (when in range struct) */
+	__vki_u8	flags;		/* Flags (fixed/auto) */
+};
+
+struct	vki_iw_quality
+{
+	__vki_u8	qual;		/* link quality (%retries, SNR,
+					   %missed beacons or better...) */
+	__vki_u8	level;		/* signal level (dBm) */
+	__vki_u8	noise;		/* noise level (dBm) */
+	__vki_u8	updated;	/* Flags to know if updated */
+};
+
+union	vki_iwreq_data
+{
+	/* Config - generic */
+	char		name[VKI_IFNAMSIZ];
+	/* Name : used to verify the presence of  wireless extensions.
+	 * Name of the protocol/provider... */
+
+	struct vki_iw_point	essid;	/* Extended network name */
+	struct vki_iw_param	nwid;	/* network id (or domain - the cell) */
+	struct vki_iw_freq	freq;	/* frequency or channel :
+					 * 0-1000 = channel
+					 * > 1000 = frequency in Hz */
+
+	struct vki_iw_param	sens;	/* signal level threshold */
+	struct vki_iw_param	bitrate;/* default bit rate */
+	struct vki_iw_param	txpower;/* default transmit power */
+	struct vki_iw_param	rts;	/* RTS threshold threshold */
+	struct vki_iw_param	frag;	/* Fragmentation threshold */
+	__vki_u32		mode;	/* Operation mode */
+	struct vki_iw_param	retry;	/* Retry limits & lifetime */
+
+	struct vki_iw_point	encoding; /* Encoding stuff : tokens */
+	struct vki_iw_param	power;	/* PM duration/timeout */
+	struct vki_iw_quality	qual;	/* Quality part of statistics */
+
+	struct vki_sockaddr ap_addr;	/* Access point address */
+	struct vki_sockaddr addr;	/* Destination address (hw/mac) */
+
+	struct vki_iw_param	param;	/* Other small parameters */
+	struct vki_iw_point	data;	/* Other large parameters */
+};
+
+struct	vki_iwreq 
+{
+	union
+	{
+		char ifrn_name[VKI_IFNAMSIZ];	/* if name, e.g. "eth0" */
+	} ifr_ifrn;
+
+	/* Data part (defined just above) */
+	union	vki_iwreq_data	u;
+};
+
+/*--------------------------------------------------------------------*/
+// From linux-2.6.31.5/include/linux/perf_counter.h
+/*--------------------------------------------------------------------*/
+
+struct vki_perf_counter_attr {
+
+	/*
+	 * Major type: hardware/software/tracepoint/etc.
+	 */
+	__vki_u32			type;
+
+	/*
+	 * Size of the attr structure, for fwd/bwd compat.
+	 */
+	__vki_u32			size;
+
+	/*
+	 * Type specific configuration information.
+	 */
+	__vki_u64			config;
+
+	union {
+		__vki_u64		sample_period;
+		__vki_u64		sample_freq;
+	};
+
+	__vki_u64			sample_type;
+	__vki_u64			read_format;
+
+	__vki_u64			disabled       :  1, /* off by default        */
+					inherit	       :  1, /* children inherit it   */
+					pinned	       :  1, /* must always be on PMU */
+					exclusive      :  1, /* only group on PMU     */
+					exclude_user   :  1, /* don't count user      */
+					exclude_kernel :  1, /* ditto kernel          */
+					exclude_hv     :  1, /* ditto hypervisor      */
+					exclude_idle   :  1, /* don't count when idle */
+					mmap           :  1, /* include mmap data     */
+					comm	       :  1, /* include comm data     */
+					freq           :  1, /* use freq, not period  */
+					inherit_stat   :  1, /* per task counts       */
+					enable_on_exec :  1, /* next exec enables     */
+					task           :  1, /* trace fork/exit       */
+
+					__reserved_1   : 50;
+
+	__vki_u32			wakeup_events;	/* wakeup every n events */
+	__vki_u32			__reserved_2;
+
+	__vki_u64			__reserved_3;
+};
+
+/*--------------------------------------------------------------------*/
+// From linux-2.6.32.4/include/linux/getcpu.h
+/*--------------------------------------------------------------------*/
+
+struct vki_getcpu_cache {
+	unsigned long blob[128 / sizeof(long)];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.33.3/include/linux/input.h
+//----------------------------------------------------------------------
+
+/*
+ * IOCTLs (0x00 - 0x7f)
+ */
+
+#define VKI_EVIOCGNAME(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x06, len)		/* get device name */
+#define VKI_EVIOCGPHYS(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x07, len)		/* get physical location */
+#define VKI_EVIOCGUNIQ(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x08, len)		/* get unique identifier */
+
+#define VKI_EVIOCGKEY(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x18, len)		/* get global keystate */
+#define VKI_EVIOCGLED(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
+#define VKI_EVIOCGSND(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
+#define VKI_EVIOCGSW(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
+
+#define VKI_EVIOCGBIT(ev,len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
+
+/*
+ * Event types
+ */
+
+#define VKI_EV_SYN		0x00
+#define VKI_EV_KEY		0x01
+#define VKI_EV_REL		0x02
+#define VKI_EV_ABS		0x03
+#define VKI_EV_MSC		0x04
+#define VKI_EV_SW		0x05
+#define VKI_EV_LED		0x11
+#define VKI_EV_SND		0x12
+#define VKI_EV_REP		0x14
+#define VKI_EV_FF		0x15
+#define VKI_EV_PWR		0x16
+#define VKI_EV_FF_STATUS	0x17
+#define VKI_EV_MAX		0x1f
+#define VKI_EV_CNT		(VKI_EV_MAX+1)
+
+#endif // __VKI_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-posixtypes-amd64-linux.h b/include/vki/vki-posixtypes-amd64-linux.h
new file mode 100644
index 0000000..1862410
--- /dev/null
+++ b/include/vki/vki-posixtypes-amd64-linux.h
@@ -0,0 +1,68 @@
+
+/*--------------------------------------------------------------------*/
+/*--- AMD64/Linux-specific kernel interface: posix types.          ---*/
+/*---                                 vki-posixtypes-amd64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_POSIXTYPES_AMD64_LINUX_H
+#define __VKI_POSIXTYPES_AMD64_LINUX_H
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-x86_64/posix_types.h
+//----------------------------------------------------------------------
+
+typedef unsigned int	__vki_kernel_mode_t;
+typedef long		__vki_kernel_off_t;
+typedef int		__vki_kernel_pid_t;
+typedef int		__vki_kernel_ipc_pid_t;
+typedef unsigned int	__vki_kernel_uid_t;
+typedef unsigned int	__vki_kernel_gid_t;
+typedef unsigned long	__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 int		__vki_kernel_clockid_t;
+typedef char *		__vki_kernel_caddr_t;
+
+typedef long long	__vki_kernel_loff_t;
+
+typedef struct {
+	int	val[2];
+} __vki_kernel_fsid_t;
+
+typedef unsigned short __vki_kernel_old_uid_t;
+typedef unsigned short __vki_kernel_old_gid_t;
+typedef __vki_kernel_uid_t __vki_kernel_uid32_t;
+typedef __vki_kernel_gid_t __vki_kernel_gid32_t;
+
+#endif // __VKI_POSIXTYPES_AMD64_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-posixtypes-arm-linux.h b/include/vki/vki-posixtypes-arm-linux.h
new file mode 100644
index 0000000..043dbad
--- /dev/null
+++ b/include/vki/vki-posixtypes-arm-linux.h
@@ -0,0 +1,68 @@
+
+/*--------------------------------------------------------------------*/
+/*--- arm/Linux-specific kernel interface: posix types.            ---*/
+/*---                                   vki-posixtypes-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_POSIXTYPES_ARM_LINUX_H
+#define __VKI_POSIXTYPES_ARM_LINUX_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 int		__vki_kernel_clockid_t;
+typedef char *		__vki_kernel_caddr_t;
+typedef unsigned int	__vki_kernel_uid32_t;
+typedef unsigned int	__vki_kernel_gid32_t;
+
+typedef unsigned short	__vki_kernel_old_uid_t;
+typedef unsigned short	__vki_kernel_old_gid_t;
+
+typedef long long	__vki_kernel_loff_t;
+
+typedef struct {
+	int	val[2];
+} __vki_kernel_fsid_t;
+
+#endif // __VKI_POSIXTYPES_ARM_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                               vki-posixtypes-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-posixtypes-ppc32-linux.h b/include/vki/vki-posixtypes-ppc32-linux.h
new file mode 100644
index 0000000..6ab8e6e
--- /dev/null
+++ b/include/vki/vki-posixtypes-ppc32-linux.h
@@ -0,0 +1,68 @@
+
+/*--------------------------------------------------------------------*/
+/*--- PPC32/Linux-specific kernel interface: posix types.          ---*/
+/*---                                 vki-posixtypes-ppc32-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_POSIXTYPES_PPC32_LINUX_H
+#define __VKI_POSIXTYPES_PPC32_LINUX_H
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/posix_types.h
+//----------------------------------------------------------------------
+
+typedef unsigned int __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 int __vki_kernel_uid_t;
+typedef unsigned int __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 int          __vki_kernel_clockid_t;
+typedef char *       __vki_kernel_caddr_t;
+typedef unsigned int __vki_kernel_uid32_t;
+typedef unsigned int __vki_kernel_gid32_t;
+
+typedef unsigned int __vki_kernel_old_uid_t;
+typedef unsigned int __vki_kernel_old_gid_t;
+
+typedef long long    __vki_kernel_loff_t;
+
+typedef struct {
+   int val[2];
+} __vki_kernel_fsid_t;
+
+#endif // __VKI_POSIXTYPES_PPC32_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-posixtypes-ppc64-linux.h b/include/vki/vki-posixtypes-ppc64-linux.h
new file mode 100644
index 0000000..3b0a91d
--- /dev/null
+++ b/include/vki/vki-posixtypes-ppc64-linux.h
@@ -0,0 +1,75 @@
+
+/*--------------------------------------------------------------------*/
+/*--- PPC64/Linux-specific kernel interface: posix types.          ---*/
+/*---                                 vki-posixtypes-ppc64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_POSIXTYPES_PPC64_LINUX_H
+#define __VKI_POSIXTYPES_PPC64_LINUX_H
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/posix_types.h
+//----------------------------------------------------------------------
+
+typedef unsigned long   __vki_kernel_ino_t;
+typedef unsigned long   __vki_kernel_nlink_t;
+typedef unsigned int    __vki_kernel_mode_t;
+typedef long            __vki_kernel_off_t;
+typedef long long       __vki_kernel_loff_t;
+typedef int             __vki_kernel_pid_t;
+typedef int             __vki_kernel_ipc_pid_t;
+typedef unsigned int    __vki_kernel_uid_t;
+typedef unsigned int    __vki_kernel_gid_t;
+typedef unsigned long   __vki_kernel_size_t;
+typedef long            __vki_kernel_ssize_t;
+typedef long            __vki_kernel_ptrdiff_t;
+typedef long            __vki_kernel_time_t;
+typedef int             __vki_kernel_timer_t;
+typedef int             __vki_kernel_clockid_t;
+typedef long            __vki_kernel_suseconds_t;
+typedef long            __vki_kernel_clock_t;
+typedef int             __vki_kernel_daddr_t;
+typedef char *          __vki_kernel_caddr_t;
+typedef unsigned short  __vki_kernel_uid16_t;
+typedef unsigned short  __vki_kernel_gid16_t;
+typedef unsigned int    __vki_kernel_uid32_t;
+typedef unsigned int    __vki_kernel_gid32_t;
+
+typedef unsigned int    __vki_kernel_old_uid_t;
+typedef unsigned int    __vki_kernel_old_gid_t;
+typedef unsigned long   __vki_kernel_old_dev_t;
+
+typedef struct {
+  int     val[2];
+} __vki_kernel_fsid_t;
+
+#endif // __VKI_POSIXTYPES_PPC64_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-posixtypes-x86-linux.h b/include/vki/vki-posixtypes-x86-linux.h
new file mode 100644
index 0000000..42b2bf0
--- /dev/null
+++ b/include/vki/vki-posixtypes-x86-linux.h
@@ -0,0 +1,68 @@
+
+/*--------------------------------------------------------------------*/
+/*--- x86/Linux-specific kernel interface: posix types.            ---*/
+/*---                                   vki-posixtypes-x86-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_POSIXTYPES_X86_LINUX_H
+#define __VKI_POSIXTYPES_X86_LINUX_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 int		__vki_kernel_clockid_t;
+typedef char *		__vki_kernel_caddr_t;
+typedef unsigned int	__vki_kernel_uid32_t;
+typedef unsigned int	__vki_kernel_gid32_t;
+
+typedef unsigned short	__vki_kernel_old_uid_t;
+typedef unsigned short	__vki_kernel_old_gid_t;
+
+typedef long long	__vki_kernel_loff_t;
+
+typedef struct {
+	int	val[2];
+} __vki_kernel_fsid_t;
+
+#endif // __VKI_POSIXTYPES_X86_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-ppc32-aix5.h b/include/vki/vki-ppc32-aix5.h
new file mode 100644
index 0000000..71ca550
--- /dev/null
+++ b/include/vki/vki-ppc32-aix5.h
@@ -0,0 +1,463 @@
+
+/*--------------------------------------------------------------------*/
+/*--- 32-bit AIX5-specific kernel interface.      vki-ppc32-aix5.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2006-2010 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.
+*/
+
+/* This file defines types and constants for the kernel interface, and to
+   make that clear everything is prefixed VKI_/vki_.
+*/
+
+/* This file was generated by running auxprogs/aix5_VKI_info.c. */
+
+#ifndef __VKI_PPC32_AIX5_H
+#define __VKI_PPC32_AIX5_H
+
+#if !defined(VGP_ppc32_aix5)
+#  error This file should be included in 32-bit AIX5 builds only.
+#endif
+
+//--------------------------------------------------------------
+// VERIFIED
+//--------------------------------------------------------------
+
+/* ---------------- Errors ---------------- */
+
+#define VKI_EINVAL 22
+#define VKI_EINTR  4
+#define VKI_ENOSYS 109
+#define VKI_EAGAIN 11
+#define VKI_ENOMEM 12
+#define VKI_EACCES 13
+#define VKI_EEXIST 17
+#define VKI_EPERM  1
+#define VKI_ENOENT 2
+#define VKI_ESRCH  3
+#define VKI_EBADF  9
+#define VKI_EFAULT 14
+#define VKI_EMFILE 24
+#define VKI_ECHILD 10
+#define VKI_EOVERFLOW 127
+#define VKI_ERESTARTSYS 0 /* AIX doesn't have this */
+
+/* ---------------- File I/O ---------------- */
+
+#define VKI_O_WRONLY 0x00000001
+#define VKI_O_RDONLY 0x00000000
+#define VKI_O_APPEND 0x00000008
+#define VKI_O_CREAT  0x00000100
+#define VKI_O_RDWR   0x00000002
+#define VKI_O_EXCL   0x00000400
+#define VKI_O_TRUNC  0x00000200
+
+#define VKI_S_IRUSR  0x00000100
+#define VKI_S_IXUSR  0x00000040
+#define VKI_S_IXGRP  0x00000008
+#define VKI_S_IXOTH  0x00000001
+#define VKI_S_IWUSR  0x00000080
+#define VKI_S_IWOTH  0x00000002
+#define VKI_S_ISUID  0x00000800
+#define VKI_S_ISGID  0x00000400
+#define VKI_S_IFMT   0x0000f000
+#define VKI_S_IFDIR  0x00004000
+#define VKI_S_IFCHR  0x00002000
+#define VKI_S_IFBLK  0x00006000
+
+/* Next 3 are from include/vki/vki-linux.h */
+#define VKI_S_ISDIR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFDIR)
+#define VKI_S_ISCHR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFCHR)
+#define VKI_S_ISBLK(m)  (((m) & VKI_S_IFMT) == VKI_S_IFBLK)
+
+#define VKI_F_DUPFD  0x00000000
+#define VKI_F_SETFD  0x00000002
+#define VKI_FD_CLOEXEC  0x00000001
+
+#define VKI_R_OK 0x00000004
+#define VKI_W_OK 0x00000002
+#define VKI_X_OK 0x00000001
+
+/* Known:
+   sizeof(struct stat) = 116
+     st_dev:  off  0 sz 4
+     st_ino:  off  4 sz 4
+     st_mode: off  8 sz 4
+     st_uid:  off 16 sz 4
+     st_gid:  off 20 sz 4
+     st_size: off 28 sz 4
+*/
+struct vki_stat {
+   /*  0 */ UInt st_dev;
+   /*  4 */ UInt st_ino;
+   /*  8 */ UInt st_mode;
+   /* 12 */ UInt __off12;
+   /* 16 */ UInt st_uid;
+   /* 20 */ UInt st_gid;
+   /* 24 */ UInt __off24;
+   /* 28 */ UInt st_size;
+   /* 32 */ UChar __off32[116-32];
+};
+
+#define VKI_STX_NORMAL  0
+
+typedef UInt vki_size_t;
+
+#define VKI_SEEK_SET 0
+#define VKI_PATH_MAX 1023
+
+/* Known:
+   sizeof(struct iovec) = 8
+     iov_base: off  0 sz 4
+      iov_len: off  4 sz 4
+*/
+struct vki_iovec {
+   /* 0 */ Addr iov_base;
+   /* 4 */ UInt iov_len;
+};
+
+#define _VKI_IOC_NONE 0
+#define _VKI_IOC_READ 1    /* kernel reads, userspace writes */
+#define _VKI_IOC_WRITE 2   /* kernel writes, userspace reads */
+#define _VKI_IOC_DIR(_x)   (((_x) >> 30) & 3)
+#define _VKI_IOC_SIZE(_x)  (((_x) >> 16) & 0x7F)
+
+/* ---------------- MMappery ---------------- */
+
+/* This assumes the page size is 4096.  That assumption is checked
+   by the launcher. */
+#define VKI_PAGE_SHIFT  12
+#define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
+#define VKI_MAX_PAGE_SHIFT      VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE       VKI_PAGE_SIZE
+
+#define VKI_PROT_NONE  0x00000000
+#define VKI_PROT_READ  0x00000001
+#define VKI_PROT_WRITE 0x00000002
+#define VKI_PROT_EXEC  0x00000004
+
+#define VKI_MAP_FIXED     0x00000100
+#define VKI_MAP_PRIVATE   0x00000002
+#define VKI_MAP_ANONYMOUS 0x00000010
+
+/* ---------------- RLimitery ---------------- */
+
+/* rlimit: these pertain to syscall "appgetrlimit" */
+#define VKI_RLIMIT_DATA   0x00000002
+#define VKI_RLIMIT_NOFILE 0x00000007
+#define VKI_RLIMIT_STACK  0x00000003
+#define VKI_RLIMIT_CORE   0x00000004
+
+/* Known:
+   sizeof(struct rlimit) = 8
+     rlim_cur: off  0 sz 4
+     rlim_max: off  4 sz 4
+*/
+struct vki_rlimit {
+   UInt rlim_cur;
+   UInt rlim_max;
+};
+
+/* ---------------- Time ---------------- */
+
+/* Known:
+   sizeof(struct timeval) = 8
+      tv_sec: off  0 sz 4
+     tv_usec: off  4 sz 4
+*/
+struct vki_timeval {
+   UInt tv_sec;         /* seconds */
+   UInt tv_usec;        /* microseconds */
+};
+
+/* Known:
+   sizeof(struct timespec) = 8
+      tv_sec: off  0 sz 4
+     tv_nsec: off  4 sz 4
+*/
+struct vki_timespec {
+   UInt tv_sec;         /* seconds */
+   UInt tv_nsec;        /* nanoseconds */
+};
+
+/* ---------------- Signals ---------------- */
+
+/* This layout verified 27 July 06. */
+#define _VKI_NSIG_BPW   32
+#define _VKI_NSIG       64
+#define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef struct {
+   UInt sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#define VKI_SIGSEGV   11
+#define VKI_SIGBUS    10
+#define VKI_SIGFPE     8
+#define VKI_SIGHUP     1
+#define VKI_SIGINT     2
+#define VKI_SIGQUIT    3
+#define VKI_SIGABRT    6
+#define VKI_SIGUSR1   30
+#define VKI_SIGUSR2   31
+#define VKI_SIGPIPE   13
+#define VKI_SIGALRM   14
+#define VKI_SIGTERM   15
+/* VKI_SIGSTKFLT does not exist on AIX 5.2 */
+#define VKI_SIGTTIN   21
+#define VKI_SIGTTOU   22
+#define VKI_SIGXCPU   24
+#define VKI_SIGXFSZ   25
+#define VKI_SIGVTALRM 34
+#define VKI_SIGPROF   32
+#define VKI_SIGIO     23
+#define VKI_SIGPWR    29
+/* VKI_SIGUNUSED does not exist on AIX 5.2 */
+#define VKI_SIGRTMIN  50
+#define VKI_SIGRTMAX  57
+#define VKI_SIGTRAP    5
+#define VKI_SIGCONT   19
+#define VKI_SIGCHLD   20
+#define VKI_SIGWINCH  28
+#define VKI_SIGURG    16
+#define VKI_SIGILL     4
+#define VKI_SIGSTOP   17
+#define VKI_SIGKILL    9
+#define VKI_SIGTSTP   18
+#define VKI_SIGSYS    12
+
+/* Known:
+    sizeof(struct sigaction) = 16
+      sa_handler: off  0 sz 4
+         sa_mask: off  4 sz 8
+        sa_flags: off 12 sz 4
+    sa_sigaction: off  0 sz 4
+*/
+struct vki_sigaction {
+   void*        ksa_handler;
+   vki_sigset_t sa_mask;
+   UInt         sa_flags;
+};
+
+#define VKI_SA_ONSTACK      1
+#define VKI_SA_RESTART      8
+#define VKI_SA_RESETHAND    2
+#define VKI_SA_SIGINFO    256
+#define VKI_SA_NODEFER    512
+#define VKI_SA_NOCLDSTOP    4
+#define VKI_SA_NOCLDWAIT 1024
+
+#define VKI_SA_RESTORER  0 /* AIX doesn't have this */
+#define VKI_SA_NOMASK    0 /* AIX doesn't have this */
+#define VKI_SA_ONESHOT   0 /* AIX doesn't have this */
+
+#define VKI_SS_ONSTACK 1
+#define VKI_SS_DISABLE 2
+
+#define VKI_MINSIGSTKSZ 1168
+
+#define VKI_SI_USER  0
+
+#define VKI_SIG_BLOCK      0
+#define VKI_SIG_SETMASK    2
+#define VKI_SIG_UNBLOCK    1
+#define VKI_SIG_IGN        (void*)1
+#define VKI_SIG_DFL        (void*)0
+
+#define VKI_SEGV_ACCERR 51
+#define VKI_SEGV_MAPERR 50
+
+#define VKI_TRAP_TRACE 61
+#define VKI_TRAP_BRKPT 60
+#define VKI_BUS_OBJERR 3
+#define VKI_BUS_ADRERR 2
+#define VKI_BUS_ADRALN 1
+#define VKI_FPE_FLTSUB 27
+#define VKI_FPE_FLTINV 26
+#define VKI_FPE_FLTRES 25
+#define VKI_FPE_FLTUND 24
+#define VKI_FPE_FLTOVF 23
+#define VKI_FPE_FLTDIV 22
+#define VKI_FPE_INTOVF 21
+#define VKI_FPE_INTDIV 20
+#define VKI_ILL_BADSTK 37
+#define VKI_ILL_COPROC 36
+#define VKI_ILL_PRVREG 35
+#define VKI_ILL_PRVOPC 34
+#define VKI_ILL_ILLTRP 33
+#define VKI_ILL_ILLADR 32
+#define VKI_ILL_ILLOPN 31
+#define VKI_ILL_ILLOPC 30
+
+/* Known: 
+    sizeof(siginfo_t) = 64
+     si_signo: off  0 sz 4
+      si_code: off  8 sz 4
+       si_pid: off 12 sz 4
+      si_addr: off 20 sz 4
+*/
+typedef struct {
+    UInt  si_signo;
+    UInt  __off4;
+    UInt  si_code;
+    UInt  si_pid;
+    UInt  __off16;
+    void* si_addr;
+    UInt  __off24;
+    UInt  __off28;
+    UInt  __off32;
+    UInt  __off36;
+    UInt  __off40;
+    UInt  __off44;
+    UInt  __off48;
+    UInt  __off52;
+    UInt  __off56;
+    UInt  __off60;
+} vki_siginfo_t;
+
+/* Known:
+   sizeof(stack_t) = 28
+       ss_sp: off  0 sz 4
+     ss_size: off  4 sz 4
+    ss_flags: off  8 sz 4
+*/
+typedef struct vki_sigaltstack {
+   /*  0 */ void* ss_sp;
+   /*  4 */ UInt  ss_size;
+   /*  8 */ UInt  ss_flags;
+   /* 12 */ UInt  __off12;
+   /* 16 */ UInt  __off16;
+   /* 20 */ UInt  __off20;
+   /* 24 */ UInt  __off24;
+} vki_stack_t;
+
+/* ---------------- Misc ---------------- */
+
+#define VKI_PTRACE_TRACEME 0  /* nb: is really PT_TRACE_ME */
+#define VKI_PTRACE_DETACH 31  /* nb: is really PT_DETACH */
+
+
+//--------------------------------------------------------------
+// BOGUS
+//--------------------------------------------------------------
+
+struct vki_dirent {
+  int bogus;
+};
+
+struct vki_sockaddr {
+  int bogus;
+};
+
+struct vki_pollfd {
+  int bogus;
+};
+
+/* Structure describing an Internet (IP) socket address. */
+//struct vki_sockaddr_in {
+//  int bogus;
+//};
+
+struct vki_ucontext {
+  int bogus;
+};
+
+
+//--------------------------------------------------------------
+// FROM glibc-ports-2.4/sysdeps/unix/sysv/aix/dlldr.h
+//--------------------------------------------------------------
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+/*
+
+ int __loadx(flag, module, arg1, arg2, arg3)
+
+ The __loadx() is a call to ld_loadutil() kernel function, which
+ does the real work. Note ld_loadutil() is not exported an cannot be
+ called directly from user space.
+
+ void *ld_loadutil() call is a utility function used for loader extensions
+ supporting run-time linking and dl*() functions.
+
+ void *   - will return the modules entry point if it succeds of NULL
+                on failure.
+
+ int flag - the flag field performas a dual role: the top 8 bits specify
+            the work for __loadx() to perform, the bottom 8 bits are
+            used to pass flags to the work routines, all other bits are
+            reserved.
+
+*/
+
+#define VKI_DL_LOAD       0x1000000 /* __loadx(flag,buf, buf_len, filename, libr_path) */
+#define VKI_DL_POSTLOADQ  0x2000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define VKI_DL_EXECQ      0x3000000 /* __loadx(flag,buf, buf_len) */
+#define VKI_DL_EXITQ      0x4000000 /* __loadx(flag,buf, buf_len) */
+#define VKI_DL_PREUNLOADQ 0x5000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define VKI_DL_INIT       0x6000000 /* __loadx(flag,NULL) */
+#define VKI_DL_GETSYM     0x7000000 /* __loadx(flag,symbol, index, modules_data_origin) */
+#define VKI_DL_SETDEPEND  0x8000000 /* __loadx(flag,import_data_org, import_index, */
+                                    /*              export_data_org, export_index) */
+#define VKI_DL_DELDEPEND  0x9000000 /* __loadx(flag,import_data_org, import_index, */
+                                    /*              export_data_org, export_index) */
+#define VKI_DL_GLOBALSYM  0xA000000 /* __loadx(flag,symbol_name, ptr_to_rec_index, */
+                                    /*                        ptr_to_rec_data_org) */
+#define VKI_DL_UNIX_SYSCALL 0xB000000 /* __loadx(flag,syscall_symbol_name) */
+
+#define VKI_DL_FUNCTION_MASK 0xFF000000
+#define VKI_DL_SRCHDEPENDS   0x00100000
+#define VKI_DL_SRCHMODULE    0x00080000
+#define VKI_DL_SRCHLOADLIST  0x00040000
+#define VKI_DL_LOAD_LDX1     0x00040000
+#define VKI_DL_LOAD_RTL      0x00020000
+#define VKI_DL_HASHSTRING    0x00020000
+#define VKI_DL_INFO_OK       0x00010000
+#define VKI_DL_LOAD_DLINFO   0x00010000
+#define VKI_DL_UNLOADED      0x00020000
+
+
+#endif // __VKI_PPC32_AIX5_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-ppc32-linux.h b/include/vki/vki-ppc32-linux.h
new file mode 100644
index 0000000..6b44386
--- /dev/null
+++ b/include/vki/vki-ppc32-linux.h
@@ -0,0 +1,934 @@
+
+/*--------------------------------------------------------------------*/
+/*--- PPC32/Linux-specific kernel interface.     vki-ppc32-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_PPC32_LINUX_H
+#define __VKI_PPC32_LINUX_H
+
+// ppc32 is big-endian.
+#define VKI_BIG_ENDIAN  1
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/types.h
+//----------------------------------------------------------------------
+
+typedef unsigned char __vki_u8;
+
+typedef __signed__ short __vki_s16;
+typedef unsigned short __vki_u16;
+
+typedef __signed__ int __vki_s32;
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long long __vki_s64;
+typedef unsigned long long __vki_u64;
+
+typedef unsigned short vki_u16;
+
+typedef unsigned int vki_u32;
+
+typedef struct {
+        __vki_u32 u[4];
+} __vki_vector128;
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/page.h
+//----------------------------------------------------------------------
+
+/* PAGE_SHIFT determines the page size, unfortunately
+   page size might vary between 32-bit and 64-bit ppc kernels */
+extern unsigned long VKI_PAGE_SHIFT;
+extern unsigned long VKI_PAGE_SIZE;
+#define VKI_MAX_PAGE_SHIFT	16
+#define VKI_MAX_PAGE_SIZE	(1UL << VKI_MAX_PAGE_SHIFT)
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h
+//----------------------------------------------------------------------
+
+#define VKI_SHMLBA  VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/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 */
+
+#define _VKI_NSIG       64
+#define _VKI_NSIG_BPW	32
+#define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
+
+typedef struct {
+        unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#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_SA_NOCLDSTOP	0x00000001
+#define VKI_SA_NOCLDWAIT	0x00000002
+#define VKI_SA_SIGINFO		0x00000004
+#define VKI_SA_ONSTACK		0x08000000
+#define VKI_SA_RESTART		0x10000000
+#define VKI_SA_NODEFER		0x40000000
+#define VKI_SA_RESETHAND	0x80000000
+
+#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
+
+/* These are 'legacy' sigactions in which the size of sa_mask is fixed
+   (cannot be expanded at any future point) because it is sandwiched
+   between two other fields.
+   (there is identical kludgery in vki-x86-linux.h) */
+struct vki_old_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;
+        vki_old_sigset_t sa_mask;
+        unsigned long sa_flags;
+        __vki_sigrestore_t sa_restorer;
+};
+
+struct vki_sigaction_base {
+        // [[See comment about extra 'k' above]]
+	__vki_sighandler_t ksa_handler;
+	unsigned long sa_flags;
+	__vki_sigrestore_t sa_restorer;
+	vki_sigset_t sa_mask;		/* mask last for extensibility */
+};
+
+/* On Linux we use the same type for passing sigactions to
+   and from the kernel.  Hence: */
+typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
+typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
+
+
+typedef struct vki_sigaltstack {
+	void __user *ss_sp;
+	int ss_flags;
+	vki_size_t ss_size;
+} vki_stack_t;
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/ptrace.h
+//----------------------------------------------------------------------
+
+struct vki_pt_regs {
+        unsigned long gpr[32];
+        unsigned long nip;
+        unsigned long msr;
+        unsigned long orig_gpr3;        /* Used for restarting system calls */
+        unsigned long ctr;
+        unsigned long link;
+        unsigned long xer;
+        unsigned long ccr;
+        unsigned long mq;               /* 601 only (not used at present) */
+                                        /* Used on APUS to hold IPL value. */
+        unsigned long trap;             /* Reason for being here */
+        /* N.B. for critical exceptions on 4xx, the dar and dsisr
+           fields are overloaded to hold srr0 and srr1. */
+        unsigned long dar;              /* Fault registers */
+        unsigned long dsisr;            /* on 4xx/Book-E used for ESR */
+        unsigned long result;           /* Result of a system call */
+
+        /* Not in kernel's definition, but apparently needed to stop
+           assertion at coredump-elf.c:267 firing.  These padding
+           words make the struct have the same size as a
+           'vki_elf_greg_t'.  See message from Ghassan Hammouri on
+           valgrind-developers on 6 April 06. */
+        unsigned long pad[4];
+};
+
+#define vki_user_regs_struct vki_pt_regs
+
+#define VKI_PT_R0		0
+#define VKI_PT_R1		1
+#define VKI_PT_R2		2
+#define VKI_PT_R3		3
+#define VKI_PT_R4		4
+#define VKI_PT_R5		5
+#define VKI_PT_R6		6
+#define VKI_PT_R7		7
+#define VKI_PT_R8		8
+#define VKI_PT_R9		9
+#define VKI_PT_R10		10
+#define VKI_PT_R11		11
+#define VKI_PT_R12		12
+#define VKI_PT_R13		13
+#define VKI_PT_R14		14
+#define VKI_PT_R15		15
+#define VKI_PT_R16		16
+#define VKI_PT_R17		17
+#define VKI_PT_R18		18
+#define VKI_PT_R19		19
+#define VKI_PT_R20		20
+#define VKI_PT_R21		21
+#define VKI_PT_R22		22
+#define VKI_PT_R23		23
+#define VKI_PT_R24		24
+#define VKI_PT_R25		25
+#define VKI_PT_R26		26
+#define VKI_PT_R27		27
+#define VKI_PT_R28		28
+#define VKI_PT_R29		29
+#define VKI_PT_R30		30
+#define VKI_PT_R31		31
+#define VKI_PT_NIP		32
+#define VKI_PT_MSR		33
+#define VKI_PT_ORIG_R3		34
+#define VKI_PT_CTR		35
+#define VKI_PT_LNK		36
+#define VKI_PT_XER		37
+#define VKI_PT_CCR		38
+#define VKI_PT_MQ		39
+#define VKI_PT_TRAP		40
+#define VKI_PT_DAR		41
+#define VKI_PT_DSISR		42
+#define VKI_PT_RESULT		43
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/sigcontext.h
+//----------------------------------------------------------------------
+
+struct vki_sigcontext {
+        unsigned long      _unused[4];
+        int                signal;
+        unsigned long      handler;
+        unsigned long      oldmask;
+        struct vki_pt_regs *regs;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/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_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
+#define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
+
+#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 */
+#define VKI_MAP_NORESERVE	0x40     /* don't reserve swap pages */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/fcntl.h
+//----------------------------------------------------------------------
+
+#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_LARGEFILE     0200000
+
+#define VKI_AT_FDCWD            -100
+
+#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_SETOWN		 8			/*  for sockets. */
+#define VKI_F_GETOWN		 9			/*  for sockets. */
+#define VKI_F_SETSIG		10			/*  for sockets. */
+#define VKI_F_GETSIG		11			/*  for sockets. */
+
+#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_F_LINUX_SPECIFIC_BASE	1024
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/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.9/include/asm-ppc/socket.h
+//----------------------------------------------------------------------
+
+#define VKI_SOL_SOCKET	1
+#define VKI_SO_TYPE	3
+
+#define VKI_SIOCSPGRP		0x8902
+#define VKI_SIOCGPGRP		0x8904
+#define VKI_SIOCGSTAMP		0x8906          /* Get stamp (timeval) */
+#define VKI_SIOCGSTAMPNS	0x8907          /* Get stamp (timespec) */
+
+//----------------------------------------------------------------------
+// From linux-2.6.10/include/asm-ppc/stat.h
+//----------------------------------------------------------------------
+
+//.. #define VKI_S_IFMT		00170000
+//.. #define VKI_S_IFSOCK	 0140000
+//.. #define VKI_S_IFLNK	 0120000
+//.. #define VKI_S_IFREG	 0100000
+//.. #define VKI_S_IFBLK	 0060000
+//.. #define VKI_S_IFDIR	 0040000
+//.. #define VKI_S_IFCHR	 0020000
+//.. #define VKI_S_IFIFO	 0010000
+//.. #define VKI_S_ISUID	 0004000
+//.. #define VKI_S_ISGID	 0002000
+//.. #define VKI_S_ISVTX	 0001000
+//.. 
+//.. #define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
+//.. #define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
+//.. #define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
+//.. #define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
+//.. #define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
+//.. #define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
+//.. #define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
+
+struct vki_stat {
+   unsigned		st_dev;
+   unsigned long	st_ino;
+   unsigned int		st_mode;
+   unsigned short	st_nlink;
+   unsigned int		st_uid;
+   unsigned int		st_gid;
+   unsigned		st_rdev;
+   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 long long   st_ino;
+   unsigned int         st_mode;
+   unsigned int         st_nlink;
+   unsigned int         st_uid;
+   unsigned int         st_gid;
+   unsigned long long   st_rdev;
+   unsigned short int   __pad2;
+   long long            st_size;
+   long                 st_blksize;
+
+   long long            st_blocks;
+   long                 st_atime;
+   unsigned long        st_atime_nsec;
+   long                 st_mtime;
+   unsigned long int    st_mtime_nsec;
+   long                 st_ctime;
+   unsigned long int    st_ctime_nsec;
+   unsigned long int    __unused4;
+   unsigned long int    __unused5;
+};
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/statfs.h
+//----------------------------------------------------------------------
+
+// [[Nb: asm-ppc/statfs.h just #include asm-generic/statfs.h directly]]
+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.9/include/asm-ppc/termios.h
+//----------------------------------------------------------------------
+
+struct vki_winsize {
+   unsigned short ws_row;
+   unsigned short ws_col;
+   unsigned short ws_xpixel;
+   unsigned short ws_ypixel;
+};
+
+#define NCC 10
+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[NCC];		/* control characters */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/termbits.h
+//----------------------------------------------------------------------
+
+typedef unsigned char   vki_cc_t;
+typedef unsigned int    vki_speed_t;
+typedef unsigned int    vki_tcflag_t;
+
+#define NCCS 19
+struct vki_termios {
+        vki_tcflag_t	c_iflag;		/* input mode flags */
+        vki_tcflag_t	c_oflag;		/* output mode flags */
+        vki_tcflag_t	c_cflag;		/* control mode flags */
+        vki_tcflag_t	c_lflag;		/* local mode flags */
+        vki_cc_t	c_cc[NCCS];		/* control characters */
+        vki_cc_t	c_line;			/* line discipline (== c_cc[19]) */
+        vki_speed_t	c_ispeed;		/* input speed */
+        vki_speed_t	c_ospeed;		/* output speed */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/ioctl.h
+//----------------------------------------------------------------------
+
+#define _VKI_IOC_NRBITS		 8
+#define _VKI_IOC_TYPEBITS	 8
+#define _VKI_IOC_SIZEBITS	13
+#define _VKI_IOC_DIRBITS	 3
+
+#define _VKI_IOC_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
+#define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
+#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	1U
+#define _VKI_IOC_READ	2U
+#define _VKI_IOC_WRITE	4U
+
+#define _VKI_IOC(dir,type,nr,size) \
+        (((dir)  << _VKI_IOC_DIRSHIFT) | \
+         ((type) << _VKI_IOC_TYPESHIFT) | \
+         ((nr)   << _VKI_IOC_NRSHIFT) | \
+         ((size) << _VKI_IOC_SIZESHIFT))
+
+/* 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 them.. */
+#define _VKI_IOC_DIR(nr)		(((nr) >> _VKI_IOC_DIRSHIFT)  & _VKI_IOC_DIRMASK)
+//.. #define _VKI_IOC_TYPE(nr)		(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
+//.. #define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT)   & _VKI_IOC_NRMASK)
+#define _VKI_IOC_SIZE(nr)		(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/ioctls.h
+//----------------------------------------------------------------------
+
+//#define VKI_FIOCLEX		_VKI_IO('f', 1)
+//#define VKI_FIONCLEX		_VKI_IO('f', 2)
+#define VKI_FIOASYNC		_VKI_IOW('f', 125, int)
+#define VKI_FIONBIO		_VKI_IOW('f', 126, int)
+#define VKI_FIONREAD		_VKI_IOR('f', 127, int)
+//#define VKI_TIOCINQ		VKI_FIONREAD
+//#define VKI_FIOQSIZE		_VKI_IOR('f', 128, vki_loff_t)
+
+//#define VKI_TIOCGETP		_VKI_IOR('t', 8, struct vki_sgttyb)
+//#define VKI_TIOCSETP		_VKI_IOW('t', 9, struct vki_sgttyb)
+//#define VKI_TIOCSETN		_VKI_IOW('t', 10, struct vki_sgttyb)    /* TIOCSETP wo flush */
+
+//#define VKI_TIOCSETC		_VKI_IOW('t', 17, struct vki_tchars)
+//#define VKI_TIOCGETC		_VKI_IOR('t', 18, struct vki_tchars)
+#define VKI_TCGETS		_VKI_IOR('t', 19, struct vki_termios)
+#define VKI_TCSETS		_VKI_IOW('t', 20, struct vki_termios)
+#define VKI_TCSETSW		_VKI_IOW('t', 21, struct vki_termios)
+#define VKI_TCSETSF		_VKI_IOW('t', 22, struct vki_termios)
+
+#define VKI_TCGETA		_VKI_IOR('t', 23, struct vki_termio)
+#define VKI_TCSETA		_VKI_IOW('t', 24, struct vki_termio)
+#define VKI_TCSETAW		_VKI_IOW('t', 25, struct vki_termio)
+#define VKI_TCSETAF		_VKI_IOW('t', 28, struct vki_termio)
+
+#define VKI_TCSBRK		_VKI_IO('t', 29)
+#define VKI_TCXONC		_VKI_IO('t', 30)
+#define VKI_TCFLSH		_VKI_IO('t', 31)
+
+#define VKI_TIOCSWINSZ		_VKI_IOW('t', 103, struct vki_winsize)
+#define VKI_TIOCGWINSZ		_VKI_IOR('t', 104, struct vki_winsize)
+//#define VKI_TIOCSTART		_VKI_IO('t', 110)	   /* start output, like ^Q */
+//#define VKI_TIOCSTOP		_VKI_IO('t', 111)	   /* stop output, like ^S */
+#define VKI_TIOCOUTQ		_VKI_IOR('t', 115, int)	   /* output queue size */
+
+//#define VKI_TIOCGLTC		_VKI_IOR('t', 116, struct vki_ltchars)
+//#define VKI_TIOCSLTC		_VKI_IOW('t', 117, struct vki_ltchars)
+#define VKI_TIOCSPGRP		_VKI_IOW('t', 118, int)
+#define VKI_TIOCGPGRP		_VKI_IOR('t', 119, int)
+
+//#define VKI_TIOCEXCL		0x540C
+//#define VKI_TIOCNXCL		0x540D
+#define VKI_TIOCSCTTY		0x540E
+
+//#define VKI_TIOCSTI		0x5412
+#define VKI_TIOCMGET		0x5415
+#define VKI_TIOCMBIS		0x5416
+#define VKI_TIOCMBIC		0x5417
+#define VKI_TIOCMSET		0x5418
+//# define VKI_TIOCM_LE		0x001
+//# define VKI_TIOCM_DTR	0x002
+//# define VKI_TIOCM_RTS	0x004
+//# define VKI_TIOCM_ST		0x008
+//# define VKI_TIOCM_SR		0x010
+//# define VKI_TIOCM_CTS	0x020
+//# define VKI_TIOCM_CAR	0x040
+//# define VKI_TIOCM_RNG	0x080
+//# define VKI_TIOCM_DSR	0x100
+//# define VKI_TIOCM_CD		VKI_TIOCM_CAR
+//# define VKI_TIOCM_RI		VKI_TIOCM_RNG
+
+//#define VKI_TIOCGSOFTCAR	0x5419
+//#define VKI_TIOCSSOFTCAR	0x541A
+#define VKI_TIOCLINUX		0x541C
+//#define VKI_TIOCCONS		0x541D
+//#define VKI_TIOCGSERIAL	0x541E
+//#define VKI_TIOCSSERIAL	0x541F
+//#define VKI_TIOCPKT		0x5420
+//# define VKI_TIOCPKT_DATA		 0
+//# define VKI_TIOCPKT_FLUSHREAD	 1
+//# define VKI_TIOCPKT_FLUSHWRITE	 2
+//# define VKI_TIOCPKT_STOP		 4
+//# define VKI_TIOCPKT_START		 8
+//# define VKI_TIOCPKT_NOSTOP		16
+//# define VKI_TIOCPKT_DOSTOP		32
+
+//#define VKI_TIOCNOTTY		0x5422
+//#define VKI_TIOCSETD		0x5423
+//#define VKI_TIOCGETD		0x5424
+#define VKI_TCSBRKP		0x5425  /* Needed for POSIX tcsendbreak() */
+//#define VKI_TIOCSBRK		0x5427  /* BSD compatibility */
+//#define VKI_TIOCCBRK		0x5428  /* BSD compatibility */
+//#define VKI_TIOCGSID		0x5429  /* Return the session ID of FD */
+#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_TIOCSERCONFIG	0x5453
+//#define VKI_TIOCSERGWILD	0x5454
+//#define VKI_TIOCSERSWILD  	0x5455
+//#define VKI_TIOCGLCKTRMIOS	0x5456
+//#define VKI_TIOCSLCKTRMIOS	0x5457
+//#define VKI_TIOCSERGSTRUCT	0x5458 /* For debugging only */
+#define VKI_TIOCSERGETLSR	0x5459 /* Get line status register */
+  /* ioctl (fd, VKI_TIOCSERGETLSR, &result) where result may be as below */
+//# define VKI_TIOCSER_TEMT	0x01   /* Transmitter physically empty */
+//#define VKI_TIOCSERGETMULTI	0x545A /* Get multiport config  */
+//#define VKI_TIOCSERSETMULTI	0x545B /* Set multiport config */
+
+//#define VKI_TIOCMIWAIT	0x545C  /* wait for a change on serial input line(s) */
+#define VKI_TIOCGICOUNT		0x545D  /* read serial port inline interrupt counts */
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/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.9/include/asm-ppc/elf.h
+//----------------------------------------------------------------------
+
+#define VKI_ELF_NGREG			48	/* includes nip, msr, lr, etc. */
+#define VKI_ELF_NFPREG			33	/* includes fpscr */
+#define VKI_ELF_NVRREG			33	/* includes vscr */
+
+/* General registers */
+typedef unsigned long vki_elf_greg_t;
+typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
+
+/* Floating point registers */
+typedef double vki_elf_fpreg_t;
+typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
+
+/* Altivec registers */
+typedef __vki_vector128 vki_elf_vrreg_t;
+typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
+
+#define VKI_AT_DCACHEBSIZE		19
+#define VKI_AT_ICACHEBSIZE		20
+#define VKI_AT_UCACHEBSIZE		21
+/* A special ignored type value for PPC, for glibc compatibility.  */
+#define VKI_AT_IGNOREPPC	  	22
+
+/* CAB: Do we want these? */
+//#define VKI_AT_SYSINFO		32
+//#define VKI_AT_SYSINFO_EHDR  		33
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/ucontext.h
+//----------------------------------------------------------------------
+
+struct vki_mcontext {
+        vki_elf_gregset_t	mc_gregs;
+        vki_elf_fpregset_t	mc_fregs;
+        unsigned long		mc_pad[2];
+        vki_elf_vrregset_t	mc_vregs __attribute__((__aligned__(16)));
+};
+
+struct vki_ucontext {
+        unsigned long		uc_flags;
+        struct vki_ucontext	__user *uc_link;
+        vki_stack_t		uc_stack;
+        int			uc_pad[7];
+        struct vki_mcontext	__user *uc_regs;		/* points to uc_mcontext field */
+        vki_sigset_t		uc_sigmask;
+        /* glibc has 1024-bit signal masks, ours are 64-bit */
+        int			uc_maskext[30];
+        int			uc_pad2[3];
+        struct vki_mcontext	uc_mcontext;
+};
+
+//.. //----------------------------------------------------------------------
+//.. // 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.9/include/asm-ppc/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;
+
+// CAB: TODO
+typedef void vki_modify_ldt_t;
+
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/ipcbuf.h
+//----------------------------------------------------------------------
+
+struct vki_ipc64_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 long	seq;
+   unsigned int		__pad2;
+   unsigned long long	__unused1;
+   unsigned long long	__unused2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/sembuf.h
+//----------------------------------------------------------------------
+
+struct vki_semid64_ds {
+   struct vki_ipc64_perm	sem_perm;		/* permissions .. see ipc.h */
+   unsigned int			__unused1;
+   __vki_kernel_time_t		sem_otime;		/* last semop time */
+   unsigned int			__unused2;
+   __vki_kernel_time_t		sem_ctime;		/* last change time */
+   unsigned long		sem_nsems;		/* no. of semaphores in array */
+   unsigned long		__unused3;
+   unsigned long		__unused4;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/msgbuf.h
+//----------------------------------------------------------------------
+
+struct vki_msqid64_ds {
+   struct vki_ipc64_perm	msg_perm;
+   unsigned int			__unused1;
+   __vki_kernel_time_t		msg_stime;		/* last msgsnd time */
+   unsigned int			__unused2;
+   __vki_kernel_time_t		msg_rtime;		/* last msgrcv time */
+   unsigned int			__unused3;
+   __vki_kernel_time_t		msg_ctime;		/* last change time */
+   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-ppc/ipc.h
+//----------------------------------------------------------------------
+
+struct vki_ipc_kludge {
+        struct vki_msgbuf __user *msgp;
+        long msgtyp;
+};
+
+#define VKI_SEMOP            1
+#define VKI_SEMGET           2
+#define VKI_SEMCTL           3
+#define VKI_SEMTIMEDOP       4
+#define VKI_MSGSND          11
+#define VKI_MSGRCV          12
+#define VKI_MSGGET          13
+#define VKI_MSGCTL          14
+#define VKI_SHMAT           21
+#define VKI_SHMDT           22
+#define VKI_SHMGET          23
+#define VKI_SHMCTL          24
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-ppc/shmbuf.h
+//----------------------------------------------------------------------
+
+struct vki_shmid64_ds {
+   struct vki_ipc64_perm	shm_perm;		/* operation perms */
+   unsigned int			__unused1;
+   __vki_kernel_time_t		shm_atime;		/* last attach time */
+   unsigned int			__unused2;
+   __vki_kernel_time_t		shm_dtime;		/* last detach time */
+   unsigned int			__unused3;
+   __vki_kernel_time_t		shm_ctime;		/* last change time */
+   unsigned int			__unused4;
+   vki_size_t			shm_segsz;		/* size of segment (bytes) */
+   __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		__unused5;
+   unsigned long		__unused6;
+};
+
+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;
+};
+
+//.. //----------------------------------------------------------------------
+//.. // DRM ioctls
+//.. //----------------------------------------------------------------------
+//.. 
+//.. // jrs 20050207: where did all this stuff come from?  Is it really
+//.. // i386 specific, or should it go into the linux-generic category?
+//.. //struct vki_drm_buf_pub {
+//.. //	Int		  idx;	       /**< Index into the master buffer list */
+//.. //	Int		  total;       /**< Buffer size */
+//.. //	Int		  used;	       /**< Amount of buffer in use (for DMA) */
+//.. //	void	  __user *address;     /**< Address of buffer */
+//.. //};
+//.. //
+//.. //struct vki_drm_buf_map {
+//.. //	Int	      count;		/**< Length of the buffer list */
+//.. //	void	      __user *virtual;	/**< Mmap'd area in user-virtual */
+//.. //	struct vki_drm_buf_pub __user *list;	/**< Buffer information */
+//.. //};
+//.. //
+//.. ///* We need to pay attention to this, because it mmaps memory */
+//.. //#define VKI_DRM_IOCTL_MAP_BUFS		_VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
+
+//----------------------------------------------------------------------
+// And that's it!
+//----------------------------------------------------------------------
+
+#endif // __VKI_PPC32_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-ppc64-aix5.h b/include/vki/vki-ppc64-aix5.h
new file mode 100644
index 0000000..092d92c
--- /dev/null
+++ b/include/vki/vki-ppc64-aix5.h
@@ -0,0 +1,464 @@
+
+/*--------------------------------------------------------------------*/
+/*--- 64-bit AIX5-specific kernel interface.      vki-ppc64-aix5.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2006-2010 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.
+*/
+
+/* This file defines types and constants for the kernel interface, and to
+   make that clear everything is prefixed VKI_/vki_.
+*/
+
+/* This file was generated by running auxprogs/aix5_VKI_info.c. */
+
+#ifndef __VKI_PPC64_AIX5_H
+#define __VKI_PPC64_AIX5_H
+
+#if !defined(VGP_ppc64_aix5)
+#  error This file should be included in 64-bit AIX5 builds only.
+#endif
+
+//--------------------------------------------------------------
+// VERIFIED
+//--------------------------------------------------------------
+
+/* ---------------- Errors ---------------- */
+
+#define VKI_EINVAL 22
+#define VKI_EINTR  4
+#define VKI_ENOSYS 109
+#define VKI_EAGAIN 11
+#define VKI_ENOMEM 12
+#define VKI_EACCES 13
+#define VKI_EEXIST 17
+#define VKI_EPERM  1
+#define VKI_ENOENT 2
+#define VKI_ESRCH  3
+#define VKI_EBADF  9
+#define VKI_EFAULT 14
+#define VKI_EMFILE 24
+#define VKI_ECHILD 10
+#define VKI_EOVERFLOW 127
+#define VKI_ERESTARTSYS 0 /* AIX doesn't have this */
+
+/* ---------------- File I/O ---------------- */
+
+#define VKI_O_WRONLY 0x00000001
+#define VKI_O_RDONLY 0x00000000
+#define VKI_O_APPEND 0x00000008
+#define VKI_O_CREAT  0x00000100
+#define VKI_O_RDWR   0x00000002
+#define VKI_O_EXCL   0x00000400
+#define VKI_O_TRUNC  0x00000200
+
+#define VKI_S_IRUSR  0x00000100
+#define VKI_S_IXUSR  0x00000040
+#define VKI_S_IXGRP  0x00000008
+#define VKI_S_IXOTH  0x00000001
+#define VKI_S_IWUSR  0x00000080
+#define VKI_S_IWOTH  0x00000002
+#define VKI_S_ISUID  0x00000800
+#define VKI_S_ISGID  0x00000400
+#define VKI_S_IFMT   0x0000f000
+#define VKI_S_IFDIR  0x00004000
+#define VKI_S_IFCHR  0x00002000
+#define VKI_S_IFBLK  0x00006000
+
+/* Next 3 are from include/vki/vki-linux.h */
+#define VKI_S_ISDIR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFDIR)
+#define VKI_S_ISCHR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFCHR)
+#define VKI_S_ISBLK(m)  (((m) & VKI_S_IFMT) == VKI_S_IFBLK)
+
+#define VKI_F_DUPFD  0x00000000
+#define VKI_F_SETFD  0x00000002
+#define VKI_FD_CLOEXEC  0x00000001
+
+#define VKI_R_OK 0x00000004
+#define VKI_W_OK 0x00000002
+#define VKI_X_OK 0x00000001
+
+/* Known:
+   sizeof(struct stat) = 176
+      st_dev:  off   0 sz 8
+      st_ino:  off   8 sz 8
+      st_mode: off  16 sz 4
+      st_uid:  off  24 sz 4
+      st_gid:  off  28 sz 4
+      st_size: off 168 sz 8
+*/
+struct vki_stat {
+   /*   0 */ ULong st_dev;
+   /*   8 */ ULong st_ino;
+   /*  16 */ UInt  st_mode;
+   /*  20 */ UInt  __off20;
+   /*  24 */ UInt  st_uid;
+   /*  28 */ UInt  st_gid;
+   /*  32 */ UChar __off28[168-32];
+   /* 168 */ ULong st_size;
+};
+
+#define VKI_STX_NORMAL  0
+
+typedef ULong vki_size_t;
+
+#define VKI_SEEK_SET 0
+#define VKI_PATH_MAX 1023
+
+/* Known:
+   sizeof(struct iovec) = 16
+      iov_base: off  0 sz 8
+      iov_len:  off  8 sz 8
+
+*/
+struct vki_iovec {
+   /* 0 */ Addr  iov_base;
+   /* 8 */ ULong iov_len;
+};
+
+#define _VKI_IOC_NONE 0
+#define _VKI_IOC_READ 1    /* kernel reads, userspace writes */
+#define _VKI_IOC_WRITE 2   /* kernel writes, userspace reads */
+#define _VKI_IOC_DIR(_x)   (((_x) >> 30) & 3)
+#define _VKI_IOC_SIZE(_x)  (((_x) >> 16) & 0x7F)
+
+/* ---------------- MMappery ---------------- */
+
+/* This assumes the page size is 4096.  That assumption is checked
+   by the launcher. */
+#define VKI_PAGE_SHIFT  12
+#define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
+#define VKI_MAX_PAGE_SHIFT      VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE       VKI_PAGE_SIZE
+
+#define VKI_PROT_NONE  0x00000000
+#define VKI_PROT_READ  0x00000001
+#define VKI_PROT_WRITE 0x00000002
+#define VKI_PROT_EXEC  0x00000004
+
+#define VKI_MAP_FIXED     0x00000100
+#define VKI_MAP_PRIVATE   0x00000002
+#define VKI_MAP_ANONYMOUS 0x00000010
+
+/* ---------------- RLimitery ---------------- */
+
+/* rlimit: these pertain to syscall "appgetrlimit" */
+#define VKI_RLIMIT_DATA   0x00000002
+#define VKI_RLIMIT_NOFILE 0x00000007
+#define VKI_RLIMIT_STACK  0x00000003
+#define VKI_RLIMIT_CORE   0x00000004
+
+/* Known:
+   sizeof(struct rlimit) = 16
+      rlim_cur: off  0 sz 8
+      rlim_max: off  8 sz 8
+*/
+struct vki_rlimit {
+   /* 0 */ ULong rlim_cur;
+   /* 8 */ ULong rlim_max;
+};
+
+/* ---------------- Time ---------------- */
+
+/* Known:
+   sizeof(struct timeval) = 16
+      tv_sec: off  0 sz 8
+     tv_usec: off  8 sz 4
+*/
+struct vki_timeval {
+   /*  0 */ ULong tv_sec;         /* seconds */
+   /*  8 */ UInt  tv_usec;        /* microseconds */
+   /* 12 */ UInt  __off12;
+};
+
+/* Known:
+   sizeof(struct timespec) = 16
+      tv_sec: off  0 sz 8
+     tv_nsec: off  8 sz 8
+*/
+struct vki_timespec {
+   /* 0 */ ULong tv_sec;         /* seconds */
+   /* 8 */ ULong tv_nsec;        /* nanoseconds */
+};
+
+/* ---------------- Signals ---------------- */
+
+/* This layout verified 27 July 06. */
+#define _VKI_NSIG_BPW   64
+#define _VKI_NSIG       256
+#define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef struct {
+   ULong sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#define VKI_SIGSEGV   11
+#define VKI_SIGBUS    10
+#define VKI_SIGFPE     8
+#define VKI_SIGHUP     1
+#define VKI_SIGINT     2
+#define VKI_SIGQUIT    3
+#define VKI_SIGABRT    6
+#define VKI_SIGUSR1   30
+#define VKI_SIGUSR2   31
+#define VKI_SIGPIPE   13
+#define VKI_SIGALRM   14
+#define VKI_SIGTERM   15
+/* VKI_SIGSTKFLT does not exist on AIX 5.2 */
+#define VKI_SIGTTIN   21
+#define VKI_SIGTTOU   22
+#define VKI_SIGXCPU   24
+#define VKI_SIGXFSZ   25
+#define VKI_SIGVTALRM 34
+#define VKI_SIGPROF   32
+#define VKI_SIGIO     23
+#define VKI_SIGPWR    29
+/* VKI_SIGUNUSED does not exist on AIX 5.2 */
+#define VKI_SIGRTMIN  50
+#define VKI_SIGRTMAX  57
+#define VKI_SIGTRAP    5
+#define VKI_SIGCONT   19
+#define VKI_SIGCHLD   20
+#define VKI_SIGWINCH  28
+#define VKI_SIGURG    16
+#define VKI_SIGILL     4
+#define VKI_SIGSTOP   17
+#define VKI_SIGKILL    9
+#define VKI_SIGTSTP   18
+#define VKI_SIGSYS    12
+
+/* Known:
+   sizeof(struct sigaction) = 48
+   sa_sigaction: off  0 sz 8
+     sa_handler: off  0 sz 8
+        sa_mask: off  8 sz 32
+       sa_flags: off 40 sz 4
+*/
+struct vki_sigaction {
+   /*  0 */ void*        ksa_handler;
+   /*  8 */ vki_sigset_t sa_mask;
+   /* 40 */ UInt         sa_flags;
+   /* 44 */ UInt         __off44;
+};
+
+#define VKI_SA_ONSTACK      1
+#define VKI_SA_RESTART      8
+#define VKI_SA_RESETHAND    2
+#define VKI_SA_SIGINFO    256
+#define VKI_SA_NODEFER    512
+#define VKI_SA_NOCLDSTOP    4
+#define VKI_SA_NOCLDWAIT 1024
+
+#define VKI_SA_RESTORER  0 /* AIX doesn't have this */
+#define VKI_SA_NOMASK    0 /* AIX doesn't have this */
+#define VKI_SA_ONESHOT   0 /* AIX doesn't have this */
+
+#define VKI_SS_ONSTACK 1
+#define VKI_SS_DISABLE 2
+
+#define VKI_MINSIGSTKSZ 1200
+
+#define VKI_SI_USER  0
+
+#define VKI_SIG_BLOCK      0
+#define VKI_SIG_SETMASK    2
+#define VKI_SIG_UNBLOCK    1
+#define VKI_SIG_IGN        (void*)1
+#define VKI_SIG_DFL        (void*)0
+
+#define VKI_SEGV_ACCERR 51
+#define VKI_SEGV_MAPERR 50
+
+#define VKI_TRAP_TRACE 61
+#define VKI_TRAP_BRKPT 60
+#define VKI_BUS_OBJERR 3
+#define VKI_BUS_ADRERR 2
+#define VKI_BUS_ADRALN 1
+#define VKI_FPE_FLTSUB 27
+#define VKI_FPE_FLTINV 26
+#define VKI_FPE_FLTRES 25
+#define VKI_FPE_FLTUND 24
+#define VKI_FPE_FLTOVF 23
+#define VKI_FPE_FLTDIV 22
+#define VKI_FPE_INTOVF 21
+#define VKI_FPE_INTDIV 20
+
+#define VKI_ILL_BADSTK 37
+#define VKI_ILL_COPROC 36
+#define VKI_ILL_PRVREG 35
+#define VKI_ILL_PRVOPC 34
+#define VKI_ILL_ILLTRP 33
+#define VKI_ILL_ILLADR 32
+#define VKI_ILL_ILLOPN 31
+#define VKI_ILL_ILLOPC 30
+
+/* Known: 
+   sizeof(siginfo_t) = 64
+      si_signo: off  0 sz 4
+       si_code: off  8 sz 4
+        si_pid: off 12 sz 4
+       si_addr: off 24 sz 8
+*/
+typedef struct {
+   /*  0 */ UInt  si_signo;
+   /*  4 */ UInt  __off4;
+   /*  8 */ UInt  si_code;
+   /* 12 */ UInt  si_pid;
+   /* 16 */ UInt  __off16;
+   /* 20 */ UInt  __off20;
+   /* 24 */ void* si_addr;
+   /* 32 */ UInt  __off32;
+   /* 36 */ UInt  __off36;
+   /* 40 */ UInt  __off40;
+   /* 44 */ UInt  __off44;
+   /* 48 */ UInt  __off48;
+   /* 52 */ UInt  __off52;
+   /* 56 */ UInt  __off56;
+   /* 60 */ UInt  __off60;
+} vki_siginfo_t;
+
+/* Known:
+   sizeof(stack_t) = 40
+       ss_sp: off  0 sz 8
+     ss_size: off  8 sz 8
+    ss_flags: off 16 sz 4
+*/
+typedef struct vki_sigaltstack {
+   /*  0 */ void* ss_sp;
+   /*  8 */ ULong ss_size;
+   /* 16 */ UInt  ss_flags;
+   /* 20 */ UInt  __off20;
+   /* 24 */ ULong __off24;
+   /* 32 */ ULong __off32;
+} vki_stack_t;
+
+/* ---------------- Misc ---------------- */
+
+#define VKI_PTRACE_TRACEME 0  /* nb: is really PT_TRACE_ME */
+#define VKI_PTRACE_DETACH 31  /* nb: is really PT_DETACH */
+
+
+//--------------------------------------------------------------
+// BOGUS
+//--------------------------------------------------------------
+
+struct vki_dirent {
+  int bogus;
+};
+
+struct vki_sockaddr {
+  int bogus;
+};
+
+struct vki_pollfd {
+  int bogus;
+};
+
+/* Structure describing an Internet (IP) socket address. */
+//struct vki_sockaddr_in {
+//  int bogus;
+//};
+
+struct vki_ucontext {
+  int bogus;
+};
+
+
+//--------------------------------------------------------------
+// FROM glibc-ports-2.4/sysdeps/unix/sysv/aix/dlldr.h
+//--------------------------------------------------------------
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+
+/*
+
+ int __loadx(flag, module, arg1, arg2, arg3)
+
+ The __loadx() is a call to ld_loadutil() kernel function, which
+ does the real work. Note ld_loadutil() is not exported an cannot be
+ called directly from user space.
+
+ void *ld_loadutil() call is a utility function used for loader extensions
+ supporting run-time linking and dl*() functions.
+
+ void *   - will return the modules entry point if it succeds of NULL
+                on failure.
+
+ int flag - the flag field performas a dual role: the top 8 bits specify
+            the work for __loadx() to perform, the bottom 8 bits are
+            used to pass flags to the work routines, all other bits are
+            reserved.
+
+*/
+
+#define VKI_DL_LOAD       0x1000000 /* __loadx(flag,buf, buf_len, filename, libr_path) */
+#define VKI_DL_POSTLOADQ  0x2000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define VKI_DL_EXECQ      0x3000000 /* __loadx(flag,buf, buf_len) */
+#define VKI_DL_EXITQ      0x4000000 /* __loadx(flag,buf, buf_len) */
+#define VKI_DL_PREUNLOADQ 0x5000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define VKI_DL_INIT       0x6000000 /* __loadx(flag,NULL) */
+#define VKI_DL_GETSYM     0x7000000 /* __loadx(flag,symbol, index, modules_data_origin) */
+#define VKI_DL_SETDEPEND  0x8000000 /* __loadx(flag,import_data_org, import_index, */
+                                    /*              export_data_org, export_index) */
+#define VKI_DL_DELDEPEND  0x9000000 /* __loadx(flag,import_data_org, import_index, */
+                                    /*              export_data_org, export_index) */
+#define VKI_DL_GLOBALSYM  0xA000000 /* __loadx(flag,symbol_name, ptr_to_rec_index, */
+                                    /*                        ptr_to_rec_data_org) */
+#define VKI_DL_UNIX_SYSCALL 0xB000000 /* __loadx(flag,syscall_symbol_name) */
+
+#define VKI_DL_FUNCTION_MASK 0xFF000000
+#define VKI_DL_SRCHDEPENDS   0x00100000
+#define VKI_DL_SRCHMODULE    0x00080000
+#define VKI_DL_SRCHLOADLIST  0x00040000
+#define VKI_DL_LOAD_LDX1     0x00040000
+#define VKI_DL_LOAD_RTL      0x00020000
+#define VKI_DL_HASHSTRING    0x00020000
+#define VKI_DL_INFO_OK       0x00010000
+#define VKI_DL_LOAD_DLINFO   0x00010000
+#define VKI_DL_UNLOADED      0x00020000
+
+
+#endif // __VKI_PPC64_AIX5_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-ppc64-linux.h b/include/vki/vki-ppc64-linux.h
new file mode 100644
index 0000000..5af8470
--- /dev/null
+++ b/include/vki/vki-ppc64-linux.h
@@ -0,0 +1,771 @@
+
+/*--------------------------------------------------------------------*/
+/*--- PPC64/Linux-specific kernel interface.     vki-ppc64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_PPC64_LINUX_H
+#define __VKI_PPC64_LINUX_H
+
+// ppc64 is big-endian.
+#define VKI_BIG_ENDIAN  1
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/types.h
+//----------------------------------------------------------------------
+
+typedef __signed__ char __vki_s8;
+typedef unsigned char __vki_u8;
+
+typedef __signed__ short __vki_s16;
+typedef unsigned short __vki_u16;
+
+typedef __signed__ int __vki_s32;
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long __vki_s64;
+typedef unsigned long __vki_u64;
+
+typedef struct {
+  __vki_u32 u[4];
+} __attribute((aligned(16))) __vki_vector128;
+
+typedef unsigned short vki_u16;
+
+typedef unsigned int vki_u32;
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/page.h
+//----------------------------------------------------------------------
+
+/* PAGE_SHIFT determines the page size, unfortunately
+   page size might vary between 32-bit and 64-bit ppc kernels */
+extern unsigned long VKI_PAGE_SHIFT;
+extern unsigned long VKI_PAGE_SIZE;
+#define VKI_MAX_PAGE_SHIFT	16
+#define VKI_MAX_PAGE_SIZE	(1UL << VKI_MAX_PAGE_SHIFT)
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/powerpc/include/asm/shmparam.h
+//----------------------------------------------------------------------
+
+#define VKI_SHMLBA  VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/signal.h
+//----------------------------------------------------------------------
+
+#define VKI_MINSIGSTKSZ     2048
+
+/* Next 9 non-blank lines asm-generic/signal.h */
+#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 */
+
+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 */
+
+/* Back in asm-ppc64/signal.h */
+#define _VKI_NSIG           64
+#define _VKI_NSIG_BPW       64
+#define _VKI_NSIG_WORDS     (_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef unsigned long vki_old_sigset_t;             /* at least 32 bits */
+
+typedef struct {
+  unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#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_SIGPOLL         VKI_SIGIO
+#define VKI_SIGPWR          30
+#define VKI_SIGSYS          31
+#define VKI_SIGUNUSED       31
+
+/* These should not be considered constants from userland.  */
+#define VKI_SIGRTMIN        32
+#define VKI_SIGRTMAX        _VKI_NSIG
+
+#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    0x20000000u /* dummy -- ignored */
+
+#define VKI_SA_RESTORER     0x04000000u
+
+#define VKI_SS_ONSTACK      1
+#define VKI_SS_DISABLE      2
+
+// See comments on corresponding decls in vki-x86-linux.h re ksa_handler
+struct vki_old_sigaction {
+  __vki_sighandler_t ksa_handler;
+  vki_old_sigset_t sa_mask;
+  unsigned long sa_flags;
+  __vki_sigrestore_t sa_restorer;
+};
+
+struct vki_sigaction_base {
+  __vki_sighandler_t ksa_handler;
+  unsigned long sa_flags;
+  __vki_sigrestore_t sa_restorer;
+  vki_sigset_t sa_mask;               /* mask last for extensibility */
+};
+
+/* On Linux we use the same type for passing sigactions to
+   and from the kernel.  Hence: */
+typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
+typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
+
+
+typedef struct vki_sigaltstack {
+  void __user *ss_sp;
+  int ss_flags;
+  vki_size_t ss_size;
+} vki_stack_t;
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PPC_REG unsigned long
+struct vki_pt_regs {
+  VKI_PPC_REG gpr[32];
+  VKI_PPC_REG nip;
+  VKI_PPC_REG msr;
+  VKI_PPC_REG orig_gpr3;      /* Used for restarting system calls */
+  VKI_PPC_REG ctr;
+  VKI_PPC_REG link;
+  VKI_PPC_REG xer;
+  VKI_PPC_REG ccr;
+  VKI_PPC_REG softe;          /* Soft enabled/disabled */
+  VKI_PPC_REG trap;           /* Reason for being here */
+  VKI_PPC_REG dar;            /* Fault registers */
+  VKI_PPC_REG dsisr;
+  VKI_PPC_REG result;         /* Result of a system call */
+
+  /* Not in kernel's definition, but apparently needed to stop
+     assertion at coredump-elf.c:267 firing.  These padding words make
+     the struct have the same size as a 'vki_elf_greg_t'.  See message
+     from Ghassan Hammouri on valgrind-developers on 6 April 06, and
+     also the analogous kludge for ppc32-linux (svn r5852 and bug
+     #121617). */
+  unsigned long pad[4];
+};
+
+/* Kludge?  I don't know where this came from or if it is right. */
+#define vki_user_regs_struct vki_pt_regs
+
+#define VKI_PT_R0   0
+#define VKI_PT_R1   1
+#define VKI_PT_R2   2
+#define VKI_PT_R3   3
+#define VKI_PT_R4   4
+#define VKI_PT_R5   5
+#define VKI_PT_R6   6
+#define VKI_PT_R7   7
+#define VKI_PT_R8   8
+#define VKI_PT_R9   9
+#define VKI_PT_R10  10
+#define VKI_PT_R11  11
+#define VKI_PT_R12  12
+#define VKI_PT_R13  13
+#define VKI_PT_R14  14
+#define VKI_PT_R15  15
+#define VKI_PT_R16  16
+#define VKI_PT_R17  17
+#define VKI_PT_R18  18
+#define VKI_PT_R19  19
+#define VKI_PT_R20  20
+#define VKI_PT_R21  21
+#define VKI_PT_R22  22
+#define VKI_PT_R23  23
+#define VKI_PT_R24  24
+#define VKI_PT_R25  25
+#define VKI_PT_R26  26
+#define VKI_PT_R27  27
+#define VKI_PT_R28  28
+#define VKI_PT_R29  29
+#define VKI_PT_R30  30
+#define VKI_PT_R31  31
+#define VKI_PT_NIP  32
+#define VKI_PT_MSR  33
+#define VKI_PT_ORIG_R3 34
+#define VKI_PT_CTR  35
+#define VKI_PT_LNK  36
+#define VKI_PT_XER  37
+#define VKI_PT_CCR  38
+#define VKI_PT_SOFTE 39
+#define VKI_PT_RESULT 43
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/elf.h
+//----------------------------------------------------------------------
+
+#define VKI_ELF_NGREG       48      /* includes nip, msr, lr, etc. */
+#define VKI_ELF_NFPREG      33      /* includes fpscr */
+#define VKI_ELF_NVRREG      34      /* includes vscr & vrsave in split vectors */
+
+typedef unsigned long vki_elf_greg_t64;
+typedef vki_elf_greg_t64 vki_elf_gregset_t64[VKI_ELF_NGREG];
+
+typedef vki_elf_gregset_t64 vki_elf_gregset_t;
+
+typedef double vki_elf_fpreg_t;
+typedef vki_elf_fpreg_t vki_elf_fpregset_t[VKI_ELF_NFPREG];
+
+/* Altivec registers */
+/*
+ * The entries with indexes 0-31 contain the corresponding vector registers.
+ * The entry with index 32 contains the vscr as the last word (offset 12)
+ * within the quadword.  This allows the vscr to be stored as either a
+ * quadword (since it must be copied via a vector register to/from storage)
+ * or as a word.  The entry with index 33 contains the vrsave as the first
+ * word (offset 0) within the quadword.
+ *
+ * This definition of the VMX state is compatible with the current PPC32
+ * ptrace interface.  This allows signal handling and ptrace to use the same
+ * structures.  This also simplifies the implementation of a bi-arch
+ * (combined (32- and 64-bit) gdb.
+ *
+ * Note that it's _not_ compatible with 32 bits ucontext which stuffs the
+ * vrsave along with vscr and so only uses 33 vectors for the register set
+ */
+typedef __vki_vector128 vki_elf_vrreg_t;
+typedef vki_elf_vrreg_t vki_elf_vrregset_t[VKI_ELF_NVRREG];
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/sigcontext.h
+//----------------------------------------------------------------------
+
+struct vki_sigcontext {
+  unsigned long       _unused[4];
+  int                 signal;
+  int                 _pad0;
+  unsigned long       handler;
+  unsigned long       oldmask;
+  struct vki_pt_regs  __user *regs;
+  vki_elf_gregset_t   gp_regs;
+  vki_elf_fpregset_t  fp_regs;
+  /*
+   * To maintain compatibility with current implementations the sigcontext is
+   * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
+   * followed by an unstructured (vmx_reserve) field of 69 doublewords.  This
+   * allows the array of vector registers to be quadword aligned independent of
+   * the alignment of the containing sigcontext or ucontext. It is the
+   * responsibility of the code setting the sigcontext to set this pointer to
+   * either NULL (if this processor does not support the VMX feature) or the
+   * address of the first quadword within the allocated (vmx_reserve) area.
+   *
+   * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
+   * an array of 34 quadword entries (elf_vrregset_t).  The entries with
+   * indexes 0-31 contain the corresponding vector registers.  The entry with
+   * index 32 contains the vscr as the last word (offset 12) within the
+   * quadword.  This allows the vscr to be stored as either a quadword (since
+   * it must be copied via a vector register to/from storage) or as a word.
+   * The entry with index 33 contains the vrsave as the first word (offset 0)
+   * within the quadword.
+   */
+  vki_elf_vrreg_t  __user *v_regs;
+  long             vmx_reserve[VKI_ELF_NVRREG+VKI_ELF_NVRREG+1];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/mman.h
+//----------------------------------------------------------------------
+
+#define VKI_PROT_NONE       0x0             /* page can not be accessed */
+#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_PROT_GROWSDOWN  0x01000000      /* mprotect flag: extend
+					       change to start of
+					       growsdown vma */
+#define VKI_PROT_GROWSUP    0x02000000      /* mprotect flag: extend
+					       change to end of
+					       growsup vma */
+
+#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_ANONYMOUS   0x20            /* don't use a file */
+#define VKI_MAP_NORESERVE   0x40            /* don't reserve swap pages */
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/fcntl.h
+//----------------------------------------------------------------------
+
+#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_LARGEFILE     0200000
+
+#define VKI_AT_FDCWD            -100
+
+#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_SETOWN        8       /*  for sockets. */
+#define VKI_F_GETOWN        9       /*  for sockets. */
+#define VKI_F_SETSIG        10      /*  for sockets. */
+#define VKI_F_GETSIG        11      /*  for sockets. */
+
+/* for F_[GET|SET]FL */
+#define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
+
+#define VKI_F_LINUX_SPECIFIC_BASE   1024
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/resource.h
+//----------------------------------------------------------------------
+
+// which just does #include <asm-generic/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.13/include/asm-ppc64/socket.h
+//----------------------------------------------------------------------
+
+#define VKI_SOL_SOCKET      1
+
+#define VKI_SO_TYPE         3
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/sockios.h
+//----------------------------------------------------------------------
+
+#define VKI_SIOCSPGRP       0x8902
+#define VKI_SIOCGPGRP       0x8904
+#define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
+#define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/stat.h
+//----------------------------------------------------------------------
+
+struct vki_stat {
+  unsigned long   st_dev;
+  unsigned long   st_ino;
+  unsigned long   st_nlink;
+  unsigned int    st_mode;
+  unsigned int    st_uid;
+  unsigned int    st_gid;
+  unsigned long   st_rdev;
+  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;
+  unsigned long   __unused6;
+};
+
+#define VKI_STAT_HAVE_NSEC 1
+
+/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
+struct vki_stat64 {
+  unsigned long st_dev;           /* Device.  */
+  unsigned long st_ino;           /* File serial number.  */
+  unsigned int st_mode;           /* File mode.  */
+  unsigned int st_nlink;          /* Link count.  */
+  unsigned int st_uid;            /* User ID of the file's owner.  */
+  unsigned int st_gid;            /* Group ID of the file's group. */
+  unsigned long st_rdev;          /* Device number, if device.  */
+  unsigned short __pad2;
+  long st_size;                   /* Size of file, in bytes.  */
+  int  st_blksize;                /* Optimal block size for I/O.  */
+
+  long st_blocks;                 /* Number 512-byte blocks allocated. */
+  int   st_atime;                 /* Time of last access.  */
+  int   st_atime_nsec;
+  int   st_mtime;                 /* Time of last modification.  */
+  int   st_mtime_nsec;
+  int   st_ctime;                 /* Time of last status change.  */
+  int   st_ctime_nsec;
+  unsigned int   __unused4;
+  unsigned int   __unused5;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/statfs.h
+//----------------------------------------------------------------------
+
+struct vki_statfs {
+  long f_type;
+  long f_bsize;
+  long f_blocks;
+  long f_bfree;
+  long f_bavail;
+  long f_files;
+  long f_ffree;
+  __vki_kernel_fsid_t f_fsid;
+  long f_namelen;
+  long f_frsize;
+  long f_spare[5];
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/termios.h
+//----------------------------------------------------------------------
+
+struct vki_winsize {
+  unsigned short ws_row;
+  unsigned short ws_col;
+  unsigned short ws_xpixel;
+  unsigned short ws_ypixel;
+};
+
+#define VKI_NCC 10
+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.13/include/asm-ppc64/termbits.h
+//----------------------------------------------------------------------
+
+typedef unsigned char   vki_cc_t;
+typedef unsigned int    vki_speed_t;
+typedef unsigned int    vki_tcflag_t;
+
+#define VKI_NCCS 19
+struct vki_termios {
+  vki_tcflag_t c_iflag;               /* input mode flags */
+  vki_tcflag_t c_oflag;               /* output mode flags */
+  vki_tcflag_t c_cflag;               /* control mode flags */
+  vki_tcflag_t c_lflag;               /* local mode flags */
+  vki_cc_t c_cc[VKI_NCCS];            /* control characters */
+  vki_cc_t c_line;                    /* line discipline (== c_cc[19]) */
+  vki_speed_t c_ispeed;               /* input speed */
+  vki_speed_t c_ospeed;               /* output speed */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ioctl.h
+//----------------------------------------------------------------------
+
+#define _VKI_IOC_NRBITS     8
+#define _VKI_IOC_TYPEBITS   8
+#define _VKI_IOC_SIZEBITS   13
+#define _VKI_IOC_DIRBITS    3
+
+#define _VKI_IOC_NRMASK     ((1 << _VKI_IOC_NRBITS)-1)
+#define _VKI_IOC_TYPEMASK   ((1 << _VKI_IOC_TYPEBITS)-1)
+#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)
+
+/*
+ * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
+ * And this turns out useful to catch old ioctl numbers in header
+ * files for us.
+ */
+#define _VKI_IOC_NONE       1U
+#define _VKI_IOC_READ       2U
+#define _VKI_IOC_WRITE      4U
+
+#define _VKI_IOC(dir,type,nr,size) \
+        (((dir)  << _VKI_IOC_DIRSHIFT) | \
+         ((type) << _VKI_IOC_TYPESHIFT) | \
+         ((nr)   << _VKI_IOC_NRSHIFT) | \
+         ((size) << _VKI_IOC_SIZESHIFT))
+
+/* 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)))
+#define _VKI_IOR_BAD(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr), \
+                                       sizeof(size))
+#define _VKI_IOW_BAD(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \
+                                       sizeof(size))
+#define _VKI_IOWR_BAD(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \
+                                       (type),(nr),sizeof(size))
+
+/* used to decode them.. */
+#define _VKI_IOC_DIR(nr)        (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
+#define _VKI_IOC_TYPE(nr)       (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
+#define _VKI_IOC_NR(nr)         (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
+#define _VKI_IOC_SIZE(nr)       (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ioctls.h
+//----------------------------------------------------------------------
+
+#define VKI_TCGETS          _VKI_IOR('t', 19, struct vki_termios)
+#define VKI_TCSETS          _VKI_IOW('t', 20, struct vki_termios)
+#define VKI_TCSETSW         _VKI_IOW('t', 21, struct vki_termios)
+#define VKI_TCSETSF         _VKI_IOW('t', 22, struct vki_termios)
+#define VKI_TCGETA          _VKI_IOR('t', 23, struct vki_termio)
+#define VKI_TCSETA          _VKI_IOW('t', 24, struct vki_termio)
+#define VKI_TCSETAW         _VKI_IOW('t', 25, struct vki_termio)
+#define VKI_TCSETAF         _VKI_IOW('t', 28, struct vki_termio)
+#define VKI_TCSBRK          _VKI_IO('t', 29)
+#define VKI_TCXONC          _VKI_IO('t', 30)
+#define VKI_TCFLSH          _VKI_IO('t', 31)
+#define VKI_TIOCSCTTY       0x540E
+#define VKI_TIOCGPGRP       _VKI_IOR('t', 119, int)
+#define VKI_TIOCSPGRP       _VKI_IOW('t', 118, int)
+#define VKI_TIOCOUTQ        _VKI_IOR('t', 115, int)     /* output queue size */
+#define VKI_TIOCGWINSZ      _VKI_IOR('t', 104, struct vki_winsize)
+#define VKI_TIOCSWINSZ      _VKI_IOW('t', 103, struct vki_winsize)
+#define VKI_TIOCMGET        0x5415
+#define VKI_TIOCMBIS        0x5416
+#define VKI_TIOCMBIC        0x5417
+#define VKI_TIOCMSET        0x5418
+#define VKI_FIONREAD        _VKI_IOR('f', 127, int)
+#define VKI_TIOCLINUX       0x541C
+#define VKI_FIONBIO         _VKI_IOW('f', 126, int)
+#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        _VKI_IOW('f', 125, int)
+#define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
+#define VKI_TIOCGICOUNT	    0x545D /* read serial port inline interrupt counts */
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/poll.h
+//----------------------------------------------------------------------
+
+#define VKI_POLLIN          0x0001
+
+struct vki_pollfd {
+  int fd;
+  short events;
+  short revents;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/user.h
+//----------------------------------------------------------------------
+
+// Not sure what's needed from here
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/elf.h
+//----------------------------------------------------------------------
+
+// Not sure what's needed from here
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ucontext.h
+//----------------------------------------------------------------------
+
+struct vki_ucontext {
+  unsigned long         uc_flags;
+  struct vki_ucontext  *uc_link;
+  vki_stack_t           uc_stack;
+  vki_sigset_t          uc_sigmask;
+  vki_sigset_t          __unused[15]; /* Allow for uc_sigmask growth */
+  struct vki_sigcontext uc_mcontext;  /* last for extensibility */
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ipcbuf.h
+//----------------------------------------------------------------------
+
+struct vki_ipc64_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 int        seq;
+  unsigned int        __pad1;
+  unsigned long       __unused1;
+  unsigned long       __unused2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/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 */
+  __vki_kernel_time_t   sem_ctime;      /* last change time */
+  unsigned long         sem_nsems;      /* no. of semaphores in array */
+  unsigned long         __unused1;
+  unsigned long         __unused2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/msgbuf.h
+//----------------------------------------------------------------------
+
+struct vki_msqid64_ds {
+  struct vki_ipc64_perm msg_perm;
+  __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_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         __unused1;
+  unsigned long         __unused2;
+};
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/ipc.h
+//----------------------------------------------------------------------
+
+// this just does #include <asm-generic/ipc.h>
+
+struct vki_ipc_kludge {
+  struct vki_msgbuf __user *msgp;
+  long msgtyp;
+};
+
+#define VKI_SEMOP            1
+#define VKI_SEMGET           2
+#define VKI_SEMCTL           3
+#define VKI_SEMTIMEDOP       4
+#define VKI_MSGSND          11
+#define VKI_MSGRCV          12
+#define VKI_MSGGET          13
+#define VKI_MSGCTL          14
+#define VKI_SHMAT           21
+#define VKI_SHMDT           22
+#define VKI_SHMGET          23
+#define VKI_SHMCTL          24
+
+//----------------------------------------------------------------------
+// From linux-2.6.13/include/asm-ppc64/shmbuf.h
+//----------------------------------------------------------------------
+
+struct vki_shmid64_ds {
+  struct vki_ipc64_perm       shm_perm;       /* operation perms */
+  __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_size_t                  shm_segsz;      /* size of segment (bytes) */
+  __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               __unused1;
+  unsigned long               __unused2;
+};
+
+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;
+};
+
+//----------------------------------------------------------------------
+// end
+//----------------------------------------------------------------------
+
+#endif // __VKI_PPC64_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-aix5.h b/include/vki/vki-scnums-aix5.h
new file mode 100644
index 0000000..3ca8ebf
--- /dev/null
+++ b/include/vki/vki-scnums-aix5.h
@@ -0,0 +1,1616 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for ppc32-aix5 and ppc64-aix5.           ---*/
+/*---                                            vki-scnums-aix5.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2006-2010 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.
+
+   Neither the names of the U.S. Department of Energy nor the
+   University of California nor the names of its contributors may be
+   used to endorse or promote products derived from this software
+   without prior written permission.
+*/
+
+#ifndef __VKI_SCNUMS_AIX5_H
+#define __VKI_SCNUMS_AIX5_H
+
+#if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
+#  error This file should be included in AIX5 builds only.
+#endif
+
+// WARNING: note that this file, unlike other vki-scnums-PLATFORM.h files,
+// isn't suitable for inclusion in asm files.
+
+//--------------------------------------------------------------
+// Syscalls for AIX 5.2 running on ppc32
+//--------------------------------------------------------------
+
+/* This is the initial value for a syscall number, when we don't
+   know what it is. */
+#define __NR_AIX5_UNKNOWN (-1)
+
+/* Vanilla AIX 5.2 ones */
+
+extern Int VG_(aix5_NR_utrchook_sc);
+#define __NR_AIX5_utrchook_sc VG_(aix5_NR_utrchook_sc)
+
+extern Int VG_(aix5_NR_thread_create);
+#define __NR_AIX5_thread_create VG_(aix5_NR_thread_create)
+
+extern Int VG_(aix5_NR_kfork);
+#define __NR_AIX5_kfork VG_(aix5_NR_kfork)
+
+extern Int VG_(aix5_NR_kra_fork);
+#define __NR_AIX5_kra_fork VG_(aix5_NR_kra_fork)
+
+extern Int VG_(aix5_NR_execve);
+#define __NR_AIX5_execve VG_(aix5_NR_execve)
+
+extern Int VG_(aix5_NR_ra_execve);
+#define __NR_AIX5_ra_execve VG_(aix5_NR_ra_execve)
+
+extern Int VG_(aix5_NR__load);
+#define __NR_AIX5__load VG_(aix5_NR__load)
+
+extern Int VG_(aix5_NR___unload);
+#define __NR_AIX5___unload VG_(aix5_NR___unload)
+
+extern Int VG_(aix5_NR_loadbind);
+#define __NR_AIX5_loadbind VG_(aix5_NR_loadbind)
+
+extern Int VG_(aix5_NR___loadx);
+#define __NR_AIX5___loadx VG_(aix5_NR___loadx)
+
+extern Int VG_(aix5_NR_bindprocessor);
+#define __NR_AIX5_bindprocessor VG_(aix5_NR_bindprocessor)
+
+extern Int VG_(aix5_NR_trcgent);
+#define __NR_AIX5_trcgent VG_(aix5_NR_trcgent)
+
+extern Int VG_(aix5_NR_trcgen);
+#define __NR_AIX5_trcgen VG_(aix5_NR_trcgen)
+
+extern Int VG_(aix5_NR_trchk);
+#define __NR_AIX5_trchk VG_(aix5_NR_trchk)
+
+extern Int VG_(aix5_NR_trchkt);
+#define __NR_AIX5_trchkt VG_(aix5_NR_trchkt)
+
+extern Int VG_(aix5_NR_trchkl);
+#define __NR_AIX5_trchkl VG_(aix5_NR_trchkl)
+
+extern Int VG_(aix5_NR_trchklt);
+#define __NR_AIX5_trchklt VG_(aix5_NR_trchklt)
+
+extern Int VG_(aix5_NR_trchkg);
+#define __NR_AIX5_trchkg VG_(aix5_NR_trchkg)
+
+extern Int VG_(aix5_NR_trchkgt);
+#define __NR_AIX5_trchkgt VG_(aix5_NR_trchkgt)
+
+extern Int VG_(aix5_NR_kill);
+#define __NR_AIX5_kill VG_(aix5_NR_kill)
+
+extern Int VG_(aix5_NR__addcpucosts);
+#define __NR_AIX5__addcpucosts VG_(aix5_NR__addcpucosts)
+
+extern Int VG_(aix5_NR_mycpu);
+#define __NR_AIX5_mycpu VG_(aix5_NR_mycpu)
+
+extern Int VG_(aix5_NR_adjtime);
+#define __NR_AIX5_adjtime VG_(aix5_NR_adjtime)
+
+extern Int VG_(aix5_NR_checkpnt_block);
+#define __NR_AIX5_checkpnt_block VG_(aix5_NR_checkpnt_block)
+
+extern Int VG_(aix5_NR__checkpnt_kill);
+#define __NR_AIX5__checkpnt_kill VG_(aix5_NR__checkpnt_kill)
+
+extern Int VG_(aix5_NR__checkpnt_fail);
+#define __NR_AIX5__checkpnt_fail VG_(aix5_NR__checkpnt_fail)
+
+extern Int VG_(aix5_NR__checkpnt_commit);
+#define __NR_AIX5__checkpnt_commit VG_(aix5_NR__checkpnt_commit)
+
+extern Int VG_(aix5_NR__checkpnt_register);
+#define __NR_AIX5__checkpnt_register VG_(aix5_NR__checkpnt_register)
+
+extern Int VG_(aix5_NR__checkpnt);
+#define __NR_AIX5__checkpnt VG_(aix5_NR__checkpnt)
+
+extern Int VG_(aix5_NR_setcrid);
+#define __NR_AIX5_setcrid VG_(aix5_NR_setcrid)
+
+extern Int VG_(aix5_NR_getcrid);
+#define __NR_AIX5_getcrid VG_(aix5_NR_getcrid)
+
+extern Int VG_(aix5_NR_mkcrid);
+#define __NR_AIX5_mkcrid VG_(aix5_NR_mkcrid)
+
+extern Int VG_(aix5_NR_checkpnt_wait);
+#define __NR_AIX5_checkpnt_wait VG_(aix5_NR_checkpnt_wait)
+
+extern Int VG_(aix5_NR_checkpnt_deliver);
+#define __NR_AIX5_checkpnt_deliver VG_(aix5_NR_checkpnt_deliver)
+
+extern Int VG_(aix5_NR_gencore);
+#define __NR_AIX5_gencore VG_(aix5_NR_gencore)
+
+extern Int VG_(aix5_NR_thread_terminate);
+#define __NR_AIX5_thread_terminate VG_(aix5_NR_thread_terminate)
+
+extern Int VG_(aix5_NR__exit);
+#define __NR_AIX5__exit VG_(aix5_NR__exit)
+
+extern Int VG_(aix5_NR_kwaitpid64);
+#define __NR_AIX5_kwaitpid64 VG_(aix5_NR_kwaitpid64)
+
+extern Int VG_(aix5_NR_kwaitpid);
+#define __NR_AIX5_kwaitpid VG_(aix5_NR_kwaitpid)
+
+extern Int VG_(aix5_NR_yield);
+#define __NR_AIX5_yield VG_(aix5_NR_yield)
+
+extern Int VG_(aix5_NR_getprocs64);
+#define __NR_AIX5_getprocs64 VG_(aix5_NR_getprocs64)
+
+extern Int VG_(aix5_NR_getevars);
+#define __NR_AIX5_getevars VG_(aix5_NR_getevars)
+
+extern Int VG_(aix5_NR_getargs);
+#define __NR_AIX5_getargs VG_(aix5_NR_getargs)
+
+extern Int VG_(aix5_NR_getthrds64);
+#define __NR_AIX5_getthrds64 VG_(aix5_NR_getthrds64)
+
+extern Int VG_(aix5_NR_getthrds);
+#define __NR_AIX5_getthrds VG_(aix5_NR_getthrds)
+
+extern Int VG_(aix5_NR_getprocs);
+#define __NR_AIX5_getprocs VG_(aix5_NR_getprocs)
+
+extern Int VG_(aix5_NR_sigcleanup);
+#define __NR_AIX5_sigcleanup VG_(aix5_NR_sigcleanup)
+
+extern Int VG_(aix5_NR__setpri);
+#define __NR_AIX5__setpri VG_(aix5_NR__setpri)
+
+extern Int VG_(aix5_NR__getpri);
+#define __NR_AIX5__getpri VG_(aix5_NR__getpri)
+
+extern Int VG_(aix5_NR_profil);
+#define __NR_AIX5_profil VG_(aix5_NR_profil)
+
+extern Int VG_(aix5_NR_reboot);
+#define __NR_AIX5_reboot VG_(aix5_NR_reboot)
+
+extern Int VG_(aix5_NR_appgetrlimit);
+#define __NR_AIX5_appgetrlimit VG_(aix5_NR_appgetrlimit)
+
+extern Int VG_(aix5_NR_appsetrlimit);
+#define __NR_AIX5_appsetrlimit VG_(aix5_NR_appsetrlimit)
+
+extern Int VG_(aix5_NR__setpriority);
+#define __NR_AIX5__setpriority VG_(aix5_NR__setpriority)
+
+extern Int VG_(aix5_NR__getpriority);
+#define __NR_AIX5__getpriority VG_(aix5_NR__getpriority)
+
+extern Int VG_(aix5_NR_setrlimit64);
+#define __NR_AIX5_setrlimit64 VG_(aix5_NR_setrlimit64)
+
+extern Int VG_(aix5_NR_getrlimit64);
+#define __NR_AIX5_getrlimit64 VG_(aix5_NR_getrlimit64)
+
+extern Int VG_(aix5_NR_appgetrusage);
+#define __NR_AIX5_appgetrusage VG_(aix5_NR_appgetrusage)
+
+extern Int VG_(aix5_NR_getrusage64);
+#define __NR_AIX5_getrusage64 VG_(aix5_NR_getrusage64)
+
+extern Int VG_(aix5_NR_getvtid);
+#define __NR_AIX5_getvtid VG_(aix5_NR_getvtid)
+
+extern Int VG_(aix5_NR_getrtid);
+#define __NR_AIX5_getrtid VG_(aix5_NR_getrtid)
+
+extern Int VG_(aix5_NR_getrpid);
+#define __NR_AIX5_getrpid VG_(aix5_NR_getrpid)
+
+extern Int VG_(aix5_NR_restart_wait);
+#define __NR_AIX5_restart_wait VG_(aix5_NR_restart_wait)
+
+extern Int VG_(aix5_NR_restart);
+#define __NR_AIX5_restart VG_(aix5_NR_restart)
+
+extern Int VG_(aix5_NR__rmcpucosts);
+#define __NR_AIX5__rmcpucosts VG_(aix5_NR__rmcpucosts)
+
+extern Int VG_(aix5_NR__clock_getcpuclockid);
+#define __NR_AIX5__clock_getcpuclockid VG_(aix5_NR__clock_getcpuclockid)
+
+extern Int VG_(aix5_NR__clock_settime);
+#define __NR_AIX5__clock_settime VG_(aix5_NR__clock_settime)
+
+extern Int VG_(aix5_NR__clock_gettime);
+#define __NR_AIX5__clock_gettime VG_(aix5_NR__clock_gettime)
+
+extern Int VG_(aix5_NR__clock_getres);
+#define __NR_AIX5__clock_getres VG_(aix5_NR__clock_getres)
+
+extern Int VG_(aix5_NR__timer_settime);
+#define __NR_AIX5__timer_settime VG_(aix5_NR__timer_settime)
+
+extern Int VG_(aix5_NR__timer_gettime);
+#define __NR_AIX5__timer_gettime VG_(aix5_NR__timer_gettime)
+
+extern Int VG_(aix5_NR__timer_getoverrun);
+#define __NR_AIX5__timer_getoverrun VG_(aix5_NR__timer_getoverrun)
+
+extern Int VG_(aix5_NR__timer_delete);
+#define __NR_AIX5__timer_delete VG_(aix5_NR__timer_delete)
+
+extern Int VG_(aix5_NR__timer_create);
+#define __NR_AIX5__timer_create VG_(aix5_NR__timer_create)
+
+extern Int VG_(aix5_NR__sigqueue);
+#define __NR_AIX5__sigqueue VG_(aix5_NR__sigqueue)
+
+extern Int VG_(aix5_NR__sigsuspend);
+#define __NR_AIX5__sigsuspend VG_(aix5_NR__sigsuspend)
+
+extern Int VG_(aix5_NR__sigaction);
+#define __NR_AIX5__sigaction VG_(aix5_NR__sigaction)
+
+extern Int VG_(aix5_NR_sigprocmask);
+#define __NR_AIX5_sigprocmask VG_(aix5_NR_sigprocmask)
+
+extern Int VG_(aix5_NR_siglocalmask);
+#define __NR_AIX5_siglocalmask VG_(aix5_NR_siglocalmask)
+
+extern Int VG_(aix5_NR_count_event_waiters);
+#define __NR_AIX5_count_event_waiters VG_(aix5_NR_count_event_waiters)
+
+extern Int VG_(aix5_NR_thread_waitact);
+#define __NR_AIX5_thread_waitact VG_(aix5_NR_thread_waitact)
+
+extern Int VG_(aix5_NR_thread_waitlock_local);
+#define __NR_AIX5_thread_waitlock_local VG_(aix5_NR_thread_waitlock_local)
+
+extern Int VG_(aix5_NR_thread_waitlock);
+#define __NR_AIX5_thread_waitlock VG_(aix5_NR_thread_waitlock)
+
+extern Int VG_(aix5_NR_thread_wait);
+#define __NR_AIX5_thread_wait VG_(aix5_NR_thread_wait)
+
+extern Int VG_(aix5_NR_thread_unlock);
+#define __NR_AIX5_thread_unlock VG_(aix5_NR_thread_unlock)
+
+extern Int VG_(aix5_NR_thread_twakeup_unlock);
+#define __NR_AIX5_thread_twakeup_unlock VG_(aix5_NR_thread_twakeup_unlock)
+
+extern Int VG_(aix5_NR_thread_twakeup_event);
+#define __NR_AIX5_thread_twakeup_event VG_(aix5_NR_thread_twakeup_event)
+
+extern Int VG_(aix5_NR_thread_twakeup);
+#define __NR_AIX5_thread_twakeup VG_(aix5_NR_thread_twakeup)
+
+extern Int VG_(aix5_NR_thread_tsleep_event);
+#define __NR_AIX5_thread_tsleep_event VG_(aix5_NR_thread_tsleep_event)
+
+extern Int VG_(aix5_NR_thread_tsleep_chkpnt);
+#define __NR_AIX5_thread_tsleep_chkpnt VG_(aix5_NR_thread_tsleep_chkpnt)
+
+extern Int VG_(aix5_NR_thread_tsleep);
+#define __NR_AIX5_thread_tsleep VG_(aix5_NR_thread_tsleep)
+
+extern Int VG_(aix5_NR_thread_post_many);
+#define __NR_AIX5_thread_post_many VG_(aix5_NR_thread_post_many)
+
+extern Int VG_(aix5_NR_thread_post);
+#define __NR_AIX5_thread_post VG_(aix5_NR_thread_post)
+
+extern Int VG_(aix5_NR_ue_proc_unregister);
+#define __NR_AIX5_ue_proc_unregister VG_(aix5_NR_ue_proc_unregister)
+
+extern Int VG_(aix5_NR_ue_proc_register);
+#define __NR_AIX5_ue_proc_register VG_(aix5_NR_ue_proc_register)
+
+extern Int VG_(aix5_NR_kthread_ctl);
+#define __NR_AIX5_kthread_ctl VG_(aix5_NR_kthread_ctl)
+
+extern Int VG_(aix5_NR__thread_setsched);
+#define __NR_AIX5__thread_setsched VG_(aix5_NR__thread_setsched)
+
+extern Int VG_(aix5_NR_threads_runnable);
+#define __NR_AIX5_threads_runnable VG_(aix5_NR_threads_runnable)
+
+extern Int VG_(aix5_NR_thread_getregs);
+#define __NR_AIX5_thread_getregs VG_(aix5_NR_thread_getregs)
+
+extern Int VG_(aix5_NR_thread_terminate_unlock);
+#define __NR_AIX5_thread_terminate_unlock VG_(aix5_NR_thread_terminate_unlock)
+
+extern Int VG_(aix5_NR_thread_terminate_ack);
+#define __NR_AIX5_thread_terminate_ack VG_(aix5_NR_thread_terminate_ack)
+
+extern Int VG_(aix5_NR_thread_setstate_fast);
+#define __NR_AIX5_thread_setstate_fast VG_(aix5_NR_thread_setstate_fast)
+
+extern Int VG_(aix5_NR_thread_setstate);
+#define __NR_AIX5_thread_setstate VG_(aix5_NR_thread_setstate)
+
+extern Int VG_(aix5_NR_thread_setmymask_fast);
+#define __NR_AIX5_thread_setmymask_fast VG_(aix5_NR_thread_setmymask_fast)
+
+extern Int VG_(aix5_NR_thread_setmystate_fast);
+#define __NR_AIX5_thread_setmystate_fast VG_(aix5_NR_thread_setmystate_fast)
+
+extern Int VG_(aix5_NR_thread_setmystate);
+#define __NR_AIX5_thread_setmystate VG_(aix5_NR_thread_setmystate)
+
+extern Int VG_(aix5_NR_thread_init);
+#define __NR_AIX5_thread_init VG_(aix5_NR_thread_init)
+
+extern Int VG_(aix5_NR_times);
+#define __NR_AIX5_times VG_(aix5_NR_times)
+
+extern Int VG_(aix5_NR__nsleep);
+#define __NR_AIX5__nsleep VG_(aix5_NR__nsleep)
+
+extern Int VG_(aix5_NR_reltimerid);
+#define __NR_AIX5_reltimerid VG_(aix5_NR_reltimerid)
+
+extern Int VG_(aix5_NR_appresinc);
+#define __NR_AIX5_appresinc VG_(aix5_NR_appresinc)
+
+extern Int VG_(aix5_NR_apprestimer);
+#define __NR_AIX5_apprestimer VG_(aix5_NR_apprestimer)
+
+extern Int VG_(aix5_NR_appresabs);
+#define __NR_AIX5_appresabs VG_(aix5_NR_appresabs)
+
+extern Int VG_(aix5_NR_appsettimer);
+#define __NR_AIX5_appsettimer VG_(aix5_NR_appsettimer)
+
+extern Int VG_(aix5_NR_appgettimer);
+#define __NR_AIX5_appgettimer VG_(aix5_NR_appgettimer)
+
+extern Int VG_(aix5_NR_gettimerid);
+#define __NR_AIX5_gettimerid VG_(aix5_NR_gettimerid)
+
+extern Int VG_(aix5_NR_incinterval);
+#define __NR_AIX5_incinterval VG_(aix5_NR_incinterval)
+
+extern Int VG_(aix5_NR_absinterval);
+#define __NR_AIX5_absinterval VG_(aix5_NR_absinterval)
+
+extern Int VG_(aix5_NR_getinterval);
+#define __NR_AIX5_getinterval VG_(aix5_NR_getinterval)
+
+extern Int VG_(aix5_NR_upfget);
+#define __NR_AIX5_upfget VG_(aix5_NR_upfget)
+
+extern Int VG_(aix5_NR__wlm_wait);
+#define __NR_AIX5__wlm_wait VG_(aix5_NR__wlm_wait)
+
+extern Int VG_(aix5_NR__wlm_post);
+#define __NR_AIX5__wlm_post VG_(aix5_NR__wlm_post)
+
+extern Int VG_(aix5_NR__wlm_event_init);
+#define __NR_AIX5__wlm_event_init VG_(aix5_NR__wlm_event_init)
+
+extern Int VG_(aix5_NR__wlm_set_tag);
+#define __NR_AIX5__wlm_set_tag VG_(aix5_NR__wlm_set_tag)
+
+extern Int VG_(aix5_NR__wlm_set);
+#define __NR_AIX5__wlm_set VG_(aix5_NR__wlm_set)
+
+extern Int VG_(aix5_NR_ptrace64);
+#define __NR_AIX5_ptrace64 VG_(aix5_NR_ptrace64)
+
+extern Int VG_(aix5_NR_ptracex);
+#define __NR_AIX5_ptracex VG_(aix5_NR_ptracex)
+
+extern Int VG_(aix5_NR_ptrace);
+#define __NR_AIX5_ptrace VG_(aix5_NR_ptrace)
+
+extern Int VG_(aix5_NR_ksetcontext_sigreturn);
+#define __NR_AIX5_ksetcontext_sigreturn VG_(aix5_NR_ksetcontext_sigreturn)
+
+extern Int VG_(aix5_NR_ksetcontext);
+#define __NR_AIX5_ksetcontext VG_(aix5_NR_ksetcontext)
+
+extern Int VG_(aix5_NR_kgetcontext);
+#define __NR_AIX5_kgetcontext VG_(aix5_NR_kgetcontext)
+
+extern Int VG_(aix5_NR_sigreturn);
+#define __NR_AIX5_sigreturn VG_(aix5_NR_sigreturn)
+
+extern Int VG_(aix5_NR__wlm_get_bio_stats);
+#define __NR_AIX5__wlm_get_bio_stats VG_(aix5_NR__wlm_get_bio_stats)
+
+extern Int VG_(aix5_NR_splice);
+#define __NR_AIX5_splice VG_(aix5_NR_splice)
+
+extern Int VG_(aix5_NR_rmsock);
+#define __NR_AIX5_rmsock VG_(aix5_NR_rmsock)
+
+extern Int VG_(aix5_NR_nrecvmsg);
+#define __NR_AIX5_nrecvmsg VG_(aix5_NR_nrecvmsg)
+
+extern Int VG_(aix5_NR_socket_aio_dequeue);
+#define __NR_AIX5_socket_aio_dequeue VG_(aix5_NR_socket_aio_dequeue)
+
+extern Int VG_(aix5_NR_getkerninfo);
+#define __NR_AIX5_getkerninfo VG_(aix5_NR_getkerninfo)
+
+extern Int VG_(aix5_NR_getpeereid);
+#define __NR_AIX5_getpeereid VG_(aix5_NR_getpeereid)
+
+extern Int VG_(aix5_NR_getpeername);
+#define __NR_AIX5_getpeername VG_(aix5_NR_getpeername)
+
+extern Int VG_(aix5_NR_ngetpeername);
+#define __NR_AIX5_ngetpeername VG_(aix5_NR_ngetpeername)
+
+extern Int VG_(aix5_NR_getsockname);
+#define __NR_AIX5_getsockname VG_(aix5_NR_getsockname)
+
+extern Int VG_(aix5_NR_ngetsockname);
+#define __NR_AIX5_ngetsockname VG_(aix5_NR_ngetsockname)
+
+extern Int VG_(aix5_NR_getsockopt);
+#define __NR_AIX5_getsockopt VG_(aix5_NR_getsockopt)
+
+extern Int VG_(aix5_NR_setsockopt);
+#define __NR_AIX5_setsockopt VG_(aix5_NR_setsockopt)
+
+extern Int VG_(aix5_NR_shutdown);
+#define __NR_AIX5_shutdown VG_(aix5_NR_shutdown)
+
+extern Int VG_(aix5_NR_recvmsg);
+#define __NR_AIX5_recvmsg VG_(aix5_NR_recvmsg)
+
+extern Int VG_(aix5_NR_recv);
+#define __NR_AIX5_recv VG_(aix5_NR_recv)
+
+extern Int VG_(aix5_NR_nrecvfrom);
+#define __NR_AIX5_nrecvfrom VG_(aix5_NR_nrecvfrom)
+
+extern Int VG_(aix5_NR_recvfrom);
+#define __NR_AIX5_recvfrom VG_(aix5_NR_recvfrom)
+
+extern Int VG_(aix5_NR_nsendmsg);
+#define __NR_AIX5_nsendmsg VG_(aix5_NR_nsendmsg)
+
+extern Int VG_(aix5_NR_sendmsg);
+#define __NR_AIX5_sendmsg VG_(aix5_NR_sendmsg)
+
+extern Int VG_(aix5_NR_send);
+#define __NR_AIX5_send VG_(aix5_NR_send)
+
+extern Int VG_(aix5_NR_sendto);
+#define __NR_AIX5_sendto VG_(aix5_NR_sendto)
+
+extern Int VG_(aix5_NR_socketpair);
+#define __NR_AIX5_socketpair VG_(aix5_NR_socketpair)
+
+extern Int VG_(aix5_NR_accept);
+#define __NR_AIX5_accept VG_(aix5_NR_accept)
+
+extern Int VG_(aix5_NR_naccept);
+#define __NR_AIX5_naccept VG_(aix5_NR_naccept)
+
+extern Int VG_(aix5_NR_listen);
+#define __NR_AIX5_listen VG_(aix5_NR_listen)
+
+extern Int VG_(aix5_NR_bind);
+#define __NR_AIX5_bind VG_(aix5_NR_bind)
+
+extern Int VG_(aix5_NR_socket);
+#define __NR_AIX5_socket VG_(aix5_NR_socket)
+
+extern Int VG_(aix5_NR_connext);
+#define __NR_AIX5_connext VG_(aix5_NR_connext)
+
+extern Int VG_(aix5_NR_setdomainname);
+#define __NR_AIX5_setdomainname VG_(aix5_NR_setdomainname)
+
+extern Int VG_(aix5_NR_getdomainname);
+#define __NR_AIX5_getdomainname VG_(aix5_NR_getdomainname)
+
+extern Int VG_(aix5_NR_sethostname);
+#define __NR_AIX5_sethostname VG_(aix5_NR_sethostname)
+
+extern Int VG_(aix5_NR_sethostid);
+#define __NR_AIX5_sethostid VG_(aix5_NR_sethostid)
+
+extern Int VG_(aix5_NR_gethostid);
+#define __NR_AIX5_gethostid VG_(aix5_NR_gethostid)
+
+extern Int VG_(aix5_NR_gethostname);
+#define __NR_AIX5_gethostname VG_(aix5_NR_gethostname)
+
+extern Int VG_(aix5_NR_send_file);
+#define __NR_AIX5_send_file VG_(aix5_NR_send_file)
+
+extern Int VG_(aix5_NR__rmlmbcost);
+#define __NR_AIX5__rmlmbcost VG_(aix5_NR__rmlmbcost)
+
+extern Int VG_(aix5_NR___rs_pickmcm);
+#define __NR_AIX5___rs_pickmcm VG_(aix5_NR___rs_pickmcm)
+
+extern Int VG_(aix5_NR_rs_getsystem);
+#define __NR_AIX5_rs_getsystem VG_(aix5_NR_rs_getsystem)
+
+extern Int VG_(aix5_NR_rs_getassociativity);
+#define __NR_AIX5_rs_getassociativity VG_(aix5_NR_rs_getassociativity)
+
+extern Int VG_(aix5_NR_rs_setpartition);
+#define __NR_AIX5_rs_setpartition VG_(aix5_NR_rs_setpartition)
+
+extern Int VG_(aix5_NR_rs_getpartition);
+#define __NR_AIX5_rs_getpartition VG_(aix5_NR_rs_getpartition)
+
+extern Int VG_(aix5_NR_ra_getrset);
+#define __NR_AIX5_ra_getrset VG_(aix5_NR_ra_getrset)
+
+extern Int VG_(aix5_NR_rs_getinfo);
+#define __NR_AIX5_rs_getinfo VG_(aix5_NR_rs_getinfo)
+
+extern Int VG_(aix5_NR_rs_getrad);
+#define __NR_AIX5_rs_getrad VG_(aix5_NR_rs_getrad)
+
+extern Int VG_(aix5_NR_rs_numrads);
+#define __NR_AIX5_rs_numrads VG_(aix5_NR_rs_numrads)
+
+extern Int VG_(aix5_NR___kdb_format_print_rele);
+#define __NR_AIX5___kdb_format_print_rele VG_(aix5_NR___kdb_format_print_rele)
+
+extern Int VG_(aix5_NR___kdb_format_print_init);
+#define __NR_AIX5___kdb_format_print_init VG_(aix5_NR___kdb_format_print_init)
+
+extern Int VG_(aix5_NR_close);
+#define __NR_AIX5_close VG_(aix5_NR_close)
+
+extern Int VG_(aix5_NR_kfsync_range);
+#define __NR_AIX5_kfsync_range VG_(aix5_NR_kfsync_range)
+
+extern Int VG_(aix5_NR_fsync);
+#define __NR_AIX5_fsync VG_(aix5_NR_fsync)
+
+extern Int VG_(aix5_NR_kpwrite);
+#define __NR_AIX5_kpwrite VG_(aix5_NR_kpwrite)
+
+extern Int VG_(aix5_NR_kwritev);
+#define __NR_AIX5_kwritev VG_(aix5_NR_kwritev)
+
+extern Int VG_(aix5_NR_kwrite);
+#define __NR_AIX5_kwrite VG_(aix5_NR_kwrite)
+
+extern Int VG_(aix5_NR_kpread);
+#define __NR_AIX5_kpread VG_(aix5_NR_kpread)
+
+extern Int VG_(aix5_NR_kreadv);
+#define __NR_AIX5_kreadv VG_(aix5_NR_kreadv)
+
+extern Int VG_(aix5_NR_kread);
+#define __NR_AIX5_kread VG_(aix5_NR_kread)
+
+extern Int VG_(aix5_NR_klseek);
+#define __NR_AIX5_klseek VG_(aix5_NR_klseek)
+
+extern Int VG_(aix5_NR__lseek);
+#define __NR_AIX5__lseek VG_(aix5_NR__lseek)
+
+extern Int VG_(aix5_NR_lseek);
+#define __NR_AIX5_lseek VG_(aix5_NR_lseek)
+
+extern Int VG_(aix5_NR__setsid);
+#define __NR_AIX5__setsid VG_(aix5_NR__setsid)
+
+extern Int VG_(aix5_NR__setpgid);
+#define __NR_AIX5__setpgid VG_(aix5_NR__setpgid)
+
+extern Int VG_(aix5_NR__setpgrp);
+#define __NR_AIX5__setpgrp VG_(aix5_NR__setpgrp)
+
+extern Int VG_(aix5_NR__getpgrpx);
+#define __NR_AIX5__getpgrpx VG_(aix5_NR__getpgrpx)
+
+extern Int VG_(aix5_NR__getpgrp);
+#define __NR_AIX5__getpgrp VG_(aix5_NR__getpgrp)
+
+extern Int VG_(aix5_NR__getppid);
+#define __NR_AIX5__getppid VG_(aix5_NR__getppid)
+
+extern Int VG_(aix5_NR__thread_self);
+#define __NR_AIX5__thread_self VG_(aix5_NR__thread_self)
+
+extern Int VG_(aix5_NR__getpid);
+#define __NR_AIX5__getpid VG_(aix5_NR__getpid)
+
+extern Int VG_(aix5_NR_kgetpgidx);
+#define __NR_AIX5_kgetpgidx VG_(aix5_NR_kgetpgidx)
+
+extern Int VG_(aix5_NR_setuid);
+#define __NR_AIX5_setuid VG_(aix5_NR_setuid)
+
+extern Int VG_(aix5_NR_setuidx);
+#define __NR_AIX5_setuidx VG_(aix5_NR_setuidx)
+
+extern Int VG_(aix5_NR_getuidx);
+#define __NR_AIX5_getuidx VG_(aix5_NR_getuidx)
+
+extern Int VG_(aix5_NR_seteuid);
+#define __NR_AIX5_seteuid VG_(aix5_NR_seteuid)
+
+extern Int VG_(aix5_NR_setreuid);
+#define __NR_AIX5_setreuid VG_(aix5_NR_setreuid)
+
+extern Int VG_(aix5_NR_chdir);
+#define __NR_AIX5_chdir VG_(aix5_NR_chdir)
+
+extern Int VG_(aix5_NR_fchdir);
+#define __NR_AIX5_fchdir VG_(aix5_NR_fchdir)
+
+extern Int VG_(aix5_NR_chroot);
+#define __NR_AIX5_chroot VG_(aix5_NR_chroot)
+
+extern Int VG_(aix5_NR_fchmod);
+#define __NR_AIX5_fchmod VG_(aix5_NR_fchmod)
+
+extern Int VG_(aix5_NR_chmod);
+#define __NR_AIX5_chmod VG_(aix5_NR_chmod)
+
+extern Int VG_(aix5_NR_chown);
+#define __NR_AIX5_chown VG_(aix5_NR_chown)
+
+extern Int VG_(aix5_NR_lchown);
+#define __NR_AIX5_lchown VG_(aix5_NR_lchown)
+
+extern Int VG_(aix5_NR_fchown);
+#define __NR_AIX5_fchown VG_(aix5_NR_fchown)
+
+extern Int VG_(aix5_NR_fchownx);
+#define __NR_AIX5_fchownx VG_(aix5_NR_fchownx)
+
+extern Int VG_(aix5_NR_chownx);
+#define __NR_AIX5_chownx VG_(aix5_NR_chownx)
+
+extern Int VG_(aix5_NR_kfclear);
+#define __NR_AIX5_kfclear VG_(aix5_NR_kfclear)
+
+extern Int VG_(aix5_NR_fclear);
+#define __NR_AIX5_fclear VG_(aix5_NR_fclear)
+
+extern Int VG_(aix5_NR_ffinfo);
+#define __NR_AIX5_ffinfo VG_(aix5_NR_ffinfo)
+
+extern Int VG_(aix5_NR_finfo);
+#define __NR_AIX5_finfo VG_(aix5_NR_finfo)
+
+extern Int VG_(aix5_NR_fscntl);
+#define __NR_AIX5_fscntl VG_(aix5_NR_fscntl)
+
+extern Int VG_(aix5_NR_ktruncate);
+#define __NR_AIX5_ktruncate VG_(aix5_NR_ktruncate)
+
+extern Int VG_(aix5_NR_kftruncate);
+#define __NR_AIX5_kftruncate VG_(aix5_NR_kftruncate)
+
+extern Int VG_(aix5_NR_truncate);
+#define __NR_AIX5_truncate VG_(aix5_NR_truncate)
+
+extern Int VG_(aix5_NR_ftruncate);
+#define __NR_AIX5_ftruncate VG_(aix5_NR_ftruncate)
+
+extern Int VG_(aix5_NR_getdirent64);
+#define __NR_AIX5_getdirent64 VG_(aix5_NR_getdirent64)
+
+extern Int VG_(aix5_NR_getdirent);
+#define __NR_AIX5_getdirent VG_(aix5_NR_getdirent)
+
+extern Int VG_(aix5_NR_kioctl32);
+#define __NR_AIX5_kioctl32 VG_(aix5_NR_kioctl32)
+
+extern Int VG_(aix5_NR_kioctl);
+#define __NR_AIX5_kioctl VG_(aix5_NR_kioctl)
+
+extern Int VG_(aix5_NR_link);
+#define __NR_AIX5_link VG_(aix5_NR_link)
+
+extern Int VG_(aix5_NR_klockf);
+#define __NR_AIX5_klockf VG_(aix5_NR_klockf)
+
+extern Int VG_(aix5_NR_lockf);
+#define __NR_AIX5_lockf VG_(aix5_NR_lockf)
+
+extern Int VG_(aix5_NR_mkdir);
+#define __NR_AIX5_mkdir VG_(aix5_NR_mkdir)
+
+extern Int VG_(aix5_NR_mknod);
+#define __NR_AIX5_mknod VG_(aix5_NR_mknod)
+
+extern Int VG_(aix5_NR_mntctl);
+#define __NR_AIX5_mntctl VG_(aix5_NR_mntctl)
+
+extern Int VG_(aix5_NR_vmount);
+#define __NR_AIX5_vmount VG_(aix5_NR_vmount)
+
+extern Int VG_(aix5_NR_creat);
+#define __NR_AIX5_creat VG_(aix5_NR_creat)
+
+extern Int VG_(aix5_NR_openx);
+#define __NR_AIX5_openx VG_(aix5_NR_openx)
+
+extern Int VG_(aix5_NR_open);
+#define __NR_AIX5_open VG_(aix5_NR_open)
+
+extern Int VG_(aix5_NR_quotactl);
+#define __NR_AIX5_quotactl VG_(aix5_NR_quotactl)
+
+extern Int VG_(aix5_NR_rename);
+#define __NR_AIX5_rename VG_(aix5_NR_rename)
+
+extern Int VG_(aix5_NR_rmdir);
+#define __NR_AIX5_rmdir VG_(aix5_NR_rmdir)
+
+extern Int VG_(aix5_NR_fstatx);
+#define __NR_AIX5_fstatx VG_(aix5_NR_fstatx)
+
+extern Int VG_(aix5_NR_statx);
+#define __NR_AIX5_statx VG_(aix5_NR_statx)
+
+extern Int VG_(aix5_NR_symlink);
+#define __NR_AIX5_symlink VG_(aix5_NR_symlink)
+
+extern Int VG_(aix5_NR_readlink);
+#define __NR_AIX5_readlink VG_(aix5_NR_readlink)
+
+extern Int VG_(aix5_NR_syncvfs);
+#define __NR_AIX5_syncvfs VG_(aix5_NR_syncvfs)
+
+extern Int VG_(aix5_NR_sync);
+#define __NR_AIX5_sync VG_(aix5_NR_sync)
+
+extern Int VG_(aix5_NR_umask);
+#define __NR_AIX5_umask VG_(aix5_NR_umask)
+
+extern Int VG_(aix5_NR_uvmount);
+#define __NR_AIX5_uvmount VG_(aix5_NR_uvmount)
+
+extern Int VG_(aix5_NR_umount);
+#define __NR_AIX5_umount VG_(aix5_NR_umount)
+
+extern Int VG_(aix5_NR_unameu);
+#define __NR_AIX5_unameu VG_(aix5_NR_unameu)
+
+extern Int VG_(aix5_NR_unamex);
+#define __NR_AIX5_unamex VG_(aix5_NR_unamex)
+
+extern Int VG_(aix5_NR_uname);
+#define __NR_AIX5_uname VG_(aix5_NR_uname)
+
+extern Int VG_(aix5_NR_unlink);
+#define __NR_AIX5_unlink VG_(aix5_NR_unlink)
+
+extern Int VG_(aix5_NR_ustat);
+#define __NR_AIX5_ustat VG_(aix5_NR_ustat)
+
+extern Int VG_(aix5_NR_utimes);
+#define __NR_AIX5_utimes VG_(aix5_NR_utimes)
+
+extern Int VG_(aix5_NR___msgxrcv);
+#define __NR_AIX5___msgxrcv VG_(aix5_NR___msgxrcv)
+
+extern Int VG_(aix5_NR___msgrcv);
+#define __NR_AIX5___msgrcv VG_(aix5_NR___msgrcv)
+
+extern Int VG_(aix5_NR___msgsnd);
+#define __NR_AIX5___msgsnd VG_(aix5_NR___msgsnd)
+
+extern Int VG_(aix5_NR_msgctl);
+#define __NR_AIX5_msgctl VG_(aix5_NR_msgctl)
+
+extern Int VG_(aix5_NR_msgget);
+#define __NR_AIX5_msgget VG_(aix5_NR_msgget)
+
+extern Int VG_(aix5_NR_getgidx);
+#define __NR_AIX5_getgidx VG_(aix5_NR_getgidx)
+
+extern Int VG_(aix5_NR___semop);
+#define __NR_AIX5___semop VG_(aix5_NR___semop)
+
+extern Int VG_(aix5_NR_semget);
+#define __NR_AIX5_semget VG_(aix5_NR_semget)
+
+extern Int VG_(aix5_NR_semctl);
+#define __NR_AIX5_semctl VG_(aix5_NR_semctl)
+
+extern Int VG_(aix5_NR_shmctl);
+#define __NR_AIX5_shmctl VG_(aix5_NR_shmctl)
+
+extern Int VG_(aix5_NR_shmdt);
+#define __NR_AIX5_shmdt VG_(aix5_NR_shmdt)
+
+extern Int VG_(aix5_NR_shmat);
+#define __NR_AIX5_shmat VG_(aix5_NR_shmat)
+
+extern Int VG_(aix5_NR_shmget);
+#define __NR_AIX5_shmget VG_(aix5_NR_shmget)
+
+extern Int VG_(aix5_NR_ra_shmgetv);
+#define __NR_AIX5_ra_shmgetv VG_(aix5_NR_ra_shmgetv)
+
+extern Int VG_(aix5_NR_ra_shmget);
+#define __NR_AIX5_ra_shmget VG_(aix5_NR_ra_shmget)
+
+extern Int VG_(aix5_NR_privcheck);
+#define __NR_AIX5_privcheck VG_(aix5_NR_privcheck)
+
+extern Int VG_(aix5_NR_disclaim);
+#define __NR_AIX5_disclaim VG_(aix5_NR_disclaim)
+
+extern Int VG_(aix5_NR__sem_destroy_unnamed);
+#define __NR_AIX5__sem_destroy_unnamed VG_(aix5_NR__sem_destroy_unnamed)
+
+extern Int VG_(aix5_NR__sem_wait);
+#define __NR_AIX5__sem_wait VG_(aix5_NR__sem_wait)
+
+extern Int VG_(aix5_NR__sem_close);
+#define __NR_AIX5__sem_close VG_(aix5_NR__sem_close)
+
+extern Int VG_(aix5_NR__sem_open);
+#define __NR_AIX5__sem_open VG_(aix5_NR__sem_open)
+
+extern Int VG_(aix5_NR_sem_unlink);
+#define __NR_AIX5_sem_unlink VG_(aix5_NR_sem_unlink)
+
+extern Int VG_(aix5_NR_sem_post);
+#define __NR_AIX5_sem_post VG_(aix5_NR_sem_post)
+
+extern Int VG_(aix5_NR_sem_init);
+#define __NR_AIX5_sem_init VG_(aix5_NR_sem_init)
+
+extern Int VG_(aix5_NR_sem_getvalue);
+#define __NR_AIX5_sem_getvalue VG_(aix5_NR_sem_getvalue)
+
+extern Int VG_(aix5_NR_sem_destroy);
+#define __NR_AIX5_sem_destroy VG_(aix5_NR_sem_destroy)
+
+extern Int VG_(aix5_NR__mq_notify);
+#define __NR_AIX5__mq_notify VG_(aix5_NR__mq_notify)
+
+extern Int VG_(aix5_NR__mq_open);
+#define __NR_AIX5__mq_open VG_(aix5_NR__mq_open)
+
+extern Int VG_(aix5_NR_mq_unlink);
+#define __NR_AIX5_mq_unlink VG_(aix5_NR_mq_unlink)
+
+extern Int VG_(aix5_NR_mq_setattr);
+#define __NR_AIX5_mq_setattr VG_(aix5_NR_mq_setattr)
+
+extern Int VG_(aix5_NR_mq_send);
+#define __NR_AIX5_mq_send VG_(aix5_NR_mq_send)
+
+extern Int VG_(aix5_NR_mq_receive);
+#define __NR_AIX5_mq_receive VG_(aix5_NR_mq_receive)
+
+extern Int VG_(aix5_NR_mq_getattr);
+#define __NR_AIX5_mq_getattr VG_(aix5_NR_mq_getattr)
+
+extern Int VG_(aix5_NR_mq_close);
+#define __NR_AIX5_mq_close VG_(aix5_NR_mq_close)
+
+extern Int VG_(aix5_NR_shm_unlink);
+#define __NR_AIX5_shm_unlink VG_(aix5_NR_shm_unlink)
+
+extern Int VG_(aix5_NR_shm_open);
+#define __NR_AIX5_shm_open VG_(aix5_NR_shm_open)
+
+extern Int VG_(aix5_NR__poll);
+#define __NR_AIX5__poll VG_(aix5_NR__poll)
+
+extern Int VG_(aix5_NR__select);
+#define __NR_AIX5__select VG_(aix5_NR__select)
+
+extern Int VG_(aix5_NR_sysconfig);
+#define __NR_AIX5_sysconfig VG_(aix5_NR_sysconfig)
+
+extern Int VG_(aix5_NR_sys_parm);
+#define __NR_AIX5_sys_parm VG_(aix5_NR_sys_parm)
+
+extern Int VG_(aix5_NR_loadquery);
+#define __NR_AIX5_loadquery VG_(aix5_NR_loadquery)
+
+extern Int VG_(aix5_NR_knlist);
+#define __NR_AIX5_knlist VG_(aix5_NR_knlist)
+
+extern Int VG_(aix5_NR_brk);
+#define __NR_AIX5_brk VG_(aix5_NR_brk)
+
+extern Int VG_(aix5_NR_fjfs_sys_call);
+#define __NR_AIX5_fjfs_sys_call VG_(aix5_NR_fjfs_sys_call)
+
+extern Int VG_(aix5_NR_jfs_sys_call);
+#define __NR_AIX5_jfs_sys_call VG_(aix5_NR_jfs_sys_call)
+
+extern Int VG_(aix5_NR_acct);
+#define __NR_AIX5_acct VG_(aix5_NR_acct)
+
+extern Int VG_(aix5_NR__dr_unregister);
+#define __NR_AIX5__dr_unregister VG_(aix5_NR__dr_unregister)
+
+extern Int VG_(aix5_NR__dr_notify);
+#define __NR_AIX5__dr_notify VG_(aix5_NR__dr_notify)
+
+extern Int VG_(aix5_NR__dr_register);
+#define __NR_AIX5__dr_register VG_(aix5_NR__dr_register)
+
+extern Int VG_(aix5_NR_getlparload);
+#define __NR_AIX5_getlparload VG_(aix5_NR_getlparload)
+
+extern Int VG_(aix5_NR_dr_reconfig);
+#define __NR_AIX5_dr_reconfig VG_(aix5_NR_dr_reconfig)
+
+extern Int VG_(aix5_NR_projctl);
+#define __NR_AIX5_projctl VG_(aix5_NR_projctl)
+
+extern Int VG_(aix5_NR_sbrk);
+#define __NR_AIX5_sbrk VG_(aix5_NR_sbrk)
+
+extern Int VG_(aix5_NR__sigpending);
+#define __NR_AIX5__sigpending VG_(aix5_NR__sigpending)
+
+extern Int VG_(aix5_NR__pause);
+#define __NR_AIX5__pause VG_(aix5_NR__pause)
+
+extern Int VG_(aix5_NR_thread_kill);
+#define __NR_AIX5_thread_kill VG_(aix5_NR_thread_kill)
+
+extern Int VG_(aix5_NR_sigstack);
+#define __NR_AIX5_sigstack VG_(aix5_NR_sigstack)
+
+extern Int VG_(aix5_NR_sigaltstack);
+#define __NR_AIX5_sigaltstack VG_(aix5_NR_sigaltstack)
+
+extern Int VG_(aix5_NR_appulimit);
+#define __NR_AIX5_appulimit VG_(aix5_NR_appulimit)
+
+extern Int VG_(aix5_NR_ras_service);
+#define __NR_AIX5_ras_service VG_(aix5_NR_ras_service)
+
+extern Int VG_(aix5_NR__wlm_class_descr2key);
+#define __NR_AIX5__wlm_class_descr2key VG_(aix5_NR__wlm_class_descr2key)
+
+extern Int VG_(aix5_NR__wlm_get_procinfo);
+#define __NR_AIX5__wlm_get_procinfo VG_(aix5_NR__wlm_get_procinfo)
+
+extern Int VG_(aix5_NR__wlm_get_info);
+#define __NR_AIX5__wlm_get_info VG_(aix5_NR__wlm_get_info)
+
+extern Int VG_(aix5_NR__wlm_getclassname);
+#define __NR_AIX5__wlm_getclassname VG_(aix5_NR__wlm_getclassname)
+
+extern Int VG_(aix5_NR__wlm_unload_classes);
+#define __NR_AIX5__wlm_unload_classes VG_(aix5_NR__wlm_unload_classes)
+
+extern Int VG_(aix5_NR__wlm_load);
+#define __NR_AIX5__wlm_load VG_(aix5_NR__wlm_load)
+
+extern Int VG_(aix5_NR__wlm_tune);
+#define __NR_AIX5__wlm_tune VG_(aix5_NR__wlm_tune)
+
+extern Int VG_(aix5_NR__wlm_assign);
+#define __NR_AIX5__wlm_assign VG_(aix5_NR__wlm_assign)
+
+extern Int VG_(aix5_NR__wlm_classify);
+#define __NR_AIX5__wlm_classify VG_(aix5_NR__wlm_classify)
+
+extern Int VG_(aix5_NR_fp_cpusync);
+#define __NR_AIX5_fp_cpusync VG_(aix5_NR_fp_cpusync)
+
+extern Int VG_(aix5_NR__fp_trapstate_ker);
+#define __NR_AIX5__fp_trapstate_ker VG_(aix5_NR__fp_trapstate_ker)
+
+extern Int VG_(aix5_NR__ewlm_classify_correlator);
+#define __NR_AIX5__ewlm_classify_correlator VG_(aix5_NR__ewlm_classify_correlator)
+
+extern Int VG_(aix5_NR__arm_stop_transaction);
+#define __NR_AIX5__arm_stop_transaction VG_(aix5_NR__arm_stop_transaction)
+
+extern Int VG_(aix5_NR__arm_destroy_application);
+#define __NR_AIX5__arm_destroy_application VG_(aix5_NR__arm_destroy_application)
+
+extern Int VG_(aix5_NR__arm_stop_application);
+#define __NR_AIX5__arm_stop_application VG_(aix5_NR__arm_stop_application)
+
+extern Int VG_(aix5_NR__arm_generate_correlator);
+#define __NR_AIX5__arm_generate_correlator VG_(aix5_NR__arm_generate_correlator)
+
+extern Int VG_(aix5_NR__arm_discard_transaction);
+#define __NR_AIX5__arm_discard_transaction VG_(aix5_NR__arm_discard_transaction)
+
+extern Int VG_(aix5_NR__arm_unbind_thread);
+#define __NR_AIX5__arm_unbind_thread VG_(aix5_NR__arm_unbind_thread)
+
+extern Int VG_(aix5_NR__arm_bind_thread);
+#define __NR_AIX5__arm_bind_thread VG_(aix5_NR__arm_bind_thread)
+
+extern Int VG_(aix5_NR__arm_unblock_transaction);
+#define __NR_AIX5__arm_unblock_transaction VG_(aix5_NR__arm_unblock_transaction)
+
+extern Int VG_(aix5_NR__arm_block_transaction);
+#define __NR_AIX5__arm_block_transaction VG_(aix5_NR__arm_block_transaction)
+
+extern Int VG_(aix5_NR__arm_update_transaction);
+#define __NR_AIX5__arm_update_transaction VG_(aix5_NR__arm_update_transaction)
+
+extern Int VG_(aix5_NR__arm_register_metric);
+#define __NR_AIX5__arm_register_metric VG_(aix5_NR__arm_register_metric)
+
+extern Int VG_(aix5_NR__arm_report_transaction);
+#define __NR_AIX5__arm_report_transaction VG_(aix5_NR__arm_report_transaction)
+
+extern Int VG_(aix5_NR__arm_start_transaction);
+#define __NR_AIX5__arm_start_transaction VG_(aix5_NR__arm_start_transaction)
+
+extern Int VG_(aix5_NR__arm_register_transaction);
+#define __NR_AIX5__arm_register_transaction VG_(aix5_NR__arm_register_transaction)
+
+extern Int VG_(aix5_NR__arm_start_application);
+#define __NR_AIX5__arm_start_application VG_(aix5_NR__arm_start_application)
+
+extern Int VG_(aix5_NR__arm_register_application);
+#define __NR_AIX5__arm_register_application VG_(aix5_NR__arm_register_application)
+
+extern Int VG_(aix5_NR__lsarm_getinfo);
+#define __NR_AIX5__lsarm_getinfo VG_(aix5_NR__lsarm_getinfo)
+
+extern Int VG_(aix5_NR__ewlm_init);
+#define __NR_AIX5__ewlm_init VG_(aix5_NR__ewlm_init)
+
+extern Int VG_(aix5_NR__ewlm_query);
+#define __NR_AIX5__ewlm_query VG_(aix5_NR__ewlm_query)
+
+extern Int VG_(aix5_NR_ewlm_verify_policy);
+#define __NR_AIX5_ewlm_verify_policy VG_(aix5_NR_ewlm_verify_policy)
+
+extern Int VG_(aix5_NR_ewlm_abort_policy);
+#define __NR_AIX5_ewlm_abort_policy VG_(aix5_NR_ewlm_abort_policy)
+
+extern Int VG_(aix5_NR_ewlm_commit_policy);
+#define __NR_AIX5_ewlm_commit_policy VG_(aix5_NR_ewlm_commit_policy)
+
+extern Int VG_(aix5_NR_ewlm_prepare_policy);
+#define __NR_AIX5_ewlm_prepare_policy VG_(aix5_NR_ewlm_prepare_policy)
+
+extern Int VG_(aix5_NR_ewlm_get_completions);
+#define __NR_AIX5_ewlm_get_completions VG_(aix5_NR_ewlm_get_completions)
+
+extern Int VG_(aix5_NR_ewlm_get_activedata);
+#define __NR_AIX5_ewlm_get_activedata VG_(aix5_NR_ewlm_get_activedata)
+
+extern Int VG_(aix5_NR_ewlm_get_appldata);
+#define __NR_AIX5_ewlm_get_appldata VG_(aix5_NR_ewlm_get_appldata)
+
+extern Int VG_(aix5_NR_ewlm_collect_samples);
+#define __NR_AIX5_ewlm_collect_samples VG_(aix5_NR_ewlm_collect_samples)
+
+extern Int VG_(aix5_NR_ewlm_disconnect);
+#define __NR_AIX5_ewlm_disconnect VG_(aix5_NR_ewlm_disconnect)
+
+extern Int VG_(aix5_NR_ewlm_connect);
+#define __NR_AIX5_ewlm_connect VG_(aix5_NR_ewlm_connect)
+
+extern Int VG_(aix5_NR_auditlog);
+#define __NR_AIX5_auditlog VG_(aix5_NR_auditlog)
+
+extern Int VG_(aix5_NR_auditproc);
+#define __NR_AIX5_auditproc VG_(aix5_NR_auditproc)
+
+extern Int VG_(aix5_NR_getgroups);
+#define __NR_AIX5_getgroups VG_(aix5_NR_getgroups)
+
+extern Int VG_(aix5_NR_setgid);
+#define __NR_AIX5_setgid VG_(aix5_NR_setgid)
+
+extern Int VG_(aix5_NR_setgidx);
+#define __NR_AIX5_setgidx VG_(aix5_NR_setgidx)
+
+extern Int VG_(aix5_NR_setgroups);
+#define __NR_AIX5_setgroups VG_(aix5_NR_setgroups)
+
+extern Int VG_(aix5_NR_frevoke);
+#define __NR_AIX5_frevoke VG_(aix5_NR_frevoke)
+
+extern Int VG_(aix5_NR_revoke);
+#define __NR_AIX5_revoke VG_(aix5_NR_revoke)
+
+extern Int VG_(aix5_NR___pag_setvalue);
+#define __NR_AIX5___pag_setvalue VG_(aix5_NR___pag_setvalue)
+
+extern Int VG_(aix5_NR___pag_getvalue);
+#define __NR_AIX5___pag_getvalue VG_(aix5_NR___pag_getvalue)
+
+extern Int VG_(aix5_NR___pag_getid);
+#define __NR_AIX5___pag_getid VG_(aix5_NR___pag_getid)
+
+extern Int VG_(aix5_NR___pag_getname);
+#define __NR_AIX5___pag_getname VG_(aix5_NR___pag_getname)
+
+extern Int VG_(aix5_NR___pag_setname);
+#define __NR_AIX5___pag_setname VG_(aix5_NR___pag_setname)
+
+extern Int VG_(aix5_NR_kcap_set_proc);
+#define __NR_AIX5_kcap_set_proc VG_(aix5_NR_kcap_set_proc)
+
+extern Int VG_(aix5_NR_kcap_get_proc);
+#define __NR_AIX5_kcap_get_proc VG_(aix5_NR_kcap_get_proc)
+
+extern Int VG_(aix5_NR_pipe);
+#define __NR_AIX5_pipe VG_(aix5_NR_pipe)
+
+extern Int VG_(aix5_NR_mwakeup);
+#define __NR_AIX5_mwakeup VG_(aix5_NR_mwakeup)
+
+extern Int VG_(aix5_NR___msleep);
+#define __NR_AIX5___msleep VG_(aix5_NR___msleep)
+
+extern Int VG_(aix5_NR_kmmap);
+#define __NR_AIX5_kmmap VG_(aix5_NR_kmmap)
+
+extern Int VG_(aix5_NR_msem_remove);
+#define __NR_AIX5_msem_remove VG_(aix5_NR_msem_remove)
+
+extern Int VG_(aix5_NR_mincore);
+#define __NR_AIX5_mincore VG_(aix5_NR_mincore)
+
+extern Int VG_(aix5_NR_madvise);
+#define __NR_AIX5_madvise VG_(aix5_NR_madvise)
+
+extern Int VG_(aix5_NR_munmap);
+#define __NR_AIX5_munmap VG_(aix5_NR_munmap)
+
+extern Int VG_(aix5_NR_msync);
+#define __NR_AIX5_msync VG_(aix5_NR_msync)
+
+extern Int VG_(aix5_NR_mprotect);
+#define __NR_AIX5_mprotect VG_(aix5_NR_mprotect)
+
+extern Int VG_(aix5_NR_mmap);
+#define __NR_AIX5_mmap VG_(aix5_NR_mmap)
+
+extern Int VG_(aix5_NR_swapqry);
+#define __NR_AIX5_swapqry VG_(aix5_NR_swapqry)
+
+extern Int VG_(aix5_NR_swapon);
+#define __NR_AIX5_swapon VG_(aix5_NR_swapon)
+
+extern Int VG_(aix5_NR_swapoff);
+#define __NR_AIX5_swapoff VG_(aix5_NR_swapoff)
+
+extern Int VG_(aix5_NR_psdanger);
+#define __NR_AIX5_psdanger VG_(aix5_NR_psdanger)
+
+extern Int VG_(aix5_NR_vmgetinfo);
+#define __NR_AIX5_vmgetinfo VG_(aix5_NR_vmgetinfo)
+
+extern Int VG_(aix5_NR_rs_admregistername);
+#define __NR_AIX5_rs_admregistername VG_(aix5_NR_rs_admregistername)
+
+extern Int VG_(aix5_NR_rs_discardname);
+#define __NR_AIX5_rs_discardname VG_(aix5_NR_rs_discardname)
+
+extern Int VG_(aix5_NR_rs_setnameattr);
+#define __NR_AIX5_rs_setnameattr VG_(aix5_NR_rs_setnameattr)
+
+extern Int VG_(aix5_NR_rs_registername);
+#define __NR_AIX5_rs_registername VG_(aix5_NR_rs_registername)
+
+extern Int VG_(aix5_NR_rs_getnamedrset);
+#define __NR_AIX5_rs_getnamedrset VG_(aix5_NR_rs_getnamedrset)
+
+extern Int VG_(aix5_NR_rs_getnameattr);
+#define __NR_AIX5_rs_getnameattr VG_(aix5_NR_rs_getnameattr)
+
+extern Int VG_(aix5_NR_rs_getrsetnames);
+#define __NR_AIX5_rs_getrsetnames VG_(aix5_NR_rs_getrsetnames)
+
+extern Int VG_(aix5_NR_ra_attachrset);
+#define __NR_AIX5_ra_attachrset VG_(aix5_NR_ra_attachrset)
+
+extern Int VG_(aix5_NR_ra_detachrset);
+#define __NR_AIX5_ra_detachrset VG_(aix5_NR_ra_detachrset)
+
+extern Int VG_(aix5_NR_dmapi_init);
+#define __NR_AIX5_dmapi_init VG_(aix5_NR_dmapi_init)
+
+extern Int VG_(aix5_NR_kdm_ioctl);
+#define __NR_AIX5_kdm_ioctl VG_(aix5_NR_kdm_ioctl)
+
+extern Int VG_(aix5_NR_access);
+#define __NR_AIX5_access VG_(aix5_NR_access)
+
+extern Int VG_(aix5_NR_accessx);
+#define __NR_AIX5_accessx VG_(aix5_NR_accessx)
+
+extern Int VG_(aix5_NR_kfcntl);
+#define __NR_AIX5_kfcntl VG_(aix5_NR_kfcntl)
+
+extern Int VG_(aix5_NR___pfcntl);
+#define __NR_AIX5___pfcntl VG_(aix5_NR___pfcntl)
+
+extern Int VG_(aix5_NR_fstatfs64);
+#define __NR_AIX5_fstatfs64 VG_(aix5_NR_fstatfs64)
+
+extern Int VG_(aix5_NR_statfs64);
+#define __NR_AIX5_statfs64 VG_(aix5_NR_statfs64)
+
+extern Int VG_(aix5_NR_fstatfs);
+#define __NR_AIX5_fstatfs VG_(aix5_NR_fstatfs)
+
+extern Int VG_(aix5_NR_statfs);
+#define __NR_AIX5_statfs VG_(aix5_NR_statfs)
+
+extern Int VG_(aix5_NR_probe);
+#define __NR_AIX5_probe VG_(aix5_NR_probe)
+
+extern Int VG_(aix5_NR_cmp_swap);
+#define __NR_AIX5_cmp_swap VG_(aix5_NR_cmp_swap)
+
+extern Int VG_(aix5_NR__validate_pag);
+#define __NR_AIX5__validate_pag VG_(aix5_NR__validate_pag)
+
+extern Int VG_(aix5_NR_kgetsidx);
+#define __NR_AIX5_kgetsidx VG_(aix5_NR_kgetsidx)
+
+extern Int VG_(aix5_NR_kgetsid);
+#define __NR_AIX5_kgetsid VG_(aix5_NR_kgetsid)
+
+extern Int VG_(aix5_NR_plock);
+#define __NR_AIX5_plock VG_(aix5_NR_plock)
+
+extern Int VG_(aix5_NR_upfput);
+#define __NR_AIX5_upfput VG_(aix5_NR_upfput)
+
+extern Int VG_(aix5_NR_usrinfo);
+#define __NR_AIX5_usrinfo VG_(aix5_NR_usrinfo)
+
+extern Int VG_(aix5_NR_audit);
+#define __NR_AIX5_audit VG_(aix5_NR_audit)
+
+extern Int VG_(aix5_NR_auditobj);
+#define __NR_AIX5_auditobj VG_(aix5_NR_auditobj)
+
+extern Int VG_(aix5_NR_auditbin);
+#define __NR_AIX5_auditbin VG_(aix5_NR_auditbin)
+
+extern Int VG_(aix5_NR_auditevents);
+#define __NR_AIX5_auditevents VG_(aix5_NR_auditevents)
+
+extern Int VG_(aix5_NR_faccessx);
+#define __NR_AIX5_faccessx VG_(aix5_NR_faccessx)
+
+extern Int VG_(aix5_NR___fchaclx);
+#define __NR_AIX5___fchaclx VG_(aix5_NR___fchaclx)
+
+extern Int VG_(aix5_NR___chaclx);
+#define __NR_AIX5___chaclx VG_(aix5_NR___chaclx)
+
+extern Int VG_(aix5_NR_fchacl);
+#define __NR_AIX5_fchacl VG_(aix5_NR_fchacl)
+
+extern Int VG_(aix5_NR_chacl);
+#define __NR_AIX5_chacl VG_(aix5_NR_chacl)
+
+extern Int VG_(aix5_NR___fstataclx);
+#define __NR_AIX5___fstataclx VG_(aix5_NR___fstataclx)
+
+extern Int VG_(aix5_NR___stataclx);
+#define __NR_AIX5___stataclx VG_(aix5_NR___stataclx)
+
+extern Int VG_(aix5_NR_fstatacl);
+#define __NR_AIX5_fstatacl VG_(aix5_NR_fstatacl)
+
+extern Int VG_(aix5_NR_statacl);
+#define __NR_AIX5_statacl VG_(aix5_NR_statacl)
+
+extern Int VG_(aix5_NR_setpriv);
+#define __NR_AIX5_setpriv VG_(aix5_NR_setpriv)
+
+extern Int VG_(aix5_NR_getpriv);
+#define __NR_AIX5_getpriv VG_(aix5_NR_getpriv)
+
+extern Int VG_(aix5_NR_fstatpriv);
+#define __NR_AIX5_fstatpriv VG_(aix5_NR_fstatpriv)
+
+extern Int VG_(aix5_NR_statpriv);
+#define __NR_AIX5_statpriv VG_(aix5_NR_statpriv)
+
+extern Int VG_(aix5_NR_fchpriv);
+#define __NR_AIX5_fchpriv VG_(aix5_NR_fchpriv)
+
+extern Int VG_(aix5_NR_chpriv);
+#define __NR_AIX5_chpriv VG_(aix5_NR_chpriv)
+
+extern Int VG_(aix5_NR_i_int2cpu_pal);
+#define __NR_AIX5_i_int2cpu_pal VG_(aix5_NR_i_int2cpu_pal)
+
+extern Int VG_(aix5_NR_hd_cfg);
+#define __NR_AIX5_hd_cfg VG_(aix5_NR_hd_cfg)
+
+extern Int VG_(aix5_NR_putpmsg);
+#define __NR_AIX5_putpmsg VG_(aix5_NR_putpmsg)
+
+extern Int VG_(aix5_NR_putmsg);
+#define __NR_AIX5_putmsg VG_(aix5_NR_putmsg)
+
+extern Int VG_(aix5_NR_getpmsg);
+#define __NR_AIX5_getpmsg VG_(aix5_NR_getpmsg)
+
+extern Int VG_(aix5_NR_getmsg);
+#define __NR_AIX5_getmsg VG_(aix5_NR_getmsg)
+
+extern Int VG_(aix5_NR_strinfo);
+#define __NR_AIX5_strinfo VG_(aix5_NR_strinfo)
+
+extern Int VG_(aix5_NR_strreset);
+#define __NR_AIX5_strreset VG_(aix5_NR_strreset)
+
+extern Int VG_(aix5_NR_dupmsg);
+#define __NR_AIX5_dupmsg VG_(aix5_NR_dupmsg)
+
+extern Int VG_(aix5_NR__kgrantpt);
+#define __NR_AIX5__kgrantpt VG_(aix5_NR__kgrantpt)
+
+extern Int VG_(aix5_NR_aixgsc);
+#define __NR_AIX5_aixgsc VG_(aix5_NR_aixgsc)
+
+extern Int VG_(aix5_NR_smaccept);
+#define __NR_AIX5_smaccept VG_(aix5_NR_smaccept)
+
+extern Int VG_(aix5_NR_smconnect);
+#define __NR_AIX5_smconnect VG_(aix5_NR_smconnect)
+
+extern Int VG_(aix5_NR_smlisten);
+#define __NR_AIX5_smlisten VG_(aix5_NR_smlisten)
+
+extern Int VG_(aix5_NR_smbind);
+#define __NR_AIX5_smbind VG_(aix5_NR_smbind)
+
+extern Int VG_(aix5_NR_smsocket);
+#define __NR_AIX5_smsocket VG_(aix5_NR_smsocket)
+
+extern Int VG_(aix5_NR_smdetatt);
+#define __NR_AIX5_smdetatt VG_(aix5_NR_smdetatt)
+
+extern Int VG_(aix5_NR_smattach);
+#define __NR_AIX5_smattach VG_(aix5_NR_smattach)
+
+extern Int VG_(aix5_NR_smselect);
+#define __NR_AIX5_smselect VG_(aix5_NR_smselect)
+
+extern Int VG_(aix5_NR_smwait);
+#define __NR_AIX5_smwait VG_(aix5_NR_smwait)
+
+extern Int VG_(aix5_NR_smsetthresh);
+#define __NR_AIX5_smsetthresh VG_(aix5_NR_smsetthresh)
+
+extern Int VG_(aix5_NR_smsendbuff);
+#define __NR_AIX5_smsendbuff VG_(aix5_NR_smsendbuff)
+
+extern Int VG_(aix5_NR_smfreebuff);
+#define __NR_AIX5_smfreebuff VG_(aix5_NR_smfreebuff)
+
+extern Int VG_(aix5_NR_smrcvbuff);
+#define __NR_AIX5_smrcvbuff VG_(aix5_NR_smrcvbuff)
+
+extern Int VG_(aix5_NR_smgetbuff);
+#define __NR_AIX5_smgetbuff VG_(aix5_NR_smgetbuff)
+
+extern Int VG_(aix5_NR_smversion);
+#define __NR_AIX5_smversion VG_(aix5_NR_smversion)
+
+extern Int VG_(aix5_NR_smtcheckinit);
+#define __NR_AIX5_smtcheckinit VG_(aix5_NR_smtcheckinit)
+
+extern Int VG_(aix5_NR_aio_nwait_timeout);
+#define __NR_AIX5_aio_nwait_timeout VG_(aix5_NR_aio_nwait_timeout)
+
+extern Int VG_(aix5_NR_kaio_stats);
+#define __NR_AIX5_kaio_stats VG_(aix5_NR_kaio_stats)
+
+extern Int VG_(aix5_NR_aio_cntl);
+#define __NR_AIX5_aio_cntl VG_(aix5_NR_aio_cntl)
+
+extern Int VG_(aix5_NR_listio);
+#define __NR_AIX5_listio VG_(aix5_NR_listio)
+
+extern Int VG_(aix5_NR_acancel);
+#define __NR_AIX5_acancel VG_(aix5_NR_acancel)
+
+extern Int VG_(aix5_NR_iosuspend);
+#define __NR_AIX5_iosuspend VG_(aix5_NR_iosuspend)
+
+extern Int VG_(aix5_NR_kaio_rdwr);
+#define __NR_AIX5_kaio_rdwr VG_(aix5_NR_kaio_rdwr)
+
+extern Int VG_(aix5_NR_aio_nwait);
+#define __NR_AIX5_aio_nwait VG_(aix5_NR_aio_nwait)
+
+extern Int VG_(aix5_NR__posix_iofsync);
+#define __NR_AIX5__posix_iofsync VG_(aix5_NR__posix_iofsync)
+
+extern Int VG_(aix5_NR__posix_aio_nwait_timeout);
+#define __NR_AIX5__posix_aio_nwait_timeout VG_(aix5_NR__posix_aio_nwait_timeout)
+
+extern Int VG_(aix5_NR__posix_kaio_stats);
+#define __NR_AIX5__posix_kaio_stats VG_(aix5_NR__posix_kaio_stats)
+
+extern Int VG_(aix5_NR__posix_listio);
+#define __NR_AIX5__posix_listio VG_(aix5_NR__posix_listio)
+
+extern Int VG_(aix5_NR__posix_acancel);
+#define __NR_AIX5__posix_acancel VG_(aix5_NR__posix_acancel)
+
+extern Int VG_(aix5_NR__posix_iosuspend);
+#define __NR_AIX5__posix_iosuspend VG_(aix5_NR__posix_iosuspend)
+
+extern Int VG_(aix5_NR__posix_kaio_rdwr);
+#define __NR_AIX5__posix_kaio_rdwr VG_(aix5_NR__posix_kaio_rdwr)
+
+extern Int VG_(aix5_NR__posix_aio_cntl);
+#define __NR_AIX5__posix_aio_cntl VG_(aix5_NR__posix_aio_cntl)
+
+extern Int VG_(aix5_NR__posix_aio_nwait);
+#define __NR_AIX5__posix_aio_nwait VG_(aix5_NR__posix_aio_nwait)
+
+extern Int VG_(aix5_NR_nfs_cntl);
+#define __NR_AIX5_nfs_cntl VG_(aix5_NR_nfs_cntl)
+
+extern Int VG_(aix5_NR_nfssvc);
+#define __NR_AIX5_nfssvc VG_(aix5_NR_nfssvc)
+
+extern Int VG_(aix5_NR_nfs_getfh);
+#define __NR_AIX5_nfs_getfh VG_(aix5_NR_nfs_getfh)
+
+extern Int VG_(aix5_NR_exportfs);
+#define __NR_AIX5_exportfs VG_(aix5_NR_exportfs)
+
+extern Int VG_(aix5_NR_lm_svc);
+#define __NR_AIX5_lm_svc VG_(aix5_NR_lm_svc)
+
+extern Int VG_(aix5_NR_pw_config);
+#define __NR_AIX5_pw_config VG_(aix5_NR_pw_config)
+
+extern Int VG_(aix5_NR_pw_post);
+#define __NR_AIX5_pw_post VG_(aix5_NR_pw_post)
+
+extern Int VG_(aix5_NR_pw_wait);
+#define __NR_AIX5_pw_wait VG_(aix5_NR_pw_wait)
+
+extern Int VG_(aix5_NR_pw_loadavg);
+#define __NR_AIX5_pw_loadavg VG_(aix5_NR_pw_loadavg)
+
+extern Int VG_(aix5_NR_pw_debug);
+#define __NR_AIX5_pw_debug VG_(aix5_NR_pw_debug)
+
+/* Extras for AIX 5.3 */
+
+extern Int VG_(aix5_NR___libc_sbrk);
+#define __NR_AIX5___libc_sbrk VG_(aix5_NR___libc_sbrk)
+
+extern Int VG_(aix5_NR_thread_waitlock_);
+#define __NR_AIX5_thread_waitlock_ VG_(aix5_NR_thread_waitlock_)
+
+extern Int VG_(aix5_NR__fp_fpscrx_sc);
+#define __NR_AIX5__fp_fpscrx_sc VG_(aix5_NR__fp_fpscrx_sc)
+
+extern Int VG_(aix5_NR_sched_get_priority_max);
+#define __NR_AIX5_sched_get_priority_max \
+        VG_(aix5_NR_sched_get_priority_max)
+
+/* Extras for AIX 5.3 64-bit mode. */
+
+extern Int VG_(aix5_NR_kload);
+#define __NR_AIX5_kload VG_(aix5_NR_kload)
+
+extern Int VG_(aix5_NR__fp_fpscrx64_);
+#define __NR_AIX5__fp_fpscrx64_ VG_(aix5_NR__fp_fpscrx64_)
+
+extern Int VG_(aix5_NR_kunload64);
+#define __NR_AIX5_kunload64 VG_(aix5_NR_kunload64)
+
+/* We need an extra fake syscall to denote signal handler returns, as
+   used in sigframe-ppc32/64-aix5.h.  Since we don't know what number we
+   can assign to it, monitor the numbers passed to
+   VG_(aix5_register_syscall), and set it to 10000+the largest syscall
+   nummber seen. */
+
+extern Int VG_(aix5_NR_FAKE_SIGRETURN);
+#define __NR_AIX5_FAKE_SIGRETURN VG_(aix5_NR_FAKE_SIGRETURN)
+
+
+//--------------------------------------------------------------
+// "Bindings" to Linux-like names
+//--------------------------------------------------------------
+
+#define __NR_getppid         __NR_AIX5__getppid
+#define __NR_getpid          __NR_AIX5__getpid
+#define __NR_close           __NR_AIX5_close
+#define __NR_open            __NR_AIX5_open
+#define __NR_mmap            __NR_AIX5_mmap
+#define __NR_write           __NR_AIX5_kwrite
+#define __NR_exit            __NR_AIX5__exit
+#define __NR_read            __NR_AIX5_kread
+#define __NR_getrlimit       __NR_AIX5_appgetrlimit
+#define __NR_setrlimit       __NR_AIX5_appsetrlimit
+#define __NR_rt_sigaction    __NR_AIX5__sigaction
+#define __NR_rt_sigprocmask  __NR_AIX5_sigprocmask
+#define __NR__sigpending     __NR_AIX5__sigpending
+#define __NR__sigsuspend     __NR_AIX5__sigsuspend
+#define __NR_fcntl           __NR_AIX5_kfcntl
+#define __NR_unlink          __NR_AIX5_unlink
+#define __NR_pipe            __NR_AIX5_pipe
+#define __NR_mprotect        __NR_AIX5_mprotect
+#define __NR_munmap          __NR_AIX5_munmap
+#define __NR_fork            __NR_AIX5_kfork
+#define __NR_execve          __NR_AIX5_execve
+#define __NR_rename          __NR_AIX5_rename
+#define __NR_access          __NR_AIX5_access
+#define __NR_kill            __NR_AIX5_kill
+#define __NR_tkill           __NR_AIX5_thread_kill
+#define __NR_getgroups       __NR_AIX5_getgroups
+#define __NR_sched_yield     __NR_AIX5_yield
+
+//--------------------------------------------------------------
+// BOGUS
+//--------------------------------------------------------------
+
+/* XXXXXXXXX BOGUS */
+#define __NR_rt_sigreturn    9999
+#define __NR_getegid         9999
+#define __NR_ptrace          9999
+#define __NR_rt_sigtimedwait 9999
+#define __NR_lseek           9999
+#define __NR_fstat           9999
+#define __NR_dup             9999
+#define __NR_getcwd          9999
+#define __NR_readlink        9999
+#define __NR_getdents        9999
+#define __NR_gettid          9999
+#define __NR_getpgrp         9999
+#define __NR_geteuid         9999
+
+
+#endif /* __VKI_SCNUMS_AIX5_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-amd64-linux.h b/include/vki/vki-scnums-amd64-linux.h
new file mode 100644
index 0000000..f891f94
--- /dev/null
+++ b/include/vki/vki-scnums-amd64-linux.h
@@ -0,0 +1,388 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for amd64-linux.                         ---*/
+/*---                                     vki-scnums-amd64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_SCNUMS_AMD64_LINUX_H
+#define __VKI_SCNUMS_AMD64_LINUX_H
+
+// From linux-2.6.9/include/asm-x86_64/unistd.h
+
+#define __NR_read                                0
+#define __NR_write                               1
+#define __NR_open                                2
+#define __NR_close                               3
+#define __NR_stat                                4
+#define __NR_fstat                               5
+#define __NR_lstat                               6
+#define __NR_poll                                7
+
+#define __NR_lseek                               8
+#define __NR_mmap                                9
+#define __NR_mprotect                           10
+#define __NR_munmap                             11
+#define __NR_brk                                12
+#define __NR_rt_sigaction                       13
+#define __NR_rt_sigprocmask                     14
+#define __NR_rt_sigreturn                       15
+
+#define __NR_ioctl                              16
+#define __NR_pread64                            17
+#define __NR_pwrite64                           18
+#define __NR_readv                              19
+#define __NR_writev                             20
+#define __NR_access                             21
+#define __NR_pipe                               22
+#define __NR_select                             23
+
+#define __NR_sched_yield                        24
+#define __NR_mremap                             25
+#define __NR_msync                              26
+#define __NR_mincore                            27
+#define __NR_madvise                            28
+#define __NR_shmget                             29
+#define __NR_shmat                              30
+#define __NR_shmctl                             31
+
+#define __NR_dup                                32
+#define __NR_dup2                               33
+#define __NR_pause                              34
+#define __NR_nanosleep                          35
+#define __NR_getitimer                          36
+#define __NR_alarm                              37
+#define __NR_setitimer                          38
+#define __NR_getpid                             39
+
+#define __NR_sendfile                           40
+#define __NR_socket                             41
+#define __NR_connect                            42
+#define __NR_accept                             43
+#define __NR_sendto                             44
+#define __NR_recvfrom                           45
+#define __NR_sendmsg                            46
+#define __NR_recvmsg                            47
+
+#define __NR_shutdown                           48
+#define __NR_bind                               49
+#define __NR_listen                             50
+#define __NR_getsockname                        51
+#define __NR_getpeername                        52
+#define __NR_socketpair                         53
+#define __NR_setsockopt                         54
+#define __NR_getsockopt                         55
+
+#define __NR_clone                              56
+#define __NR_fork                               57
+#define __NR_vfork                              58
+#define __NR_execve                             59
+#define __NR_exit                               60
+#define __NR_wait4                              61
+#define __NR_kill                               62
+#define __NR_uname                              63
+
+#define __NR_semget                             64
+#define __NR_semop                              65
+#define __NR_semctl                             66
+#define __NR_shmdt                              67
+#define __NR_msgget                             68
+#define __NR_msgsnd                             69
+#define __NR_msgrcv                             70
+#define __NR_msgctl                             71
+
+#define __NR_fcntl                              72
+#define __NR_flock                              73
+#define __NR_fsync                              74
+#define __NR_fdatasync                          75
+#define __NR_truncate                           76
+#define __NR_ftruncate                          77
+#define __NR_getdents                           78
+#define __NR_getcwd                             79
+
+#define __NR_chdir                              80
+#define __NR_fchdir                             81
+#define __NR_rename                             82
+#define __NR_mkdir                              83
+#define __NR_rmdir                              84
+#define __NR_creat                              85
+#define __NR_link                               86
+#define __NR_unlink                             87
+
+#define __NR_symlink                            88
+#define __NR_readlink                           89
+#define __NR_chmod                              90
+#define __NR_fchmod                             91
+#define __NR_chown                              92
+#define __NR_fchown                             93
+#define __NR_lchown                             94
+#define __NR_umask                              95
+
+#define __NR_gettimeofday                       96
+#define __NR_getrlimit                          97
+#define __NR_getrusage                          98
+#define __NR_sysinfo                            99
+#define __NR_times                             100
+#define __NR_ptrace                            101
+#define __NR_getuid                            102
+#define __NR_syslog                            103
+
+/* at the very end the stuff that never runs during the benchmarks */
+#define __NR_getgid                            104
+#define __NR_setuid                            105
+#define __NR_setgid                            106
+#define __NR_geteuid                           107
+#define __NR_getegid                           108
+#define __NR_setpgid                           109
+#define __NR_getppid                           110
+#define __NR_getpgrp                           111
+
+#define __NR_setsid                            112
+#define __NR_setreuid                          113
+#define __NR_setregid                          114
+#define __NR_getgroups                         115
+#define __NR_setgroups                         116
+#define __NR_setresuid                         117
+#define __NR_getresuid                         118
+#define __NR_setresgid                         119
+
+#define __NR_getresgid                         120
+#define __NR_getpgid                           121
+#define __NR_setfsuid                          122
+#define __NR_setfsgid                          123
+#define __NR_getsid                            124
+#define __NR_capget                            125
+#define __NR_capset                            126
+
+#define __NR_rt_sigpending                     127
+#define __NR_rt_sigtimedwait                   128
+#define __NR_rt_sigqueueinfo                   129
+#define __NR_rt_sigsuspend                     130
+#define __NR_sigaltstack                       131
+#define __NR_utime                             132
+#define __NR_mknod                             133
+
+#define __NR_uselib                            134
+#define __NR_personality                       135
+
+#define __NR_ustat                             136
+#define __NR_statfs                            137
+#define __NR_fstatfs                           138
+#define __NR_sysfs                             139
+
+#define __NR_getpriority                       140
+#define __NR_setpriority                       141
+#define __NR_sched_setparam                    142
+#define __NR_sched_getparam                    143
+#define __NR_sched_setscheduler                144
+#define __NR_sched_getscheduler                145
+#define __NR_sched_get_priority_max            146
+#define __NR_sched_get_priority_min            147
+#define __NR_sched_rr_get_interval             148
+
+#define __NR_mlock                             149
+#define __NR_munlock                           150
+#define __NR_mlockall                          151
+#define __NR_munlockall                        152
+
+#define __NR_vhangup                           153
+
+#define __NR_modify_ldt                        154
+
+#define __NR_pivot_root                        155
+
+#define __NR__sysctl                           156
+
+#define __NR_prctl                             157
+#define __NR_arch_prctl                        158
+
+#define __NR_adjtimex                          159
+
+#define __NR_setrlimit                         160
+
+#define __NR_chroot                            161
+
+#define __NR_sync                              162
+
+#define __NR_acct                              163
+
+#define __NR_settimeofday                      164
+
+#define __NR_mount                             165
+#define __NR_umount2                           166
+
+#define __NR_swapon                            167
+#define __NR_swapoff                           168
+
+#define __NR_reboot                            169
+
+#define __NR_sethostname                       170
+#define __NR_setdomainname                     171
+
+#define __NR_iopl                              172
+#define __NR_ioperm                            173
+
+#define __NR_create_module                     174
+#define __NR_init_module                       175
+#define __NR_delete_module                     176
+#define __NR_get_kernel_syms                   177
+#define __NR_query_module                      178
+
+#define __NR_quotactl                          179
+
+#define __NR_nfsservctl                        180
+
+#define __NR_getpmsg                           181	/* reserved for LiS/STREAMS */
+#define __NR_putpmsg                           182	/* reserved for LiS/STREAMS */
+
+#define __NR_afs_syscall                       183	/* reserved for AFS */ 
+
+#define __NR_tuxcall      		184 /* reserved for tux */
+
+#define __NR_security			185
+
+#define __NR_gettid		186
+
+#define __NR_readahead		187
+#define __NR_setxattr		188
+#define __NR_lsetxattr		189
+#define __NR_fsetxattr		190
+#define __NR_getxattr		191
+#define __NR_lgetxattr		192
+#define __NR_fgetxattr		193
+#define __NR_listxattr		194
+#define __NR_llistxattr		195
+#define __NR_flistxattr		196
+#define __NR_removexattr	197
+#define __NR_lremovexattr	198
+#define __NR_fremovexattr	199
+#define __NR_tkill	200
+#define __NR_time      201
+#define __NR_futex     202
+#define __NR_sched_setaffinity    203
+#define __NR_sched_getaffinity     204
+#define __NR_set_thread_area	205
+#define __NR_io_setup	206
+#define __NR_io_destroy	207
+#define __NR_io_getevents	208
+#define __NR_io_submit	209
+#define __NR_io_cancel	210
+#define __NR_get_thread_area	211
+#define __NR_lookup_dcookie	212
+#define __NR_epoll_create	213
+#define __NR_epoll_ctl_old	214
+#define __NR_epoll_wait_old	215
+#define __NR_remap_file_pages	216
+#define __NR_getdents64	217
+#define __NR_set_tid_address	218
+#define __NR_restart_syscall	219
+#define __NR_semtimedop		220
+#define __NR_fadvise64		221
+#define __NR_timer_create		222
+#define __NR_timer_settime		223
+#define __NR_timer_gettime		224
+#define __NR_timer_getoverrun		225
+#define __NR_timer_delete	226
+#define __NR_clock_settime	227
+#define __NR_clock_gettime	228
+#define __NR_clock_getres	229
+#define __NR_clock_nanosleep	230
+#define __NR_exit_group		231
+#define __NR_epoll_wait		232
+#define __NR_epoll_ctl		233
+#define __NR_tgkill		234
+#define __NR_utimes		235
+#define __NR_vserver		236
+#define __NR_vserver		236
+#define __NR_mbind 		237
+#define __NR_set_mempolicy 	238
+#define __NR_get_mempolicy 	239
+#define __NR_mq_open 		240
+#define __NR_mq_unlink 		241
+#define __NR_mq_timedsend 	242
+#define __NR_mq_timedreceive	243
+#define __NR_mq_notify 		244
+#define __NR_mq_getsetattr 	245
+#define __NR_kexec_load 	246
+#define __NR_waitid		247
+#define __NR_add_key		248
+#define __NR_request_key	249
+#define __NR_keyctl		250
+#define __NR_ioprio_set		251
+#define __NR_ioprio_get		252
+#define __NR_inotify_init	253
+#define __NR_inotify_add_watch	254
+#define __NR_inotify_rm_watch	255
+#define __NR_migrate_pages	256
+#define __NR_openat		257
+#define __NR_mkdirat		258
+#define __NR_mknodat		259
+#define __NR_fchownat		260
+#define __NR_futimesat		261
+#define __NR_newfstatat		262
+#define __NR_unlinkat		263
+#define __NR_renameat		264
+#define __NR_linkat		265
+#define __NR_symlinkat		266
+#define __NR_readlinkat		267
+#define __NR_fchmodat		268
+#define __NR_faccessat		269
+#define __NR_pselect6		270
+#define __NR_ppoll		271
+#define __NR_unshare		272
+#define __NR_set_robust_list	273
+#define __NR_get_robust_list	274
+#define __NR_splice		275
+#define __NR_tee		276
+#define __NR_sync_file_range	277
+#define __NR_vmsplice		278
+#define __NR_move_pages		279
+#define __NR_utimensat		280
+#define __NR_epoll_pwait	281
+#define __NR_signalfd		282
+#define __NR_timerfd_create	283
+#define __NR_eventfd		284
+#define __NR_fallocate		285
+#define __NR_timerfd_settime	286
+#define __NR_timerfd_gettime	287
+#define __NR_accept4            288
+#define __NR_signalfd4          289
+#define __NR_eventfd2           290
+#define __NR_epoll_create1      291
+#define __NR_dup3               292
+#define __NR_pipe2              293
+#define __NR_inotify_init1      294
+#define __NR_preadv             295
+#define __NR_pwritev            296
+#define __NR_rt_tgsigqueueinfo  297
+#define __NR_perf_counter_open  298
+
+#endif /* __VKI_SCNUMS_AMD64_LINUX_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-arm-linux.h b/include/vki/vki-scnums-arm-linux.h
new file mode 100644
index 0000000..6300897
--- /dev/null
+++ b/include/vki/vki-scnums-arm-linux.h
@@ -0,0 +1,415 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for arm-linux.                           ---*/
+/*---                                       vki-scnums-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2008-2010 Evan Geller
+      gaze@bea.ms
+
+   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 __VKI_SCNUMS_ARM_LINUX_H
+#define __VKI_SCNUMS_ARM_LINUX_H
+
+// From linux-2.6.26.2/include/asm-arm/unistd.h
+
+#define __NR_restart_syscall		  0
+#define __NR_exit			  1
+#define __NR_fork			  2
+#define __NR_read			  3
+#define __NR_write			  4
+#define __NR_open			  5
+#define __NR_close			  6
+					/* 7 was sys_waitpid */
+#define __NR_creat			  8
+#define __NR_link			  9
+#define __NR_unlink			 10
+#define __NR_execve			 11
+#define __NR_chdir			 12
+#define __NR_time			 13
+#define __NR_mknod			 14
+#define __NR_chmod			 15
+#define __NR_lchown			 16
+					/* 17 was sys_break */
+					/* 18 was sys_stat */
+#define __NR_lseek			 19
+#define __NR_getpid			 20
+#define __NR_mount			 21
+#define __NR_umount			 22
+#define __NR_setuid			 23
+#define __NR_getuid			 24
+#define __NR_stime			 25
+#define __NR_ptrace			 26
+#define __NR_alarm			 27
+					/* 28 was sys_fstat */
+#define __NR_pause			 29
+#define __NR_utime			 30
+					/* 31 was sys_stty */
+					/* 32 was sys_gtty */
+#define __NR_access			 33
+#define __NR_nice			 34
+					/* 35 was sys_ftime */
+#define __NR_sync			 36
+#define __NR_kill			 37
+#define __NR_rename			 38
+#define __NR_mkdir			 39
+#define __NR_rmdir			 40
+#define __NR_dup			 41
+#define __NR_pipe			 42
+#define __NR_times			 43
+					/* 44 was sys_prof */
+#define __NR_brk			 45
+#define __NR_setgid			 46
+#define __NR_getgid			 47
+					/* 48 was sys_signal */
+#define __NR_geteuid			 49
+#define __NR_getegid			 50
+#define __NR_acct			 51
+#define __NR_umount2			 52
+					/* 53 was sys_lock */
+#define __NR_ioctl			 54
+#define __NR_fcntl			 55
+					/* 56 was sys_mpx */
+#define __NR_setpgid			 57
+					/* 58 was sys_ulimit */
+					/* 59 was sys_olduname */
+#define __NR_umask			 60
+#define __NR_chroot			 61
+#define __NR_ustat			 62
+#define __NR_dup2			 63
+#define __NR_getppid			 64
+#define __NR_getpgrp			 65
+#define __NR_setsid			 66
+#define __NR_sigaction			 67
+					/* 68 was sys_sgetmask */
+					/* 69 was sys_ssetmask */
+#define __NR_setreuid			 70
+#define __NR_setregid			 71
+#define __NR_sigsuspend			 72
+#define __NR_sigpending			 73
+#define __NR_sethostname		 74
+#define __NR_setrlimit			 75
+#define __NR_getrlimit			 76	/* Back compat 2GB limited rlimit */
+#define __NR_getrusage			 77
+#define __NR_gettimeofday		 78
+#define __NR_settimeofday		 79
+#define __NR_getgroups			 80
+#define __NR_setgroups			 81
+#define __NR_select			 82
+#define __NR_symlink			 83
+					/* 84 was sys_lstat */
+#define __NR_readlink			 85
+#define __NR_uselib			 86
+#define __NR_swapon			 87
+#define __NR_reboot			 88
+#define __NR_readdir			 89
+#define __NR_mmap			 90
+#define __NR_munmap			 91
+#define __NR_truncate			 92
+#define __NR_ftruncate			 93
+#define __NR_fchmod			 94
+#define __NR_fchown			 95
+#define __NR_getpriority		 96
+#define __NR_setpriority		 97
+					/* 98 was sys_profil */
+#define __NR_statfs			 99
+#define __NR_fstatfs			100
+					/* 101 was sys_ioperm */
+#define __NR_socketcall			102
+#define __NR_syslog			103
+#define __NR_setitimer			104
+#define __NR_getitimer			105
+#define __NR_stat			106
+#define __NR_lstat			107
+#define __NR_fstat			108
+					/* 109 was sys_uname */
+					/* 110 was sys_iopl */
+#define __NR_vhangup			111
+					/* 112 was sys_idle */
+#define __NR_syscall			113 /* syscall to call a syscall! */
+#define __NR_wait4			114
+#define __NR_swapoff			115
+#define __NR_sysinfo			116
+#define __NR_ipc			117
+#define __NR_fsync			118
+#define __NR_sigreturn			119
+#define __NR_clone			120
+#define __NR_setdomainname		121
+#define __NR_uname			122
+					/* 123 was sys_modify_ldt */
+#define __NR_adjtimex			124
+#define __NR_mprotect			125
+#define __NR_sigprocmask		126
+					/* 127 was sys_create_module */
+#define __NR_init_module		128
+#define __NR_delete_module		129
+					/* 130 was sys_get_kernel_syms */
+#define __NR_quotactl			131
+#define __NR_getpgid			132
+#define __NR_fchdir			133
+#define __NR_bdflush			134
+#define __NR_sysfs			135
+#define __NR_personality		136
+					/* 137 was sys_afs_syscall */
+#define __NR_setfsuid			138
+#define __NR_setfsgid			139
+#define __NR__llseek			140
+#define __NR_getdents			141
+#define __NR__newselect			142
+#define __NR_flock			143
+#define __NR_msync			144
+#define __NR_readv			145
+#define __NR_writev			146
+#define __NR_getsid			147
+#define __NR_fdatasync			148
+#define __NR__sysctl			149
+#define __NR_mlock			150
+#define __NR_munlock			151
+#define __NR_mlockall			152
+#define __NR_munlockall			153
+#define __NR_sched_setparam		154
+#define __NR_sched_getparam		155
+#define __NR_sched_setscheduler		156
+#define __NR_sched_getscheduler		157
+#define __NR_sched_yield		158
+#define __NR_sched_get_priority_max	159
+#define __NR_sched_get_priority_min	160
+#define __NR_sched_rr_get_interval	161
+#define __NR_nanosleep			162
+#define __NR_mremap			163
+#define __NR_setresuid			164
+#define __NR_getresuid			165
+					/* 166 was sys_vm86 */
+					/* 167 was sys_query_module */
+#define __NR_poll			168
+#define __NR_nfsservctl			169
+#define __NR_setresgid			170
+#define __NR_getresgid			171
+#define __NR_prctl			172
+#define __NR_rt_sigreturn		173
+#define __NR_rt_sigaction		174
+#define __NR_rt_sigprocmask		175
+#define __NR_rt_sigpending		176
+#define __NR_rt_sigtimedwait		177
+#define __NR_rt_sigqueueinfo		178
+#define __NR_rt_sigsuspend		179
+#define __NR_pread64			180
+#define __NR_pwrite64			181
+#define __NR_chown			182
+#define __NR_getcwd			183
+#define __NR_capget			184
+#define __NR_capset			185
+#define __NR_sigaltstack		186
+#define __NR_sendfile			187
+					/* 188 reserved */
+					/* 189 reserved */
+#define __NR_vfork			190
+#define __NR_ugetrlimit			191	/* SuS compliant getrlimit */
+#define __NR_mmap2			192
+#define __NR_truncate64			193
+#define __NR_ftruncate64		194
+#define __NR_stat64			195
+#define __NR_lstat64			196
+#define __NR_fstat64			197
+#define __NR_lchown32			198
+#define __NR_getuid32			199
+#define __NR_getgid32			200
+#define __NR_geteuid32			201
+#define __NR_getegid32			202
+#define __NR_setreuid32			203
+#define __NR_setregid32			204
+#define __NR_getgroups32		205
+#define __NR_setgroups32		206
+#define __NR_fchown32			207
+#define __NR_setresuid32		208
+#define __NR_getresuid32		209
+#define __NR_setresgid32		210
+#define __NR_getresgid32		211
+#define __NR_chown32			212
+#define __NR_setuid32			213
+#define __NR_setgid32			214
+#define __NR_setfsuid32			215
+#define __NR_setfsgid32			216
+#define __NR_getdents64			217
+#define __NR_pivot_root			218
+#define __NR_mincore			219
+#define __NR_madvise			220
+#define __NR_fcntl64			221
+					/* 222 for tux */
+					/* 223 is unused */
+#define __NR_gettid			224
+#define __NR_readahead			225
+#define __NR_setxattr			226
+#define __NR_lsetxattr			227
+#define __NR_fsetxattr			228
+#define __NR_getxattr			229
+#define __NR_lgetxattr			230
+#define __NR_fgetxattr			231
+#define __NR_listxattr			232
+#define __NR_llistxattr			233
+#define __NR_flistxattr			234
+#define __NR_removexattr		235
+#define __NR_lremovexattr		236
+#define __NR_fremovexattr		237
+#define __NR_tkill			238
+#define __NR_sendfile64			239
+#define __NR_futex			240
+#define __NR_sched_setaffinity		241
+#define __NR_sched_getaffinity		242
+#define __NR_io_setup			243
+#define __NR_io_destroy			244
+#define __NR_io_getevents		245
+#define __NR_io_submit			246
+#define __NR_io_cancel			247
+#define __NR_exit_group			248
+#define __NR_lookup_dcookie		249
+#define __NR_epoll_create		250
+#define __NR_epoll_ctl			251
+#define __NR_epoll_wait			252
+#define __NR_remap_file_pages		253
+					/* 254 for set_thread_area */
+					/* 255 for get_thread_area */
+#define __NR_set_tid_address		256
+#define __NR_timer_create		257
+#define __NR_timer_settime		258
+#define __NR_timer_gettime		259
+#define __NR_timer_getoverrun		260
+#define __NR_timer_delete		261
+#define __NR_clock_settime		262
+#define __NR_clock_gettime		263
+#define __NR_clock_getres		264
+#define __NR_clock_nanosleep		265
+#define __NR_statfs64			266
+#define __NR_fstatfs64			267
+#define __NR_tgkill			268
+#define __NR_utimes			269
+#define __NR_arm_fadvise64_64		270
+#define __NR_fadvise64          270 //Added by Johan, 2008-10-11, not sure why it's called _arm_.. otherwise.
+#define __NR_pciconfig_iobase		271
+#define __NR_pciconfig_read		272
+#define __NR_pciconfig_write		273
+#define __NR_mq_open			274
+#define __NR_mq_unlink			275
+#define __NR_mq_timedsend		276
+#define __NR_mq_timedreceive		277
+#define __NR_mq_notify			278
+#define __NR_mq_getsetattr		279
+#define __NR_waitid			280
+#define __NR_socket			281
+#define __NR_bind			282
+#define __NR_connect			283
+#define __NR_listen			284
+#define __NR_accept			285
+#define __NR_getsockname		286
+#define __NR_getpeername		287
+#define __NR_socketpair			288
+#define __NR_send			289
+#define __NR_sendto			290
+#define __NR_recv			291
+#define __NR_recvfrom			292
+#define __NR_shutdown			293
+#define __NR_setsockopt			294
+#define __NR_getsockopt			295
+#define __NR_sendmsg			296
+#define __NR_recvmsg			297
+#define __NR_semop			298
+#define __NR_semget			299
+#define __NR_semctl			300
+#define __NR_msgsnd			301
+#define __NR_msgrcv			302
+#define __NR_msgget			303
+#define __NR_msgctl			304
+#define __NR_shmat			305
+#define __NR_shmdt			306
+#define __NR_shmget			307
+#define __NR_shmctl			308
+#define __NR_add_key			309
+#define __NR_request_key		310
+#define __NR_keyctl			311
+#define __NR_semtimedop			312
+#define __NR_vserver			313
+#define __NR_ioprio_set			314
+#define __NR_ioprio_get			315
+#define __NR_inotify_init		316
+#define __NR_inotify_add_watch		317
+#define __NR_inotify_rm_watch		318
+#define __NR_mbind			319
+#define __NR_get_mempolicy		320
+#define __NR_set_mempolicy		321
+#define __NR_openat			322
+#define __NR_mkdirat			323
+#define __NR_mknodat			324
+#define __NR_fchownat			325
+#define __NR_futimesat			326
+#define __NR_fstatat64			327
+#define __NR_unlinkat			328
+#define __NR_renameat			329
+#define __NR_linkat			330
+#define __NR_symlinkat			331
+#define __NR_readlinkat			332
+#define __NR_fchmodat			333
+#define __NR_faccessat			334
+#define __NR_pselect6			335 /* JRS 20100812: is this correct? */
+#define __NR_ppoll	       		336
+#define __NR_unshare			337
+#define __NR_set_robust_list		338
+#define __NR_get_robust_list		339
+#define __NR_splice			340
+#define __NR_arm_sync_file_range	341
+#define __NR_sync_file_range2		__NR_arm_sync_file_range
+#define __NR_tee			342
+#define __NR_vmsplice			343
+#define __NR_move_pages			344
+#define __NR_getcpu			345
+					/* 346 for epoll_pwait */
+#define __NR_kexec_load			347
+#define __NR_utimensat			348
+#define __NR_signalfd			349
+#define __NR_timerfd_create		350
+#define __NR_eventfd			351
+#define __NR_fallocate			352
+#define __NR_timerfd_settime		353
+#define __NR_timerfd_gettime		354
+#define __NR_signalfd4                  355
+#define __NR_eventfd2                   356
+#define __NR_epoll_create1              357
+#define __NR_dup3                       358
+#define __NR_pipe2                      359
+#define __NR_inotify_init1              360
+
+
+
+#define __NR_ARM_BASE                   (0x0f0000)
+#define __NR_ARM_breakpoint             (__NR_ARM_BASE+1)
+#define __NR_ARM_cacheflush             (__NR_ARM_BASE+2)
+#define __NR_ARM_usr26                  (__NR_ARM_BASE+3)
+#define __NR_ARM_usr32                  (__NR_ARM_BASE+4)
+#define __NR_ARM_set_tls                (__NR_ARM_BASE+5)
+
+
+#endif /* __VKI_SCNUMS_ARM_LINUX_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                   vki-scnums-arm-linux.h ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h
new file mode 100644
index 0000000..f39f28e
--- /dev/null
+++ b/include/vki/vki-scnums-darwin.h
@@ -0,0 +1,669 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for Darwin.          vki-scnums-darwin.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2007-2010 Apple Inc.
+      Greg Parker  gparker@apple.com
+
+   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 __VKI_SCNUMS_DARWIN_H
+#define __VKI_SCNUMS_DARWIN_H
+
+
+// need DARWIN_10_x definitions
+#include "config.h"
+
+// osfmk/mach/i386/syscall_sw.h
+
+// There are two syscall number encodings in Darwin.
+//
+// The 64-bit encoding is that the top 8-bits are the syscall class.  The low
+// 24 are the syscall number (index) within that class.
+//
+// The 32-bit encoding is that the syscall number (index) is stored as-is and
+// the syscall class is encoded as the argument to the 'int' instruction used
+// to trigger the syscall:
+// - 0x80: Unix
+// - 0x81: Mach
+// - 0x82: Machine-dependent
+// - 0x83: Diagnostic
+// Furthermore, just to make life interesting, for Mach traps the number is
+// negative.
+//
+// Within Valgrind we only use the 64-bit encoding -- on 32-bit systems, we
+// convert any syscall number to 64-bit encoding when we receive it, and
+// convert back with VG_DARWIN_SYSNO_FOR_KERNEL when passing any syscall
+// number back to the kernel (__NR_something shouldn't be passed directly to
+// the kernel).
+//
+// Hack: x86 `int $0x80` (unix, 64-bit result) are special.
+// [I haven't worked out why... --njn]
+
+#define VG_DARWIN_SYSCALL_CLASS_SHIFT     24
+#define VG_DARWIN_SYSCALL_CLASS_MASK      (0xFF << VG_DARWIN_SYSCALL_CLASS_SHIFT)
+#define VG_DARWIN_SYSCALL_NUMBER_MASK     (~VG_DARWIN_SYSCALL_CLASS_MASK)
+
+#define VG_DARWIN_SYSCALL_CLASS_NONE      0       /* Invalid */
+#define VG_DARWIN_SYSCALL_CLASS_MACH      1       /* Mach */      
+#define VG_DARWIN_SYSCALL_CLASS_UNIX      2       /* Unix/BSD */
+#define VG_DARWIN_SYSCALL_CLASS_MDEP      3       /* Machine-dependent */
+#define VG_DARWIN_SYSCALL_CLASS_DIAG      4       /* Diagnostics */
+
+// Macros for encoding syscall numbers in the 64-bit encoding scheme.
+#define VG_DARWIN_SYSCALL_CONSTRUCT_MACH(syscall_number) \
+    ((VG_DARWIN_SYSCALL_CLASS_MACH << VG_DARWIN_SYSCALL_CLASS_SHIFT) | \
+     (VG_DARWIN_SYSCALL_NUMBER_MASK & (syscall_number)))
+
+#define VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(syscall_number) \
+    ((VG_DARWIN_SYSCALL_CLASS_UNIX << VG_DARWIN_SYSCALL_CLASS_SHIFT) | \
+     (VG_DARWIN_SYSCALL_NUMBER_MASK & (syscall_number)))
+
+#define VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(syscall_number) \
+    ((VG_DARWIN_SYSCALL_CLASS_MDEP << VG_DARWIN_SYSCALL_CLASS_SHIFT) | \
+     (VG_DARWIN_SYSCALL_NUMBER_MASK & (syscall_number)))
+
+#define VG_DARWIN_SYSCALL_CONSTRUCT_DIAG(syscall_number) \
+    ((VG_DARWIN_SYSCALL_CLASS_DIAG << VG_DARWIN_SYSCALL_CLASS_SHIFT) | \
+     (VG_DARWIN_SYSCALL_NUMBER_MASK & (syscall_number)))
+
+
+/* Macros for decoding syscall numbers from the 64-bit encoding scheme. */
+#define VG_DARWIN_SYSNO_INDEX(sysno) ((sysno) & VG_DARWIN_SYSCALL_NUMBER_MASK)
+#define VG_DARWIN_SYSNO_CLASS(sysno) ((sysno) >> VG_DARWIN_SYSCALL_CLASS_SHIFT)
+
+
+/* Macros for converting syscall numbers to the form expected by the kernel.*/
+#if defined(VGA_x86)
+   // This converts the 64-bit syscall number encoding, which we use
+   // throughout Valgrind, into the 32-bit syscall number encoding, which is
+   // suitable for passing to the (32-bit) kernel.
+#  define VG_DARWIN_SYSNO_FOR_KERNEL(sysno) \
+    ((VG_DARWIN_SYSNO_CLASS(sysno) == VG_DARWIN_SYSCALL_CLASS_MACH) \
+    ? -VG_DARWIN_SYSNO_INDEX(sysno) \
+    :  VG_DARWIN_SYSNO_INDEX(sysno) \
+    )
+
+#elif defined(VGA_amd64)
+   // For 64-bit systems, we don't need to do anything to the syscall number.
+#  define VG_DARWIN_SYSNO_FOR_KERNEL(sysno) (sysno)
+
+#else
+#  error Unknown architecture
+#endif
+
+
+// mdep syscalls
+
+#if defined(VGA_x86)
+
+// osfmk/i386/machdep_call.c
+// DDD: the last two are BSD_CALL instead of CALL...
+//#define __NR_thread_get_cthread_self      VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(0)
+//#define __NR_thread_set_cthread_self      VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(1)
+// 2 is invalid
+#define __NR_thread_fast_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3)
+//#define __NR_thread_set_user_ldt          VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(4)
+//#define __NR_i386_set_ldt                 VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(5)
+//#define __NR_i386_get_ldt                 VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(6)
+
+#elif defined(VGA_amd64)
+
+// osfmk/i386/machdep_call.c
+// 0, 1, 2 are invalid
+#define __NR_thread_fast_set_cthread_self VG_DARWIN_SYSCALL_CONSTRUCT_MDEP(3)
+// 4, 5, 6 are invalid
+
+#else
+#  error unknown architecture
+#endif
+
+
+// osfmk/mach/syscall_sw.h
+
+#define __NR_mach_reply_port                  VG_DARWIN_SYSCALL_CONSTRUCT_MACH(26)
+#define __NR_thread_self_trap                 VG_DARWIN_SYSCALL_CONSTRUCT_MACH(27)
+#define __NR_task_self_trap                   VG_DARWIN_SYSCALL_CONSTRUCT_MACH(28)
+#define __NR_host_self_trap                   VG_DARWIN_SYSCALL_CONSTRUCT_MACH(29)
+
+#define __NR_mach_msg_trap                    VG_DARWIN_SYSCALL_CONSTRUCT_MACH(31)
+#define __NR_mach_msg_overwrite_trap          VG_DARWIN_SYSCALL_CONSTRUCT_MACH(32)
+#define __NR_semaphore_signal_trap            VG_DARWIN_SYSCALL_CONSTRUCT_MACH(33)
+#define __NR_semaphore_signal_all_trap        VG_DARWIN_SYSCALL_CONSTRUCT_MACH(34)
+#define __NR_semaphore_signal_thread_trap     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(35)
+#define __NR_semaphore_wait_trap              VG_DARWIN_SYSCALL_CONSTRUCT_MACH(36)
+#define __NR_semaphore_wait_signal_trap       VG_DARWIN_SYSCALL_CONSTRUCT_MACH(37)
+#define __NR_semaphore_timedwait_trap         VG_DARWIN_SYSCALL_CONSTRUCT_MACH(38)
+#define __NR_semaphore_timedwait_signal_trap  VG_DARWIN_SYSCALL_CONSTRUCT_MACH(39)
+
+#if defined(VGA_x86)
+#define __NR_init_process                     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(41)
+#define __NR_map_fd                           VG_DARWIN_SYSCALL_CONSTRUCT_MACH(43)
+#endif
+
+#define __NR_task_name_for_pid                VG_DARWIN_SYSCALL_CONSTRUCT_MACH(44)
+#define __NR_task_for_pid                     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(45)
+#define __NR_pid_for_task                     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(46)
+
+#if defined(VGA_x86)
+#define __NR_macx_swapon                      VG_DARWIN_SYSCALL_CONSTRUCT_MACH(48)
+#define __NR_macx_swapoff                     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(49)
+#define __NR_macx_triggers                    VG_DARWIN_SYSCALL_CONSTRUCT_MACH(51)
+#define __NR_macx_backing_store_suspend       VG_DARWIN_SYSCALL_CONSTRUCT_MACH(52)
+#define __NR_macx_backing_store_recovery      VG_DARWIN_SYSCALL_CONSTRUCT_MACH(53)
+#endif
+
+#define __NR_swtch_pri                        VG_DARWIN_SYSCALL_CONSTRUCT_MACH(59)
+#define __NR_swtch                            VG_DARWIN_SYSCALL_CONSTRUCT_MACH(60)
+#define __NR_sched_yield  __NR_swtch  /* linux-alike name */
+#define __NR_syscall_thread_switch            VG_DARWIN_SYSCALL_CONSTRUCT_MACH(61)
+#define __NR_clock_sleep_trap                 VG_DARWIN_SYSCALL_CONSTRUCT_MACH(62)
+
+#define __NR_mach_timebase_info               VG_DARWIN_SYSCALL_CONSTRUCT_MACH(89)
+#define __NR_mach_wait_until                  VG_DARWIN_SYSCALL_CONSTRUCT_MACH(90)
+#define __NR_mk_timer_create                  VG_DARWIN_SYSCALL_CONSTRUCT_MACH(91)
+#define __NR_mk_timer_destroy                 VG_DARWIN_SYSCALL_CONSTRUCT_MACH(92)
+#define __NR_mk_timer_arm                     VG_DARWIN_SYSCALL_CONSTRUCT_MACH(93)
+#define __NR_mk_timer_cancel                  VG_DARWIN_SYSCALL_CONSTRUCT_MACH(94)
+
+#define __NR_iokit_user_client_trap           VG_DARWIN_SYSCALL_CONSTRUCT_MACH(100)
+
+
+// bsd/sys/syscall.h
+ 
+#define	__NR_syscall        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(0)
+#define	__NR_exit           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(1)
+#define	__NR_fork           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(2) // was UX64
+#define	__NR_read           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(3)
+#define	__NR_write          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(4)
+#define	__NR_open           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(5)
+#define	__NR_close          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(6)
+#define	__NR_wait4          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(7)
+			/* 8  old creat */
+#define	__NR_link           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(9)
+#define	__NR_unlink         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(10)
+			/* 11  old execv */
+#define	__NR_chdir          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(12)
+#define	__NR_fchdir         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(13)
+#define	__NR_mknod          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(14)
+#define	__NR_chmod          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(15)
+#define	__NR_chown          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(16)
+			/* 17  old break */
+#define	__NR_getfsstat      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(18)
+			/* 19  old lseek */
+#define	__NR_getpid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(20)
+			/* 21  old mount */
+			/* 22  old umount */
+#define	__NR_setuid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(23)
+#define	__NR_getuid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(24)
+#define	__NR_geteuid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(25)
+#define	__NR_ptrace         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(26)
+#define	__NR_recvmsg        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(27)
+#define	__NR_sendmsg        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(28)
+#define	__NR_recvfrom       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(29)
+#define	__NR_accept         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(30)
+#define	__NR_getpeername    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(31)
+#define	__NR_getsockname    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(32)
+#define	__NR_access         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(33)
+#define	__NR_chflags        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(34)
+#define	__NR_fchflags       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(35)
+#define	__NR_sync           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(36)
+#define	__NR_kill           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(37)
+			/* 38  old stat */
+#define	__NR_getppid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(39)
+			/* 40  old lstat */
+#define	__NR_dup            VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(41)
+#define	__NR_pipe           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(42) // was UX64
+#define	__NR_getegid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(43)
+#define	__NR_profil         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(44)
+			/* 45  old ktrace */
+#define	__NR_sigaction      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(46)
+#define	__NR_getgid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(47)
+#define	__NR_sigprocmask    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(48)
+#define	__NR_getlogin       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(49)
+#define	__NR_setlogin       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(50)
+#define	__NR_acct           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(51)
+#define	__NR_sigpending     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(52)
+#define	__NR_sigaltstack    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(53)
+#define	__NR_ioctl          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(54)
+#define	__NR_reboot         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(55)
+#define	__NR_revoke         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(56)
+#define	__NR_symlink        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(57)
+#define	__NR_readlink       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(58)
+#define	__NR_execve         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(59)
+#define	__NR_umask          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(60)
+#define	__NR_chroot         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(61)
+			/* 62  old fstat */
+			/* 63  used internally , reserved */
+			/* 64  old getpagesize */
+#define	__NR_msync          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(65)
+#define	__NR_vfork          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(66)
+			/* 67  old vread */
+			/* 68  old vwrite */
+			/* 69  old sbrk */
+			/* 70  old sstk */
+			/* 71  old mmap */
+			/* 72  old vadvise */
+#define	__NR_munmap         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(73)
+#define	__NR_mprotect       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(74)
+#define	__NR_madvise        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(75)
+			/* 76  old vhangup */
+			/* 77  old vlimit */
+#define	__NR_mincore        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(78)
+#define	__NR_getgroups      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(79)
+#define	__NR_setgroups      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(80)
+#define	__NR_getpgrp        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(81)
+#define	__NR_setpgid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(82)
+#define	__NR_setitimer      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(83)
+			/* 84  old wait */
+#define	__NR_swapon         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(85)
+#define	__NR_getitimer      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(86)
+			/* 87  old gethostname */
+			/* 88  old sethostname */
+#define	__NR_getdtablesize  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(89)
+#define	__NR_dup2           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(90)
+			/* 91  old getdopt */
+#define	__NR_fcntl          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(92)
+#define	__NR_select         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(93)
+			/* 94  old setdopt */
+#define	__NR_fsync          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(95)
+#define	__NR_setpriority    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(96)
+#define	__NR_socket         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(97)
+#define	__NR_connect        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(98)
+			/* 99  old accept */
+#define	__NR_getpriority    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(100)
+			/* 101  old send */
+			/* 102  old recv */
+			/* 103  old sigreturn */
+#define	__NR_bind           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(104)
+#define	__NR_setsockopt     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(105)
+#define	__NR_listen         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(106)
+			/* 107  old vtimes */
+			/* 108  old sigvec */
+			/* 109  old sigblock */
+			/* 110  old sigsetmask */
+#define	__NR_sigsuspend     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(111)
+			/* 112  old sigstack */
+			/* 113  old recvmsg */
+			/* 114  old sendmsg */
+			/* 115  old vtrace */
+#define	__NR_gettimeofday   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(116)
+#define	__NR_getrusage      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(117)
+#define	__NR_getsockopt     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(118)
+			/* 119  old resuba */
+#define	__NR_readv          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(120)
+#define	__NR_writev         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(121)
+#define	__NR_settimeofday   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(122)
+#define	__NR_fchown         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(123)
+#define	__NR_fchmod         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(124)
+			/* 125  old recvfrom */
+#define	__NR_setreuid       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(126)
+#define	__NR_setregid       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(127)
+#define	__NR_rename         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(128)
+			/* 129  old truncate */
+			/* 130  old ftruncate */
+#define	__NR_flock          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(131)
+#define	__NR_mkfifo         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(132)
+#define	__NR_sendto         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(133)
+#define	__NR_shutdown       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(134)
+#define	__NR_socketpair     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(135)
+#define	__NR_mkdir          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(136)
+#define	__NR_rmdir          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(137)
+#define	__NR_utimes         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(138)
+#define	__NR_futimes        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(139)
+#define	__NR_adjtime        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(140)
+			/* 141  old getpeername */
+#define __NR_gethostuuid    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(142)
+			/* 143  old sethostid */
+			/* 144  old getrlimit */
+			/* 145  old setrlimit */
+			/* 146  old killpg */
+#define	__NR_setsid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(147)
+			/* 148  old setquota */
+			/* 149  old qquota */
+			/* 150  old getsockname */
+#define	__NR_getpgid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(151)
+#define	__NR_setprivexec    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(152)
+#define	__NR_pread          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(153)
+#define	__NR_pwrite         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(154)
+#define __NR_nfssvc         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(155)
+			/* 156  old getdirentries */
+#define	__NR_statfs         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(157)
+#define	__NR_fstatfs        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(158)
+#define	__NR_unmount        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(159)
+			/* 160  old async_daemon */
+#define __NR_getfh          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(161)
+			/* 162  old getdomainname */
+			/* 163  old setdomainname */
+			/* 164  */
+#define	__NR_quotactl       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(165)
+			/* 166  old exportfs */
+#define	__NR_mount          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(167)
+			/* 168  old ustat */
+#define __NR_csops          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(169)
+			/* 170  old table */
+			/* 171  old wait3 */
+			/* 172  old rpause */
+#define	__NR_waitid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(173)
+			/* 174  old getdents */
+			/* 175  old gc_control */
+#define	__NR_add_profil     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(176)
+			/* 177  */
+			/* 178  */
+			/* 179  */
+#define	__NR_kdebug_trace   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(180)
+#define	__NR_setgid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(181)
+#define	__NR_setegid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(182)
+#define	__NR_seteuid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(183)
+#define __NR_sigreturn      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(184)
+#define __NR_chud           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(185)
+			/* 186  */
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fdatasync      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(187)
+#else
+			/* 187  */
+#endif
+#define	__NR_stat           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(188)
+#define	__NR_fstat          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(189)
+#define	__NR_lstat          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(190)
+#define	__NR_pathconf       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(191)
+#define	__NR_fpathconf      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(192)
+			/* 193 */
+#define	__NR_getrlimit      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(194)
+#define	__NR_setrlimit      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(195)
+#define	__NR_getdirentries  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(196)
+#define	__NR_mmap           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(197)
+			/* 198  __syscall */
+#define	__NR_lseek          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(199) // was UX64
+#define	__NR_truncate       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(200)
+#define	__NR_ftruncate      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(201)
+#define	__NR___sysctl       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(202)
+#define	__NR_mlock          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(203)
+#define	__NR_munlock        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(204)
+#define	__NR_undelete       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(205)
+#define	__NR_ATsocket       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(206)
+#define	__NR_ATgetmsg       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(207)
+#define	__NR_ATputmsg       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(208)
+#define	__NR_ATPsndreq      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(209)
+#define	__NR_ATPsndrsp      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(210)
+#define	__NR_ATPgetreq      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(211)
+#define	__NR_ATPgetrsp      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(212)
+			/* 213  Reserved for AppleTalk */
+#if DARWIN_VERS >= DARWIN_10_6
+                        /* 214  old kqueue_from_portset_np*/
+                        /* 215  old kqueue_portset_np*/
+#else
+#define __NR_kqueue_from_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(214)
+#define __NR_kqueue_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(215)
+#endif
+#define	__NR_mkcomplex      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(216)
+#define	__NR_statv          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(217)
+#define	__NR_lstatv         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(218)
+#define	__NR_fstatv         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(219)
+#define	__NR_getattrlist    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(220)
+#define	__NR_setattrlist    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(221)
+#define	__NR_getdirentriesattr VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(222)
+#define	__NR_exchangedata   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(223)
+			/* 224  old checkuseraccess */
+#define	__NR_searchfs       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(225)
+#define	__NR_delete         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(226)
+#define	__NR_copyfile       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(227)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fgetattrlist   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(228)
+#define __NR_fsetattrlist   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(229)
+#else
+			/* 228  */
+			/* 229  */
+#endif
+#define	__NR_poll           VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(230)
+#define	__NR_watchevent     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(231)
+#define	__NR_waitevent      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(232)
+#define	__NR_modwatch       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(233)
+#define	__NR_getxattr       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(234)
+#define	__NR_fgetxattr      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(235)
+#define	__NR_setxattr       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(236)
+#define	__NR_fsetxattr      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(237)
+#define	__NR_removexattr    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(238)
+#define	__NR_fremovexattr   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(239)
+#define	__NR_listxattr      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(240)
+#define	__NR_flistxattr     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(241)
+#define	__NR_fsctl          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(242)
+#define	__NR_initgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(243)
+#define __NR_posix_spawn    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(244)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_ffsctl         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(245)
+#else
+			/* 245  */
+#endif
+			/* 246  */
+#define __NR_nfsclnt        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(247)
+#define __NR_fhopen         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(248)
+			/* 249  */
+#define	__NR_minherit       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(250)
+#define	__NR_semsys         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(251)
+#define	__NR_msgsys         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(252)
+#define	__NR_shmsys         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(253)
+#define	__NR_semctl         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(254)
+#define	__NR_semget         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(255)
+#define	__NR_semop          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(256)
+			/* 257  */
+#define	__NR_msgctl         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(258)
+#define	__NR_msgget         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(259)
+#define	__NR_msgsnd         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(260)
+#define	__NR_msgrcv         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(261)
+#define	__NR_shmat          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(262)
+#define	__NR_shmctl         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(263)
+#define	__NR_shmdt          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(264)
+#define	__NR_shmget         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(265)
+#define	__NR_shm_open       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(266)
+#define	__NR_shm_unlink     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(267)
+#define	__NR_sem_open       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(268)
+#define	__NR_sem_close      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(269)
+#define	__NR_sem_unlink     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(270)
+#define	__NR_sem_wait       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(271)
+#define	__NR_sem_trywait    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(272)
+#define	__NR_sem_post       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(273)
+#define	__NR_sem_getvalue   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(274)
+#define	__NR_sem_init       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(275)
+#define	__NR_sem_destroy    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(276)
+#define	__NR_open_extended  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(277)
+#define	__NR_umask_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(278)
+#define	__NR_stat_extended  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(279)
+#define	__NR_lstat_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(280)
+#define	__NR_fstat_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(281)
+#define	__NR_chmod_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(282)
+#define	__NR_fchmod_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(283)
+#define	__NR_access_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(284)
+#define	__NR_settid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(285)
+#define	__NR_gettid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(286)
+#define	__NR_setsgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(287)
+#define	__NR_getsgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(288)
+#define	__NR_setwgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(289)
+#define	__NR_getwgroups     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(290)
+#define	__NR_mkfifo_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(291)
+#define	__NR_mkdir_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(292)
+#define	__NR_identitysvc    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(293)
+#define	__NR_shared_region_check_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(294)
+#define	__NR_shared_region_map_np   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(295)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_vm_pressure_monitor    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(296)
+#else
+			/* 296  old load_shared_file */
+#endif
+			/* 297  old reset_shared_file */
+			/* 298  old new_system_shared_regions */
+			/* 299  old shared_region_map_file_np */
+			/* 300  old shared_region_make_private_np */
+			/* 301 */
+			/* 302 */
+			/* 303 */
+			/* 304 */
+			/* 305 */
+			/* 306 */
+			/* 307 */
+			/* 308 */
+			/* 309 */
+#define	__NR_getsid         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(310)
+#define	__NR_settid_with_pid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(311)
+			/* 312 */
+#define	__NR_aio_fsync      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(313)
+#define	__NR_aio_return     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(314)
+#define	__NR_aio_suspend    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(315)
+#define	__NR_aio_cancel     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(316)
+#define	__NR_aio_error      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(317)
+#define	__NR_aio_read       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(318)
+#define	__NR_aio_write      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(319)
+#define	__NR_lio_listio     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(320)
+			/* 321 */
+#define __NR_iopolicysys    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(322)
+			/* 323  */
+#define	__NR_mlockall       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(324)
+#define	__NR_munlockall     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(325)
+			/* 326  */
+#define	__NR_issetugid      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(327)
+#define	__NR___pthread_kill VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(328)
+#define	__NR___pthread_sigmask VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(329)
+#define	__NR___sigwait        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(330)
+#define	__NR___disable_threadsignal VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(331)
+#define	__NR___pthread_markcancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(332)
+#define	__NR___pthread_canceled VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(333)
+#define	__NR___semwait_signal VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(334)
+			/* 335  old utrace */
+#define __NR_proc_info      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(336)
+#define __NR_sendfile       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(337)
+#define __NR_stat64         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(338)
+#define __NR_fstat64        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(339)
+#define __NR_lstat64        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(340)
+#define __NR_stat64_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(341)
+#define __NR_lstat64_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(342)
+#define __NR_fstat64_extended VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(343)
+#define __NR_getdirentries64 VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(344)
+#define __NR_statfs64       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(345)
+#define __NR_fstatfs64      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(346)
+#define __NR_getfsstat64    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(347)
+#define __NR___pthread_chdir VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(348)
+#define __NR___pthread_fchdir VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(349)
+
+#define	__NR_audit          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(350)
+#define	__NR_auditon        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(351)
+			/* 352  */
+#define	__NR_getauid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(353)
+#define	__NR_setauid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(354)
+#define	__NR_getaudit       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(355)
+#define	__NR_setaudit       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(356)
+#define	__NR_getaudit_addr  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(357)
+#define	__NR_setaudit_addr  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(358)
+#define	__NR_auditctl       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(359)
+#define	__NR_bsdthread_create VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(360)
+#define	__NR_bsdthread_terminate VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(361)
+#define	__NR_kqueue         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(362)
+#define	__NR_kevent         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(363)
+#define	__NR_lchown         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(364)
+#define __NR_stack_snapshot VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(365)
+#define __NR_bsdthread_register VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(366)
+#define __NR_workq_open     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(367)
+#define __NR_workq_ops      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(368)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_kevent64       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(369)
+#else
+			/* 369  */
+#endif
+			/* 370  */
+			/* 371  */
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR___thread_selfid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(372)  // was UX64
+#else
+			/* 372  */
+#endif
+			/* 373  */
+			/* 374  */
+			/* 375  */
+			/* 376  */
+			/* 377  */
+			/* 378  */
+			/* 379  */
+#define __NR___mac_execve   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(380)
+#define __NR___mac_syscall  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(381)
+#define __NR___mac_get_file VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(382)
+#define __NR___mac_set_file VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(383)
+#define __NR___mac_get_link VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(384)
+#define __NR___mac_set_link VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(385)
+#define __NR___mac_get_proc VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(386)
+#define __NR___mac_set_proc VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(387)
+#define __NR___mac_get_fd   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(388)
+#define __NR___mac_set_fd   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(389)
+#define __NR___mac_get_pid  VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(390)
+#define __NR___mac_get_lcid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(391)
+#define __NR___mac_get_lctx VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(392)
+#define __NR___mac_set_lctx VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(393)
+#define __NR_setlcid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(394)
+#define __NR_getlcid        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(395)
+#define __NR_read_nocancel          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(396)
+#define __NR_write_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(397)
+#define __NR_open_nocancel          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(398)
+#define __NR_close_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(399)
+#define __NR_wait4_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(400)
+#define __NR_recvmsg_nocancel       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(401)
+#define __NR_sendmsg_nocancel       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(402)
+#define __NR_recvfrom_nocancel      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(403)
+#define __NR_accept_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(404)
+#define __NR_msync_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(405)
+#define __NR_fcntl_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(406)
+#define __NR_select_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(407)
+#define __NR_fsync_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(408)
+#define __NR_connect_nocancel       VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(409)
+#define __NR_sigsuspend_nocancel    VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(410)
+#define __NR_readv_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(411)
+#define __NR_writev_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(412)
+#define __NR_sendto_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(413)
+#define __NR_pread_nocancel         VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(414)
+#define __NR_pwrite_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(415)
+#define __NR_waitid_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(416)
+#define __NR_poll_nocancel          VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(417)
+#define __NR_msgsnd_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(418)
+#define __NR_msgrcv_nocancel        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(419)
+#define __NR_sem_wait_nocancel      VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(420)
+#define __NR_aio_suspend_nocancel   VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(421)
+#define __NR___sigwait_nocancel     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(422)
+#define __NR___semwait_signal_nocancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(423)
+#define __NR___mac_mount            VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(424)
+#define __NR___mac_get_mount        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(425)
+#define __NR___mac_getfsstat        VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(426)
+#if DARWIN_VERS >= DARWIN_10_6
+#define __NR_fsgetpath              VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(427)
+#define __NR_audit_session_self     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(428)
+#define __NR_audit_session_join     VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(429)
+#endif
+
+#if DARWIN_VERS < DARWIN_10_6
+#define	__NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(427)
+#elif DARWIN_VERSION < DARWIN_10_7
+#define	__NR_MAXSYSCALL             VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(430)
+#else
+#error unknown darwin version
+#endif
+
+#define __NR_DARWIN_FAKE_SIGRETURN (1 + __NR_MAXSYSCALL)
+
+#endif
diff --git a/include/vki/vki-scnums-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h
new file mode 100644
index 0000000..2235653
--- /dev/null
+++ b/include/vki/vki-scnums-ppc32-linux.h
@@ -0,0 +1,373 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for ppc32-linux.                         ---*/
+/*---                                     vki-scnums-ppc32-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_SCNUMS_PPC32_LINUX_H
+#define __VKI_SCNUMS_PPC32_LINUX_H
+
+// From linux-2.6.9/include/asm-ppc/unistd.h
+
+#define __NR_restart_syscall	  0
+#define __NR_exit		  1
+#define __NR_fork		  2
+#define __NR_read		  3
+#define __NR_write		  4
+#define __NR_open		  5
+#define __NR_close		  6
+#define __NR_waitpid		  7
+#define __NR_creat		  8
+#define __NR_link		  9
+#define __NR_unlink		 10
+#define __NR_execve		 11
+#define __NR_chdir		 12
+#define __NR_time		 13
+#define __NR_mknod		 14
+#define __NR_chmod		 15
+#define __NR_lchown		 16
+#define __NR_break		 17
+#define __NR_oldstat		 18
+#define __NR_lseek		 19
+#define __NR_getpid		 20
+#define __NR_mount		 21
+#define __NR_umount		 22
+#define __NR_setuid		 23
+#define __NR_getuid		 24
+#define __NR_stime		 25
+#define __NR_ptrace		 26
+#define __NR_alarm		 27
+#define __NR_oldfstat		 28
+#define __NR_pause		 29
+#define __NR_utime		 30
+#define __NR_stty		 31
+#define __NR_gtty		 32
+#define __NR_access		 33
+#define __NR_nice		 34
+#define __NR_ftime		 35
+#define __NR_sync		 36
+#define __NR_kill		 37
+#define __NR_rename		 38
+#define __NR_mkdir		 39
+#define __NR_rmdir		 40
+#define __NR_dup		 41
+#define __NR_pipe		 42
+#define __NR_times		 43
+#define __NR_prof		 44
+#define __NR_brk		 45
+#define __NR_setgid		 46
+#define __NR_getgid		 47
+#define __NR_signal		 48
+#define __NR_geteuid		 49
+#define __NR_getegid		 50
+#define __NR_acct		 51
+#define __NR_umount2		 52
+#define __NR_lock		 53
+#define __NR_ioctl		 54
+#define __NR_fcntl		 55
+#define __NR_mpx		 56
+#define __NR_setpgid		 57
+#define __NR_ulimit		 58
+#define __NR_oldolduname	 59
+#define __NR_umask		 60
+#define __NR_chroot		 61
+#define __NR_ustat		 62
+#define __NR_dup2		 63
+#define __NR_getppid		 64
+#define __NR_getpgrp		 65
+#define __NR_setsid		 66
+#define __NR_sigaction		 67
+#define __NR_sgetmask		 68
+#define __NR_ssetmask		 69
+#define __NR_setreuid		 70
+#define __NR_setregid		 71
+#define __NR_sigsuspend		 72
+#define __NR_sigpending		 73
+#define __NR_sethostname	 74
+#define __NR_setrlimit		 75
+#define __NR_getrlimit		 76
+#define __NR_getrusage		 77
+#define __NR_gettimeofday	 78
+#define __NR_settimeofday	 79
+#define __NR_getgroups		 80
+#define __NR_setgroups		 81
+#define __NR_select		 82
+#define __NR_symlink		 83
+#define __NR_oldlstat		 84
+#define __NR_readlink		 85
+#define __NR_uselib		 86
+#define __NR_swapon		 87
+#define __NR_reboot		 88
+#define __NR_readdir		 89
+#define __NR_mmap		 90
+#define __NR_munmap		 91
+#define __NR_truncate		 92
+#define __NR_ftruncate		 93
+#define __NR_fchmod		 94
+#define __NR_fchown		 95
+#define __NR_getpriority	 96
+#define __NR_setpriority	 97
+#define __NR_profil		 98
+#define __NR_statfs		 99
+#define __NR_fstatfs		100
+#define __NR_ioperm		101
+#define __NR_socketcall		102
+#define __NR_syslog		103
+#define __NR_setitimer		104
+#define __NR_getitimer		105
+#define __NR_stat		106
+#define __NR_lstat		107
+#define __NR_fstat		108
+#define __NR_olduname		109
+#define __NR_iopl		110
+#define __NR_vhangup		111
+#define __NR_idle		112
+#define __NR_vm86		113
+#define __NR_wait4		114
+#define __NR_swapoff		115
+#define __NR_sysinfo		116
+#define __NR_ipc		117
+#define __NR_fsync		118
+#define __NR_sigreturn		119
+#define __NR_clone		120
+#define __NR_setdomainname	121
+#define __NR_uname		122
+#define __NR_modify_ldt		123
+#define __NR_adjtimex		124
+#define __NR_mprotect		125
+#define __NR_sigprocmask	126
+#define __NR_create_module	127
+#define __NR_init_module	128
+#define __NR_delete_module	129
+#define __NR_get_kernel_syms	130
+#define __NR_quotactl		131
+#define __NR_getpgid		132
+#define __NR_fchdir		133
+#define __NR_bdflush		134
+#define __NR_sysfs		135
+#define __NR_personality	136
+#define __NR_afs_syscall	137 /* Syscall for Andrew File System */
+#define __NR_setfsuid		138
+#define __NR_setfsgid		139
+#define __NR__llseek		140
+#define __NR_getdents		141
+#define __NR__newselect		142
+#define __NR_flock		143
+#define __NR_msync		144
+#define __NR_readv		145
+#define __NR_writev		146
+#define __NR_getsid		147
+#define __NR_fdatasync		148
+#define __NR__sysctl		149
+#define __NR_mlock		150
+#define __NR_munlock		151
+#define __NR_mlockall		152
+#define __NR_munlockall		153
+#define __NR_sched_setparam		154
+#define __NR_sched_getparam		155
+#define __NR_sched_setscheduler		156
+#define __NR_sched_getscheduler		157
+#define __NR_sched_yield		158
+#define __NR_sched_get_priority_max	159
+#define __NR_sched_get_priority_min	160
+#define __NR_sched_rr_get_interval	161
+#define __NR_nanosleep		162
+#define __NR_mremap		163
+#define __NR_setresuid		164
+#define __NR_getresuid		165
+#define __NR_query_module	166
+#define __NR_poll		167
+#define __NR_nfsservctl		168
+#define __NR_setresgid		169
+#define __NR_getresgid		170
+#define __NR_prctl		171
+#define __NR_rt_sigreturn	172
+#define __NR_rt_sigaction	173
+#define __NR_rt_sigprocmask	174
+#define __NR_rt_sigpending	175
+#define __NR_rt_sigtimedwait	176
+#define __NR_rt_sigqueueinfo	177
+#define __NR_rt_sigsuspend	178
+#define __NR_pread64		179
+#define __NR_pwrite64		180
+#define __NR_chown		181
+#define __NR_getcwd		182
+#define __NR_capget		183
+#define __NR_capset		184
+#define __NR_sigaltstack	185
+#define __NR_sendfile		186
+#define __NR_getpmsg		187	/* some people actually want streams */
+#define __NR_putpmsg		188	/* some people actually want streams */
+#define __NR_vfork		189
+#define __NR_ugetrlimit		190	/* SuS compliant getrlimit */
+#define __NR_readahead		191
+#ifndef __powerpc64__			/* these are 32-bit only */
+#define __NR_mmap2		192
+#define __NR_truncate64		193
+#define __NR_ftruncate64	194
+#define __NR_stat64		195
+#define __NR_lstat64		196
+#define __NR_fstat64		197
+#endif
+#define __NR_pciconfig_read	198
+#define __NR_pciconfig_write	199
+#define __NR_pciconfig_iobase	200
+#define __NR_multiplexer	201
+#define __NR_getdents64		202
+#define __NR_pivot_root		203
+#ifndef __powerpc64__
+#define __NR_fcntl64		204
+#endif
+#define __NR_madvise		205
+#define __NR_mincore		206
+#define __NR_gettid		207
+#define __NR_tkill		208
+#define __NR_setxattr		209
+#define __NR_lsetxattr		210
+#define __NR_fsetxattr		211
+#define __NR_getxattr		212
+#define __NR_lgetxattr		213
+#define __NR_fgetxattr		214
+#define __NR_listxattr		215
+#define __NR_llistxattr		216
+#define __NR_flistxattr		217
+#define __NR_removexattr	218
+#define __NR_lremovexattr	219
+#define __NR_fremovexattr	220
+#define __NR_futex		221
+#define __NR_sched_setaffinity	222
+#define __NR_sched_getaffinity	223
+/* 224 currently unused */
+#define __NR_tuxcall		225
+#ifndef __powerpc64__
+#define __NR_sendfile64		226
+#endif
+#define __NR_io_setup		227
+#define __NR_io_destroy		228
+#define __NR_io_getevents	229
+#define __NR_io_submit		230
+#define __NR_io_cancel		231
+#define __NR_set_tid_address	232
+#define __NR_fadvise64		233
+#define __NR_exit_group		234
+#define __NR_lookup_dcookie	235
+#define __NR_epoll_create	236
+#define __NR_epoll_ctl		237
+#define __NR_epoll_wait		238
+#define __NR_remap_file_pages	239
+#define __NR_timer_create	240
+#define __NR_timer_settime	241
+#define __NR_timer_gettime	242
+#define __NR_timer_getoverrun	243
+#define __NR_timer_delete	244
+#define __NR_clock_settime	245
+#define __NR_clock_gettime	246
+#define __NR_clock_getres	247
+#define __NR_clock_nanosleep	248
+#define __NR_swapcontext	249
+#define __NR_tgkill		250
+#define __NR_utimes		251
+#define __NR_statfs64		252
+#define __NR_fstatfs64		253
+#ifndef __powerpc64__
+#define __NR_fadvise64_64	254
+#endif
+#define __NR_rtas		255
+#define __NR_sys_debug_setcontext 256
+/* Number 257 is reserved for vserver */
+/* 258 currently unused */
+#define __NR_mbind		259
+#define __NR_get_mempolicy	260
+#define __NR_set_mempolicy	261
+#define __NR_mq_open		262
+#define __NR_mq_unlink		263
+#define __NR_mq_timedsend	264
+#define __NR_mq_timedreceive	265
+#define __NR_mq_notify		266
+#define __NR_mq_getsetattr	267
+#define __NR_kexec_load		268
+#define __NR_add_key		269
+#define __NR_request_key	270
+#define __NR_keyctl		271
+#define __NR_waitid		272
+#define __NR_ioprio_set		273
+#define __NR_ioprio_get		274
+#define __NR_inotify_init	275
+#define __NR_inotify_add_watch	276
+#define __NR_inotify_rm_watch	277
+#define __NR_spu_run		278
+#define __NR_spu_create		279
+#define __NR_pselect6		280
+#define __NR_ppoll		281
+#define __NR_unshare		282
+#define __NR_splice		283
+#define __NR_tee		284
+#define __NR_vmsplice		285
+#define __NR_openat		286
+#define __NR_mkdirat		287
+#define __NR_mknodat		288
+#define __NR_fchownat		289
+#define __NR_futimesat		290
+#define __NR_fstatat64		291
+#define __NR_unlinkat		292
+#define __NR_renameat		293
+#define __NR_linkat		294
+#define __NR_symlinkat		295
+#define __NR_readlinkat		296
+#define __NR_fchmodat		297
+#define __NR_faccessat		298
+#define __NR_get_robust_list	299
+#define __NR_set_robust_list	300
+#define __NR_move_pages		301
+#define __NR_getcpu		302
+#define __NR_epoll_pwait	303
+#define __NR_utimensat		304
+#define __NR_signalfd		305
+#define __NR_timerfd_create	306
+#define __NR_eventfd		307
+#define __NR_sync_file_range2	308
+#define __NR_fallocate		309
+#define __NR_subpage_prot	310
+#define __NR_timerfd_settime	311
+#define __NR_timerfd_gettime	312
+#define __NR_signalfd4          313
+#define __NR_eventfd2           314
+#define __NR_epoll_create1      315
+#define __NR_dup3               316
+#define __NR_pipe2              317
+#define __NR_inotify_init1      318
+#define __NR_perf_counter_open  319
+#define __NR_preadv             320
+#define __NR_pwritev            321
+#define __NR_rt_tgsigqueueinfo  322
+
+#endif /* __VKI_SCNUMS_PPC32_LINUX_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-ppc64-linux.h b/include/vki/vki-scnums-ppc64-linux.h
new file mode 100644
index 0000000..e019e6f
--- /dev/null
+++ b/include/vki/vki-scnums-ppc64-linux.h
@@ -0,0 +1,365 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for ppc64-linux.                         ---*/
+/*---                                     vki-scnums-ppc64-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2005-2010 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 __VKI_SCNUMS_PPC64_LINUX_H
+#define __VKI_SCNUMS_PPC64_LINUX_H
+
+// From linux-2.6.16-rc4/include/asm-powerpc/unistd.h
+
+#define __NR_restart_syscall      0
+#define __NR_exit                 1
+#define __NR_fork                 2
+#define __NR_read                 3
+#define __NR_write                4
+#define __NR_open                 5
+#define __NR_close                6
+#define __NR_waitpid              7
+#define __NR_creat                8
+#define __NR_link                 9
+#define __NR_unlink              10
+#define __NR_execve              11
+#define __NR_chdir               12
+#define __NR_time                13
+#define __NR_mknod               14
+#define __NR_chmod               15
+#define __NR_lchown              16
+#define __NR_break               17
+#define __NR_oldstat             18
+#define __NR_lseek               19
+#define __NR_getpid              20
+#define __NR_mount               21
+#define __NR_umount              22
+#define __NR_setuid              23
+#define __NR_getuid              24
+#define __NR_stime               25
+#define __NR_ptrace              26
+#define __NR_alarm               27
+#define __NR_oldfstat            28
+#define __NR_pause               29
+#define __NR_utime               30
+#define __NR_stty                31
+#define __NR_gtty                32
+#define __NR_access              33
+#define __NR_nice                34
+#define __NR_ftime               35
+#define __NR_sync                36
+#define __NR_kill                37
+#define __NR_rename              38
+#define __NR_mkdir               39
+#define __NR_rmdir               40
+#define __NR_dup                 41
+#define __NR_pipe                42
+#define __NR_times               43
+#define __NR_prof                44
+#define __NR_brk                 45
+#define __NR_setgid              46
+#define __NR_getgid              47
+#define __NR_signal              48
+#define __NR_geteuid             49
+#define __NR_getegid             50
+#define __NR_acct                51
+#define __NR_umount2             52
+#define __NR_lock                53
+#define __NR_ioctl               54
+#define __NR_fcntl               55
+#define __NR_mpx                 56
+#define __NR_setpgid             57
+#define __NR_ulimit              58
+#define __NR_oldolduname         59
+#define __NR_umask               60
+#define __NR_chroot              61
+#define __NR_ustat               62
+#define __NR_dup2                63
+#define __NR_getppid             64
+#define __NR_getpgrp             65
+#define __NR_setsid              66
+#define __NR_sigaction           67
+#define __NR_sgetmask            68
+#define __NR_ssetmask            69
+#define __NR_setreuid            70
+#define __NR_setregid            71
+#define __NR_sigsuspend          72
+#define __NR_sigpending          73
+#define __NR_sethostname         74
+#define __NR_setrlimit           75
+#define __NR_getrlimit           76
+#define __NR_getrusage           77
+#define __NR_gettimeofday        78
+#define __NR_settimeofday        79
+#define __NR_getgroups           80
+#define __NR_setgroups           81
+#define __NR_select              82
+#define __NR_symlink             83
+#define __NR_oldlstat            84
+#define __NR_readlink            85
+#define __NR_uselib              86
+#define __NR_swapon              87
+#define __NR_reboot              88
+#define __NR_readdir             89
+#define __NR_mmap                90
+#define __NR_munmap              91
+#define __NR_truncate            92
+#define __NR_ftruncate           93
+#define __NR_fchmod              94
+#define __NR_fchown              95
+#define __NR_getpriority         96
+#define __NR_setpriority         97
+#define __NR_profil              98
+#define __NR_statfs              99
+#define __NR_fstatfs            100
+#define __NR_ioperm             101
+#define __NR_socketcall         102
+#define __NR_syslog             103
+#define __NR_setitimer          104
+#define __NR_getitimer          105
+#define __NR_stat               106
+#define __NR_lstat              107
+#define __NR_fstat              108
+#define __NR_olduname           109
+#define __NR_iopl               110
+#define __NR_vhangup            111
+#define __NR_idle               112
+#define __NR_vm86               113
+#define __NR_wait4              114
+#define __NR_swapoff            115
+#define __NR_sysinfo            116
+#define __NR_ipc                117
+#define __NR_fsync              118
+#define __NR_sigreturn          119
+#define __NR_clone              120
+#define __NR_setdomainname      121
+#define __NR_uname              122
+#define __NR_modify_ldt         123
+#define __NR_adjtimex           124
+#define __NR_mprotect           125
+#define __NR_sigprocmask        126
+#define __NR_create_module      127
+#define __NR_init_module        128
+#define __NR_delete_module      129
+#define __NR_get_kernel_syms    130
+#define __NR_quotactl           131
+#define __NR_getpgid            132
+#define __NR_fchdir             133
+#define __NR_bdflush            134
+#define __NR_sysfs              135
+#define __NR_personality        136
+#define __NR_afs_syscall        137 /* Syscall for Andrew File System */
+#define __NR_setfsuid           138
+#define __NR_setfsgid           139
+#define __NR__llseek            140
+#define __NR_getdents           141
+#define __NR__newselect         142
+#define __NR_flock              143
+#define __NR_msync              144
+#define __NR_readv              145
+#define __NR_writev             146
+#define __NR_getsid             147
+#define __NR_fdatasync          148
+#define __NR__sysctl            149
+#define __NR_mlock              150
+#define __NR_munlock            151
+#define __NR_mlockall           152
+#define __NR_munlockall         153
+#define __NR_sched_setparam             154
+#define __NR_sched_getparam             155
+#define __NR_sched_setscheduler         156
+#define __NR_sched_getscheduler         157
+#define __NR_sched_yield                158
+#define __NR_sched_get_priority_max     159
+#define __NR_sched_get_priority_min     160
+#define __NR_sched_rr_get_interval      161
+#define __NR_nanosleep          162
+#define __NR_mremap             163
+#define __NR_setresuid          164
+#define __NR_getresuid          165
+#define __NR_query_module       166
+#define __NR_poll               167
+#define __NR_nfsservctl         168
+#define __NR_setresgid          169
+#define __NR_getresgid          170
+#define __NR_prctl              171
+#define __NR_rt_sigreturn       172
+#define __NR_rt_sigaction       173
+#define __NR_rt_sigprocmask     174
+#define __NR_rt_sigpending      175
+#define __NR_rt_sigtimedwait    176
+#define __NR_rt_sigqueueinfo    177
+#define __NR_rt_sigsuspend      178
+#define __NR_pread64            179
+#define __NR_pwrite64           180
+#define __NR_chown              181
+#define __NR_getcwd             182
+#define __NR_capget             183
+#define __NR_capset             184
+#define __NR_sigaltstack        185
+#define __NR_sendfile           186
+#define __NR_getpmsg            187     /* some people actually want streams */
+#define __NR_putpmsg            188     /* some people actually want streams */
+#define __NR_vfork              189
+#define __NR_ugetrlimit         190     /* SuS compliant getrlimit */
+#define __NR_readahead          191
+/* #define __NR_mmap2           192     32bit only */
+/* #define __NR_truncate64      193     32bit only */
+/* #define __NR_ftruncate64     194     32bit only */
+/* #define __NR_stat64          195     32bit only */
+/* #define __NR_lstat64         196     32bit only */
+/* #define __NR_fstat64         197     32bit only */
+#define __NR_pciconfig_read     198
+#define __NR_pciconfig_write    199
+#define __NR_pciconfig_iobase   200
+#define __NR_multiplexer        201
+#define __NR_getdents64         202
+#define __NR_pivot_root         203
+#define __NR_fcntl64            204     /* ???!!! 32bit only */
+#define __NR_madvise            205
+#define __NR_mincore            206
+#define __NR_gettid             207
+#define __NR_tkill              208
+#define __NR_setxattr           209
+#define __NR_lsetxattr          210
+#define __NR_fsetxattr          211
+#define __NR_getxattr           212
+#define __NR_lgetxattr          213
+#define __NR_fgetxattr          214
+#define __NR_listxattr          215
+#define __NR_llistxattr         216
+#define __NR_flistxattr         217
+#define __NR_removexattr        218
+#define __NR_lremovexattr       219
+#define __NR_fremovexattr       220
+#define __NR_futex              221
+#define __NR_sched_setaffinity  222
+#define __NR_sched_getaffinity  223
+/* 224 currently unused */
+#define __NR_tuxcall            225
+/* #define __NR_sendfile64      226     32bit only */
+#define __NR_io_setup           227
+#define __NR_io_destroy         228
+#define __NR_io_getevents       229
+#define __NR_io_submit          230
+#define __NR_io_cancel          231
+#define __NR_set_tid_address    232
+#define __NR_fadvise64          233
+#define __NR_exit_group         234
+#define __NR_lookup_dcookie     235
+#define __NR_epoll_create       236
+#define __NR_epoll_ctl          237
+#define __NR_epoll_wait         238
+#define __NR_remap_file_pages   239
+#define __NR_timer_create       240
+#define __NR_timer_settime      241
+#define __NR_timer_gettime      242
+#define __NR_timer_getoverrun   243
+#define __NR_timer_delete       244
+#define __NR_clock_settime      245
+#define __NR_clock_gettime      246
+#define __NR_clock_getres       247
+#define __NR_clock_nanosleep    248
+#define __NR_swapcontext        249
+#define __NR_tgkill             250
+#define __NR_utimes             251
+#define __NR_statfs64           252
+#define __NR_fstatfs64          253
+/* #define __NR_fadvise64_64    254     32bit only */
+#define __NR_rtas               255
+/* Number 256 is reserved for sys_debug_setcontext */
+/* Number 257 is reserved for vserver */
+/* 258 currently unused */
+#define __NR_mbind              259
+#define __NR_get_mempolicy      260
+#define __NR_set_mempolicy      261
+#define __NR_mq_open            262
+#define __NR_mq_unlink          263
+#define __NR_mq_timedsend       264
+#define __NR_mq_timedreceive    265
+#define __NR_mq_notify          266
+#define __NR_mq_getsetattr      267
+#define __NR_kexec_load         268
+#define __NR_add_key            269
+#define __NR_request_key        270
+#define __NR_keyctl             271
+#define __NR_waitid             272
+#define __NR_ioprio_set         273
+#define __NR_ioprio_get         274
+#define __NR_inotify_init       275
+#define __NR_inotify_add_watch  276
+#define __NR_inotify_rm_watch   277
+#define __NR_spu_run		278
+#define __NR_spu_create		279
+#define __NR_pselect6		280
+#define __NR_ppoll		281
+#define __NR_unshare		282
+#define __NR_splice		283
+#define __NR_tee		284
+#define __NR_vmsplice		285
+#define __NR_openat		286
+#define __NR_mkdirat		287
+#define __NR_mknodat		288
+#define __NR_fchownat		289
+#define __NR_futimesat		290
+#define __NR_newfstatat		291
+#define __NR_unlinkat		292
+#define __NR_renameat		293
+#define __NR_linkat		294
+#define __NR_symlinkat		295
+#define __NR_readlinkat		296
+#define __NR_fchmodat		297
+#define __NR_faccessat		298
+#define __NR_get_robust_list	299
+#define __NR_set_robust_list	300
+#define __NR_move_pages		301
+#define __NR_getcpu		302
+#define __NR_epoll_pwait	303
+#define __NR_utimensat		304
+#define __NR_signalfd		305
+#define __NR_timerfd_create	306
+#define __NR_eventfd		307
+#define __NR_sync_file_range2	308
+#define __NR_fallocate		309
+#define __NR_subpage_prot	310
+#define __NR_timerfd_settime	311
+#define __NR_timerfd_gettime	312
+#define __NR_signalfd4          313
+#define __NR_eventfd2           314
+#define __NR_epoll_create1      315
+#define __NR_dup3               316
+#define __NR_pipe2              317
+#define __NR_inotify_init1      318
+#define __NR_perf_counter_open  319
+#define __NR_preadv             320
+#define __NR_pwritev            321
+#define __NR_rt_tgsigqueueinfo  322
+
+#endif /* __VKI_SCNUMS_PPC64_LINUX_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-scnums-x86-linux.h b/include/vki/vki-scnums-x86-linux.h
new file mode 100644
index 0000000..f194277
--- /dev/null
+++ b/include/vki/vki-scnums-x86-linux.h
@@ -0,0 +1,379 @@
+
+/*--------------------------------------------------------------------*/
+/*--- System call numbers for x86-linux.                           ---*/
+/*---                                       vki-scnums-x86-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_SCNUMS_X86_LINUX_H
+#define __VKI_SCNUMS_X86_LINUX_H
+
+// From linux-2.6.9/include/asm-i386/unistd.h
+
+#define __NR_restart_syscall      0
+#define __NR_exit		  1
+#define __NR_fork		  2
+#define __NR_read		  3
+#define __NR_write		  4
+#define __NR_open		  5
+#define __NR_close		  6
+#define __NR_waitpid		  7
+#define __NR_creat		  8
+#define __NR_link		  9
+#define __NR_unlink		 10
+#define __NR_execve		 11
+#define __NR_chdir		 12
+#define __NR_time		 13
+#define __NR_mknod		 14
+#define __NR_chmod		 15
+#define __NR_lchown		 16
+#define __NR_break		 17
+#define __NR_oldstat		 18
+#define __NR_lseek		 19
+#define __NR_getpid		 20
+#define __NR_mount		 21
+#define __NR_umount		 22
+#define __NR_setuid		 23
+#define __NR_getuid		 24
+#define __NR_stime		 25
+#define __NR_ptrace		 26
+#define __NR_alarm		 27
+#define __NR_oldfstat		 28
+#define __NR_pause		 29
+#define __NR_utime		 30
+#define __NR_stty		 31
+#define __NR_gtty		 32
+#define __NR_access		 33
+#define __NR_nice		 34
+#define __NR_ftime		 35
+#define __NR_sync		 36
+#define __NR_kill		 37
+#define __NR_rename		 38
+#define __NR_mkdir		 39
+#define __NR_rmdir		 40
+#define __NR_dup		 41
+#define __NR_pipe		 42
+#define __NR_times		 43
+#define __NR_prof		 44
+#define __NR_brk		 45
+#define __NR_setgid		 46
+#define __NR_getgid		 47
+#define __NR_signal		 48
+#define __NR_geteuid		 49
+#define __NR_getegid		 50
+#define __NR_acct		 51
+#define __NR_umount2		 52
+#define __NR_lock		 53
+#define __NR_ioctl		 54
+#define __NR_fcntl		 55
+#define __NR_mpx		 56
+#define __NR_setpgid		 57
+#define __NR_ulimit		 58
+#define __NR_oldolduname	 59
+#define __NR_umask		 60
+#define __NR_chroot		 61
+#define __NR_ustat		 62
+#define __NR_dup2		 63
+#define __NR_getppid		 64
+#define __NR_getpgrp		 65
+#define __NR_setsid		 66
+#define __NR_sigaction		 67
+#define __NR_sgetmask		 68
+#define __NR_ssetmask		 69
+#define __NR_setreuid		 70
+#define __NR_setregid		 71
+#define __NR_sigsuspend		 72
+#define __NR_sigpending		 73
+#define __NR_sethostname	 74
+#define __NR_setrlimit		 75
+#define __NR_getrlimit		 76	/* Back compatible 2Gig limited rlimit */
+#define __NR_getrusage		 77
+#define __NR_gettimeofday	 78
+#define __NR_settimeofday	 79
+#define __NR_getgroups		 80
+#define __NR_setgroups		 81
+#define __NR_select		 82
+#define __NR_symlink		 83
+#define __NR_oldlstat		 84
+#define __NR_readlink		 85
+#define __NR_uselib		 86
+#define __NR_swapon		 87
+#define __NR_reboot		 88
+#define __NR_readdir		 89
+#define __NR_mmap		 90
+#define __NR_munmap		 91
+#define __NR_truncate		 92
+#define __NR_ftruncate		 93
+#define __NR_fchmod		 94
+#define __NR_fchown		 95
+#define __NR_getpriority	 96
+#define __NR_setpriority	 97
+#define __NR_profil		 98
+#define __NR_statfs		 99
+#define __NR_fstatfs		100
+#define __NR_ioperm		101
+#define __NR_socketcall		102
+#define __NR_syslog		103
+#define __NR_setitimer		104
+#define __NR_getitimer		105
+#define __NR_stat		106
+#define __NR_lstat		107
+#define __NR_fstat		108
+#define __NR_olduname		109
+#define __NR_iopl		110
+#define __NR_vhangup		111
+#define __NR_idle		112
+#define __NR_vm86old		113
+#define __NR_wait4		114
+#define __NR_swapoff		115
+#define __NR_sysinfo		116
+#define __NR_ipc		117
+#define __NR_fsync		118
+#define __NR_sigreturn		119
+#define __NR_clone		120
+#define __NR_setdomainname	121
+#define __NR_uname		122
+#define __NR_modify_ldt		123
+#define __NR_adjtimex		124
+#define __NR_mprotect		125
+#define __NR_sigprocmask	126
+#define __NR_create_module	127
+#define __NR_init_module	128
+#define __NR_delete_module	129
+#define __NR_get_kernel_syms	130
+#define __NR_quotactl		131
+#define __NR_getpgid		132
+#define __NR_fchdir		133
+#define __NR_bdflush		134
+#define __NR_sysfs		135
+#define __NR_personality	136
+#define __NR_afs_syscall	137 /* Syscall for Andrew File System */
+#define __NR_setfsuid		138
+#define __NR_setfsgid		139
+#define __NR__llseek		140
+#define __NR_getdents		141
+#define __NR__newselect		142
+#define __NR_flock		143
+#define __NR_msync		144
+#define __NR_readv		145
+#define __NR_writev		146
+#define __NR_getsid		147
+#define __NR_fdatasync		148
+#define __NR__sysctl		149
+#define __NR_mlock		150
+#define __NR_munlock		151
+#define __NR_mlockall		152
+#define __NR_munlockall		153
+#define __NR_sched_setparam		154
+#define __NR_sched_getparam		155
+#define __NR_sched_setscheduler		156
+#define __NR_sched_getscheduler		157
+#define __NR_sched_yield		158
+#define __NR_sched_get_priority_max	159
+#define __NR_sched_get_priority_min	160
+#define __NR_sched_rr_get_interval	161
+#define __NR_nanosleep		162
+#define __NR_mremap		163
+#define __NR_setresuid		164
+#define __NR_getresuid		165
+#define __NR_vm86		166
+#define __NR_query_module	167
+#define __NR_poll		168
+#define __NR_nfsservctl		169
+#define __NR_setresgid		170
+#define __NR_getresgid		171
+#define __NR_prctl              172
+#define __NR_rt_sigreturn	173
+#define __NR_rt_sigaction	174
+#define __NR_rt_sigprocmask	175
+#define __NR_rt_sigpending	176
+#define __NR_rt_sigtimedwait	177
+#define __NR_rt_sigqueueinfo	178
+#define __NR_rt_sigsuspend	179
+#define __NR_pread64		180
+#define __NR_pwrite64		181
+#define __NR_chown		182
+#define __NR_getcwd		183
+#define __NR_capget		184
+#define __NR_capset		185
+#define __NR_sigaltstack	186
+#define __NR_sendfile		187
+#define __NR_getpmsg		188	/* some people actually want streams */
+#define __NR_putpmsg		189	/* some people actually want streams */
+#define __NR_vfork		190
+#define __NR_ugetrlimit		191	/* SuS compliant getrlimit */
+#define __NR_mmap2		192
+#define __NR_truncate64		193
+#define __NR_ftruncate64	194
+#define __NR_stat64		195
+#define __NR_lstat64		196
+#define __NR_fstat64		197
+#define __NR_lchown32		198
+#define __NR_getuid32		199
+#define __NR_getgid32		200
+#define __NR_geteuid32		201
+#define __NR_getegid32		202
+#define __NR_setreuid32		203
+#define __NR_setregid32		204
+#define __NR_getgroups32	205
+#define __NR_setgroups32	206
+#define __NR_fchown32		207
+#define __NR_setresuid32	208
+#define __NR_getresuid32	209
+#define __NR_setresgid32	210
+#define __NR_getresgid32	211
+#define __NR_chown32		212
+#define __NR_setuid32		213
+#define __NR_setgid32		214
+#define __NR_setfsuid32		215
+#define __NR_setfsgid32		216
+#define __NR_pivot_root		217
+#define __NR_mincore		218
+#define __NR_madvise		219
+#define __NR_madvise1		219	/* delete when C lib stub is removed */
+#define __NR_getdents64		220
+#define __NR_fcntl64		221
+/* 223 is unused */
+#define __NR_gettid		224
+#define __NR_readahead		225
+#define __NR_setxattr		226
+#define __NR_lsetxattr		227
+#define __NR_fsetxattr		228
+#define __NR_getxattr		229
+#define __NR_lgetxattr		230
+#define __NR_fgetxattr		231
+#define __NR_listxattr		232
+#define __NR_llistxattr		233
+#define __NR_flistxattr		234
+#define __NR_removexattr	235
+#define __NR_lremovexattr	236
+#define __NR_fremovexattr	237
+#define __NR_tkill		238
+#define __NR_sendfile64		239
+#define __NR_futex		240
+#define __NR_sched_setaffinity	241
+#define __NR_sched_getaffinity	242
+#define __NR_set_thread_area	243
+#define __NR_get_thread_area	244
+#define __NR_io_setup		245
+#define __NR_io_destroy		246
+#define __NR_io_getevents	247
+#define __NR_io_submit		248
+#define __NR_io_cancel		249
+#define __NR_fadvise64		250
+#define __NR_set_zone_reclaim	251
+#define __NR_exit_group		252
+#define __NR_lookup_dcookie	253
+#define __NR_epoll_create	254
+#define __NR_epoll_ctl		255
+#define __NR_epoll_wait		256
+#define __NR_remap_file_pages	257
+#define __NR_set_tid_address	258
+#define __NR_timer_create	259
+#define __NR_timer_settime	(__NR_timer_create+1)
+#define __NR_timer_gettime	(__NR_timer_create+2)
+#define __NR_timer_getoverrun	(__NR_timer_create+3)
+#define __NR_timer_delete	(__NR_timer_create+4)
+#define __NR_clock_settime	(__NR_timer_create+5)
+#define __NR_clock_gettime	(__NR_timer_create+6)
+#define __NR_clock_getres	(__NR_timer_create+7)
+#define __NR_clock_nanosleep	(__NR_timer_create+8)
+#define __NR_statfs64		268
+#define __NR_fstatfs64		269
+#define __NR_tgkill		270
+#define __NR_utimes		271
+#define __NR_fadvise64_64	272
+#define __NR_vserver		273
+#define __NR_mbind		274
+#define __NR_get_mempolicy	275
+#define __NR_set_mempolicy	276
+#define __NR_mq_open 		277
+#define __NR_mq_unlink		(__NR_mq_open+1)
+#define __NR_mq_timedsend	(__NR_mq_open+2)
+#define __NR_mq_timedreceive	(__NR_mq_open+3)
+#define __NR_mq_notify		(__NR_mq_open+4)
+#define __NR_mq_getsetattr	(__NR_mq_open+5)
+#define __NR_sys_kexec_load	283
+#define __NR_waitid		284
+/* #define __NR_sys_setaltroot	285 */
+#define __NR_add_key		286
+#define __NR_request_key	287
+#define __NR_keyctl		288
+#define __NR_ioprio_set		289
+#define __NR_ioprio_get		290
+#define __NR_inotify_init	291
+#define __NR_inotify_add_watch	292
+#define __NR_inotify_rm_watch	293
+#define __NR_migrate_pages	294
+#define __NR_openat		295
+#define __NR_mkdirat		296
+#define __NR_mknodat		297
+#define __NR_fchownat		298
+#define __NR_futimesat		299
+#define __NR_fstatat64		300
+#define __NR_unlinkat		301
+#define __NR_renameat		302
+#define __NR_linkat		303
+#define __NR_symlinkat		304
+#define __NR_readlinkat		305
+#define __NR_fchmodat		306
+#define __NR_faccessat		307
+#define __NR_pselect6		308
+#define __NR_ppoll		309
+#define __NR_unshare		310
+#define __NR_set_robust_list	311
+#define __NR_get_robust_list	312
+#define __NR_splice		313
+#define __NR_sync_file_range	314
+#define __NR_tee		315
+#define __NR_vmsplice		316
+#define __NR_move_pages		317
+#define __NR_getcpu		318
+#define __NR_epoll_pwait	319
+#define __NR_utimensat		320
+#define __NR_signalfd		321
+#define __NR_timerfd_create	322
+#define __NR_eventfd		323
+#define __NR_fallocate		324
+#define __NR_timerfd_settime	325
+#define __NR_timerfd_gettime	326
+#define __NR_signalfd4          327
+#define __NR_eventfd2           328
+#define __NR_epoll_create1      329
+#define __NR_dup3               330
+#define __NR_pipe2              331
+#define __NR_inotify_init1      332
+#define __NR_preadv             333
+#define __NR_pwritev            334
+#define __NR_rt_tgsigqueueinfo  335
+#define __NR_perf_counter_open  336
+
+#endif /* __VKI_SCNUMS_X86_LINUX_H */
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-x86-linux.h b/include/vki/vki-x86-linux.h
new file mode 100644
index 0000000..8f8aec8
--- /dev/null
+++ b/include/vki/vki-x86-linux.h
@@ -0,0 +1,885 @@
+
+/*--------------------------------------------------------------------*/
+/*--- x86/Linux-specific kernel interface.         vki-x86-linux.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+   This file is part of Valgrind, a dynamic binary instrumentation
+   framework.
+
+   Copyright (C) 2000-2010 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 __VKI_X86_LINUX_H
+#define __VKI_X86_LINUX_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 __signed__ int __vki_s32;
+typedef unsigned int __vki_u32;
+
+typedef __signed__ long long __vki_s64;
+typedef unsigned long long __vki_u64;
+
+typedef unsigned short vki_u16;
+
+typedef unsigned int vki_u32;
+
+//----------------------------------------------------------------------
+// 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)
+#define VKI_MAX_PAGE_SHIFT	VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE	VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
+//----------------------------------------------------------------------
+
+#define VKI_SHMLBA  VKI_PAGE_SIZE
+
+//----------------------------------------------------------------------
+// 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 */
+
+#define _VKI_NSIG	64
+#define _VKI_NSIG_BPW	32
+#define _VKI_NSIG_WORDS	(_VKI_NSIG / _VKI_NSIG_BPW)
+
+typedef unsigned long vki_old_sigset_t;		/* at least 32 bits */
+
+typedef struct {
+	unsigned long sig[_VKI_NSIG_WORDS];
+} vki_sigset_t;
+
+#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_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
+
+/* These are 'legacy' sigactions in which the size of sa_mask is fixed
+   (cannot be expanded at any future point) because it is sandwiched
+   between two other fields.
+   (there is identical kludgery in vki-ppc32-linux.h) */
+struct vki_old_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;
+        vki_old_sigset_t sa_mask;
+        unsigned long sa_flags;
+        __vki_sigrestore_t sa_restorer;
+};
+
+struct vki_sigaction_base {
+        // [[See comment about extra 'k' above]]
+	__vki_sighandler_t ksa_handler;
+	unsigned long sa_flags;
+	__vki_sigrestore_t sa_restorer;
+	vki_sigset_t sa_mask;		/* mask last for extensibility */
+};
+
+/* On Linux we use the same type for passing sigactions to
+   and from the kernel.  Hence: */
+typedef  struct vki_sigaction_base  vki_sigaction_toK_t;
+typedef  struct vki_sigaction_base  vki_sigaction_fromK_t;
+
+
+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_PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
+#define VKI_PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
+
+#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 */
+#define VKI_MAP_NORESERVE	0x4000		/* don't check for reservations */
+
+//----------------------------------------------------------------------
+// From linux-2.6.8.1/include/asm-i386/fcntl.h
+//----------------------------------------------------------------------
+
+#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_LARGEFILE	0100000
+
+#define VKI_AT_FDCWD            -100
+
+#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_SETOWN		8	/*  for sockets. */
+#define VKI_F_GETOWN		9	/*  for sockets. */
+#define VKI_F_SETSIG		10	/*  for sockets. */
+#define VKI_F_GETSIG		11	/*  for sockets. */
+
+#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_F_LINUX_SPECIFIC_BASE	1024
+
+//----------------------------------------------------------------------
+// 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
+
+//----------------------------------------------------------------------
+// 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 (timeval) */
+#define VKI_SIOCGSTAMPNS	0x8907		/* Get stamp (timespec) */
+
+//----------------------------------------------------------------------
+// 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
+//----------------------------------------------------------------------
+
+// [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
+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
+//----------------------------------------------------------------------
+
+typedef unsigned char   vki_cc_t;
+typedef unsigned int    vki_tcflag_t;
+
+#define VKI_NCCS 19
+struct vki_termios {
+	vki_tcflag_t c_iflag;		/* input mode flags */
+	vki_tcflag_t c_oflag;		/* output mode flags */
+	vki_tcflag_t c_cflag;		/* control mode flags */
+	vki_tcflag_t c_lflag;		/* local mode flags */
+	vki_cc_t c_line;		/* line discipline */
+	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
+};
+
+//----------------------------------------------------------------------
+// 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_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
+#define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
+#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))
+
+/* 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_TYPE(nr)	(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
+#define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
+#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_TIOCMGET	0x5415
+#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
+#define VKI_TIOCSERGETLSR   0x5459 /* Get line status register */
+
+#define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
+
+//----------------------------------------------------------------------
+// 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;
+};
+
+#define VKI_SEMOP		 1
+#define VKI_SEMGET		 2
+#define VKI_SEMCTL		 3
+#define VKI_SEMTIMEDOP	 	 4
+#define VKI_MSGSND		11
+#define VKI_MSGRCV		12
+#define VKI_MSGGET		13
+#define VKI_MSGCTL		14
+#define VKI_SHMAT		21
+#define VKI_SHMDT		22
+#define VKI_SHMGET		23
+#define VKI_SHMCTL		24
+
+
+//----------------------------------------------------------------------
+// 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;
+};
+
+//----------------------------------------------------------------------
+// DRM ioctls
+//----------------------------------------------------------------------
+
+// jrs 20050207: where did all this stuff come from?  Is it really
+// i386 specific, or should it go into the linux-generic category?
+//struct vki_drm_buf_pub {
+//	Int		  idx;	       /**< Index into the master buffer list */
+//	Int		  total;       /**< Buffer size */
+//	Int		  used;	       /**< Amount of buffer in use (for DMA) */
+//	void	  __user *address;     /**< Address of buffer */
+//};
+//
+//struct vki_drm_buf_map {
+//	Int	      count;		/**< Length of the buffer list */
+//	void	      __user *virtual;	/**< Mmap'd area in user-virtual */
+//	struct vki_drm_buf_pub __user *list;	/**< Buffer information */
+//};
+//
+///* We need to pay attention to this, because it mmaps memory */
+//#define VKI_DRM_IOCTL_MAP_BUFS		_VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
+
+//----------------------------------------------------------------------
+// From linux-2.6.9/include/asm-i386/ptrace.h
+//----------------------------------------------------------------------
+
+#define VKI_PTRACE_GETREGS            12
+#define VKI_PTRACE_SETREGS            13
+#define VKI_PTRACE_GETFPREGS          14
+#define VKI_PTRACE_SETFPREGS          15
+#define VKI_PTRACE_GETFPXREGS         18
+#define VKI_PTRACE_SETFPXREGS         19
+
+//----------------------------------------------------------------------
+// From linux-2.6.15.4/include/asm-i386/vm86.h
+//----------------------------------------------------------------------
+
+#define VKI_VM86_PLUS_INSTALL_CHECK	0
+#define VKI_VM86_ENTER			1
+#define VKI_VM86_ENTER_NO_BYPASS	2
+#define	VKI_VM86_REQUEST_IRQ		3
+#define VKI_VM86_FREE_IRQ		4
+#define VKI_VM86_GET_IRQ_BITS		5
+#define VKI_VM86_GET_AND_RESET_IRQ	6
+
+struct vki_vm86_regs {
+/*
+ * normal regs, with special meaning for the segment descriptors..
+ */
+	long ebx;
+	long ecx;
+	long edx;
+	long esi;
+	long edi;
+	long ebp;
+	long eax;
+	long __null_ds;
+	long __null_es;
+	long __null_fs;
+	long __null_gs;
+	long orig_eax;
+	long eip;
+	unsigned short cs, __csh;
+	long eflags;
+	long esp;
+	unsigned short ss, __ssh;
+/*
+ * these are specific to v86 mode:
+ */
+	unsigned short es, __esh;
+	unsigned short ds, __dsh;
+	unsigned short fs, __fsh;
+	unsigned short gs, __gsh;
+};
+
+struct vki_revectored_struct {
+	unsigned long __map[8];			/* 256 bits */
+};
+
+struct vki_vm86_struct {
+	struct vki_vm86_regs regs;
+	unsigned long flags;
+	unsigned long screen_bitmap;
+	unsigned long cpu_type;
+	struct vki_revectored_struct int_revectored;
+	struct vki_revectored_struct int21_revectored;
+};
+
+struct vki_vm86plus_info_struct {
+	unsigned long force_return_for_pic:1;
+	unsigned long vm86dbg_active:1;       /* for debugger */
+	unsigned long vm86dbg_TFpendig:1;     /* for debugger */
+	unsigned long unused:28;
+	unsigned long is_vm86pus:1;	      /* for vm86 internal use */
+	unsigned char vm86dbg_intxxtab[32];   /* for debugger */
+};
+
+struct vki_vm86plus_struct {
+	struct vki_vm86_regs regs;
+	unsigned long flags;
+	unsigned long screen_bitmap;
+	unsigned long cpu_type;
+	struct vki_revectored_struct int_revectored;
+	struct vki_revectored_struct int21_revectored;
+	struct vki_vm86plus_info_struct vm86plus;
+};
+
+//----------------------------------------------------------------------
+// And that's it!
+//----------------------------------------------------------------------
+
+#endif // __VKI_X86_LINUX_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/