diff options
author | Stephane Marchesin <marchesin@icps.u-strasbg.fr> | 2009-05-04 19:05:59 +0200 |
---|---|---|
committer | Stephane Marchesin <marchesin@icps.u-strasbg.fr> | 2009-05-04 19:05:59 +0200 |
commit | 6e410b3bb6ff51580897431105aae14591cbf7fb (patch) | |
tree | f8aeba9352710f10cd6b1d5138c8fc3ece91c8c3 /include |
Diffstat (limited to 'include')
119 files changed, 39262 insertions, 0 deletions
diff --git a/include/.svn/dir-prop-base b/include/.svn/dir-prop-base new file mode 100644 index 0000000..c344368 --- /dev/null +++ b/include/.svn/dir-prop-base @@ -0,0 +1,8 @@ +K 10 +svn:ignore +V 38 +Makefile.in +Makefile +tool.h +valgrind.h +END diff --git a/include/.svn/entries b/include/.svn/entries new file mode 100644 index 0000000..7f0f628 --- /dev/null +++ b/include/.svn/entries @@ -0,0 +1,442 @@ +8 + +dir +9703 +svn://svn.valgrind.org/valgrind/trunk/include +svn://svn.valgrind.org/valgrind + + + +2009-04-30T05:23:22.182900Z +9700 +njn +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +a5019735-40e9-0310-863c-91ae7b9d1cf9 + +pub_tool_vki.h +file + + + + +2009-03-13T17:30:10.000000Z +8c0df23baf33da26840760d758d9045b +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_options.h +file + + + + +2009-03-13T17:30:10.000000Z +86b1b3974b7f58ee7fa3c44c1f903dfa +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_hashtable.h +file + + + + +2009-03-13T17:30:10.000000Z +a3b8d051b833c480c137a4edfad36958 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_aspacemgr.h +file + + + + +2009-03-13T17:30:10.000000Z +4ecf208eea211774d1bbd9864cdf7743 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_machine.h +file + + + + +2009-03-13T17:30:10.000000Z +95e8e0473517c37c55579dad517694c9 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_libcbase.h +file + + + + +2009-03-13T17:30:10.000000Z +1d0bac6294ceefc80b5c9d58d7b27369 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_basics_asm.h +file + + + + +2009-04-30T16:43:59.000000Z +8ff719c2299ba39f01a779d67b54eb58 +2009-04-24T04:57:07.028318Z +9601 +njn + +pub_tool_cpuid.h +file + + + + +2009-03-13T17:30:10.000000Z +b5f4eed0320ee5682727fa6c640e858c +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_tooliface.h +file + + + + +2009-03-13T17:30:10.000000Z +764813639dfc11934392fe4d2e73e993 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_seqmatch.h +file + + + + +2009-03-13T17:30:10.000000Z +4d9283faf4350f2fb2f8541d1863e6cd +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_clreq.h +file + + + + +2009-03-13T17:30:10.000000Z +4ae6e4f917a160ad4485384c464ffe8a +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_threadstate.h +file + + + + +2009-03-13T17:30:10.000000Z +359cc0a78af71ec69d02508cbe897f58 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_clientstate.h +file + + + + +2009-03-13T17:30:10.000000Z +70f7717a93645dae31d8d146d2bd1169 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_vkiscnums.h +file + + + + +2009-03-13T17:30:10.000000Z +0302afd0234e0764f5557decd2548fd1 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_stacktrace.h +file + + + + +2009-03-13T17:30:10.000000Z +3192155a184517799e8b0ca100694c82 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_sparsewa.h +file + + + + +2009-03-13T17:30:10.000000Z +e527dad02f04fc93db02388361a92c0e +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_libcprint.h +file + + + + +2009-04-30T16:43:59.000000Z +22571e17a647bcd48765ddf2f6cfe500 +2009-04-30T04:17:45.496239Z +9693 +njn + +pub_tool_execontext.h +file + + + + +2009-03-13T17:30:10.000000Z +2bdb1c23f24375f69d4cde5cd46edc39 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_libcassert.h +file + + + + +2009-03-13T17:30:10.000000Z +d65d5859175e57e7eff56c383b5e431a +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_libcproc.h +file + + + + +2009-03-13T17:30:10.000000Z +44340a7ee527423a7d7f170b576c23a7 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_wordfm.h +file + + + + +2009-03-13T17:30:10.000000Z +98d950ed66b67627ac30dd56e13a1e0b +2009-03-10T22:02:09.669944Z +9344 +njn +has-props + +pub_tool_errormgr.h +file + + + + +2009-03-13T17:30:10.000000Z +010abc7e891425aff3905c7aba8d281e +2009-03-10T22:02:09.669944Z +9344 +njn + +vki +dir + +pub_tool_signals.h +file + + + + +2009-03-13T17:30:10.000000Z +514b83cf57f4319e5a98fe84b66f9c44 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_debuginfo.h +file + + + + +2009-03-13T17:30:10.000000Z +40e2b13a6023dc68be40e0a6305e5b74 +2009-03-10T22:02:09.669944Z +9344 +njn + +valgrind.h +file + + + + +2009-04-30T16:43:59.000000Z +f562afeb8973591fa41b46a0667f0009 +2009-04-22T22:42:10.255420Z +9580 +sewardj +has-props + +pub_tool_replacemalloc.h +file + + + + +2009-03-13T17:30:10.000000Z +b9789db48287d26f144105711141ddc2 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_basics.h +file + + + + +2009-04-30T16:43:59.000000Z +77c531e7628c6db35c29d12af5a83043 +2009-04-24T04:57:07.028318Z +9601 +njn + +pub_tool_redir.h +file + + + + +2009-03-13T17:30:10.000000Z +228612233618db51771d95eba93d9f0e +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_xarray.h +file + + + + +2009-03-13T17:30:10.000000Z +a6c6bb6ba595696ce82c8f9634aac49c +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_libcsignal.h +file + + + + +2009-03-13T17:30:10.000000Z +9290e85a737bf052598334941719d888 +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_mallocfree.h +file + + + + +2009-04-30T16:43:59.000000Z +aaf6d5f22425aea9aa9a228a2ae3567f +2009-03-15T23:25:38.213170Z +9416 +njn + +pub_tool_libcfile.h +file + + + + +2009-03-13T17:30:10.000000Z +00fcd9b8d4c5ab5675022d3a09a0501e +2009-03-10T22:02:09.669944Z +9344 +njn + +pub_tool_oset.h +file + + + + +2009-04-30T16:43:59.000000Z +abafe3130a5f81588bc7ac5dc9d2c1f5 +2009-04-26T07:15:58.034266Z +9634 +bart + +Makefile.am +file + + + + +2009-03-13T17:30:10.000000Z +43988b1cd4881956b04dd5567ad6cc30 +2008-12-12T08:07:49.045161Z +8816 +sewardj +has-props + diff --git a/include/.svn/format b/include/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/include/.svn/format @@ -0,0 +1 @@ +8 diff --git a/include/.svn/prop-base/Makefile.am.svn-base b/include/.svn/prop-base/Makefile.am.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/.svn/prop-base/Makefile.am.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/.svn/prop-base/pub_tool_wordfm.h.svn-base b/include/.svn/prop-base/pub_tool_wordfm.h.svn-base new file mode 100644 index 0000000..3160658 --- /dev/null +++ b/include/.svn/prop-base/pub_tool_wordfm.h.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mergeinfo +V 0 + +END diff --git a/include/.svn/prop-base/valgrind.h.svn-base b/include/.svn/prop-base/valgrind.h.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/.svn/prop-base/valgrind.h.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/.svn/text-base/Makefile.am.svn-base b/include/.svn/text-base/Makefile.am.svn-base new file mode 100644 index 0000000..e73f5cd --- /dev/null +++ b/include/.svn/text-base/Makefile.am.svn-base @@ -0,0 +1,39 @@ + +SUBDIRS = vki + +incincdir = $(includedir)/valgrind + +incinc_HEADERS = \ + pub_tool_basics.h \ + pub_tool_basics_asm.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_wordfm.h \ + pub_tool_xarray.h \ + valgrind.h diff --git a/include/.svn/text-base/pub_tool_aspacemgr.h.svn-base b/include/.svn/text-base/pub_tool_aspacemgr.h.svn-base new file mode 100644 index 0000000..f84dfa6 --- /dev/null +++ b/include/.svn/text-base/pub_tool_aspacemgr.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_basics.h.svn-base b/include/.svn/text-base/pub_tool_basics.h.svn-base new file mode 100644 index 0000000..9bff837 --- /dev/null +++ b/include/.svn/text-base/pub_tool_basics.h.svn-base @@ -0,0 +1,214 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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> + +/* For HAVE_BUILTIN_EXPECT */ +#include "config.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. +typedef Word OffT; // 32 64 +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, + res holds the return value, and err is zero. + When .isError == True, + err holds the error code, and res is zero. + + 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. +*/ +typedef + struct { + UWord res; + UWord err; + Bool isError; + } + SysRes; + + +/* --------------------------------------------------------------------- + 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) +# define VG_LITTLEENDIAN 1 +#elif defined(VGA_ppc32) || defined(VGA_ppc64) +# define VG_BIGENDIAN 1 +#endif + +/* Regparmness */ +#if defined(VGA_x86) +# define VG_REGPARM(n) __attribute__((regparm(n))) +#elif defined(VGA_amd64) || defined(VGA_ppc32) || defined(VGA_ppc64) +# 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 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 + + +#endif /* __PUB_TOOL_BASICS_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_basics_asm.h.svn-base b/include/.svn/text-base/pub_tool_basics_asm.h.svn-base new file mode 100644 index 0000000..201c1b5 --- /dev/null +++ b/include/.svn/text-base/pub_tool_basics_asm.h.svn-base @@ -0,0 +1,58 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#define VG_(str) VGAPPEND(vgPlain_, str) +#define ML_(str) VGAPPEND(vgModuleLocal_, str) + +#endif /* __PUB_TOOL_BASICS_ASM_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_clientstate.h.svn-base b/include/.svn/text-base/pub_tool_clientstate.h.svn-base new file mode 100644 index 0000000..9a47fcc --- /dev/null +++ b/include/.svn/text-base/pub_tool_clientstate.h.svn-base @@ -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-2009 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 HChar* VG_(args_the_exename); + + +#endif // __PUB_TOOL_CLIENTSTATE_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_clreq.h.svn-base b/include/.svn/text-base/pub_tool_clreq.h.svn-base new file mode 100644 index 0000000..f200d12 --- /dev/null +++ b/include/.svn/text-base/pub_tool_clreq.h.svn-base @@ -0,0 +1,40 @@ + +/*--------------------------------------------------------------------*/ +/*--- Client requests. pub_tool_clreq.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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/.svn/text-base/pub_tool_cpuid.h.svn-base b/include/.svn/text-base/pub_tool_cpuid.h.svn-base new file mode 100644 index 0000000..9e994c5 --- /dev/null +++ b/include/.svn/text-base/pub_tool_cpuid.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_debuginfo.h.svn-base b/include/.svn/text-base/pub_tool_debuginfo.h.svn-base new file mode 100644 index 0000000..e5ad9f7 --- /dev/null +++ b/include/.svn/text-base/pub_tool_debuginfo.h.svn-base @@ -0,0 +1,236 @@ + +/*--------------------------------------------------------------------*/ +/*--- DebugInfo. pub_tool_debuginfo.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 (or as much as will + fit) is put into into dname{1,2}[0 .. n_dname-1] and is guaranteed + to be zero terminated. */ +extern Bool VG_(get_data_description)( /*OUT*/Char* dname1, + /*OUT*/Char* dname2, + Int n_dname, + 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 segment information ===*/ +/*====================================================================*/ + +/* A way to get information about what segments are mapped */ +typedef struct _DebugInfo DebugInfo; + +/* Returns NULL if the DebugInfo isn't found. It doesn't matter if + debug info is present or not. */ +extern DebugInfo* VG_(find_seginfo) ( Addr a ); + +/* Fish bits out of DebugInfos. */ +extern Addr VG_(seginfo_get_text_avma)( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_text_size)( const DebugInfo *di ); +extern Addr VG_(seginfo_get_plt_avma) ( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_plt_size) ( const DebugInfo *di ); +extern Addr VG_(seginfo_get_gotplt_avma)( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_gotplt_size)( const DebugInfo *di ); +extern const UChar* VG_(seginfo_soname) ( const DebugInfo *di ); +extern const UChar* VG_(seginfo_filename) ( const DebugInfo *di ); +extern PtrdiffT VG_(seginfo_get_text_bias)( const DebugInfo *di ); + +/* Function for traversing the seginfo list. When called with NULL it + returns the first element; otherwise it returns the given element's + successor. */ +extern const DebugInfo* VG_(next_seginfo) ( 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. */ +extern Int VG_(seginfo_syms_howmany) ( const DebugInfo *di ); +extern void VG_(seginfo_syms_getidx) ( const DebugInfo *di, + Int idx, + /*OUT*/Addr* avma, + /*OUT*/Addr* tocptr, + /*OUT*/UInt* size, + /*OUT*/HChar** name, + /*OUT*/Bool* isText ); + +/* 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. */ +extern +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). */ +extern +VgSectKind VG_(seginfo_sect_kind)( /*OUT*/UChar* name, SizeT n_name, + Addr a); + + +#endif // __PUB_TOOL_DEBUGINFO_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_errormgr.h.svn-base b/include/.svn/text-base/pub_tool_errormgr.h.svn-base new file mode 100644 index 0000000..0d22c1b --- /dev/null +++ b/include/.svn/text-base/pub_tool_errormgr.h.svn-base @@ -0,0 +1,132 @@ +/*--------------------------------------------------------------------*/ +/*--- ErrorMgr: management of errors and suppressions. ---*/ +/*--- pub_tool_errormgr.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 of at most nBuf chars from fd. + Skips leading spaces on the line. Returns True if EOF was hit instead. + Useful for reading in extra tool-specific suppression lines. */ +extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ); + + +/* ------------------------------------------------------------------ */ +/* 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/.svn/text-base/pub_tool_execontext.h.svn-base b/include/.svn/text-base/pub_tool_execontext.h.svn-base new file mode 100644 index 0000000..3506026 --- /dev/null +++ b/include/.svn/text-base/pub_tool_execontext.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_hashtable.h.svn-base b/include/.svn/text-base/pub_tool_hashtable.h.svn-base new file mode 100644 index 0000000..6348799 --- /dev/null +++ b/include/.svn/text-base/pub_tool_hashtable.h.svn-base @@ -0,0 +1,100 @@ + +/*--------------------------------------------------------------------*/ +/*--- A hash table implementation. pub_tool_hashtable.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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. */ +extern void VG_(HT_add_node) ( VgHashTable t, void* node ); + +/* Looks up a VgHashNode in the table. Returns NULL if not found. */ +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 all the hashtable elements + into it, then returns both the array and the size of it. This is + used by the memory-leak detector. 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/.svn/text-base/pub_tool_libcassert.h.svn-base b/include/.svn/text-base/pub_tool_libcassert.h.svn-base new file mode 100644 index 0000000..6e4f69a --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcassert.h.svn-base @@ -0,0 +1,64 @@ + +/*--------------------------------------------------------------------*/ +/*--- Assertions, etc. pub_tool_libcassert.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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, #expr, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, \ + ""), \ + 0))) + +#define tl_assert2(expr, format, args...) \ + ((void) ((expr) ? 0 : \ + (VG_(assert_fail) (/*isCore?*/False, #expr, \ + __FILE__, __LINE__, __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/.svn/text-base/pub_tool_libcbase.h.svn-base b/include/.svn/text-base/pub_tool_libcbase.h.svn-base new file mode 100644 index 0000000..4e627be --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcbase.h.svn-base @@ -0,0 +1,151 @@ + +/*--------------------------------------------------------------------*/ +/*--- Standalone libc stuff. pub_tool_libcbase.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 ); + +/* --------------------------------------------------------------------- + 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_(strncmp) ( const Char* s1, const Char* s2, SizeT nmax ); +extern Char* VG_(strstr) ( 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* accept ); +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 ); + +/* --------------------------------------------------------------------- + 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_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/.svn/text-base/pub_tool_libcfile.h.svn-base b/include/.svn/text-base/pub_tool_libcfile.h.svn-base new file mode 100644 index 0000000..f870109 --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcfile.h.svn-base @@ -0,0 +1,91 @@ + +/*--------------------------------------------------------------------*/ +/*--- File/socket-related libc stuff. pub_tool_libcfile.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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. */ +struct vg_stat { + ULong st_dev; + ULong st_ino; + ULong st_nlink; + UInt st_mode; + UInt st_uid; + UInt st_gid; + ULong st_rdev; + Long st_size; + ULong st_blksize; + ULong st_blocks; + ULong st_atime; + ULong st_atime_nsec; + ULong st_mtime; + ULong st_mtime_nsec; + ULong st_ctime; + ULong st_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) ( 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) ( Char* old_name, Char* new_name ); +extern Int VG_(unlink) ( Char* file_name ); + +extern Int VG_(readlink)( Char* path, Char* buf, UInt bufsize ); +extern Int VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count ); + +/* 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/.svn/text-base/pub_tool_libcprint.h.svn-base b/include/.svn/text-base/pub_tool_libcprint.h.svn-base new file mode 100644 index 0000000..b3386b2 --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcprint.h.svn-base @@ -0,0 +1,111 @@ + +/*--------------------------------------------------------------------*/ +/*--- Printing libc stuff. pub_tool_libcprint.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 + + +/* Enable compile-time format string checking by gcc. + This feature is supported since at least gcc version 2.95. + For more information about the format attribute, see also + 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 + + +/* --------------------------------------------------------------------- + Basic printing + ------------------------------------------------------------------ */ + +/* Note that they all output to the file descriptor given by the + * --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr). + * Hence no need for VG_(fprintf)(). + */ +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); +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[]); + +/* --------------------------------------------------------------------- + Messages for the user + ------------------------------------------------------------------ */ + +/* No, really. I _am_ that strange. */ +#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn) + +/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind. + Should be used for all user output. */ + +typedef + enum { Vg_UserMsg, /* '?' == '=' */ + Vg_DebugMsg, /* '?' == '-' */ + Vg_DebugExtraMsg, /* '?' == '+' */ + Vg_ClientMsg /* '?' == '*' */ + } + VgMsgKind; + +/* Send a single-part message. Appends a newline. The format + specification may contain any ISO C format specifier or %t. + No attempt is made to let the compiler verify consistency of the + format string and the argument list. */ +extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... ); +/* Send a single-part message. Appends a newline. The format + specification may contain any ISO C format specifier. The gcc compiler + will verify consistency of the format string and the argument list. */ +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)(). +#define VG_UMSG( format, args... ) VG_(message)(Vg_UserMsg, format, ##args) +#define VG_DMSG( format, args... ) VG_(message)(Vg_DebugMsg, format, ##args) +#define VG_EMSG( format, args... ) VG_(message)(Vg_DebugExtraMsg, \ + format, ##args) + +#endif // __PUB_TOOL_LIBCPRINT_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_libcproc.h.svn-base b/include/.svn/text-base/pub_tool_libcproc.h.svn-base new file mode 100644 index 0000000..cd668b1 --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcproc.h.svn-base @@ -0,0 +1,95 @@ + +/*--------------------------------------------------------------------*/ +/*--- Process-related libc stuff pub_tool_libcproc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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); + +/* --------------------------------------------------------------------- + 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/.svn/text-base/pub_tool_libcsignal.h.svn-base b/include/.svn/text-base/pub_tool_libcsignal.h.svn-base new file mode 100644 index 0000000..d8aa0f5 --- /dev/null +++ b/include/.svn/text-base/pub_tool_libcsignal.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_machine.h.svn-base b/include/.svn/text-base/pub_tool_machine.h.svn-base new file mode 100644 index 0000000..7301d51 --- /dev/null +++ b/include/.svn/text-base/pub_tool_machine.h.svn-base @@ -0,0 +1,137 @@ + +/*--------------------------------------------------------------------*/ +/*--- Machine-related stuff. pub_tool_machine.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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_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? +#else +# error Unknown platform +#endif + +// Guest state accessors +extern Addr VG_(get_SP) ( ThreadId tid ); +extern Addr VG_(get_IP) ( ThreadId tid ); +extern Addr VG_(get_FP) ( ThreadId tid ); +extern Addr VG_(get_LR) ( ThreadId tid ); + +extern void VG_(set_SP) ( ThreadId tid, Addr sp ); +extern void VG_(set_IP) ( ThreadId tid, Addr ip ); + +// 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 Addr VG_(thread_get_stack_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/.svn/text-base/pub_tool_mallocfree.h.svn-base b/include/.svn/text-base/pub_tool_mallocfree.h.svn-base new file mode 100644 index 0000000..efab2c2 --- /dev/null +++ b/include/.svn/text-base/pub_tool_mallocfree.h.svn-base @@ -0,0 +1,58 @@ + +/*--------------------------------------------------------------------*/ +/*--- MallocFree: high-level memory management. ---*/ +/*--- pub_tool_mallocfree.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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). +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/.svn/text-base/pub_tool_options.h.svn-base b/include/.svn/text-base/pub_tool_options.h.svn-base new file mode 100644 index 0000000..cab2101 --- /dev/null +++ b/include/.svn/text-base/pub_tool_options.h.svn-base @@ -0,0 +1,198 @@ + +/*--------------------------------------------------------------------*/ +/*--- Command line options. pub_tool_options.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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_(err_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; \ + /* 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_(err_bad_option)(qq_arg); \ + /* Check bounds. */ \ + if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \ + VG_(message)(Vg_UserMsg, \ + "'%s' argument must be between %lld and %lld", \ + (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \ + VG_(err_bad_option)(qq_arg); \ + } \ + 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_(err_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); + +/* 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); + + +/* Call this if a recognised 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. + It returns a Bool so it can be used in the _CLO_ macros. */ +__attribute__((noreturn)) +extern void VG_(err_bad_option) ( Char* opt ); + +/* 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/.svn/text-base/pub_tool_oset.h.svn-base b/include/.svn/text-base/pub_tool_oset.h.svn-base new file mode 100644 index 0000000..687d34f --- /dev/null +++ b/include/.svn/text-base/pub_tool_oset.h.svn-base @@ -0,0 +1,259 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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* ec, 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. +// - 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* ec, + 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)(). +// - 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* ec, + 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. +// +// * 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_Next) ( OSet* os ); + +// set up 'oset' for iteration so that the first key subsequently +// produced VG_(OSetGen_Next) is the smallest key in the map +// >= start_at. Naturally ">=" is defined by the comparison +// function supplied to VG_(OSetGen_Create). +extern void VG_(OSetGen_ResetIterAt) ( OSet* oset, const void* key ); + +#endif // __PUB_TOOL_OSET_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_redir.h.svn-base b/include/.svn/text-base/pub_tool_redir.h.svn-base new file mode 100644 index 0000000..a249fb2 --- /dev/null +++ b/include/.svn/text-base/pub_tool_redir.h.svn-base @@ -0,0 +1,205 @@ + +/*--------------------------------------------------------------------*/ +/*--- Redirections, etc. pub_tool_redir.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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) + + --> Zp (plus) + : --> Zc (colon) + . --> Zd (dot) + _ --> Zu (underscore) + - --> Zh (hyphen) + (space) --> Zs (space) + @ --> ZA (at) + Z --> ZZ (Z) + ( --> ZL (left) + ) --> ZR (right) + + 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. --------- */ + +/* --- 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) +#else +# error "Unknown platform" +#endif + +/* --- Soname of the GNU C++ library. --- */ + +// DDD: this one and those below should probably be conditionally compiled, +// as should all the redirects in the tools that use them. +#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 + +/* --- Sonames for Linux ELF linkers. --- */ + +#define VG_Z_LD_LINUX_SO_2 ldZhlinuxZdsoZd2 // ld-linux.so.2 +#define VG_Z_LD_LINUX_X86_64_SO_2 ldZhlinuxZhx86Zh64ZdsoZd2 // ld-linux-x86-64.so.2 +#define VG_Z_LD64_SO_1 ld64ZdsoZd1 // ld64.so.1 +#define VG_Z_LD_SO_1 ldZdsoZd1 // ld.so.1 + + +#endif // __PUB_TOOL_REDIR_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_replacemalloc.h.svn-base b/include/.svn/text-base/pub_tool_replacemalloc.h.svn-base new file mode 100644 index 0000000..9cb2e9e --- /dev/null +++ b/include/.svn/text-base/pub_tool_replacemalloc.h.svn-base @@ -0,0 +1,74 @@ + +/*--------------------------------------------------------------------*/ +/*--- Malloc replacement. pub_tool_replacemalloc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 ); +extern void VG_(replacement_malloc_print_usage) ( void ); +extern void VG_(replacement_malloc_print_debug_usage) ( void ); + +#endif // __PUB_TOOL_REPLACEMALLOC_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_seqmatch.h.svn-base b/include/.svn/text-base/pub_tool_seqmatch.h.svn-base new file mode 100644 index 0000000..a1763b7 --- /dev/null +++ b/include/.svn/text-base/pub_tool_seqmatch.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_signals.h.svn-base b/include/.svn/text-base/pub_tool_signals.h.svn-base new file mode 100644 index 0000000..bb96018 --- /dev/null +++ b/include/.svn/text-base/pub_tool_signals.h.svn-base @@ -0,0 +1,47 @@ + +/*--------------------------------------------------------------------*/ +/*--- Signals stuff. pub_tool_signals.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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/.svn/text-base/pub_tool_sparsewa.h.svn-base b/include/.svn/text-base/pub_tool_sparsewa.h.svn-base new file mode 100644 index 0000000..29bb336 --- /dev/null +++ b/include/.svn/text-base/pub_tool_sparsewa.h.svn-base @@ -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-2009 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/.svn/text-base/pub_tool_stacktrace.h.svn-base b/include/.svn/text-base/pub_tool_stacktrace.h.svn-base new file mode 100644 index 0000000..f17758b --- /dev/null +++ b/include/.svn/text-base/pub_tool_stacktrace.h.svn-base @@ -0,0 +1,82 @@ +/*--------------------------------------------------------------------*/ +/*--- Stack traces: getting, traversing, printing. ---*/ +/*--- tool_stacktrace.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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. Doesn't go below main() unless +// --show-below-main=yes is set. +extern void VG_(apply_StackTrace)( void(*action)(UInt n, Addr ip), + 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/.svn/text-base/pub_tool_threadstate.h.svn-base b/include/.svn/text-base/pub_tool_threadstate.h.svn-base new file mode 100644 index 0000000..d572e87 --- /dev/null +++ b/include/.svn/text-base/pub_tool_threadstate.h.svn-base @@ -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-2009 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 300 + +/* 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/.svn/text-base/pub_tool_tooliface.h.svn-base b/include/.svn/text-base/pub_tool_tooliface.h.svn-base new file mode 100644 index 0000000..3a7c391 --- /dev/null +++ b/include/.svn/text-base/pub_tool_tooliface.h.svn-base @@ -0,0 +1,643 @@ + +/*--------------------------------------------------------------------*/ +/*--- The core/tool interface. pub_tool_tooliface.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 equal enough. `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), + + // 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. + Bool (*read_extra_suppression_info)(Int fd, Char* buf, Int nBuf, 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 any extra info for the error, for --gen-suppressions, + // including the newline. This is the inverse of + // VG_(tdict).tool_read_extra_suppression_info(). + void (*print_extra_suppression_info)(Error* err) +); + +/* 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. 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. + 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! +extern void VG_(needs_syscall_wrapper) ( + void (* pre_syscall)(ThreadId tid, UInt syscallno), + void (*post_syscall)(ThreadId tid, UInt syscallno, 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, + 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/.svn/text-base/pub_tool_vki.h.svn-base b/include/.svn/text-base/pub_tool_vki.h.svn-base new file mode 100644 index 0000000..75da646 --- /dev/null +++ b/include/.svn/text-base/pub_tool_vki.h.svn-base @@ -0,0 +1,62 @@ + +/*--------------------------------------------------------------------*/ +/*--- Top level for kernel interface declarations. ---*/ +/*--- pub_tool_vki.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 Julian Seward + jseward@acm.org + Copyright (C) 2005-2009 Nicholas Nethercote + njn@valgrind.org + Copyright (C) 2006-2009 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" +#else +# error Unknown Plat/OS +#endif + +#endif // __PUB_TOOL_VKI_H + +/*--------------------------------------------------------------------*/ +/*--- end pub_tool_vki.h ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_vkiscnums.h.svn-base b/include/.svn/text-base/pub_tool_vkiscnums.h.svn-base new file mode 100644 index 0000000..147a761 --- /dev/null +++ b/include/.svn/text-base/pub_tool_vkiscnums.h.svn-base @@ -0,0 +1,88 @@ + +/*--------------------------------------------------------------------*/ +/*--- Top level for kernel interface system call numbers. ---*/ +/*--- pub_tool_vkiscnums.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 Nicholas Nethercote + njn@valgrind.org + Copyright (C) 2006-2009 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 the system call numbers. + + On Linux they are a bunch of #define'd constants of the form + __NR_name, and this file must contain nothing else, since it will + be included in assembly code (m_trampoline.S). + + On AIX the __NR_name consts are renamings of global variables which + tell us the number for each syscall. This elaboration is necessary + because on AIX the syscall numbers are not constant; they can be + different for each process (in principle; in practice they rarely + change). 32- and 64-bit AIX5 share a common "implementation". + + 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_vkiscnums.h. +*/ + +#ifndef __PUB_TOOL_VKISCNUMS_H +#define __PUB_TOOL_VKISCNUMS_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_ppc32_aix5) || defined(VGP_ppc64_aix5) +# include "vki/vki-scnums-aix5.h" + +/* Make it possible to include this file in assembly sources. */ +#if !defined(VG_IN_ASSEMBLY_SOURCE) + +/* Look up the name of a syscall, using the bindings previously + created by VG_(aix5_register_syscall), for the purposes of making + error messages. */ +extern UChar* VG_(aix5_sysno_to_sysname)( Int sysno ); + +#endif /* !defined(VG_IN_ASSEMBLY_SOURCE) */ + +#else +# error Unknown platform +#endif + +#endif // __PUB_TOOL_VKISCNUMS_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/pub_tool_wordfm.h.svn-base b/include/.svn/text-base/pub_tool_wordfm.h.svn-base new file mode 100644 index 0000000..57c57db --- /dev/null +++ b/include/.svn/text-base/pub_tool_wordfm.h.svn-base @@ -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-2009 Julian Seward + jseward@acm.org + + This code is based on previous work by Nicholas Nethercote + (coregrind/m_oset.c) which is + + Copyright (C) 2005-2009 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/.svn/text-base/pub_tool_xarray.h.svn-base b/include/.svn/text-base/pub_tool_xarray.h.svn-base new file mode 100644 index 0000000..111f63a --- /dev/null +++ b/include/.svn/text-base/pub_tool_xarray.h.svn-base @@ -0,0 +1,115 @@ + +/*--------------------------------------------------------------------*/ +/*--- An expandable array implementation. pub_tool_xarray.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2007-2009 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 ); + +/* 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. */ +extern void VG_(dropTailXA) ( 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 ); + +#endif // __PUB_TOOL_XARRAY_H + +/*--------------------------------------------------------------------*/ +/*--- end pub_tool_xarray.h ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/.svn/text-base/valgrind.h.svn-base b/include/.svn/text-base/valgrind.h.svn-base new file mode 100644 index 0000000..5b4b8af --- /dev/null +++ b/include/.svn/text-base/valgrind.h.svn-base @@ -0,0 +1,3937 @@ +/* -*- 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-2009 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 + +#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). */ +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#if !defined(_AIX) && defined(__i386__) +# define PLAT_x86_linux 1 +#elif !defined(_AIX) && defined(__x86_64__) +# define PLAT_amd64_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__) +# define PLAT_ppc32_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__) +# define PLAT_ppc64_linux 1 +#elif defined(_AIX) && defined(__64BIT__) +# define PLAT_ppc64_aix5 1 +#elif defined(_AIX) && !defined(__64BIT__) +# define PLAT_ppc32_aix5 1 +#endif + + +/* If we're not compiling for our target platform, don't generate + any inline asms. */ +#if !defined(PLAT_x86_linux) && !defined(PLAT_amd64_linux) \ + && !defined(PLAT_ppc32_linux) && !defined(PLAT_ppc64_linux) \ + && !defined(PLAT_ppc32_aix5) && !defined(PLAT_ppc64_aix5) +# 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 ------------------------- */ + +#if defined(PLAT_x86_linux) + +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 */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +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 */ + +/* ------------------------ 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 */ + +/* ------------------------ 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. */ + +#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \ + _vgwZU_##soname##_##fnname + +#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \ + _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) + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +/* 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( \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $4, %%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( \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $8, %%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( \ + "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 $12, %%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( \ + "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 $20, %%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( \ + "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 $24, %%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( \ + "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 $28, %%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( \ + "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 $36, %%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( \ + "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 $40, %%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( \ + "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 $44, %%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 */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +/* 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" + +/* 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( \ + "subq $128,%%rsp\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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 */ \ + "addq $128,%%rsp\n\t" \ + VALGRIND_CALL_NOREDIR_RAX \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_amd64_linux */ + +/* ------------------------ 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 */ + +/* ------------------------ 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. */ + VG_USERREQ__PRINTF = 0x1401, + VG_USERREQ__PRINTF_BACKTRACE = 0x1402, + + /* 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 + } Vg_ClientRequest; + +#if !defined(__GNUC__) +# define __extension__ /* */ +#endif + +/* 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 __extension__ \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* if not */, \ + VG_USERREQ__RUNNING_ON_VALGRIND, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + }) + + +/* 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. */ + +#if defined(NVALGRIND) + +# define VALGRIND_PRINTF(...) +# define VALGRIND_PRINTF_BACKTRACE(...) + +#else /* NVALGRIND */ + +/* 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__)); +static int +VALGRIND_PRINTF(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF_BACKTRACE(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + 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; \ + }) + +/* Mark a block of memory as having been allocated by a malloc()-like + function. `addr' is the start of the usable block (ie. after any + redzone) `rzB' is redzone size if the allocator can apply redzones; + use '0' if not. Adding redzones makes it more likely Valgrind will spot + block overruns. `is_zeroed' indicates if the memory is zeroed, as it is + for calloc(). Put it immediately after the point where a block is + allocated. + + If you're using Memcheck: If you're allocating memory via superblocks, + and then handing out small chunks of each superblock, if you don't have + redzones on your small blocks, it's worth marking the superblock with + VALGRIND_MAKE_MEM_NOACCESS when it's created, so that block overruns are + detected. But if you can put redzones on, it's probably better to not do + this, so that messages for small overruns are described in terms of the + small block rather than the superblock (but if you have a big overrun + that skips over a redzone, you could miss an error this way). See + memcheck/tests/custom_alloc.c for an example. + + WARNING: if your allocator uses malloc() or 'new' to allocate + superblocks, rather than mmap() or brk(), this will not work properly -- + you'll likely get assertion failures during leak detection. This is + because Valgrind doesn't like seeing overlapping heap blocks. Sorry. + + Nb: block must be freed via a free()-like function specified + with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */ +#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); \ + } + +/* Mark a block of memory as having been freed by a free()-like function. + `rzB' is redzone size; it must match that given to + VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak + checker. Put it immediately after the point where the block is freed. */ +#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); \ + } + + +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#endif /* __VALGRIND_H */ diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..24981ab --- /dev/null +++ b/include/Makefile @@ -0,0 +1,567 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# include/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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. + + + + +pkgdatadir = $(datadir)/valgrind +pkglibdir = $(libdir)/valgrind +pkgincludedir = $(includedir)/valgrind +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 = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = include +DIST_COMMON = $(incinc_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 = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +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 = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(incincdir)" +incincHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(incinc_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/steph/compile/valgrind/missing --run aclocal-1.10 +AMTAR = ${SHELL} /home/steph/compile/valgrind/missing --run tar +AR = /usr/bin/ar +AUTOCONF = ${SHELL} /home/steph/compile/valgrind/missing --run autoconf +AUTOHEADER = ${SHELL} /home/steph/compile/valgrind/missing --run autoheader +AUTOMAKE = ${SHELL} /home/steph/compile/valgrind/missing --run automake-1.10 +AWK = gawk +BOOST_CFLAGS = +BOOST_LIBS = -lboost_thread-mt -m64 +CC = gcc +CCAS = gcc +CCASDEPMODE = depmode=gcc3 +CCASFLAGS = -Wno-long-long +CCDEPMODE = depmode=gcc3 +CFLAGS = -Wno-long-long -Wno-pointer-sign -Wdeclaration-after-statement -fno-stack-protector +CPP = gcc -E +CPPFLAGS = +CXX = g++ +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -g -O2 +CYGPATH_W = echo +DEFAULT_SUPP = exp-ptrcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DIFF = diff -u +DISTCHECK_CONFIGURE_FLAGS = --with-vex=$(top_srcdir)/VEX +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +FLAG_FNO_STACK_PROTECTOR = -fno-stack-protector +FLAG_M32 = -m32 +FLAG_M64 = -m64 +FLAG_MAIX32 = +FLAG_MAIX64 = +FLAG_MMMX = -mmmx +FLAG_MSSE = -msse +FLAG_UNLIMITED_INLINE_UNIT_GROWTH = --param inline-unit-growth=900 +FLAG_WDECL_AFTER_STMT = -Wdeclaration-after-statement +FLAG_W_EXTRA = -Wextra +FLAG_W_NO_FORMAT_ZERO_LENGTH = -Wno-format-zero-length +GDB = /usr/bin/gdb +GLIBC_VERSION = 2.8 +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LDFLAGS = +LIBOBJS = +LIBS = +LN_S = ln -s +LTLIBOBJS = +MAINT = # +MAKEINFO = ${SHELL} /home/steph/compile/valgrind/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +MPI_CC = mpicc +OBJEXT = o +PACKAGE = valgrind +PACKAGE_BUGREPORT = valgrind-users@lists.sourceforge.net +PACKAGE_NAME = Valgrind +PACKAGE_STRING = Valgrind 3.5.0.SVN +PACKAGE_TARNAME = valgrind +PACKAGE_VERSION = 3.5.0.SVN +PATH_SEPARATOR = : +PERL = /usr/bin/perl +PKG_CONFIG = /usr/bin/pkg-config +PREFERRED_STACK_BOUNDARY = +QTCORE_CFLAGS = -DQT_SHARED -I/usr/include/QtCore +QTCORE_LIBS = -lQtCore +RANLIB = ranlib +SET_MAKE = +SHELL = /bin/sh +STRIP = +VALT_LOAD_ADDRESS = 0x38000000 +VERSION = 3.5.0.SVN +VEX_DIR = $(top_srcdir)/VEX +VGCONF_ARCH_PRI = amd64 +VGCONF_OS = linux +VGCONF_PLATFORM_PRI_CAPS = AMD64_LINUX +VGCONF_PLATFORM_SEC_CAPS = +abs_builddir = /home/steph/compile/valgrind/include +abs_srcdir = /home/steph/compile/valgrind/include +abs_top_builddir = /home/steph/compile/valgrind +abs_top_srcdir = /home/steph/compile/valgrind +ac_ct_CC = gcc +ac_ct_CXX = g++ +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/steph/compile/valgrind/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_builddir = .. +top_srcdir = .. +SUBDIRS = vki +incincdir = $(includedir)/valgrind +incinc_HEADERS = \ + pub_tool_basics.h \ + pub_tool_basics_asm.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_wordfm.h \ + pub_tool_xarray.h \ + valgrind.h + +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \ + 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: # $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-incincHEADERS: $(incinc_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(incincdir)" || $(MKDIR_P) "$(DESTDIR)$(incincdir)" + @list='$(incinc_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(incincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(incincdir)/$$f'"; \ + $(incincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(incincdir)/$$f"; \ + done + +uninstall-incincHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(incinc_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(incincdir)/$$f'"; \ + rm -f "$(DESTDIR)$(incincdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(incincdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +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) + +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-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-incincHEADERS + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-incincHEADERS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic ctags \ + ctags-recursive 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-incincHEADERS install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-incincHEADERS + +# 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/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..e73f5cd --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,39 @@ + +SUBDIRS = vki + +incincdir = $(includedir)/valgrind + +incinc_HEADERS = \ + pub_tool_basics.h \ + pub_tool_basics_asm.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_wordfm.h \ + pub_tool_xarray.h \ + valgrind.h diff --git a/include/Makefile.in b/include/Makefile.in new file mode 100644 index 0000000..d004713 --- /dev/null +++ b/include/Makefile.in @@ -0,0 +1,567 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@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 = $(incinc_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 = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +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 = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(incincdir)" +incincHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(incinc_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +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@ +DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ +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_UNLIMITED_INLINE_UNIT_GROWTH = @FLAG_UNLIMITED_INLINE_UNIT_GROWTH@ +FLAG_WDECL_AFTER_STMT = @FLAG_WDECL_AFTER_STMT@ +FLAG_W_EXTRA = @FLAG_W_EXTRA@ +FLAG_W_NO_FORMAT_ZERO_LENGTH = @FLAG_W_NO_FORMAT_ZERO_LENGTH@ +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_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@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VALT_LOAD_ADDRESS = @VALT_LOAD_ADDRESS@ +VERSION = @VERSION@ +VEX_DIR = @VEX_DIR@ +VGCONF_ARCH_PRI = @VGCONF_ARCH_PRI@ +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_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = vki +incincdir = $(includedir)/valgrind +incinc_HEADERS = \ + pub_tool_basics.h \ + pub_tool_basics_asm.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_wordfm.h \ + pub_tool_xarray.h \ + valgrind.h + +all: all-recursive + +.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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \ + 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 +install-incincHEADERS: $(incinc_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(incincdir)" || $(MKDIR_P) "$(DESTDIR)$(incincdir)" + @list='$(incinc_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(incincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(incincdir)/$$f'"; \ + $(incincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(incincdir)/$$f"; \ + done + +uninstall-incincHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(incinc_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(incincdir)/$$f'"; \ + rm -f "$(DESTDIR)$(incincdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(incincdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +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) + +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-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-incincHEADERS + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-incincHEADERS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic ctags \ + ctags-recursive 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-incincHEADERS install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-incincHEADERS + +# 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_aspacemgr.h b/include/pub_tool_aspacemgr.h new file mode 100644 index 0000000..f84dfa6 --- /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-2009 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..9bff837 --- /dev/null +++ b/include/pub_tool_basics.h @@ -0,0 +1,214 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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> + +/* For HAVE_BUILTIN_EXPECT */ +#include "config.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. +typedef Word OffT; // 32 64 +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, + res holds the return value, and err is zero. + When .isError == True, + err holds the error code, and res is zero. + + 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. +*/ +typedef + struct { + UWord res; + UWord err; + Bool isError; + } + SysRes; + + +/* --------------------------------------------------------------------- + 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) +# define VG_LITTLEENDIAN 1 +#elif defined(VGA_ppc32) || defined(VGA_ppc64) +# define VG_BIGENDIAN 1 +#endif + +/* Regparmness */ +#if defined(VGA_x86) +# define VG_REGPARM(n) __attribute__((regparm(n))) +#elif defined(VGA_amd64) || defined(VGA_ppc32) || defined(VGA_ppc64) +# 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 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 + + +#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..201c1b5 --- /dev/null +++ b/include/pub_tool_basics_asm.h @@ -0,0 +1,58 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#define VG_(str) VGAPPEND(vgPlain_, str) +#define ML_(str) VGAPPEND(vgModuleLocal_, str) + +#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..9a47fcc --- /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-2009 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 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..f200d12 --- /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-2009 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..9e994c5 --- /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-2009 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..e5ad9f7 --- /dev/null +++ b/include/pub_tool_debuginfo.h @@ -0,0 +1,236 @@ + +/*--------------------------------------------------------------------*/ +/*--- DebugInfo. pub_tool_debuginfo.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 (or as much as will + fit) is put into into dname{1,2}[0 .. n_dname-1] and is guaranteed + to be zero terminated. */ +extern Bool VG_(get_data_description)( /*OUT*/Char* dname1, + /*OUT*/Char* dname2, + Int n_dname, + 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 segment information ===*/ +/*====================================================================*/ + +/* A way to get information about what segments are mapped */ +typedef struct _DebugInfo DebugInfo; + +/* Returns NULL if the DebugInfo isn't found. It doesn't matter if + debug info is present or not. */ +extern DebugInfo* VG_(find_seginfo) ( Addr a ); + +/* Fish bits out of DebugInfos. */ +extern Addr VG_(seginfo_get_text_avma)( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_text_size)( const DebugInfo *di ); +extern Addr VG_(seginfo_get_plt_avma) ( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_plt_size) ( const DebugInfo *di ); +extern Addr VG_(seginfo_get_gotplt_avma)( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_gotplt_size)( const DebugInfo *di ); +extern const UChar* VG_(seginfo_soname) ( const DebugInfo *di ); +extern const UChar* VG_(seginfo_filename) ( const DebugInfo *di ); +extern PtrdiffT VG_(seginfo_get_text_bias)( const DebugInfo *di ); + +/* Function for traversing the seginfo list. When called with NULL it + returns the first element; otherwise it returns the given element's + successor. */ +extern const DebugInfo* VG_(next_seginfo) ( 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. */ +extern Int VG_(seginfo_syms_howmany) ( const DebugInfo *di ); +extern void VG_(seginfo_syms_getidx) ( const DebugInfo *di, + Int idx, + /*OUT*/Addr* avma, + /*OUT*/Addr* tocptr, + /*OUT*/UInt* size, + /*OUT*/HChar** name, + /*OUT*/Bool* isText ); + +/* 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. */ +extern +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). */ +extern +VgSectKind VG_(seginfo_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..0d22c1b --- /dev/null +++ b/include/pub_tool_errormgr.h @@ -0,0 +1,132 @@ +/*--------------------------------------------------------------------*/ +/*--- ErrorMgr: management of errors and suppressions. ---*/ +/*--- pub_tool_errormgr.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 of at most nBuf chars from fd. + Skips leading spaces on the line. Returns True if EOF was hit instead. + Useful for reading in extra tool-specific suppression lines. */ +extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ); + + +/* ------------------------------------------------------------------ */ +/* 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..3506026 --- /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-2009 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..6348799 --- /dev/null +++ b/include/pub_tool_hashtable.h @@ -0,0 +1,100 @@ + +/*--------------------------------------------------------------------*/ +/*--- A hash table implementation. pub_tool_hashtable.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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. */ +extern void VG_(HT_add_node) ( VgHashTable t, void* node ); + +/* Looks up a VgHashNode in the table. Returns NULL if not found. */ +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 all the hashtable elements + into it, then returns both the array and the size of it. This is + used by the memory-leak detector. 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..6e4f69a --- /dev/null +++ b/include/pub_tool_libcassert.h @@ -0,0 +1,64 @@ + +/*--------------------------------------------------------------------*/ +/*--- Assertions, etc. pub_tool_libcassert.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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, #expr, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, \ + ""), \ + 0))) + +#define tl_assert2(expr, format, args...) \ + ((void) ((expr) ? 0 : \ + (VG_(assert_fail) (/*isCore?*/False, #expr, \ + __FILE__, __LINE__, __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..4e627be --- /dev/null +++ b/include/pub_tool_libcbase.h @@ -0,0 +1,151 @@ + +/*--------------------------------------------------------------------*/ +/*--- Standalone libc stuff. pub_tool_libcbase.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 ); + +/* --------------------------------------------------------------------- + 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_(strncmp) ( const Char* s1, const Char* s2, SizeT nmax ); +extern Char* VG_(strstr) ( 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* accept ); +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 ); + +/* --------------------------------------------------------------------- + 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_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..f870109 --- /dev/null +++ b/include/pub_tool_libcfile.h @@ -0,0 +1,91 @@ + +/*--------------------------------------------------------------------*/ +/*--- File/socket-related libc stuff. pub_tool_libcfile.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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. */ +struct vg_stat { + ULong st_dev; + ULong st_ino; + ULong st_nlink; + UInt st_mode; + UInt st_uid; + UInt st_gid; + ULong st_rdev; + Long st_size; + ULong st_blksize; + ULong st_blocks; + ULong st_atime; + ULong st_atime_nsec; + ULong st_mtime; + ULong st_mtime_nsec; + ULong st_ctime; + ULong st_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) ( 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) ( Char* old_name, Char* new_name ); +extern Int VG_(unlink) ( Char* file_name ); + +extern Int VG_(readlink)( Char* path, Char* buf, UInt bufsize ); +extern Int VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count ); + +/* 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..b3386b2 --- /dev/null +++ b/include/pub_tool_libcprint.h @@ -0,0 +1,111 @@ + +/*--------------------------------------------------------------------*/ +/*--- Printing libc stuff. pub_tool_libcprint.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 + + +/* Enable compile-time format string checking by gcc. + This feature is supported since at least gcc version 2.95. + For more information about the format attribute, see also + 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 + + +/* --------------------------------------------------------------------- + Basic printing + ------------------------------------------------------------------ */ + +/* Note that they all output to the file descriptor given by the + * --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr). + * Hence no need for VG_(fprintf)(). + */ +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); +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[]); + +/* --------------------------------------------------------------------- + Messages for the user + ------------------------------------------------------------------ */ + +/* No, really. I _am_ that strange. */ +#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn) + +/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind. + Should be used for all user output. */ + +typedef + enum { Vg_UserMsg, /* '?' == '=' */ + Vg_DebugMsg, /* '?' == '-' */ + Vg_DebugExtraMsg, /* '?' == '+' */ + Vg_ClientMsg /* '?' == '*' */ + } + VgMsgKind; + +/* Send a single-part message. Appends a newline. The format + specification may contain any ISO C format specifier or %t. + No attempt is made to let the compiler verify consistency of the + format string and the argument list. */ +extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... ); +/* Send a single-part message. Appends a newline. The format + specification may contain any ISO C format specifier. The gcc compiler + will verify consistency of the format string and the argument list. */ +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)(). +#define VG_UMSG( format, args... ) VG_(message)(Vg_UserMsg, format, ##args) +#define VG_DMSG( format, args... ) VG_(message)(Vg_DebugMsg, format, ##args) +#define VG_EMSG( format, args... ) VG_(message)(Vg_DebugExtraMsg, \ + format, ##args) + +#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..cd668b1 --- /dev/null +++ b/include/pub_tool_libcproc.h @@ -0,0 +1,95 @@ + +/*--------------------------------------------------------------------*/ +/*--- Process-related libc stuff pub_tool_libcproc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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); + +/* --------------------------------------------------------------------- + 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..d8aa0f5 --- /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-2009 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..7301d51 --- /dev/null +++ b/include/pub_tool_machine.h @@ -0,0 +1,137 @@ + +/*--------------------------------------------------------------------*/ +/*--- Machine-related stuff. pub_tool_machine.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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_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? +#else +# error Unknown platform +#endif + +// Guest state accessors +extern Addr VG_(get_SP) ( ThreadId tid ); +extern Addr VG_(get_IP) ( ThreadId tid ); +extern Addr VG_(get_FP) ( ThreadId tid ); +extern Addr VG_(get_LR) ( ThreadId tid ); + +extern void VG_(set_SP) ( ThreadId tid, Addr sp ); +extern void VG_(set_IP) ( ThreadId tid, Addr ip ); + +// 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 Addr VG_(thread_get_stack_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..efab2c2 --- /dev/null +++ b/include/pub_tool_mallocfree.h @@ -0,0 +1,58 @@ + +/*--------------------------------------------------------------------*/ +/*--- MallocFree: high-level memory management. ---*/ +/*--- pub_tool_mallocfree.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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). +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..cab2101 --- /dev/null +++ b/include/pub_tool_options.h @@ -0,0 +1,198 @@ + +/*--------------------------------------------------------------------*/ +/*--- Command line options. pub_tool_options.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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_(err_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; \ + /* 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_(err_bad_option)(qq_arg); \ + /* Check bounds. */ \ + if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \ + VG_(message)(Vg_UserMsg, \ + "'%s' argument must be between %lld and %lld", \ + (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \ + VG_(err_bad_option)(qq_arg); \ + } \ + 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_(err_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); + +/* 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); + + +/* Call this if a recognised 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. + It returns a Bool so it can be used in the _CLO_ macros. */ +__attribute__((noreturn)) +extern void VG_(err_bad_option) ( Char* opt ); + +/* 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..687d34f --- /dev/null +++ b/include/pub_tool_oset.h @@ -0,0 +1,259 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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* ec, 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. +// - 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* ec, + 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)(). +// - 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* ec, + 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. +// +// * 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_Next) ( OSet* os ); + +// set up 'oset' for iteration so that the first key subsequently +// produced VG_(OSetGen_Next) is the smallest key in the map +// >= start_at. Naturally ">=" is defined by the comparison +// function supplied to VG_(OSetGen_Create). +extern void VG_(OSetGen_ResetIterAt) ( OSet* oset, const void* key ); + +#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..a249fb2 --- /dev/null +++ b/include/pub_tool_redir.h @@ -0,0 +1,205 @@ + +/*--------------------------------------------------------------------*/ +/*--- Redirections, etc. pub_tool_redir.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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) + + --> Zp (plus) + : --> Zc (colon) + . --> Zd (dot) + _ --> Zu (underscore) + - --> Zh (hyphen) + (space) --> Zs (space) + @ --> ZA (at) + Z --> ZZ (Z) + ( --> ZL (left) + ) --> ZR (right) + + 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. --------- */ + +/* --- 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) +#else +# error "Unknown platform" +#endif + +/* --- Soname of the GNU C++ library. --- */ + +// DDD: this one and those below should probably be conditionally compiled, +// as should all the redirects in the tools that use them. +#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 + +/* --- Sonames for Linux ELF linkers. --- */ + +#define VG_Z_LD_LINUX_SO_2 ldZhlinuxZdsoZd2 // ld-linux.so.2 +#define VG_Z_LD_LINUX_X86_64_SO_2 ldZhlinuxZhx86Zh64ZdsoZd2 // ld-linux-x86-64.so.2 +#define VG_Z_LD64_SO_1 ld64ZdsoZd1 // ld64.so.1 +#define VG_Z_LD_SO_1 ldZdsoZd1 // ld.so.1 + + +#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..9cb2e9e --- /dev/null +++ b/include/pub_tool_replacemalloc.h @@ -0,0 +1,74 @@ + +/*--------------------------------------------------------------------*/ +/*--- Malloc replacement. pub_tool_replacemalloc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 ); +extern void VG_(replacement_malloc_print_usage) ( void ); +extern void VG_(replacement_malloc_print_debug_usage) ( void ); + +#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..a1763b7 --- /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-2009 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..bb96018 --- /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-2009 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..29bb336 --- /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-2009 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..f17758b --- /dev/null +++ b/include/pub_tool_stacktrace.h @@ -0,0 +1,82 @@ +/*--------------------------------------------------------------------*/ +/*--- Stack traces: getting, traversing, printing. ---*/ +/*--- tool_stacktrace.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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. Doesn't go below main() unless +// --show-below-main=yes is set. +extern void VG_(apply_StackTrace)( void(*action)(UInt n, Addr ip), + 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..d572e87 --- /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-2009 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 300 + +/* 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..3a7c391 --- /dev/null +++ b/include/pub_tool_tooliface.h @@ -0,0 +1,643 @@ + +/*--------------------------------------------------------------------*/ +/*--- The core/tool interface. pub_tool_tooliface.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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 equal enough. `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), + + // 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. + Bool (*read_extra_suppression_info)(Int fd, Char* buf, Int nBuf, 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 any extra info for the error, for --gen-suppressions, + // including the newline. This is the inverse of + // VG_(tdict).tool_read_extra_suppression_info(). + void (*print_extra_suppression_info)(Error* err) +); + +/* 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. 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. + 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! +extern void VG_(needs_syscall_wrapper) ( + void (* pre_syscall)(ThreadId tid, UInt syscallno), + void (*post_syscall)(ThreadId tid, UInt syscallno, 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, + 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..75da646 --- /dev/null +++ b/include/pub_tool_vki.h @@ -0,0 +1,62 @@ + +/*--------------------------------------------------------------------*/ +/*--- Top level for kernel interface declarations. ---*/ +/*--- pub_tool_vki.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 Julian Seward + jseward@acm.org + Copyright (C) 2005-2009 Nicholas Nethercote + njn@valgrind.org + Copyright (C) 2006-2009 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" +#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..147a761 --- /dev/null +++ b/include/pub_tool_vkiscnums.h @@ -0,0 +1,88 @@ + +/*--------------------------------------------------------------------*/ +/*--- Top level for kernel interface system call numbers. ---*/ +/*--- pub_tool_vkiscnums.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 Nicholas Nethercote + njn@valgrind.org + Copyright (C) 2006-2009 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 the system call numbers. + + On Linux they are a bunch of #define'd constants of the form + __NR_name, and this file must contain nothing else, since it will + be included in assembly code (m_trampoline.S). + + On AIX the __NR_name consts are renamings of global variables which + tell us the number for each syscall. This elaboration is necessary + because on AIX the syscall numbers are not constant; they can be + different for each process (in principle; in practice they rarely + change). 32- and 64-bit AIX5 share a common "implementation". + + 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_vkiscnums.h. +*/ + +#ifndef __PUB_TOOL_VKISCNUMS_H +#define __PUB_TOOL_VKISCNUMS_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_ppc32_aix5) || defined(VGP_ppc64_aix5) +# include "vki/vki-scnums-aix5.h" + +/* Make it possible to include this file in assembly sources. */ +#if !defined(VG_IN_ASSEMBLY_SOURCE) + +/* Look up the name of a syscall, using the bindings previously + created by VG_(aix5_register_syscall), for the purposes of making + error messages. */ +extern UChar* VG_(aix5_sysno_to_sysname)( Int sysno ); + +#endif /* !defined(VG_IN_ASSEMBLY_SOURCE) */ + +#else +# error Unknown platform +#endif + +#endif // __PUB_TOOL_VKISCNUMS_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_wordfm.h b/include/pub_tool_wordfm.h new file mode 100644 index 0000000..57c57db --- /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-2009 Julian Seward + jseward@acm.org + + This code is based on previous work by Nicholas Nethercote + (coregrind/m_oset.c) which is + + Copyright (C) 2005-2009 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..111f63a --- /dev/null +++ b/include/pub_tool_xarray.h @@ -0,0 +1,115 @@ + +/*--------------------------------------------------------------------*/ +/*--- An expandable array implementation. pub_tool_xarray.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2007-2009 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 ); + +/* 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. */ +extern void VG_(dropTailXA) ( 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 ); + +#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..5b4b8af --- /dev/null +++ b/include/valgrind.h @@ -0,0 +1,3937 @@ +/* -*- 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-2009 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 + +#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). */ +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#if !defined(_AIX) && defined(__i386__) +# define PLAT_x86_linux 1 +#elif !defined(_AIX) && defined(__x86_64__) +# define PLAT_amd64_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__) +# define PLAT_ppc32_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__) +# define PLAT_ppc64_linux 1 +#elif defined(_AIX) && defined(__64BIT__) +# define PLAT_ppc64_aix5 1 +#elif defined(_AIX) && !defined(__64BIT__) +# define PLAT_ppc32_aix5 1 +#endif + + +/* If we're not compiling for our target platform, don't generate + any inline asms. */ +#if !defined(PLAT_x86_linux) && !defined(PLAT_amd64_linux) \ + && !defined(PLAT_ppc32_linux) && !defined(PLAT_ppc64_linux) \ + && !defined(PLAT_ppc32_aix5) && !defined(PLAT_ppc64_aix5) +# 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 ------------------------- */ + +#if defined(PLAT_x86_linux) + +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 */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +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 */ + +/* ------------------------ 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 */ + +/* ------------------------ 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. */ + +#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \ + _vgwZU_##soname##_##fnname + +#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \ + _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) + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +/* 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( \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $4, %%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( \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $8, %%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( \ + "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 $12, %%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( \ + "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 $20, %%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( \ + "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 $24, %%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( \ + "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 $28, %%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( \ + "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 $36, %%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( \ + "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 $40, %%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( \ + "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 $44, %%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 */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +/* 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" + +/* 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( \ + "subq $128,%%rsp\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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" \ + : /*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( \ + "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 */ \ + "addq $128,%%rsp\n\t" \ + VALGRIND_CALL_NOREDIR_RAX \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*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( \ + "subq $128,%%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 $128,%%rsp\n\t" \ + : /*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( \ + "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" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_amd64_linux */ + +/* ------------------------ 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 */ + +/* ------------------------ 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. */ + VG_USERREQ__PRINTF = 0x1401, + VG_USERREQ__PRINTF_BACKTRACE = 0x1402, + + /* 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 + } Vg_ClientRequest; + +#if !defined(__GNUC__) +# define __extension__ /* */ +#endif + +/* 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 __extension__ \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* if not */, \ + VG_USERREQ__RUNNING_ON_VALGRIND, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + }) + + +/* 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. */ + +#if defined(NVALGRIND) + +# define VALGRIND_PRINTF(...) +# define VALGRIND_PRINTF_BACKTRACE(...) + +#else /* NVALGRIND */ + +/* 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__)); +static int +VALGRIND_PRINTF(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF_BACKTRACE(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + 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; \ + }) + +/* Mark a block of memory as having been allocated by a malloc()-like + function. `addr' is the start of the usable block (ie. after any + redzone) `rzB' is redzone size if the allocator can apply redzones; + use '0' if not. Adding redzones makes it more likely Valgrind will spot + block overruns. `is_zeroed' indicates if the memory is zeroed, as it is + for calloc(). Put it immediately after the point where a block is + allocated. + + If you're using Memcheck: If you're allocating memory via superblocks, + and then handing out small chunks of each superblock, if you don't have + redzones on your small blocks, it's worth marking the superblock with + VALGRIND_MAKE_MEM_NOACCESS when it's created, so that block overruns are + detected. But if you can put redzones on, it's probably better to not do + this, so that messages for small overruns are described in terms of the + small block rather than the superblock (but if you have a big overrun + that skips over a redzone, you could miss an error this way). See + memcheck/tests/custom_alloc.c for an example. + + WARNING: if your allocator uses malloc() or 'new' to allocate + superblocks, rather than mmap() or brk(), this will not work properly -- + you'll likely get assertion failures during leak detection. This is + because Valgrind doesn't like seeing overlapping heap blocks. Sorry. + + Nb: block must be freed via a free()-like function specified + with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */ +#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); \ + } + +/* Mark a block of memory as having been freed by a free()-like function. + `rzB' is redzone size; it must match that given to + VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak + checker. Put it immediately after the point where the block is freed. */ +#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); \ + } + + +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#endif /* __VALGRIND_H */ diff --git a/include/vki/.svn/dir-prop-base b/include/vki/.svn/dir-prop-base new file mode 100644 index 0000000..a57f544 --- /dev/null +++ b/include/vki/.svn/dir-prop-base @@ -0,0 +1,7 @@ +K 10 +svn:ignore +V 21 +Makefile +Makefile.in + +END diff --git a/include/vki/.svn/entries b/include/vki/.svn/entries new file mode 100644 index 0000000..995dc9e --- /dev/null +++ b/include/vki/.svn/entries @@ -0,0 +1,236 @@ +8 + +dir +9703 +svn://svn.valgrind.org/valgrind/trunk/include/vki +svn://svn.valgrind.org/valgrind + + + +2009-04-30T05:23:22.182900Z +9700 +njn +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +a5019735-40e9-0310-863c-91ae7b9d1cf9 + +vki-posixtypes-x86-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +68cb51339fff6ae251041c6b94fcc3b3 +2009-03-10T22:02:09.669944Z +9344 +njn +has-props + +vki-amd64-linux.h +file + + + + +2009-04-30T16:43:59.000000Z +72393728151d8a41909a40489ca2e114 +2009-03-31T10:36:58.106193Z +9502 +tom + +vki-posixtypes-ppc32-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +65d331bb7845e77d4448302090235ce6 +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-scnums-aix5.h +file + + + + +2009-03-13T17:30:10.000000Z +7d0068d8eadfc9736052b419fe36917a +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-posixtypes-ppc64-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +072f05c2829817579a0b84ed9df3cebf +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-scnums-amd64-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +4968f8ecb8de473a98e3878ff2f1c18f +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-x86-linux.h +file + + + + +2009-04-30T16:43:59.000000Z +24ed0971cf426dbf8caebe04de9d237d +2009-03-31T10:36:58.106193Z +9502 +tom +has-props + +vki-ppc32-linux.h +file + + + + +2009-04-30T16:43:59.000000Z +2141629ec24b0112dfaf672029783343 +2009-03-31T10:36:58.106193Z +9502 +tom + +vki-scnums-x86-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +6246829035b6d887b8b4105b1b95ade1 +2009-03-10T22:02:09.669944Z +9344 +njn +has-props + +vki-ppc64-linux.h +file + + + + +2009-04-30T16:43:59.000000Z +9e012ed8313462b418a9dcf5332d1207 +2009-03-31T10:36:58.106193Z +9502 +tom + +vki-scnums-ppc32-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +4421ab85803370f4a419a9e0bd0bac49 +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-ppc32-aix5.h +file + + + + +2009-04-30T16:43:59.000000Z +90ccb189a061486087d6fbf703378dd5 +2009-04-30T05:23:22.182900Z +9700 +njn + +Makefile.am +file + + + + +2009-03-13T17:30:10.000000Z +973bbe412979500c5403de87ca2e44e7 +2007-12-02T02:06:46.998290Z +7264 +sewardj + +vki-posixtypes-amd64-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +f4ca4f2113d65b04f488556416ce9981 +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-scnums-ppc64-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +3f23272affb4003cc966476c62c3c507 +2009-03-10T22:02:09.669944Z +9344 +njn + +vki-linux.h +file + + + + +2009-03-13T17:30:10.000000Z +2a10b4455db795f93de421a0ef04bf4b +2009-03-10T22:02:09.669944Z +9344 +njn +has-props + +vki-ppc64-aix5.h +file + + + + +2009-04-30T16:43:59.000000Z +43e410aedd00b972452513c413ae3c76 +2009-04-30T05:23:22.182900Z +9700 +njn + diff --git a/include/vki/.svn/format b/include/vki/.svn/format new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/include/vki/.svn/format @@ -0,0 +1 @@ +8 diff --git a/include/vki/.svn/prop-base/vki-linux.h.svn-base b/include/vki/.svn/prop-base/vki-linux.h.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/vki/.svn/prop-base/vki-linux.h.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/vki/.svn/prop-base/vki-posixtypes-x86-linux.h.svn-base b/include/vki/.svn/prop-base/vki-posixtypes-x86-linux.h.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/vki/.svn/prop-base/vki-posixtypes-x86-linux.h.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/vki/.svn/prop-base/vki-scnums-x86-linux.h.svn-base b/include/vki/.svn/prop-base/vki-scnums-x86-linux.h.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/vki/.svn/prop-base/vki-scnums-x86-linux.h.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/vki/.svn/prop-base/vki-x86-linux.h.svn-base b/include/vki/.svn/prop-base/vki-x86-linux.h.svn-base new file mode 100644 index 0000000..df54a06 --- /dev/null +++ b/include/vki/.svn/prop-base/vki-x86-linux.h.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 12 +svn:keywords +V 23 +author date id revision +END diff --git a/include/vki/.svn/text-base/Makefile.am.svn-base b/include/vki/.svn/text-base/Makefile.am.svn-base new file mode 100644 index 0000000..137fe1d --- /dev/null +++ b/include/vki/.svn/text-base/Makefile.am.svn-base @@ -0,0 +1,22 @@ + +incincdir = $(includedir)/valgrind/vki + +incinc_HEADERS = \ + vki-linux.h \ + vki-posixtypes-amd64-linux.h \ + vki-posixtypes-ppc32-linux.h \ + vki-posixtypes-ppc64-linux.h \ + vki-posixtypes-x86-linux.h \ + vki-amd64-linux.h \ + vki-ppc32-linux.h \ + vki-ppc64-linux.h \ + vki-x86-linux.h \ + vki-scnums-amd64-linux.h \ + vki-scnums-ppc32-linux.h \ + vki-scnums-ppc64-linux.h \ + vki-scnums-x86-linux.h + +noinst_HEADERS = \ + vki-ppc32-aix5.h \ + vki-ppc64-aix5.h \ + vki-scnums-aix5.h diff --git a/include/vki/.svn/text-base/vki-amd64-linux.h.svn-base b/include/vki/.svn/text-base/vki-amd64-linux.h.svn-base new file mode 100644 index 0000000..50e7dcb --- /dev/null +++ b/include/vki/.svn/text-base/vki-amd64-linux.h.svn-base @@ -0,0 +1,659 @@ + +/*--------------------------------------------------------------------*/ +/*--- AMD64/Linux-specific kernel interface. vki-amd64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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.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 { + // [[Nb: a 'k' prefix is added to "sa_handler" because + // bits/sigaction.h (which gets dragged in somehow via signal.h) + // #defines it as something else. Since that is done for glibc's + // purposes, which we don't care about here, we use our own name.]] + __vki_sighandler_t ksa_handler; + unsigned long sa_flags; + __vki_sigrestore_t sa_restorer; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; + +typedef struct vki_sigaltstack { + void __user *ss_sp; + int ss_flags; + vki_size_t ss_size; +} vki_stack_t; + +//---------------------------------------------------------------------- +// From linux-2.6.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/.svn/text-base/vki-linux.h.svn-base b/include/vki/.svn/text-base/vki-linux.h.svn-base new file mode 100644 index 0000000..9f59836 --- /dev/null +++ b/include/vki/.svn/text-base/vki-linux.h.svn-base @@ -0,0 +1,2552 @@ + +/*--------------------------------------------------------------------*/ +/*--- Linux-specific kernel interface. vki-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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" +#else +# error Unknown platform +#endif + +//---------------------------------------------------------------------- +// 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" +#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 ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TICK 0x4000 /* tick value */ +//#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/times.h +//---------------------------------------------------------------------- + +struct vki_tms { + vki_clock_t tms_utime; + vki_clock_t tms_stime; + vki_clock_t tms_cutime; + vki_clock_t tms_cstime; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/utime.h +//---------------------------------------------------------------------- + +struct vki_utimbuf { + vki_time_t actime; + vki_time_t modtime; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sched.h +//---------------------------------------------------------------------- + +#define VKI_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) */ + +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.10-rc3-mm1/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_PRIVATE_FLAG (128) + +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_NOTIFY (VKI_F_LINUX_SPECIFIC_BASE+2) + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sysctl.h +//---------------------------------------------------------------------- + +struct __vki_sysctl_args { + int __user *name; + int nlen; + void __user *oldval; + vki_size_t __user *oldlenp; + void __user *newval; + vki_size_t newlen; + unsigned long __unused[4]; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/aio_abi.h +//---------------------------------------------------------------------- + +typedef unsigned long vki_aio_context_t; + +enum { + VKI_IOCB_CMD_PREAD = 0, + VKI_IOCB_CMD_PWRITE = 1, +}; + +/* read() from /dev/aio returns these structures. */ +struct vki_io_event { + __vki_u64 data; /* the data field from the iocb */ + __vki_u64 obj; /* what iocb this event came from */ + // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is + // a macro in vg_syscalls.c!]] + __vki_s64 result; /* result code for this event */ + __vki_s64 result2; /* secondary result */ +}; + +#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_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 */ + +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_RESUME = _VKI_IO('A', 0x47), + VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48), + 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_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) + +//---------------------------------------------------------------------- +// 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; +}; + + +#endif // __VKI_LINUX_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-posixtypes-amd64-linux.h.svn-base b/include/vki/.svn/text-base/vki-posixtypes-amd64-linux.h.svn-base new file mode 100644 index 0000000..f3f9bb0 --- /dev/null +++ b/include/vki/.svn/text-base/vki-posixtypes-amd64-linux.h.svn-base @@ -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-2009 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/.svn/text-base/vki-posixtypes-ppc32-linux.h.svn-base b/include/vki/.svn/text-base/vki-posixtypes-ppc32-linux.h.svn-base new file mode 100644 index 0000000..5cf1b2c --- /dev/null +++ b/include/vki/.svn/text-base/vki-posixtypes-ppc32-linux.h.svn-base @@ -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-2009 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/.svn/text-base/vki-posixtypes-ppc64-linux.h.svn-base b/include/vki/.svn/text-base/vki-posixtypes-ppc64-linux.h.svn-base new file mode 100644 index 0000000..28cf4c7 --- /dev/null +++ b/include/vki/.svn/text-base/vki-posixtypes-ppc64-linux.h.svn-base @@ -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-2009 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/.svn/text-base/vki-posixtypes-x86-linux.h.svn-base b/include/vki/.svn/text-base/vki-posixtypes-x86-linux.h.svn-base new file mode 100644 index 0000000..39fc88d --- /dev/null +++ b/include/vki/.svn/text-base/vki-posixtypes-x86-linux.h.svn-base @@ -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-2009 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/.svn/text-base/vki-ppc32-aix5.h.svn-base b/include/vki/.svn/text-base/vki-ppc32-aix5.h.svn-base new file mode 100644 index 0000000..0780d27 --- /dev/null +++ b/include/vki/.svn/text-base/vki-ppc32-aix5.h.svn-base @@ -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-2009 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/.svn/text-base/vki-ppc32-linux.h.svn-base b/include/vki/.svn/text-base/vki-ppc32-linux.h.svn-base new file mode 100644 index 0000000..074a8f8 --- /dev/null +++ b/include/vki/.svn/text-base/vki-ppc32-linux.h.svn-base @@ -0,0 +1,925 @@ + +/*--------------------------------------------------------------------*/ +/*--- PPC32/Linux-specific kernel interface. vki-ppc32-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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.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 + +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 { + // [[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 */ +}; + +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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __VKI_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __VKI_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode 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/.svn/text-base/vki-ppc64-aix5.h.svn-base b/include/vki/.svn/text-base/vki-ppc64-aix5.h.svn-base new file mode 100644 index 0000000..0e3e73f --- /dev/null +++ b/include/vki/.svn/text-base/vki-ppc64-aix5.h.svn-base @@ -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-2009 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/.svn/text-base/vki-ppc64-linux.h.svn-base b/include/vki/.svn/text-base/vki-ppc64-linux.h.svn-base new file mode 100644 index 0000000..063fc55 --- /dev/null +++ b/include/vki/.svn/text-base/vki-ppc64-linux.h.svn-base @@ -0,0 +1,766 @@ + +/*--------------------------------------------------------------------*/ +/*--- PPC64/Linux-specific kernel interface. vki-ppc64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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.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 { + __vki_sighandler_t ksa_handler; + unsigned long sa_flags; + __vki_sigrestore_t sa_restorer; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; + +typedef struct vki_sigaltstack { + void __user *ss_sp; + int ss_flags; + vki_size_t ss_size; +} vki_stack_t; + +//---------------------------------------------------------------------- +// From linux-2.6.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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr), \ + (_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \ + (_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \ + (type),(nr),(_VKI_IOC_TYPECHECK(size))) +#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/.svn/text-base/vki-scnums-aix5.h.svn-base b/include/vki/.svn/text-base/vki-scnums-aix5.h.svn-base new file mode 100644 index 0000000..c014b96 --- /dev/null +++ b/include/vki/.svn/text-base/vki-scnums-aix5.h.svn-base @@ -0,0 +1,1618 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +//-------------------------------------------------------------- +// Syscalls for AIX 5.2 running on ppc32 +//-------------------------------------------------------------- + +/* Make it possible to include this file in assembly sources. */ +#if !defined(VG_IN_ASSEMBLY_SOURCE) + +/* 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 /* !defined(VG_IN_ASSEMBLY_SOURCE) */ + + +#endif /* __VKI_SCNUMS_AIX5_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-scnums-amd64-linux.h.svn-base b/include/vki/.svn/text-base/vki-scnums-amd64-linux.h.svn-base new file mode 100644 index 0000000..d4b3fd7 --- /dev/null +++ b/include/vki/.svn/text-base/vki-scnums-amd64-linux.h.svn-base @@ -0,0 +1,384 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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_paccept 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 + +#endif /* __VKI_SCNUMS_AMD64_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-scnums-ppc32-linux.h.svn-base b/include/vki/.svn/text-base/vki-scnums-ppc32-linux.h.svn-base new file mode 100644 index 0000000..7ae5b23 --- /dev/null +++ b/include/vki/.svn/text-base/vki-scnums-ppc32-linux.h.svn-base @@ -0,0 +1,369 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#endif /* __VKI_SCNUMS_PPC32_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-scnums-ppc64-linux.h.svn-base b/include/vki/.svn/text-base/vki-scnums-ppc64-linux.h.svn-base new file mode 100644 index 0000000..1123a4e --- /dev/null +++ b/include/vki/.svn/text-base/vki-scnums-ppc64-linux.h.svn-base @@ -0,0 +1,361 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#endif /* __VKI_SCNUMS_PPC64_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-scnums-x86-linux.h.svn-base b/include/vki/.svn/text-base/vki-scnums-x86-linux.h.svn-base new file mode 100644 index 0000000..165b07e --- /dev/null +++ b/include/vki/.svn/text-base/vki-scnums-x86-linux.h.svn-base @@ -0,0 +1,375 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#endif /* __VKI_SCNUMS_X86_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/.svn/text-base/vki-x86-linux.h.svn-base b/include/vki/.svn/text-base/vki-x86-linux.h.svn-base new file mode 100644 index 0000000..13a4e4e --- /dev/null +++ b/include/vki/.svn/text-base/vki-x86-linux.h.svn-base @@ -0,0 +1,876 @@ + +/*--------------------------------------------------------------------*/ +/*--- x86/Linux-specific kernel interface. vki-x86-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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.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 { + // [[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 */ +}; + +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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __vki_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __vki_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode ioctl numbers.. */ +#define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) +#define _VKI_IOC_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 ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/Makefile b/include/vki/Makefile new file mode 100644 index 0000000..cbb7a7b --- /dev/null +++ b/include/vki/Makefile @@ -0,0 +1,437 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# include/vki/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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. + + + + +pkgdatadir = $(datadir)/valgrind +pkglibdir = $(libdir)/valgrind +pkgincludedir = $(includedir)/valgrind +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 = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = include/vki +DIST_COMMON = $(incinc_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 = +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 = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(incincdir)" +incincHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(incinc_HEADERS) $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/steph/compile/valgrind/missing --run aclocal-1.10 +AMTAR = ${SHELL} /home/steph/compile/valgrind/missing --run tar +AR = /usr/bin/ar +AUTOCONF = ${SHELL} /home/steph/compile/valgrind/missing --run autoconf +AUTOHEADER = ${SHELL} /home/steph/compile/valgrind/missing --run autoheader +AUTOMAKE = ${SHELL} /home/steph/compile/valgrind/missing --run automake-1.10 +AWK = gawk +BOOST_CFLAGS = +BOOST_LIBS = -lboost_thread-mt -m64 +CC = gcc +CCAS = gcc +CCASDEPMODE = depmode=gcc3 +CCASFLAGS = -Wno-long-long +CCDEPMODE = depmode=gcc3 +CFLAGS = -Wno-long-long -Wno-pointer-sign -Wdeclaration-after-statement -fno-stack-protector +CPP = gcc -E +CPPFLAGS = +CXX = g++ +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -g -O2 +CYGPATH_W = echo +DEFAULT_SUPP = exp-ptrcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DIFF = diff -u +DISTCHECK_CONFIGURE_FLAGS = --with-vex=$(top_srcdir)/VEX +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +FLAG_FNO_STACK_PROTECTOR = -fno-stack-protector +FLAG_M32 = -m32 +FLAG_M64 = -m64 +FLAG_MAIX32 = +FLAG_MAIX64 = +FLAG_MMMX = -mmmx +FLAG_MSSE = -msse +FLAG_UNLIMITED_INLINE_UNIT_GROWTH = --param inline-unit-growth=900 +FLAG_WDECL_AFTER_STMT = -Wdeclaration-after-statement +FLAG_W_EXTRA = -Wextra +FLAG_W_NO_FORMAT_ZERO_LENGTH = -Wno-format-zero-length +GDB = /usr/bin/gdb +GLIBC_VERSION = 2.8 +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LDFLAGS = +LIBOBJS = +LIBS = +LN_S = ln -s +LTLIBOBJS = +MAINT = # +MAKEINFO = ${SHELL} /home/steph/compile/valgrind/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +MPI_CC = mpicc +OBJEXT = o +PACKAGE = valgrind +PACKAGE_BUGREPORT = valgrind-users@lists.sourceforge.net +PACKAGE_NAME = Valgrind +PACKAGE_STRING = Valgrind 3.5.0.SVN +PACKAGE_TARNAME = valgrind +PACKAGE_VERSION = 3.5.0.SVN +PATH_SEPARATOR = : +PERL = /usr/bin/perl +PKG_CONFIG = /usr/bin/pkg-config +PREFERRED_STACK_BOUNDARY = +QTCORE_CFLAGS = -DQT_SHARED -I/usr/include/QtCore +QTCORE_LIBS = -lQtCore +RANLIB = ranlib +SET_MAKE = +SHELL = /bin/sh +STRIP = +VALT_LOAD_ADDRESS = 0x38000000 +VERSION = 3.5.0.SVN +VEX_DIR = $(top_srcdir)/VEX +VGCONF_ARCH_PRI = amd64 +VGCONF_OS = linux +VGCONF_PLATFORM_PRI_CAPS = AMD64_LINUX +VGCONF_PLATFORM_SEC_CAPS = +abs_builddir = /home/steph/compile/valgrind/include/vki +abs_srcdir = /home/steph/compile/valgrind/include/vki +abs_top_builddir = /home/steph/compile/valgrind +abs_top_srcdir = /home/steph/compile/valgrind +ac_ct_CC = gcc +ac_ct_CXX = g++ +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/steph/compile/valgrind/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_builddir = ../.. +top_srcdir = ../.. +incincdir = $(includedir)/valgrind/vki +incinc_HEADERS = \ + vki-linux.h \ + vki-posixtypes-amd64-linux.h \ + vki-posixtypes-ppc32-linux.h \ + vki-posixtypes-ppc64-linux.h \ + vki-posixtypes-x86-linux.h \ + vki-amd64-linux.h \ + vki-ppc32-linux.h \ + vki-ppc64-linux.h \ + vki-x86-linux.h \ + vki-scnums-amd64-linux.h \ + vki-scnums-ppc32-linux.h \ + vki-scnums-ppc64-linux.h \ + vki-scnums-x86-linux.h + +noinst_HEADERS = \ + vki-ppc32-aix5.h \ + vki-ppc64-aix5.h \ + vki-scnums-aix5.h + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/vki/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign include/vki/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: # $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): # $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-incincHEADERS: $(incinc_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(incincdir)" || $(MKDIR_P) "$(DESTDIR)$(incincdir)" + @list='$(incinc_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(incincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(incincdir)/$$f'"; \ + $(incincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(incincdir)/$$f"; \ + done + +uninstall-incincHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(incinc_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(incincdir)/$$f'"; \ + rm -f "$(DESTDIR)$(incincdir)/$$f"; \ + done + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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)$(incincdir)"; 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) + +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 + +info: info-am + +info-am: + +install-data-am: install-incincHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: 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-incincHEADERS + +.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-incincHEADERS install-info install-info-am install-man \ + 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-incincHEADERS + +# 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/vki/Makefile.am b/include/vki/Makefile.am new file mode 100644 index 0000000..137fe1d --- /dev/null +++ b/include/vki/Makefile.am @@ -0,0 +1,22 @@ + +incincdir = $(includedir)/valgrind/vki + +incinc_HEADERS = \ + vki-linux.h \ + vki-posixtypes-amd64-linux.h \ + vki-posixtypes-ppc32-linux.h \ + vki-posixtypes-ppc64-linux.h \ + vki-posixtypes-x86-linux.h \ + vki-amd64-linux.h \ + vki-ppc32-linux.h \ + vki-ppc64-linux.h \ + vki-x86-linux.h \ + vki-scnums-amd64-linux.h \ + vki-scnums-ppc32-linux.h \ + vki-scnums-ppc64-linux.h \ + vki-scnums-x86-linux.h + +noinst_HEADERS = \ + vki-ppc32-aix5.h \ + vki-ppc64-aix5.h \ + vki-scnums-aix5.h diff --git a/include/vki/Makefile.in b/include/vki/Makefile.in new file mode 100644 index 0000000..b6ea677 --- /dev/null +++ b/include/vki/Makefile.in @@ -0,0 +1,437 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@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/vki +DIST_COMMON = $(incinc_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 = +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 = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(incincdir)" +incincHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(incinc_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@ +DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ +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_UNLIMITED_INLINE_UNIT_GROWTH = @FLAG_UNLIMITED_INLINE_UNIT_GROWTH@ +FLAG_WDECL_AFTER_STMT = @FLAG_WDECL_AFTER_STMT@ +FLAG_W_EXTRA = @FLAG_W_EXTRA@ +FLAG_W_NO_FORMAT_ZERO_LENGTH = @FLAG_W_NO_FORMAT_ZERO_LENGTH@ +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_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@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VALT_LOAD_ADDRESS = @VALT_LOAD_ADDRESS@ +VERSION = @VERSION@ +VEX_DIR = @VEX_DIR@ +VGCONF_ARCH_PRI = @VGCONF_ARCH_PRI@ +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_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +incincdir = $(includedir)/valgrind/vki +incinc_HEADERS = \ + vki-linux.h \ + vki-posixtypes-amd64-linux.h \ + vki-posixtypes-ppc32-linux.h \ + vki-posixtypes-ppc64-linux.h \ + vki-posixtypes-x86-linux.h \ + vki-amd64-linux.h \ + vki-ppc32-linux.h \ + vki-ppc64-linux.h \ + vki-x86-linux.h \ + vki-scnums-amd64-linux.h \ + vki-scnums-ppc32-linux.h \ + vki-scnums-ppc64-linux.h \ + vki-scnums-x86-linux.h + +noinst_HEADERS = \ + vki-ppc32-aix5.h \ + vki-ppc64-aix5.h \ + 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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/vki/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign include/vki/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 +install-incincHEADERS: $(incinc_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(incincdir)" || $(MKDIR_P) "$(DESTDIR)$(incincdir)" + @list='$(incinc_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(incincHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(incincdir)/$$f'"; \ + $(incincHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(incincdir)/$$f"; \ + done + +uninstall-incincHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(incinc_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(incincdir)/$$f'"; \ + rm -f "$(DESTDIR)$(incincdir)/$$f"; \ + done + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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)$(incincdir)"; 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) + +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 + +info: info-am + +info-am: + +install-data-am: install-incincHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: 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-incincHEADERS + +.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-incincHEADERS install-info install-info-am install-man \ + 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-incincHEADERS + +# 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/vki/vki-amd64-linux.h b/include/vki/vki-amd64-linux.h new file mode 100644 index 0000000..50e7dcb --- /dev/null +++ b/include/vki/vki-amd64-linux.h @@ -0,0 +1,659 @@ + +/*--------------------------------------------------------------------*/ +/*--- AMD64/Linux-specific kernel interface. vki-amd64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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.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 { + // [[Nb: a 'k' prefix is added to "sa_handler" because + // bits/sigaction.h (which gets dragged in somehow via signal.h) + // #defines it as something else. Since that is done for glibc's + // purposes, which we don't care about here, we use our own name.]] + __vki_sighandler_t ksa_handler; + unsigned long sa_flags; + __vki_sigrestore_t sa_restorer; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; + +typedef struct vki_sigaltstack { + void __user *ss_sp; + int ss_flags; + vki_size_t ss_size; +} vki_stack_t; + +//---------------------------------------------------------------------- +// From linux-2.6.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-linux.h b/include/vki/vki-linux.h new file mode 100644 index 0000000..9f59836 --- /dev/null +++ b/include/vki/vki-linux.h @@ -0,0 +1,2552 @@ + +/*--------------------------------------------------------------------*/ +/*--- Linux-specific kernel interface. vki-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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" +#else +# error Unknown platform +#endif + +//---------------------------------------------------------------------- +// 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" +#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 ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TICK 0x4000 /* tick value */ +//#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/times.h +//---------------------------------------------------------------------- + +struct vki_tms { + vki_clock_t tms_utime; + vki_clock_t tms_stime; + vki_clock_t tms_cutime; + vki_clock_t tms_cstime; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/utime.h +//---------------------------------------------------------------------- + +struct vki_utimbuf { + vki_time_t actime; + vki_time_t modtime; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sched.h +//---------------------------------------------------------------------- + +#define VKI_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) */ + +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.10-rc3-mm1/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_PRIVATE_FLAG (128) + +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_NOTIFY (VKI_F_LINUX_SPECIFIC_BASE+2) + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sysctl.h +//---------------------------------------------------------------------- + +struct __vki_sysctl_args { + int __user *name; + int nlen; + void __user *oldval; + vki_size_t __user *oldlenp; + void __user *newval; + vki_size_t newlen; + unsigned long __unused[4]; +}; + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/aio_abi.h +//---------------------------------------------------------------------- + +typedef unsigned long vki_aio_context_t; + +enum { + VKI_IOCB_CMD_PREAD = 0, + VKI_IOCB_CMD_PWRITE = 1, +}; + +/* read() from /dev/aio returns these structures. */ +struct vki_io_event { + __vki_u64 data; /* the data field from the iocb */ + __vki_u64 obj; /* what iocb this event came from */ + // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is + // a macro in vg_syscalls.c!]] + __vki_s64 result; /* result code for this event */ + __vki_s64 result2; /* secondary result */ +}; + +#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_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 */ + +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_RESUME = _VKI_IO('A', 0x47), + VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48), + 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_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) + +//---------------------------------------------------------------------- +// 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; +}; + + +#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..f3f9bb0 --- /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-2009 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-ppc32-linux.h b/include/vki/vki-posixtypes-ppc32-linux.h new file mode 100644 index 0000000..5cf1b2c --- /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-2009 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..28cf4c7 --- /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-2009 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..39fc88d --- /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-2009 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..0780d27 --- /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-2009 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..074a8f8 --- /dev/null +++ b/include/vki/vki-ppc32-linux.h @@ -0,0 +1,925 @@ + +/*--------------------------------------------------------------------*/ +/*--- PPC32/Linux-specific kernel interface. vki-ppc32-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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.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 + +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 { + // [[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 */ +}; + +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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __VKI_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __VKI_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode 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..0e3e73f --- /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-2009 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..063fc55 --- /dev/null +++ b/include/vki/vki-ppc64-linux.h @@ -0,0 +1,766 @@ + +/*--------------------------------------------------------------------*/ +/*--- PPC64/Linux-specific kernel interface. vki-ppc64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2005-2009 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.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 { + __vki_sighandler_t ksa_handler; + unsigned long sa_flags; + __vki_sigrestore_t sa_restorer; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; + +typedef struct vki_sigaltstack { + void __user *ss_sp; + int ss_flags; + vki_size_t ss_size; +} vki_stack_t; + +//---------------------------------------------------------------------- +// From linux-2.6.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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr), \ + (_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr), \ + (_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE, \ + (type),(nr),(_VKI_IOC_TYPECHECK(size))) +#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..c014b96 --- /dev/null +++ b/include/vki/vki-scnums-aix5.h @@ -0,0 +1,1618 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +//-------------------------------------------------------------- +// Syscalls for AIX 5.2 running on ppc32 +//-------------------------------------------------------------- + +/* Make it possible to include this file in assembly sources. */ +#if !defined(VG_IN_ASSEMBLY_SOURCE) + +/* 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 /* !defined(VG_IN_ASSEMBLY_SOURCE) */ + + +#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..d4b3fd7 --- /dev/null +++ b/include/vki/vki-scnums-amd64-linux.h @@ -0,0 +1,384 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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_paccept 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 + +#endif /* __VKI_SCNUMS_AMD64_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/vki/vki-scnums-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h new file mode 100644 index 0000000..7ae5b23 --- /dev/null +++ b/include/vki/vki-scnums-ppc32-linux.h @@ -0,0 +1,369 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#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..1123a4e --- /dev/null +++ b/include/vki/vki-scnums-ppc64-linux.h @@ -0,0 +1,361 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#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..165b07e --- /dev/null +++ b/include/vki/vki-scnums-x86-linux.h @@ -0,0 +1,375 @@ + +/*--------------------------------------------------------------------*/ +/*--- 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-2009 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 + +#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..13a4e4e --- /dev/null +++ b/include/vki/vki-x86-linux.h @@ -0,0 +1,876 @@ + +/*--------------------------------------------------------------------*/ +/*--- x86/Linux-specific kernel interface. vki-x86-linux.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2009 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.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 { + // [[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 */ +}; + +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)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __vki_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __vki_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode ioctl numbers.. */ +#define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) +#define _VKI_IOC_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 ---*/ +/*--------------------------------------------------------------------*/ |