Home | History | Annotate | Download | only in vki
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- Linux-specific kernel interface.                 vki-linux.h ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2000-2012 Julian Seward
     11       jseward (at) acm.org
     12 
     13    This program is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License as
     15    published by the Free Software Foundation; either version 2 of the
     16    License, or (at your option) any later version.
     17 
     18    This program is distributed in the hope that it will be useful, but
     19    WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     21    General Public License for more details.
     22 
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     26    02111-1307, USA.
     27 
     28    The GNU General Public License is contained in the file COPYING.
     29 */
     30 
     31 /* This file defines types and constants for the kernel interface, and to
     32    make that clear everything is prefixed VKI_/vki_.
     33 
     34    All code is copied verbatim from kernel source files, except that:
     35    - VKI_/vki_ prefixes are added
     36    - some extra explanatory comments are included;  they are all within
     37      "[[ ]]"
     38    - for some types, we only care about the size;  for a few of them (big
     39      ones that are painful to fully drag in here), a VKI_SIZEOF_* constant
     40      is used.
     41 
     42    The files the code is taken from is indicated.
     43 
     44    Note especially that the types are not the glibc versions, many of which
     45    are different to those in here.
     46 
     47    Also note that this file contains all the generic header info, ie. that
     48    from linux/include/linux/ *.h.  The arch-specific header info, eg. that
     49    from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and
     50    vki_posixtypes-$PLATFORM.h.  (Two files are required to avoid
     51    circular dependencies between the generic VKI header and the
     52    arch-specific VKI header.  It's possible in the future, as more stuff
     53    gets pulled in, that we might have to split files up some more to avoid
     54    further circular dependencies.)
     55 
     56    Finally, note that it is assumed that __KERNEL__ is set for all these
     57    definitions, which affects some of them.
     58 */
     59 
     60 /* The structure is (aiui, jrs 20060504):
     61 
     62      #include plat-specific posix types (vki-posixtypes-ARCH-linux.h)
     63 
     64      Lots more types, structs, consts, in this file
     65 
     66      #include other plat-specific stuff (vki-ARCH-linux.h)
     67 
     68      Even more types, structs, consts, in this file
     69 
     70    The system call numbers are dealt with by
     71    pub_{core,tool}_vkiscnums.h, not via pub_{core,tool}_vki.h, which
     72    is what this file is part of.
     73 */
     74 
     75 #ifndef __VKI_LINUX_H
     76 #define __VKI_LINUX_H
     77 
     78 //----------------------------------------------------------------------
     79 // Arch-specific POSIX types
     80 //----------------------------------------------------------------------
     81 
     82 #if defined(VGA_x86)
     83 #  include "vki-posixtypes-x86-linux.h"
     84 #elif defined(VGA_amd64)
     85 #  include "vki-posixtypes-amd64-linux.h"
     86 #elif defined(VGA_ppc32)
     87 #  include "vki-posixtypes-ppc32-linux.h"
     88 #elif defined(VGA_ppc64)
     89 #  include "vki-posixtypes-ppc64-linux.h"
     90 #elif defined(VGA_arm)
     91 #  include "vki-posixtypes-arm-linux.h"
     92 #elif defined(VGA_s390x)
     93 #  include "vki-posixtypes-s390x-linux.h"
     94 #elif defined(VGA_mips32)
     95 #  include "vki-posixtypes-mips32-linux.h"
     96 #else
     97 #  error Unknown platform
     98 #endif
     99 
    100 //----------------------------------------------------------------------
    101 // VKI_STATIC_ASSERT(). Inspired by BUILD_BUG_ON() from
    102 // linux-2.6.34/include/linux/kernel.h
    103 //----------------------------------------------------------------------
    104 
    105 /*
    106  * Evaluates to zero if 'expr' is true and forces a compilation error if
    107  * 'expr' is false. Can be used in a context where no comma expressions
    108  * are allowed.
    109  */
    110 #ifdef __cplusplus
    111 template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
    112 #define VKI_STATIC_ASSERT(expr)                         \
    113     (sizeof(vki_static_assert<(expr)>) - sizeof(int))
    114 #else
    115 #define VKI_STATIC_ASSERT(expr) (sizeof(struct { int:-!(expr); }))
    116 #endif
    117 
    118 //----------------------------------------------------------------------
    119 // Based on _IOC_TYPECHECK() from linux-2.6.34/asm-generic/ioctl.h
    120 //----------------------------------------------------------------------
    121 
    122 /* provoke compile error for invalid uses of size argument */
    123 #define _VKI_IOC_TYPECHECK(t)                                           \
    124     (VKI_STATIC_ASSERT((sizeof(t) == sizeof(t[1])                       \
    125                         && sizeof(t) < (1 << _VKI_IOC_SIZEBITS)))       \
    126      + sizeof(t))
    127 
    128 //----------------------------------------------------------------------
    129 // From linux-2.6.8.1/include/linux/compiler.h
    130 //----------------------------------------------------------------------
    131 
    132 # define __user
    133 
    134 //----------------------------------------------------------------------
    135 // From linux/include/linux/compiler-gcc.h
    136 //----------------------------------------------------------------------
    137 
    138 #ifdef __GNUC__
    139 #define __vki_packed			__attribute__((packed))
    140 #endif
    141 
    142 //----------------------------------------------------------------------
    143 // From linux-2.6.8.1/include/linux/posix_types.h
    144 //----------------------------------------------------------------------
    145 
    146 #undef __VKI_NFDBITS
    147 #define __VKI_NFDBITS	(8 * sizeof(unsigned long))
    148 
    149 #undef __VKI_FD_SETSIZE
    150 #define __VKI_FD_SETSIZE	1024
    151 
    152 #undef __VKI_FDSET_LONGS
    153 #define __VKI_FDSET_LONGS	(__VKI_FD_SETSIZE/__VKI_NFDBITS)
    154 
    155 #undef __VKI_FDELT
    156 #define	__VKI_FDELT(d)	((d) / __VKI_NFDBITS)
    157 
    158 #undef __VKI_FDMASK
    159 #define	__VKI_FDMASK(d)	(1UL << ((d) % __VKI_NFDBITS))
    160 
    161 typedef struct {
    162 	unsigned long fds_bits [__VKI_FDSET_LONGS];
    163 } __vki_kernel_fd_set;
    164 
    165 typedef int __vki_kernel_key_t;
    166 typedef int __vki_kernel_mqd_t;
    167 
    168 //----------------------------------------------------------------------
    169 // From linux-2.6.8.1/include/linux/types.h
    170 //----------------------------------------------------------------------
    171 
    172 typedef __vki_kernel_fd_set	vki_fd_set;
    173 typedef __vki_kernel_mode_t	vki_mode_t;
    174 typedef __vki_kernel_off_t	vki_off_t;
    175 typedef __vki_kernel_pid_t	vki_pid_t;
    176 typedef __vki_kernel_key_t	vki_key_t;
    177 typedef __vki_kernel_suseconds_t	vki_suseconds_t;
    178 typedef __vki_kernel_timer_t	vki_timer_t;
    179 typedef __vki_kernel_clockid_t	vki_clockid_t;
    180 typedef __vki_kernel_mqd_t	vki_mqd_t;
    181 
    182 // [[Nb: it's a bit unclear due to a #ifdef, but I think this is right. --njn]]
    183 typedef __vki_kernel_uid32_t	vki_uid_t;
    184 typedef __vki_kernel_gid32_t	vki_gid_t;
    185 
    186 typedef __vki_kernel_old_uid_t	vki_old_uid_t;
    187 typedef __vki_kernel_old_gid_t	vki_old_gid_t;
    188 
    189 typedef __vki_kernel_loff_t	vki_loff_t;
    190 
    191 typedef __vki_kernel_size_t	vki_size_t;
    192 typedef __vki_kernel_time_t	vki_time_t;
    193 typedef __vki_kernel_clock_t	vki_clock_t;
    194 typedef __vki_kernel_caddr_t	vki_caddr_t;
    195 
    196 typedef unsigned long           vki_u_long;
    197 
    198 typedef unsigned int	        vki_uint;
    199 
    200 //----------------------------------------------------------------------
    201 // Now the rest of the arch-specific stuff
    202 //----------------------------------------------------------------------
    203 
    204 #if defined(VGA_x86)
    205 #  include "vki-x86-linux.h"
    206 #elif defined(VGA_amd64)
    207 #  include "vki-amd64-linux.h"
    208 #elif defined(VGA_ppc32)
    209 #  include "vki-ppc32-linux.h"
    210 #elif defined(VGA_ppc64)
    211 #  include "vki-ppc64-linux.h"
    212 #elif defined(VGA_arm)
    213 #  include "vki-arm-linux.h"
    214 #elif defined(VGA_s390x)
    215 #  include "vki-s390x-linux.h"
    216 #elif defined(VGA_mips32)
    217 #  include "vki-mips32-linux.h"
    218 #else
    219 #  error Unknown platform
    220 #endif
    221 
    222 //----------------------------------------------------------------------
    223 // From linux-2.6.20.1/include/linux/types.h
    224 //----------------------------------------------------------------------
    225 
    226 typedef		__vki_s32	vki_int32_t;
    227 typedef		__vki_s64	vki_int64_t;
    228 
    229 typedef		__vki_u8	vki_uint8_t;
    230 typedef		__vki_u16	vki_uint16_t;
    231 typedef		__vki_u32	vki_uint32_t;
    232 
    233 typedef		__vki_u16	__vki_le16;
    234 
    235 //----------------------------------------------------------------------
    236 // From linux-2.6.8.1/include/linux/limits.h
    237 //----------------------------------------------------------------------
    238 
    239 #define VKI_PATH_MAX       4096	/* # chars in a path name including nul */
    240 
    241 //----------------------------------------------------------------------
    242 // From linux-2.6.8.1/include/linux/kernel.h
    243 //----------------------------------------------------------------------
    244 
    245 struct vki_sysinfo {
    246 	long uptime;			/* Seconds since boot */
    247 	unsigned long loads[3];		/* 1, 5, and 15 minute load averages */
    248 	unsigned long totalram;		/* Total usable main memory size */
    249 	unsigned long freeram;		/* Available memory size */
    250 	unsigned long sharedram;	/* Amount of shared memory */
    251 	unsigned long bufferram;	/* Memory used by buffers */
    252 	unsigned long totalswap;	/* Total swap space size */
    253 	unsigned long freeswap;		/* swap space still available */
    254 	unsigned short procs;		/* Number of current processes */
    255 	unsigned short pad;		/* explicit padding for m68k */
    256 	unsigned long totalhigh;	/* Total high memory size */
    257 	unsigned long freehigh;		/* Available high memory size */
    258 	unsigned int mem_unit;		/* Memory unit size in bytes */
    259 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
    260 };
    261 
    262 //----------------------------------------------------------------------
    263 // From linux-2.6.8.1/include/linux/time.h
    264 //----------------------------------------------------------------------
    265 
    266 #define VKI_CLOCK_REALTIME            0
    267 #define VKI_CLOCK_MONOTONIC           1
    268 #define VKI_CLOCK_PROCESS_CPUTIME_ID  2
    269 #define VKI_CLOCK_THREAD_CPUTIME_ID   3
    270 
    271 struct vki_timespec {
    272 	vki_time_t	tv_sec;		/* seconds */
    273 	long		tv_nsec;	/* nanoseconds */
    274 };
    275 
    276 struct vki_timeval {
    277 	vki_time_t	tv_sec;		/* seconds */
    278 	vki_suseconds_t	tv_usec;	/* microseconds */
    279 };
    280 
    281 struct vki_timezone {
    282 	int	tz_minuteswest;	/* minutes west of Greenwich */
    283 	int	tz_dsttime;	/* type of dst correction */
    284 };
    285 
    286 struct  vki_itimerspec {
    287         struct  vki_timespec it_interval;    /* timer period */
    288         struct  vki_timespec it_value;       /* timer expiration */
    289 };
    290 
    291 struct	vki_itimerval {
    292 	struct	vki_timeval it_interval;	/* timer interval */
    293 	struct	vki_timeval it_value;	/* current value */
    294 };
    295 
    296 //----------------------------------------------------------------------
    297 // From linux-2.6.8.1/include/linux/timex.h
    298 //----------------------------------------------------------------------
    299 
    300 struct vki_timex {
    301 	unsigned int modes;	/* mode selector */
    302 	long offset;		/* time offset (usec) */
    303 	long freq;		/* frequency offset (scaled ppm) */
    304 	long maxerror;		/* maximum error (usec) */
    305 	long esterror;		/* estimated error (usec) */
    306 	int status;		/* clock command/status */
    307 	long constant;		/* pll time constant */
    308 	long precision;		/* clock precision (usec) (read only) */
    309 	long tolerance;		/* clock frequency tolerance (ppm)
    310 				 * (read only)
    311 				 */
    312 	struct vki_timeval time;	/* (read only) */
    313 	long tick;		/* (modified) usecs between clock ticks */
    314 
    315 	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
    316 	long jitter;            /* pps jitter (us) (ro) */
    317 	int shift;              /* interval duration (s) (shift) (ro) */
    318 	long stabil;            /* pps stability (scaled ppm) (ro) */
    319 	long jitcnt;            /* jitter limit exceeded (ro) */
    320 	long calcnt;            /* calibration intervals (ro) */
    321 	long errcnt;            /* calibration errors (ro) */
    322 	long stbcnt;            /* stability limit exceeded (ro) */
    323 
    324 	int  :32; int  :32; int  :32; int  :32;
    325 	int  :32; int  :32; int  :32; int  :32;
    326 	int  :32; int  :32; int  :32; int  :32;
    327 };
    328 
    329 #define VKI_ADJ_OFFSET			0x0001	/* time offset */
    330 #define VKI_ADJ_FREQUENCY		0x0002	/* frequency offset */
    331 #define VKI_ADJ_MAXERROR		0x0004	/* maximum time error */
    332 #define VKI_ADJ_ESTERROR		0x0008	/* estimated time error */
    333 #define VKI_ADJ_STATUS			0x0010	/* clock status */
    334 #define VKI_ADJ_TIMECONST		0x0020	/* pll time constant */
    335 #define VKI_ADJ_TAI			0x0080	/* set TAI offset */
    336 #define VKI_ADJ_TICK			0x4000	/* tick value */
    337 #define VKI_ADJ_ADJTIME			0x8000	/* switch between adjtime/adjtimex modes */
    338 //#define VKI_ADJ_OFFSET_SINGLESHOT	0x8001	/* old-fashioned adjtime */
    339 #define VKI_ADJ_OFFSET_READONLY		0x2000	/* read-only adjtime */
    340 
    341 //----------------------------------------------------------------------
    342 // From linux-2.6.8.1/include/linux/times.h
    343 //----------------------------------------------------------------------
    344 
    345 struct vki_tms {
    346 	vki_clock_t tms_utime;
    347 	vki_clock_t tms_stime;
    348 	vki_clock_t tms_cutime;
    349 	vki_clock_t tms_cstime;
    350 };
    351 
    352 //----------------------------------------------------------------------
    353 // From linux-2.6.8.1/include/linux/utime.h
    354 //----------------------------------------------------------------------
    355 
    356 struct vki_utimbuf {
    357 	vki_time_t actime;
    358 	vki_time_t modtime;
    359 };
    360 
    361 //----------------------------------------------------------------------
    362 // From linux-2.6.8.1/include/linux/sched.h
    363 //----------------------------------------------------------------------
    364 
    365 #define VKI_CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
    366 #define VKI_CLONE_VM		0x00000100	/* set if VM shared between processes */
    367 #define VKI_CLONE_FS		0x00000200	/* set if fs info shared between processes */
    368 #define VKI_CLONE_FILES		0x00000400	/* set if open files shared between processes */
    369 #define VKI_CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
    370 #define VKI_CLONE_VFORK		0x00004000	/* set if the parent wants the child to wake it up on mm_release */
    371 #define VKI_CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
    372 #define VKI_CLONE_THREAD	0x00010000	/* Same thread group? */
    373 #define VKI_CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
    374 #define VKI_CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
    375 #define VKI_CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
    376 #define VKI_CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
    377 #define VKI_CLONE_DETACHED	0x00400000	/* Unused, ignored */
    378 #define VKI_CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
    379 
    380 struct vki_sched_param {
    381 	int sched_priority;
    382 };
    383 
    384 #define VKI_TASK_COMM_LEN 16
    385 
    386 //----------------------------------------------------------------------
    387 // From linux-2.6.8.1/include/asm-generic/siginfo.h
    388 //----------------------------------------------------------------------
    389 
    390 // Some archs, such as MIPS, have non-standard vki_siginfo.
    391 #ifndef HAVE_ARCH_SIGINFO_T
    392 typedef union vki_sigval {
    393 	int sival_int;
    394 	void __user *sival_ptr;
    395 } vki_sigval_t;
    396 
    397 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE
    398 #define __VKI_ARCH_SI_PREAMBLE_SIZE	(3 * sizeof(int))
    399 #endif
    400 
    401 #define VKI_SI_MAX_SIZE	128
    402 
    403 #ifndef VKI_SI_PAD_SIZE
    404 #define VKI_SI_PAD_SIZE	((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
    405 #endif
    406 
    407 #ifndef __VKI_ARCH_SI_UID_T
    408 #define __VKI_ARCH_SI_UID_T	vki_uid_t
    409 #endif
    410 
    411 #ifndef __VKI_ARCH_SI_BAND_T
    412 #define __VKI_ARCH_SI_BAND_T long
    413 #endif
    414 
    415 // [[Nb: this type changed between 2.4 and 2.6, but not in a way that
    416 // affects Valgrind.]]
    417 typedef struct vki_siginfo {
    418 	int si_signo;
    419 	int si_errno;
    420 	int si_code;
    421 
    422 	union {
    423 		int _pad[VKI_SI_PAD_SIZE];
    424 
    425 		/* kill() */
    426 		struct {
    427 			vki_pid_t _pid;		/* sender's pid */
    428 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    429 		} _kill;
    430 
    431 		/* POSIX.1b timers */
    432 		struct {
    433 			vki_timer_t _tid;		/* timer id */
    434 			int _overrun;		/* overrun count */
    435 			char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)];
    436 			vki_sigval_t _sigval;	/* same as below */
    437 			int _sys_private;       /* not to be passed to user */
    438 		} _timer;
    439 
    440 		/* POSIX.1b signals */
    441 		struct {
    442 			vki_pid_t _pid;		/* sender's pid */
    443 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    444 			vki_sigval_t _sigval;
    445 		} _rt;
    446 
    447 		/* SIGCHLD */
    448 		struct {
    449 			vki_pid_t _pid;		/* which child */
    450 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    451 			int _status;		/* exit code */
    452 			vki_clock_t _utime;
    453 			vki_clock_t _stime;
    454 		} _sigchld;
    455 
    456 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
    457 		struct {
    458 			void __user *_addr; /* faulting insn/memory ref. */
    459 #ifdef __ARCH_SI_TRAPNO
    460 			int _trapno;	/* TRAP # which caused the signal */
    461 #endif
    462 		} _sigfault;
    463 
    464 		/* SIGPOLL */
    465 		struct {
    466 			__VKI_ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
    467 			int _fd;
    468 		} _sigpoll;
    469 	} _sifields;
    470 } vki_siginfo_t;
    471 #endif
    472 
    473 #define __VKI_SI_FAULT	0
    474 
    475 /*
    476  * si_code values
    477  * Digital reserves positive values for kernel-generated signals.
    478  */
    479 #define VKI_SI_USER	0		/* sent by kill, sigsend, raise */
    480 #define VKI_SI_TKILL	-6		/* sent by tkill system call */
    481 
    482 /*
    483  * SIGILL si_codes
    484  */
    485 #define VKI_ILL_ILLOPC	(__VKI_SI_FAULT|1)	/* illegal opcode */
    486 #define VKI_ILL_ILLOPN	(__VKI_SI_FAULT|2)	/* illegal operand */
    487 #define VKI_ILL_ILLADR	(__VKI_SI_FAULT|3)	/* illegal addressing mode */
    488 #define VKI_ILL_ILLTRP	(__VKI_SI_FAULT|4)	/* illegal trap */
    489 #define VKI_ILL_PRVOPC	(__VKI_SI_FAULT|5)	/* privileged opcode */
    490 #define VKI_ILL_PRVREG	(__VKI_SI_FAULT|6)	/* privileged register */
    491 #define VKI_ILL_COPROC	(__VKI_SI_FAULT|7)	/* coprocessor error */
    492 #define VKI_ILL_BADSTK	(__VKI_SI_FAULT|8)	/* internal stack error */
    493 
    494 /*
    495  * SIGFPE si_codes
    496  */
    497 #define VKI_FPE_INTDIV	(__VKI_SI_FAULT|1)	/* integer divide by zero */
    498 #define VKI_FPE_INTOVF	(__VKI_SI_FAULT|2)	/* integer overflow */
    499 #define VKI_FPE_FLTDIV	(__VKI_SI_FAULT|3)	/* floating point divide by zero */
    500 #define VKI_FPE_FLTOVF	(__VKI_SI_FAULT|4)	/* floating point overflow */
    501 #define VKI_FPE_FLTUND	(__VKI_SI_FAULT|5)	/* floating point underflow */
    502 #define VKI_FPE_FLTRES	(__VKI_SI_FAULT|6)	/* floating point inexact result */
    503 #define VKI_FPE_FLTINV	(__VKI_SI_FAULT|7)	/* floating point invalid operation */
    504 #define VKI_FPE_FLTSUB	(__VKI_SI_FAULT|8)	/* subscript out of range */
    505 
    506 /*
    507  * SIGSEGV si_codes
    508  */
    509 #define VKI_SEGV_MAPERR	(__VKI_SI_FAULT|1)	/* address not mapped to object */
    510 #define VKI_SEGV_ACCERR	(__VKI_SI_FAULT|2)	/* invalid permissions for mapped object */
    511 
    512 /*
    513  * SIGBUS si_codes
    514  */
    515 #define VKI_BUS_ADRALN	(__VKI_SI_FAULT|1)	/* invalid address alignment */
    516 #define VKI_BUS_ADRERR	(__VKI_SI_FAULT|2)	/* non-existant physical address */
    517 #define VKI_BUS_OBJERR	(__VKI_SI_FAULT|3)	/* object specific hardware error */
    518 
    519 /*
    520  * SIGTRAP si_codes
    521  */
    522 #define VKI_TRAP_BRKPT      (__VKI_SI_FAULT|1)  /* process breakpoint */
    523 #define VKI_TRAP_TRACE      (__VKI_SI_FAULT|2)  /* process trace trap */
    524 
    525 /*
    526  * This works because the alignment is ok on all current architectures
    527  * but we leave open this being overridden in the future
    528  */
    529 #ifndef VKI___ARCH_SIGEV_PREAMBLE_SIZE
    530 #define VKI___ARCH_SIGEV_PREAMBLE_SIZE	(sizeof(int) * 2 + sizeof(vki_sigval_t))
    531 #endif
    532 
    533 #define VKI_SIGEV_MAX_SIZE	64
    534 #define VKI_SIGEV_PAD_SIZE	((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
    535 		/ sizeof(int))
    536 
    537 typedef struct vki_sigevent {
    538 	vki_sigval_t sigev_value;
    539 	int sigev_signo;
    540 	int sigev_notify;
    541 	union {
    542 		int _pad[VKI_SIGEV_PAD_SIZE];
    543 		 int _tid;
    544 
    545 		struct {
    546 			void (*_function)(vki_sigval_t);
    547 			void *_attribute;	/* really pthread_attr_t */
    548 		} _sigev_thread;
    549 	} _sigev_un;
    550 } vki_sigevent_t;
    551 
    552 //----------------------------------------------------------------------
    553 // From elsewhere...
    554 //----------------------------------------------------------------------
    555 
    556 // [[The kernel actually uses the numbers 0,1,2 directly here, believe it or
    557 // not.  So we introduce our own constants, based on the glibc ones.]]
    558 #define VKI_SEEK_SET              0
    559 #define VKI_SEEK_CUR              1
    560 #define VKI_SEEK_END              2
    561 
    562 //----------------------------------------------------------------------
    563 // From linux-2.6.8.1/include/linux/net.h
    564 //----------------------------------------------------------------------
    565 
    566 #define VKI_SYS_SOCKET		1	/* sys_socket(2)		*/
    567 #define VKI_SYS_BIND		2	/* sys_bind(2)			*/
    568 #define VKI_SYS_CONNECT		3	/* sys_connect(2)		*/
    569 #define VKI_SYS_LISTEN		4	/* sys_listen(2)		*/
    570 #define VKI_SYS_ACCEPT		5	/* sys_accept(2)		*/
    571 #define VKI_SYS_GETSOCKNAME	6	/* sys_getsockname(2)		*/
    572 #define VKI_SYS_GETPEERNAME	7	/* sys_getpeername(2)		*/
    573 #define VKI_SYS_SOCKETPAIR	8	/* sys_socketpair(2)		*/
    574 #define VKI_SYS_SEND		9	/* sys_send(2)			*/
    575 #define VKI_SYS_RECV		10	/* sys_recv(2)			*/
    576 #define VKI_SYS_SENDTO		11	/* sys_sendto(2)		*/
    577 #define VKI_SYS_RECVFROM	12	/* sys_recvfrom(2)		*/
    578 #define VKI_SYS_SHUTDOWN	13	/* sys_shutdown(2)		*/
    579 #define VKI_SYS_SETSOCKOPT	14	/* sys_setsockopt(2)		*/
    580 #define VKI_SYS_GETSOCKOPT	15	/* sys_getsockopt(2)		*/
    581 #define VKI_SYS_SENDMSG		16	/* sys_sendmsg(2)		*/
    582 #define VKI_SYS_RECVMSG		17	/* sys_recvmsg(2)		*/
    583 #define VKI_SYS_ACCEPT4		18	/* sys_accept4(2)		*/
    584 
    585 enum vki_sock_type {
    586 	VKI_SOCK_STREAM	= 1,
    587 	// [[others omitted]]
    588 };
    589 
    590 //----------------------------------------------------------------------
    591 // From linux-2.6.8.1/include/linux/uio.h
    592 //----------------------------------------------------------------------
    593 
    594 struct vki_iovec
    595 {
    596 	void __user *iov_base;	/* BSD uses caddr_t (1003.1g requires void *) */
    597 	__vki_kernel_size_t iov_len; /* Must be size_t (1003.1g) */
    598 };
    599 
    600 //----------------------------------------------------------------------
    601 // From linux-2.6.8.1/include/linux/socket.h
    602 //----------------------------------------------------------------------
    603 
    604 // [[Resolved arbitrarily;  doesn't really matter whether it's '__inline__'
    605 //   or 'inline']]
    606 #define __KINLINE static __inline__
    607 
    608 typedef unsigned short	vki_sa_family_t;
    609 
    610 struct vki_sockaddr {
    611 	vki_sa_family_t	sa_family;	/* address family, AF_xxx	*/
    612 	char		sa_data[14];	/* 14 bytes of protocol address	*/
    613 };
    614 
    615 struct vki_msghdr {
    616 	void	*	msg_name;	/* Socket name			*/
    617 	int		msg_namelen;	/* Length of name		*/
    618 	struct vki_iovec *	msg_iov;	/* Data blocks			*/
    619 	__vki_kernel_size_t	msg_iovlen;	/* Number of blocks		*/
    620 	void 	*	msg_control;	/* Per protocol magic (eg BSD file descriptor passing) */
    621 	__vki_kernel_size_t	msg_controllen;	/* Length of cmsg list */
    622 	unsigned	msg_flags;
    623 };
    624 
    625 struct vki_mmsghdr {
    626 	struct vki_msghdr   msg_hdr;
    627 	unsigned        msg_len;
    628 };
    629 
    630 struct vki_cmsghdr {
    631 	__vki_kernel_size_t	cmsg_len;	/* data byte count, including hdr */
    632         int		cmsg_level;	/* originating protocol */
    633         int		cmsg_type;	/* protocol-specific type */
    634 };
    635 
    636 #define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
    637 #define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
    638 
    639 #define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
    640 
    641 #define VKI_CMSG_DATA(cmsg)	((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
    642 
    643 #define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
    644 				  (struct vki_cmsghdr *)(ctl) : \
    645 				  (struct vki_cmsghdr *)NULL)
    646 #define VKI_CMSG_FIRSTHDR(msg)	__VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
    647 
    648 // [[Urgh, this is revolting...]
    649 __KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_t __size,
    650 					       struct vki_cmsghdr *__cmsg)
    651 {
    652 	struct vki_cmsghdr * __ptr;
    653 
    654 	__ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
    655 	if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
    656 		return (struct vki_cmsghdr *)0;
    657 
    658 	return __ptr;
    659 }
    660 
    661 __KINLINE struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
    662 {
    663 	return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
    664 }
    665 
    666 #define	VKI_SCM_RIGHTS	0x01		/* rw: access rights (array of int) */
    667 
    668 #define VKI_AF_UNIX	1	/* Unix domain sockets 		*/
    669 #define VKI_AF_INET	2	/* Internet IP Protocol		*/
    670 #define VKI_AF_INET6	10	/* IP version 6			*/
    671 
    672 #define VKI_MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
    673 
    674 #define VKI_SOL_SCTP	132
    675 
    676 //----------------------------------------------------------------------
    677 // From linux-2.6.8.1/include/linux/in.h
    678 //----------------------------------------------------------------------
    679 
    680 struct vki_in_addr {
    681 	__vki_u32	s_addr;
    682 };
    683 
    684 /* Structure describing an Internet (IP) socket address. */
    685 #define __VKI_SOCK_SIZE__	16	/* sizeof(struct sockaddr)	*/
    686 struct vki_sockaddr_in {
    687   vki_sa_family_t	sin_family;	/* Address family		*/
    688   unsigned short int	sin_port;	/* Port number			*/
    689   struct vki_in_addr	sin_addr;	/* Internet address		*/
    690 
    691   /* Pad to size of `struct sockaddr'. */
    692   unsigned char		__pad[__VKI_SOCK_SIZE__ - sizeof(short int) -
    693 			sizeof(unsigned short int) - sizeof(struct vki_in_addr)];
    694 };
    695 
    696 //----------------------------------------------------------------------
    697 // From linux-2.6.8.1/include/linux/in6.h
    698 //----------------------------------------------------------------------
    699 
    700 struct vki_in6_addr
    701 {
    702 	union
    703 	{
    704 		__vki_u8	u6_addr8[16];
    705 		__vki_u16	u6_addr16[8];
    706 		__vki_u32	u6_addr32[4];
    707 	} vki_in6_u;
    708 #define vki_s6_addr		vki_in6_u.u6_addr8
    709 #define vki_s6_addr16		vki_in6_u.u6_addr16
    710 #define vki_s6_addr32		vki_in6_u.u6_addr32
    711 };
    712 
    713 struct vki_sockaddr_in6 {
    714 	unsigned short int	sin6_family;    /* AF_INET6 */
    715 	__vki_u16		sin6_port;      /* Transport layer port # */
    716 	__vki_u32		sin6_flowinfo;  /* IPv6 flow information */
    717 	struct vki_in6_addr	sin6_addr;      /* IPv6 address */
    718 	__vki_u32		sin6_scope_id;  /* scope id (new in RFC2553) */
    719 };
    720 
    721 //----------------------------------------------------------------------
    722 // From linux-2.6.8.1/include/linux/un.h
    723 //----------------------------------------------------------------------
    724 
    725 #define VKI_UNIX_PATH_MAX	108
    726 
    727 struct vki_sockaddr_un {
    728 	vki_sa_family_t sun_family;	/* AF_UNIX */
    729 	char sun_path[VKI_UNIX_PATH_MAX];	/* pathname */
    730 };
    731 
    732 //----------------------------------------------------------------------
    733 // From linux-2.6.8.1/include/linux/if.h
    734 //----------------------------------------------------------------------
    735 
    736 #define	VKI_IFNAMSIZ	16
    737 
    738 struct vki_ifmap
    739 {
    740 	unsigned long mem_start;
    741 	unsigned long mem_end;
    742 	unsigned short base_addr;
    743 	unsigned char irq;
    744 	unsigned char dma;
    745 	unsigned char port;
    746 	/* 3 bytes spare */
    747 };
    748 
    749 struct vki_if_settings
    750 {
    751 	unsigned int type;	/* Type of physical device or protocol */
    752 	unsigned int size;	/* Size of the data allocated by the caller */
    753 	union {
    754                 // [[Nb: converted these all to void* to avoid pulling in
    755                 //   unnecessary headers]]]
    756 		/* {atm/eth/dsl}_settings anyone ? */
    757 		void /*raw_hdlc_proto		*/__user *raw_hdlc;
    758 		void /*cisco_proto		*/__user *cisco;
    759 		void /*fr_proto			*/__user *fr;
    760 		void /*fr_proto_pvc		*/__user *fr_pvc;
    761 		void /*fr_proto_pvc_info	*/__user *fr_pvc_info;
    762 
    763 		/* interface settings */
    764 		void /*sync_serial_settings	*/__user *sync;
    765 		void /*te1_settings		*/__user *te1;
    766 	} ifs_ifsu;
    767 };
    768 
    769 struct vki_ifreq
    770 {
    771 #define VKI_IFHWADDRLEN	6
    772 	union
    773 	{
    774 		char	ifrn_name[VKI_IFNAMSIZ];		/* if name, e.g. "en0" */
    775 	} ifr_ifrn;
    776 
    777 	union {
    778 		struct	vki_sockaddr ifru_addr;
    779 		struct	vki_sockaddr ifru_dstaddr;
    780 		struct	vki_sockaddr ifru_broadaddr;
    781 		struct	vki_sockaddr ifru_netmask;
    782 		struct  vki_sockaddr ifru_hwaddr;
    783 		short	ifru_flags;
    784 		int	ifru_ivalue;
    785 		int	ifru_mtu;
    786 		struct  vki_ifmap ifru_map;
    787 		char	ifru_slave[VKI_IFNAMSIZ];	/* Just fits the size */
    788 		char	ifru_newname[VKI_IFNAMSIZ];
    789 		void __user *	ifru_data;
    790 		struct	vki_if_settings ifru_settings;
    791 	} ifr_ifru;
    792 };
    793 
    794 #define vki_ifr_name	ifr_ifrn.ifrn_name	/* interface name 	*/
    795 #define ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address 		*/
    796 #define	ifr_addr	ifr_ifru.ifru_addr	/* address		*/
    797 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk	*/
    798 #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address	*/
    799 #define	ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask	*/
    800 #define	vki_ifr_flags	ifr_ifru.ifru_flags	/* flags		*/
    801 #define	vki_ifr_metric	ifr_ifru.ifru_ivalue	/* metric		*/
    802 #define	vki_ifr_mtu		ifr_ifru.ifru_mtu	/* mtu			*/
    803 #define ifr_map		ifr_ifru.ifru_map	/* device map		*/
    804 #define ifr_slave	ifr_ifru.ifru_slave	/* slave device		*/
    805 #define	vki_ifr_data	ifr_ifru.ifru_data	/* for use by interface	*/
    806 #define vki_ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index	*/
    807 #define ifr_bandwidth	ifr_ifru.ifru_ivalue    /* link bandwidth	*/
    808 #define ifr_qlen	ifr_ifru.ifru_ivalue	/* Queue length 	*/
    809 #define ifr_newname	ifr_ifru.ifru_newname	/* New name		*/
    810 #define ifr_settings	ifr_ifru.ifru_settings	/* Device/proto settings*/
    811 
    812 struct vki_ifconf
    813 {
    814 	int	ifc_len;			/* size of buffer	*/
    815 	union
    816 	{
    817 		char __user *ifcu_buf;
    818 		struct vki_ifreq __user *ifcu_req;
    819 	} ifc_ifcu;
    820 };
    821 #define	vki_ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address	*/
    822 
    823 //----------------------------------------------------------------------
    824 // From linux-2.6.8.1/include/linux/if_arp.h
    825 //----------------------------------------------------------------------
    826 
    827 struct vki_arpreq {
    828   struct vki_sockaddr	arp_pa;		/* protocol address		*/
    829   struct vki_sockaddr	arp_ha;		/* hardware address		*/
    830   int			arp_flags;	/* flags			*/
    831   struct vki_sockaddr   arp_netmask;    /* netmask (only for proxy arps) */
    832   char			arp_dev[16];
    833 };
    834 
    835 //----------------------------------------------------------------------
    836 // From linux-2.6.8.1/include/linux/route.h
    837 //----------------------------------------------------------------------
    838 
    839 struct vki_rtentry
    840 {
    841 	unsigned long	rt_pad1;
    842 	struct vki_sockaddr	rt_dst;		/* target address		*/
    843 	struct vki_sockaddr	rt_gateway;	/* gateway addr (RTF_GATEWAY)	*/
    844 	struct vki_sockaddr	rt_genmask;	/* target network mask (IP)	*/
    845 	unsigned short	rt_flags;
    846 	short		rt_pad2;
    847 	unsigned long	rt_pad3;
    848 	void		*rt_pad4;
    849 	short		rt_metric;	/* +1 for binary compatibility!	*/
    850 	char __user	*rt_dev;	/* forcing the device at add	*/
    851 	unsigned long	rt_mtu;		/* per route MTU/Window 	*/
    852 // [[Not important for Valgrind]]
    853 //#ifndef __KERNEL__
    854 //#define rt_mss	rt_mtu		/* Compatibility :-(            */
    855 //#endif
    856 	unsigned long	rt_window;	/* Window clamping 		*/
    857 	unsigned short	rt_irtt;	/* Initial RTT			*/
    858 };
    859 
    860 //----------------------------------------------------------------------
    861 // From linux-2.6.13-rc5/include/net/sctp/user.h
    862 //----------------------------------------------------------------------
    863 
    864 typedef __vki_s32 vki_sctp_assoc_t;
    865 
    866 enum vki_sctp_optname {
    867 	VKI_SCTP_RTOINFO,
    868 #define VKI_SCTP_RTOINFO VKI_SCTP_RTOINFO
    869 	VKI_SCTP_ASSOCINFO,
    870 #define VKI_SCTP_ASSOCINFO VKI_SCTP_ASSOCINFO
    871 	VKI_SCTP_INITMSG,
    872 #define VKI_SCTP_INITMSG VKI_SCTP_INITMSG
    873 	VKI_SCTP_NODELAY, 	/* Get/set nodelay option. */
    874 #define VKI_SCTP_NODELAY	VKI_SCTP_NODELAY
    875 	VKI_SCTP_AUTOCLOSE,
    876 #define VKI_SCTP_AUTOCLOSE VKI_SCTP_AUTOCLOSE
    877 	VKI_SCTP_SET_PEER_PRIMARY_ADDR,
    878 #define VKI_SCTP_SET_PEER_PRIMARY_ADDR VKI_SCTP_SET_PEER_PRIMARY_ADDR
    879 	VKI_SCTP_PRIMARY_ADDR,
    880 #define VKI_SCTP_PRIMARY_ADDR VKI_SCTP_PRIMARY_ADDR
    881 	VKI_SCTP_ADAPTION_LAYER,
    882 #define VKI_SCTP_ADAPTION_LAYER VKI_SCTP_ADAPTION_LAYER
    883 	VKI_SCTP_DISABLE_FRAGMENTS,
    884 #define VKI_SCTP_DISABLE_FRAGMENTS VKI_SCTP_DISABLE_FRAGMENTS
    885 	VKI_SCTP_PEER_ADDR_PARAMS,
    886 #define VKI_SCTP_PEER_ADDR_PARAMS VKI_SCTP_PEER_ADDR_PARAMS
    887 	VKI_SCTP_DEFAULT_SEND_PARAM,
    888 #define VKI_SCTP_DEFAULT_SEND_PARAM VKI_SCTP_DEFAULT_SEND_PARAM
    889 	VKI_SCTP_EVENTS,
    890 #define VKI_SCTP_EVENTS VKI_SCTP_EVENTS
    891 	VKI_SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
    892 #define VKI_SCTP_I_WANT_MAPPED_V4_ADDR VKI_SCTP_I_WANT_MAPPED_V4_ADDR
    893 	VKI_SCTP_MAXSEG, 	/* Get/set maximum fragment. */
    894 #define VKI_SCTP_MAXSEG 	VKI_SCTP_MAXSEG
    895 	VKI_SCTP_STATUS,
    896 #define VKI_SCTP_STATUS VKI_SCTP_STATUS
    897 	VKI_SCTP_GET_PEER_ADDR_INFO,
    898 #define VKI_SCTP_GET_PEER_ADDR_INFO VKI_SCTP_GET_PEER_ADDR_INFO
    899 
    900 	/* Internal Socket Options. Some of the sctp library functions are
    901 	 * implemented using these socket options.
    902 	 */
    903 	VKI_SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
    904 #define VKI_SCTP_SOCKOPT_BINDX_ADD	VKI_SCTP_SOCKOPT_BINDX_ADD
    905 	VKI_SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
    906 #define VKI_SCTP_SOCKOPT_BINDX_REM	VKI_SCTP_SOCKOPT_BINDX_REM
    907 	VKI_SCTP_SOCKOPT_PEELOFF, 	/* peel off association. */
    908 #define VKI_SCTP_SOCKOPT_PEELOFF	VKI_SCTP_SOCKOPT_PEELOFF
    909 	VKI_SCTP_GET_PEER_ADDRS_NUM, 	/* Get number of peer addresss. */
    910 #define VKI_SCTP_GET_PEER_ADDRS_NUM	VKI_SCTP_GET_PEER_ADDRS_NUM
    911 	VKI_SCTP_GET_PEER_ADDRS, 	/* Get all peer addresss. */
    912 #define VKI_SCTP_GET_PEER_ADDRS	VKI_SCTP_GET_PEER_ADDRS
    913 	VKI_SCTP_GET_LOCAL_ADDRS_NUM, 	/* Get number of local addresss. */
    914 #define VKI_SCTP_GET_LOCAL_ADDRS_NUM	VKI_SCTP_GET_LOCAL_ADDRS_NUM
    915 	VKI_SCTP_GET_LOCAL_ADDRS, 	/* Get all local addresss. */
    916 #define VKI_SCTP_GET_LOCAL_ADDRS	VKI_SCTP_GET_LOCAL_ADDRS
    917 	VKI_SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
    918 #define VKI_SCTP_SOCKOPT_CONNECTX	VKI_SCTP_SOCKOPT_CONNECTX
    919 };
    920 
    921 struct vki_sctp_getaddrs {
    922 	vki_sctp_assoc_t        assoc_id;
    923 	int			addr_num;
    924 	struct vki_sockaddr	*addrs;
    925 };
    926 
    927 //----------------------------------------------------------------------
    928 // From linux-2.6.8.1/include/linux/resource.h
    929 //----------------------------------------------------------------------
    930 
    931 struct	vki_rusage {
    932 	struct vki_timeval ru_utime;	/* user time used */
    933 	struct vki_timeval ru_stime;	/* system time used */
    934 	long	ru_maxrss;		/* maximum resident set size */
    935 	long	ru_ixrss;		/* integral shared memory size */
    936 	long	ru_idrss;		/* integral unshared data size */
    937 	long	ru_isrss;		/* integral unshared stack size */
    938 	long	ru_minflt;		/* page reclaims */
    939 	long	ru_majflt;		/* page faults */
    940 	long	ru_nswap;		/* swaps */
    941 	long	ru_inblock;		/* block input operations */
    942 	long	ru_oublock;		/* block output operations */
    943 	long	ru_msgsnd;		/* messages sent */
    944 	long	ru_msgrcv;		/* messages received */
    945 	long	ru_nsignals;		/* signals received */
    946 	long	ru_nvcsw;		/* voluntary context switches */
    947 	long	ru_nivcsw;		/* involuntary " */
    948 };
    949 
    950 struct vki_rlimit {
    951 	unsigned long	rlim_cur;
    952 	unsigned long	rlim_max;
    953 };
    954 
    955 struct vki_rlimit64 {
    956 	__vki_u64 rlim_cur;
    957 	__vki_u64 rlim_max;
    958 };
    959 
    960 //----------------------------------------------------------------------
    961 // From linux-2.6.8.1/include/linux/elfcore.h
    962 //----------------------------------------------------------------------
    963 
    964 struct vki_elf_siginfo
    965 {
    966 	int	si_signo;			/* signal number */
    967 	int	si_code;			/* extra code */
    968 	int	si_errno;			/* errno */
    969 };
    970 
    971 // [[Removed some commented out lines here]]
    972 struct vki_elf_prstatus
    973 {
    974 	struct vki_elf_siginfo pr_info;	/* Info associated with signal */
    975 	short	pr_cursig;		/* Current signal */
    976 	unsigned long pr_sigpend;	/* Set of pending signals */
    977 	unsigned long pr_sighold;	/* Set of held signals */
    978 	vki_pid_t	pr_pid;
    979 	vki_pid_t	pr_ppid;
    980 	vki_pid_t	pr_pgrp;
    981 	vki_pid_t	pr_sid;
    982 	struct vki_timeval pr_utime;	/* User time */
    983 	struct vki_timeval pr_stime;	/* System time */
    984 	struct vki_timeval pr_cutime;	/* Cumulative user time */
    985 	struct vki_timeval pr_cstime;	/* Cumulative system time */
    986 	vki_elf_gregset_t pr_reg;	/* GP registers */
    987 	int pr_fpvalid;		/* True if math co-processor being used.  */
    988 };
    989 
    990 #define VKI_ELF_PRARGSZ	(80)	/* Number of chars for args */
    991 
    992 struct vki_elf_prpsinfo
    993 {
    994 	char	pr_state;	/* numeric process state */
    995 	char	pr_sname;	/* char for pr_state */
    996 	char	pr_zomb;	/* zombie */
    997 	char	pr_nice;	/* nice val */
    998 	unsigned long pr_flag;	/* flags */
    999 	__vki_kernel_uid_t	pr_uid;
   1000 	__vki_kernel_gid_t	pr_gid;
   1001 	vki_pid_t	pr_pid, pr_ppid, pr_pgrp, pr_sid;
   1002 	/* Lots missing */
   1003 	char	pr_fname[16];	/* filename of executable */
   1004 	char	pr_psargs[VKI_ELF_PRARGSZ];	/* initial part of arg list */
   1005 };
   1006 
   1007 //----------------------------------------------------------------------
   1008 // From linux-2.6.12.1/include/linux/eventpoll.h
   1009 //----------------------------------------------------------------------
   1010 
   1011 /* Valid opcodes to issue to sys_epoll_ctl() */
   1012 #define VKI_EPOLL_CTL_ADD 1
   1013 #define VKI_EPOLL_CTL_DEL 2
   1014 #define VKI_EPOLL_CTL_MOD 3
   1015 
   1016 #ifdef __x86_64__
   1017 #define VKI_EPOLL_PACKED __attribute__((packed))
   1018 #else
   1019 #define VKI_EPOLL_PACKED
   1020 #endif
   1021 
   1022 struct vki_epoll_event {
   1023 	__vki_u32 events;
   1024 	__vki_u64 data;
   1025 } VKI_EPOLL_PACKED;
   1026 
   1027 
   1028 //----------------------------------------------------------------------
   1029 // From linux-2.6.8.1/include/linux/mqueue.h
   1030 //----------------------------------------------------------------------
   1031 
   1032 struct vki_mq_attr {
   1033 	long	mq_flags;	/* message queue flags			*/
   1034 	long	mq_maxmsg;	/* maximum number of messages		*/
   1035 	long	mq_msgsize;	/* maximum message size			*/
   1036 	long	mq_curmsgs;	/* number of messages currently queued	*/
   1037 	long	__reserved[4];	/* ignored for input, zeroed for output */
   1038 };
   1039 
   1040 //----------------------------------------------------------------------
   1041 // From linux-2.6.8.1/include/linux/utsname.h
   1042 //----------------------------------------------------------------------
   1043 
   1044 struct vki_new_utsname {
   1045 	char sysname[65];
   1046 	char nodename[65];
   1047 	char release[65];
   1048 	char version[65];
   1049 	char machine[65];
   1050 	char domainname[65];
   1051 };
   1052 
   1053 //----------------------------------------------------------------------
   1054 // From linux-2.6.8.1/include/linux/mii.h
   1055 //----------------------------------------------------------------------
   1056 
   1057 /* This structure is used in all SIOCxMIIxxx ioctl calls */
   1058 struct vki_mii_ioctl_data {
   1059 	vki_u16		phy_id;
   1060 	vki_u16		reg_num;
   1061 	vki_u16		val_in;
   1062 	vki_u16		val_out;
   1063 };
   1064 
   1065 //----------------------------------------------------------------------
   1066 // From linux-2.6.8.1/include/linux/capability.h
   1067 //----------------------------------------------------------------------
   1068 
   1069 // [[capget()/capset() man page says this, ominously:
   1070 //
   1071 //   The kernel API is likely to change and use of these functions  (in
   1072 //   particular the format of the cap_user_*_t types) is subject to
   1073 //   change with each kernel revision.
   1074 //
   1075 // However, the format hasn't changed since at least Linux 2.4.6.]]
   1076 
   1077 typedef struct __vki_user_cap_header_struct {
   1078 	__vki_u32 version;
   1079 	int pid;
   1080 } __user *vki_cap_user_header_t;
   1081 
   1082 typedef struct __vki_user_cap_data_struct {
   1083         __vki_u32 effective;
   1084         __vki_u32 permitted;
   1085         __vki_u32 inheritable;
   1086 } __user *vki_cap_user_data_t;
   1087 
   1088 
   1089 //----------------------------------------------------------------------
   1090 // From linux-2.6.8.1/include/linux/module.h
   1091 //----------------------------------------------------------------------
   1092 
   1093 // [[We do a VKI_SIZEOF_* here because this type is so big, and its size
   1094 //   depends on the word size, so see vki_arch.h]]
   1095 
   1096 //----------------------------------------------------------------------
   1097 // From linux-2.6.8.1/include/linux/ipc.h
   1098 //----------------------------------------------------------------------
   1099 
   1100 /* Obsolete, used only for backwards compatibility and libc5 compiles */
   1101 struct vki_ipc_perm
   1102 {
   1103 	__vki_kernel_key_t	key;
   1104 	__vki_kernel_uid_t	uid;
   1105 	__vki_kernel_gid_t	gid;
   1106 	__vki_kernel_uid_t	cuid;
   1107 	__vki_kernel_gid_t	cgid;
   1108 	__vki_kernel_mode_t	mode;
   1109 	unsigned short	seq;
   1110 };
   1111 
   1112 #define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
   1113 #define VKI_IPC_EXCL   00002000   /* fail if key exists */
   1114 #define VKI_IPC_NOWAIT 00004000   /* return error on wait */
   1115 
   1116 //#define VKI_IPC_RMID 0     /* remove resource */
   1117 #define VKI_IPC_SET  1     /* set ipc_perm options */
   1118 #define VKI_IPC_STAT 2     /* get ipc_perm options */
   1119 #define VKI_IPC_INFO 3     /* see ipcs */
   1120 
   1121 #define VKI_IPC_64  0x0100  /* New version (support 32-bit UIDs, bigger
   1122 			       message sizes, etc. */
   1123 
   1124 //----------------------------------------------------------------------
   1125 // From linux-2.6.8.1/include/linux/sem.h
   1126 //----------------------------------------------------------------------
   1127 
   1128 #define VKI_GETALL  13       /* get all semval's */
   1129 #define VKI_SETVAL  16       /* set semval */
   1130 #define VKI_SETALL  17       /* set all semval's */
   1131 
   1132 #define VKI_SEM_STAT 18
   1133 #define VKI_SEM_INFO 19
   1134 
   1135 /* Obsolete, used only for backwards compatibility and libc5 compiles */
   1136 struct vki_semid_ds {
   1137 	struct vki_ipc_perm	sem_perm;		/* permissions .. see ipc.h */
   1138 	__vki_kernel_time_t	sem_otime;		/* last semop time */
   1139 	__vki_kernel_time_t	sem_ctime;		/* last change time */
   1140         // [[Use void* to avoid excess header copying]]
   1141 	void/*struct sem	*/*sem_base;		/* ptr to first semaphore in array */
   1142 	void/*struct sem_queue */*sem_pending;		/* pending operations to be processed */
   1143 	void/*struct sem_queue */**sem_pending_last;	/* last pending operation */
   1144 	void/*struct sem_undo	*/*undo;			/* undo requests on this array */
   1145 	unsigned short	sem_nsems;		/* no. of semaphores in array */
   1146 };
   1147 
   1148 struct vki_sembuf {
   1149 	unsigned short  sem_num;	/* semaphore index in array */
   1150 	short		sem_op;		/* semaphore operation */
   1151 	short		sem_flg;	/* operation flags */
   1152 };
   1153 
   1154 union vki_semun {
   1155 	int val;			/* value for SETVAL */
   1156 	struct vki_semid_ds __user *buf;	/* buffer for IPC_STAT & IPC_SET */
   1157 	unsigned short __user *array;	/* array for GETALL & SETALL */
   1158 	struct vki_seminfo __user *__buf;	/* buffer for IPC_INFO */
   1159 	void __user *__pad;
   1160 };
   1161 
   1162 struct  vki_seminfo {
   1163 	int semmap;
   1164 	int semmni;
   1165 	int semmns;
   1166 	int semmnu;
   1167 	int semmsl;
   1168 	int semopm;
   1169 	int semume;
   1170 	int semusz;
   1171 	int semvmx;
   1172 	int semaem;
   1173 };
   1174 
   1175 //----------------------------------------------------------------------
   1176 // From linux-2.6.8.1/include/asm-generic/errno-base.h
   1177 //----------------------------------------------------------------------
   1178 
   1179 #define	VKI_EPERM		 1	/* Operation not permitted */
   1180 #define	VKI_ENOENT		 2	/* No such file or directory */
   1181 #define	VKI_ESRCH		 3	/* No such process */
   1182 #define	VKI_EINTR		 4	/* Interrupted system call */
   1183 #define	VKI_EIO			 5	/* I/O error */
   1184 #define	VKI_ENXIO		 6	/* No such device or address */
   1185 #define	VKI_E2BIG		 7	/* Argument list too long */
   1186 #define	VKI_ENOEXEC		 8	/* Exec format error */
   1187 #define	VKI_EBADF		 9	/* Bad file number */
   1188 #define	VKI_ECHILD		10	/* No child processes */
   1189 #define	VKI_EAGAIN		11	/* Try again */
   1190 #define	VKI_ENOMEM		12	/* Out of memory */
   1191 #define	VKI_EACCES		13	/* Permission denied */
   1192 #define	VKI_EFAULT		14	/* Bad address */
   1193 #define	VKI_ENOTBLK		15	/* Block device required */
   1194 #define	VKI_EBUSY		16	/* Device or resource busy */
   1195 #define	VKI_EEXIST		17	/* File exists */
   1196 #define	VKI_EXDEV		18	/* Cross-device link */
   1197 #define	VKI_ENODEV		19	/* No such device */
   1198 #define	VKI_ENOTDIR		20	/* Not a directory */
   1199 #define	VKI_EISDIR		21	/* Is a directory */
   1200 #define	VKI_EINVAL		22	/* Invalid argument */
   1201 #define	VKI_ENFILE		23	/* File table overflow */
   1202 #define	VKI_EMFILE		24	/* Too many open files */
   1203 #define	VKI_ENOTTY		25	/* Not a typewriter */
   1204 #define	VKI_ETXTBSY		26	/* Text file busy */
   1205 #define	VKI_EFBIG		27	/* File too large */
   1206 #define	VKI_ENOSPC		28	/* No space left on device */
   1207 #define	VKI_ESPIPE		29	/* Illegal seek */
   1208 #define	VKI_EROFS		30	/* Read-only file system */
   1209 #define	VKI_EMLINK		31	/* Too many links */
   1210 #define	VKI_EPIPE		32	/* Broken pipe */
   1211 #define	VKI_EDOM		33	/* Math argument out of domain of func */
   1212 #define	VKI_ERANGE		34	/* Math result not representable */
   1213 
   1214 //----------------------------------------------------------------------
   1215 // From linux-2.6.8.1/include/asm-generic/errno.h
   1216 //----------------------------------------------------------------------
   1217 
   1218 #define VKI_EWOULDBLOCK		VKI_EAGAIN
   1219 
   1220 #define	VKI_ENOSYS		38	/* Function not implemented */
   1221 #define	VKI_EOVERFLOW		75	/* Value too large for defined data type */
   1222 
   1223 //----------------------------------------------------------------------
   1224 // From linux-2.6.8.1/include/linux/wait.h
   1225 //----------------------------------------------------------------------
   1226 
   1227 #define VKI_WNOHANG	0x00000001
   1228 
   1229 #define __VKI_WALL	0x40000000	/* Wait on all children, regardless of type */
   1230 #define __VKI_WCLONE	0x80000000	/* Wait only on non-SIGCHLD children */
   1231 
   1232 //----------------------------------------------------------------------
   1233 // From linux-2.6.8.1/include/linux/mman.h
   1234 //----------------------------------------------------------------------
   1235 
   1236 #define VKI_MREMAP_MAYMOVE	1
   1237 #define VKI_MREMAP_FIXED	2
   1238 
   1239 //----------------------------------------------------------------------
   1240 // From linux-2.6.31-rc4/include/linux/futex.h
   1241 //----------------------------------------------------------------------
   1242 
   1243 #define VKI_FUTEX_WAIT (0)
   1244 #define VKI_FUTEX_WAKE (1)
   1245 #define VKI_FUTEX_FD (2)
   1246 #define VKI_FUTEX_REQUEUE (3)
   1247 #define VKI_FUTEX_CMP_REQUEUE (4)
   1248 #define VKI_FUTEX_WAKE_OP (5)
   1249 #define VKI_FUTEX_LOCK_PI (6)
   1250 #define VKI_FUTEX_UNLOCK_PI (7)
   1251 #define VKI_FUTEX_TRYLOCK_PI (8)
   1252 #define VKI_FUTEX_WAIT_BITSET (9)
   1253 #define VKI_FUTEX_WAKE_BITSET (10)
   1254 #define VKI_FUTEX_WAIT_REQUEUE_PI (11)
   1255 #define VKI_FUTEX_CMP_REQUEUE_PI (12)
   1256 #define VKI_FUTEX_PRIVATE_FLAG (128)
   1257 #define VKI_FUTEX_CLOCK_REALTIME (256)
   1258 
   1259 struct vki_robust_list {
   1260 	struct vki_robust_list __user *next;
   1261 };
   1262 
   1263 struct vki_robust_list_head {
   1264 	/*
   1265 	 * The head of the list. Points back to itself if empty:
   1266 	 */
   1267 	struct vki_robust_list list;
   1268 
   1269 	/*
   1270 	 * This relative offset is set by user-space, it gives the kernel
   1271 	 * the relative position of the futex field to examine. This way
   1272 	 * we keep userspace flexible, to freely shape its data-structure,
   1273 	 * without hardcoding any particular offset into the kernel:
   1274 	 */
   1275 	long futex_offset;
   1276 
   1277 	/*
   1278 	 * The death of the thread may race with userspace setting
   1279 	 * up a lock's links. So to handle this race, userspace first
   1280 	 * sets this field to the address of the to-be-taken lock,
   1281 	 * then does the lock acquire, and then adds itself to the
   1282 	 * list, and then clears this field. Hence the kernel will
   1283 	 * always have full knowledge of all locks that the thread
   1284 	 * _might_ have taken. We check the owner TID in any case,
   1285 	 * so only truly owned locks will be handled.
   1286 	 */
   1287 	struct vki_robust_list __user *list_op_pending;
   1288 };
   1289 
   1290 //----------------------------------------------------------------------
   1291 // From linux-2.6.8.1/include/linux/errno.h
   1292 //----------------------------------------------------------------------
   1293 
   1294 #define VKI_ERESTARTSYS	512
   1295 
   1296 //----------------------------------------------------------------------
   1297 // From linux-2.6.8.1/include/linux/stat.h
   1298 //----------------------------------------------------------------------
   1299 
   1300 #define VKI_S_IFMT  00170000
   1301 #define VKI_S_IFSOCK 0140000
   1302 #define VKI_S_IFLNK  0120000
   1303 #define VKI_S_IFREG  0100000
   1304 #define VKI_S_IFBLK  0060000
   1305 #define VKI_S_IFDIR  0040000
   1306 #define VKI_S_IFCHR  0020000
   1307 #define VKI_S_IFIFO  0010000
   1308 #define VKI_S_ISUID  0004000
   1309 #define VKI_S_ISGID  0002000
   1310 #define VKI_S_ISVTX  0001000
   1311 
   1312 #define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
   1313 #define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
   1314 #define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
   1315 #define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
   1316 #define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
   1317 #define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
   1318 #define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
   1319 
   1320 #define VKI_S_IRWXU 00700
   1321 #define VKI_S_IRUSR 00400
   1322 #define VKI_S_IWUSR 00200
   1323 #define VKI_S_IXUSR 00100
   1324 
   1325 #define VKI_S_IRWXG 00070
   1326 #define VKI_S_IRGRP 00040
   1327 #define VKI_S_IWGRP 00020
   1328 #define VKI_S_IXGRP 00010
   1329 
   1330 #define VKI_S_IRWXO 00007
   1331 #define VKI_S_IROTH 00004
   1332 #define VKI_S_IWOTH 00002
   1333 #define VKI_S_IXOTH 00001
   1334 
   1335 //----------------------------------------------------------------------
   1336 // From linux-2.6.8.1/include/linux/dirent.h
   1337 //----------------------------------------------------------------------
   1338 
   1339 struct vki_dirent {
   1340 	long		d_ino;
   1341 	__vki_kernel_off_t	d_off;
   1342 	unsigned short	d_reclen;
   1343 	char		d_name[256]; /* We must not include limits.h! */
   1344 };
   1345 
   1346 //----------------------------------------------------------------------
   1347 // From linux-2.6.8.1/include/linux/fcntl.h
   1348 //----------------------------------------------------------------------
   1349 
   1350 #define VKI_F_SETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 0)
   1351 #define VKI_F_GETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 1)
   1352 
   1353 #define VKI_F_CANCELLK      (VKI_F_LINUX_SPECIFIC_BASE + 5)
   1354 
   1355 #define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6)
   1356 
   1357 #define VKI_F_NOTIFY        (VKI_F_LINUX_SPECIFIC_BASE + 2)
   1358 
   1359 #define VKI_F_SETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 7)
   1360 #define VKI_F_GETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 8)
   1361 
   1362 //----------------------------------------------------------------------
   1363 // From linux-2.6.8.1/include/linux/sysctl.h
   1364 //----------------------------------------------------------------------
   1365 
   1366 struct __vki_sysctl_args {
   1367 	int __user *name;
   1368 	int nlen;
   1369 	void __user *oldval;
   1370 	vki_size_t __user *oldlenp;
   1371 	void __user *newval;
   1372 	vki_size_t newlen;
   1373 	unsigned long __unused[4];
   1374 };
   1375 
   1376 //----------------------------------------------------------------------
   1377 // From linux-2.6.8.1/include/linux/aio_abi.h
   1378 //----------------------------------------------------------------------
   1379 
   1380 typedef unsigned long	vki_aio_context_t;
   1381 
   1382 enum {
   1383 	VKI_IOCB_CMD_PREAD = 0,
   1384 	VKI_IOCB_CMD_PWRITE = 1,
   1385 	VKI_IOCB_CMD_FSYNC = 2,
   1386 	VKI_IOCB_CMD_FDSYNC = 3,
   1387 	VKI_IOCB_CMD_PREADV = 7,
   1388 	VKI_IOCB_CMD_PWRITEV = 8,
   1389 };
   1390 
   1391 /* read() from /dev/aio returns these structures. */
   1392 struct vki_io_event {
   1393 	__vki_u64	data;		/* the data field from the iocb */
   1394 	__vki_u64	obj;		/* what iocb this event came from */
   1395         // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is
   1396         //   a macro in vg_syscalls.c!]]
   1397 	__vki_s64	result;		/* result code for this event */
   1398 	__vki_s64	result2;	/* secondary result */
   1399 };
   1400 
   1401 #if defined(VKI_LITTLE_ENDIAN)
   1402 #  define VKI_PADDED(x,y)	x, y
   1403 #elif defined(VKI_BIG_ENDIAN)
   1404 #  define VKI_PADDED(x,y)	y, x
   1405 #else
   1406 #error edit for your odd byteorder.
   1407 #endif
   1408 
   1409 struct vki_iocb {
   1410 	/* these are internal to the kernel/libc. */
   1411 	__vki_u64	aio_data;	/* data to be returned in event's data */
   1412 	__vki_u32	VKI_PADDED(aio_key, aio_reserved1);
   1413 				/* the kernel sets aio_key to the req # */
   1414 
   1415 	/* common fields */
   1416 	__vki_u16	aio_lio_opcode;	/* see IOCB_CMD_ above */
   1417 	__vki_s16	aio_reqprio;
   1418 	__vki_u32	aio_fildes;
   1419 
   1420 	__vki_u64	aio_buf;
   1421 	__vki_u64	aio_nbytes;
   1422 	__vki_s64	aio_offset;
   1423 
   1424 	/* extra parameters */
   1425 	__vki_u64	aio_reserved2;	/* TODO: use this for a (struct sigevent *) */
   1426 	__vki_u64	aio_reserved3;
   1427 }; /* 64 bytes */
   1428 
   1429 //----------------------------------------------------------------------
   1430 // From linux-2.6.8.1/include/linux/aio.h
   1431 //----------------------------------------------------------------------
   1432 
   1433 struct vki_aio_ring {
   1434 	unsigned	id;	/* kernel internal index number */
   1435 	unsigned	nr;	/* number of io_events */
   1436 	unsigned	head;
   1437 	unsigned	tail;
   1438 
   1439 	unsigned	magic;
   1440 	unsigned	compat_features;
   1441 	unsigned	incompat_features;
   1442 	unsigned	header_length;	/* size of aio_ring */
   1443 
   1444 	struct vki_io_event		io_events[0];
   1445 }; /* 128 bytes + ring size */
   1446 
   1447 //----------------------------------------------------------------------
   1448 // From linux-2.6.8.1/include/linux/msg.h
   1449 //----------------------------------------------------------------------
   1450 
   1451 #define VKI_MSG_STAT 11
   1452 #define VKI_MSG_INFO 12
   1453 
   1454 struct vki_msqid_ds {
   1455 	struct vki_ipc_perm msg_perm;
   1456 	struct vki_msg *msg_first;		/* first message on queue,unused  */
   1457 	struct vki_msg *msg_last;		/* last message in queue,unused */
   1458 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
   1459 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
   1460 	__vki_kernel_time_t msg_ctime;	/* last change time */
   1461 	unsigned long  msg_lcbytes;	/* Reuse junk fields for 32 bit */
   1462 	unsigned long  msg_lqbytes;	/* ditto */
   1463 	unsigned short msg_cbytes;	/* current number of bytes on queue */
   1464 	unsigned short msg_qnum;	/* number of messages in queue */
   1465 	unsigned short msg_qbytes;	/* max number of bytes on queue */
   1466 	__vki_kernel_ipc_pid_t msg_lspid;	/* pid of last msgsnd */
   1467 	__vki_kernel_ipc_pid_t msg_lrpid;	/* last receive pid */
   1468 };
   1469 
   1470 struct vki_msgbuf {
   1471 	long mtype;         /* type of message */
   1472 	char mtext[1];      /* message text */
   1473 };
   1474 
   1475 struct vki_msginfo {
   1476 	int msgpool;
   1477 	int msgmap;
   1478 	int msgmax;
   1479 	int msgmnb;
   1480 	int msgmni;
   1481 	int msgssz;
   1482 	int msgtql;
   1483 	unsigned short  msgseg;
   1484 };
   1485 
   1486 //----------------------------------------------------------------------
   1487 // From linux-2.6.8.1/include/linux/shm.h
   1488 //----------------------------------------------------------------------
   1489 
   1490 struct vki_shmid_ds {
   1491 	struct vki_ipc_perm		shm_perm;	/* operation perms */
   1492 	int			shm_segsz;	/* size of segment (bytes) */
   1493 	__vki_kernel_time_t		shm_atime;	/* last attach time */
   1494 	__vki_kernel_time_t		shm_dtime;	/* last detach time */
   1495 	__vki_kernel_time_t		shm_ctime;	/* last change time */
   1496 	__vki_kernel_ipc_pid_t	shm_cpid;	/* pid of creator */
   1497 	__vki_kernel_ipc_pid_t	shm_lpid;	/* pid of last operator */
   1498 	unsigned short		shm_nattch;	/* no. of current attaches */
   1499 	unsigned short 		shm_unused;	/* compatibility */
   1500 	void 			*shm_unused2;	/* ditto - used by DIPC */
   1501 	void			*shm_unused3;	/* unused */
   1502 };
   1503 
   1504 #define VKI_SHM_RDONLY  010000  /* read-only access */
   1505 #define VKI_SHM_RND     020000  /* round attach address to SHMLBA boundary */
   1506 
   1507 #define VKI_SHM_STAT 	13
   1508 #define VKI_SHM_INFO 	14
   1509 
   1510 /* Obsolete, used only for backwards compatibility */
   1511 struct	vki_shminfo {
   1512 	int shmmax;
   1513 	int shmmin;
   1514 	int shmmni;
   1515 	int shmseg;
   1516 	int shmall;
   1517 };
   1518 
   1519 struct vki_shm_info {
   1520 	int used_ids;
   1521 	unsigned long shm_tot;	/* total allocated shm */
   1522 	unsigned long shm_rss;	/* total resident shm */
   1523 	unsigned long shm_swp;	/* total swapped shm */
   1524 	unsigned long swap_attempts;
   1525 	unsigned long swap_successes;
   1526 };
   1527 
   1528 //----------------------------------------------------------------------
   1529 // From linux-2.6.8.1/include/linux/rtc.h
   1530 //----------------------------------------------------------------------
   1531 
   1532 struct vki_rtc_time {
   1533 	int tm_sec;
   1534 	int tm_min;
   1535 	int tm_hour;
   1536 	int tm_mday;
   1537 	int tm_mon;
   1538 	int tm_year;
   1539 	int tm_wday;
   1540 	int tm_yday;
   1541 	int tm_isdst;
   1542 };
   1543 
   1544 #define VKI_RTC_AIE_ON	_VKI_IO('p', 0x01)	/* Alarm int. enable on	*/
   1545 #define VKI_RTC_AIE_OFF	_VKI_IO('p', 0x02)	/* ... off		*/
   1546 #define VKI_RTC_UIE_ON	_VKI_IO('p', 0x03)	/* Update int. enable on*/
   1547 #define VKI_RTC_UIE_OFF	_VKI_IO('p', 0x04)	/* ... off		*/
   1548 #define VKI_RTC_PIE_ON	_VKI_IO('p', 0x05)	/* Periodic int. enable on*/
   1549 #define VKI_RTC_PIE_OFF	_VKI_IO('p', 0x06)	/* ... off		*/
   1550 
   1551 #define VKI_RTC_ALM_SET		_VKI_IOW('p', 0x07, struct vki_rtc_time) /* Set alarm time  */
   1552 #define VKI_RTC_ALM_READ	_VKI_IOR('p', 0x08, struct vki_rtc_time) /* Read alarm time */
   1553 #define VKI_RTC_RD_TIME		_VKI_IOR('p', 0x09, struct vki_rtc_time) /* Read RTC time   */
   1554 //#define RTC_SET_TIME	_IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
   1555 #define VKI_RTC_IRQP_READ	_VKI_IOR('p', 0x0b, unsigned long)	 /* Read IRQ rate   */
   1556 #define VKI_RTC_IRQP_SET	_VKI_IOW('p', 0x0c, unsigned long)	 /* Set IRQ rate    */
   1557 
   1558 //----------------------------------------------------------------------
   1559 // From linux-2.6.8.1/include/linux/isdn.h
   1560 //----------------------------------------------------------------------
   1561 
   1562 // [[Nb: Resolved this for the common case where CONFIG_COBALT_MICRO_SERVER
   1563 //   is not defined]]
   1564 #define VKI_ISDN_MAX_CHANNELS   64
   1565 
   1566 #define VKI_IIOCGETCPS  _VKI_IO('I',21)
   1567 
   1568 #define VKI_IIOCNETGPN  _VKI_IO('I',34)
   1569 
   1570 #define VKI_ISDN_MSNLEN          32
   1571 
   1572 typedef struct {
   1573   char name[10];
   1574   char phone[VKI_ISDN_MSNLEN];
   1575   int  outgoing;
   1576 } vki_isdn_net_ioctl_phone;
   1577 
   1578 //----------------------------------------------------------------------
   1579 // From linux-2.6.8.1/include/linux/sockios.h
   1580 //----------------------------------------------------------------------
   1581 
   1582 #define VKI_SIOCOUTQ		VKI_TIOCOUTQ
   1583 
   1584 #define VKI_SIOCADDRT		0x890B	/* add routing table entry	*/
   1585 #define VKI_SIOCDELRT		0x890C	/* delete routing table entry	*/
   1586 
   1587 #define VKI_SIOCGIFNAME		0x8910	/* get iface name		*/
   1588 #define VKI_SIOCGIFCONF		0x8912	/* get iface list		*/
   1589 #define VKI_SIOCGIFFLAGS	0x8913	/* get flags			*/
   1590 #define VKI_SIOCSIFFLAGS	0x8914	/* set flags			*/
   1591 #define VKI_SIOCGIFADDR		0x8915	/* get PA address		*/
   1592 #define VKI_SIOCSIFADDR		0x8916	/* set PA address		*/
   1593 #define VKI_SIOCGIFDSTADDR	0x8917	/* get remote PA address	*/
   1594 #define VKI_SIOCSIFDSTADDR	0x8918	/* set remote PA address	*/
   1595 #define VKI_SIOCGIFBRDADDR	0x8919	/* get broadcast PA address	*/
   1596 #define VKI_SIOCSIFBRDADDR	0x891a	/* set broadcast PA address	*/
   1597 #define VKI_SIOCGIFNETMASK	0x891b	/* get network PA mask		*/
   1598 #define VKI_SIOCSIFNETMASK	0x891c	/* set network PA mask		*/
   1599 #define VKI_SIOCGIFMETRIC	0x891d	/* get metric			*/
   1600 #define VKI_SIOCSIFMETRIC	0x891e	/* set metric			*/
   1601 #define VKI_SIOCGIFMTU		0x8921	/* get MTU size			*/
   1602 #define VKI_SIOCSIFMTU		0x8922	/* set MTU size			*/
   1603 #define	VKI_SIOCSIFHWADDR	0x8924	/* set hardware address 	*/
   1604 #define VKI_SIOCGIFHWADDR	0x8927	/* Get hardware address		*/
   1605 #define VKI_SIOCGIFINDEX	0x8933	/* name -> if_index mapping	*/
   1606 
   1607 #define VKI_SIOCGIFTXQLEN	0x8942	/* Get the tx queue length	*/
   1608 #define VKI_SIOCSIFTXQLEN	0x8943	/* Set the tx queue length 	*/
   1609 
   1610 #define VKI_SIOCGMIIPHY		0x8947	/* Get address of MII PHY in use. */
   1611 #define VKI_SIOCGMIIREG		0x8948	/* Read MII PHY register.	*/
   1612 #define VKI_SIOCSMIIREG		0x8949	/* Write MII PHY register.	*/
   1613 
   1614 #define VKI_SIOCDARP		0x8953	/* delete ARP table entry	*/
   1615 #define VKI_SIOCGARP		0x8954	/* get ARP table entry		*/
   1616 #define VKI_SIOCSARP		0x8955	/* set ARP table entry		*/
   1617 
   1618 #define VKI_SIOCDRARP		0x8960	/* delete RARP table entry	*/
   1619 #define VKI_SIOCGRARP		0x8961	/* get RARP table entry		*/
   1620 #define VKI_SIOCSRARP		0x8962	/* set RARP table entry		*/
   1621 
   1622 #define VKI_SIOCGIFMAP		0x8970	/* Get device parameters	*/
   1623 #define VKI_SIOCSIFMAP		0x8971	/* Set device parameters	*/
   1624 
   1625 #define VKI_SIOCSHWTSTAMP	0x89B0	/* Set hardware time stamping */
   1626 
   1627 //----------------------------------------------------------------------
   1628 // From linux-2.6.8.1/include/linux/ppdev.h
   1629 //----------------------------------------------------------------------
   1630 
   1631 #define VKI_PP_MAJOR	99
   1632 
   1633 #define VKI_PP_IOCTL	'p'
   1634 
   1635 /* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
   1636 #define VKI_PPSETMODE	_VKI_IOW(VKI_PP_IOCTL, 0x80, int)
   1637 
   1638 /* Read status */
   1639 #define VKI_PPRSTATUS	_VKI_IOR(VKI_PP_IOCTL, 0x81, unsigned char)
   1640 //#define PPWSTATUS	OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
   1641 
   1642 /* Read/write control */
   1643 #define VKI_PPRCONTROL	_VKI_IOR(VKI_PP_IOCTL, 0x83, unsigned char)
   1644 #define VKI_PPWCONTROL	_VKI_IOW(VKI_PP_IOCTL, 0x84, unsigned char)
   1645 
   1646 struct vki_ppdev_frob_struct {
   1647 	unsigned char mask;
   1648 	unsigned char val;
   1649 };
   1650 #define VKI_PPFCONTROL      _VKI_IOW(VKI_PP_IOCTL, 0x8e, struct vki_ppdev_frob_struct)
   1651 
   1652 /* Read/write data */
   1653 #define VKI_PPRDATA		_VKI_IOR(VKI_PP_IOCTL, 0x85, unsigned char)
   1654 #define VKI_PPWDATA		_VKI_IOW(VKI_PP_IOCTL, 0x86, unsigned char)
   1655 
   1656 /* Claim the port to start using it */
   1657 #define VKI_PPCLAIM		_VKI_IO(VKI_PP_IOCTL, 0x8b)
   1658 
   1659 /* Release the port when you aren't using it */
   1660 #define VKI_PPRELEASE	_VKI_IO(VKI_PP_IOCTL, 0x8c)
   1661 
   1662 /* Yield the port (release it if another driver is waiting,
   1663  * then reclaim) */
   1664 #define VKI_PPYIELD		_VKI_IO(VKI_PP_IOCTL, 0x8d)
   1665 
   1666 /* Register device exclusively (must be before PPCLAIM). */
   1667 #define VKI_PPEXCL		_VKI_IO(VKI_PP_IOCTL, 0x8f)
   1668 
   1669 /* Data line direction: non-zero for input mode. */
   1670 #define VKI_PPDATADIR	_VKI_IOW(VKI_PP_IOCTL, 0x90, int)
   1671 
   1672 /* Negotiate a particular IEEE 1284 mode. */
   1673 #define VKI_PPNEGOT	_VKI_IOW(VKI_PP_IOCTL, 0x91, int)
   1674 
   1675 /* Set control lines when an interrupt occurs. */
   1676 #define VKI_PPWCTLONIRQ	_VKI_IOW(VKI_PP_IOCTL, 0x92, unsigned char)
   1677 
   1678 /* Clear (and return) interrupt count. */
   1679 #define VKI_PPCLRIRQ	_VKI_IOR(VKI_PP_IOCTL, 0x93, int)
   1680 
   1681 /* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
   1682 #define VKI_PPSETPHASE	_VKI_IOW(VKI_PP_IOCTL, 0x94, int)
   1683 
   1684 /* Set and get port timeout (struct timeval's) */
   1685 #define VKI_PPGETTIME	_VKI_IOR(VKI_PP_IOCTL, 0x95, struct vki_timeval)
   1686 #define VKI_PPSETTIME	_VKI_IOW(VKI_PP_IOCTL, 0x96, struct vki_timeval)
   1687 
   1688 #define VKI_PPGETMODES	_VKI_IOR(VKI_PP_IOCTL, 0x97, unsigned int)
   1689 
   1690 #define VKI_PPGETMODE	_VKI_IOR(VKI_PP_IOCTL, 0x98, int)
   1691 #define VKI_PPGETPHASE	_VKI_IOR(VKI_PP_IOCTL, 0x99, int)
   1692 
   1693 #define VKI_PPGETFLAGS	_VKI_IOR(VKI_PP_IOCTL, 0x9a, int)
   1694 #define VKI_PPSETFLAGS	_VKI_IOW(VKI_PP_IOCTL, 0x9b, int)
   1695 
   1696 //----------------------------------------------------------------------
   1697 // From linux-2.6.8.1/include/linux/fs.h
   1698 //----------------------------------------------------------------------
   1699 
   1700 #define VKI_BLKROSET   _VKI_IO(0x12,93)	/* set device read-only (0 = read-write) */
   1701 #define VKI_BLKROGET   _VKI_IO(0x12,94)	/* get read-only status (0 = read_write) */
   1702 #define VKI_BLKGETSIZE _VKI_IO(0x12,96) /* return device size /512 (long *arg) */
   1703 #define VKI_BLKRASET   _VKI_IO(0x12,98)	/* set read ahead for block device */
   1704 #define VKI_BLKRAGET   _VKI_IO(0x12,99)	/* get current read ahead setting */
   1705 #define VKI_BLKFRASET  _VKI_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
   1706 #define VKI_BLKFRAGET  _VKI_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
   1707 #define VKI_BLKSECTGET _VKI_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
   1708 #define VKI_BLKSSZGET  _VKI_IO(0x12,104)/* get block device sector size */
   1709 #define VKI_BLKBSZGET  _VKI_IOR(0x12,112,vki_size_t)
   1710 #define VKI_BLKBSZSET  _VKI_IOW(0x12,113,vki_size_t)
   1711 #define VKI_BLKGETSIZE64 _VKI_IOR(0x12,114,vki_size_t) /* return device size in bytes (u64 *arg) */
   1712 
   1713 #define VKI_FIBMAP	_VKI_IO(0x00,1)	/* bmap access */
   1714 #define VKI_FIGETBSZ    _VKI_IO(0x00,2)	/* get the block size used for bmap */
   1715 
   1716 //----------------------------------------------------------------------
   1717 // From linux-2.6.8.1/include/scsi/sg.h
   1718 //----------------------------------------------------------------------
   1719 
   1720 typedef struct vki_sg_io_hdr
   1721 {
   1722     int interface_id;           /* [i] 'S' for SCSI generic (required) */
   1723     int dxfer_direction;        /* [i] data transfer direction  */
   1724     unsigned char cmd_len;      /* [i] SCSI command length ( <= 16 bytes) */
   1725     unsigned char mx_sb_len;    /* [i] max length to write to sbp */
   1726     unsigned short iovec_count; /* [i] 0 implies no scatter gather */
   1727     unsigned int dxfer_len;     /* [i] byte count of data transfer */
   1728     void __user *dxferp;	/* [i], [*io] points to data transfer memory
   1729 					      or scatter gather list */
   1730     unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
   1731     void __user *sbp;		/* [i], [*o] points to sense_buffer memory */
   1732     unsigned int timeout;       /* [i] MAX_UINT->no timeout (unit: millisec) */
   1733     unsigned int flags;         /* [i] 0 -> default, see SG_FLAG... */
   1734     int pack_id;                /* [i->o] unused internally (normally) */
   1735     void __user * usr_ptr;      /* [i->o] unused internally */
   1736     unsigned char status;       /* [o] scsi status */
   1737     unsigned char masked_status;/* [o] shifted, masked scsi status */
   1738     unsigned char msg_status;   /* [o] messaging level data (optional) */
   1739     unsigned char sb_len_wr;    /* [o] byte count actually written to sbp */
   1740     unsigned short host_status; /* [o] errors from host adapter */
   1741     unsigned short driver_status;/* [o] errors from software driver */
   1742     int resid;                  /* [o] dxfer_len - actual_transferred */
   1743     unsigned int duration;      /* [o] time taken by cmd (unit: millisec) */
   1744     unsigned int info;          /* [o] auxiliary information */
   1745 } vki_sg_io_hdr_t;  /* 64 bytes long (on i386) */
   1746 
   1747 typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
   1748     int host_no;        /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
   1749     int channel;
   1750     int scsi_id;        /* scsi id of target device */
   1751     int lun;
   1752     int scsi_type;      /* TYPE_... defined in scsi/scsi.h */
   1753     short h_cmd_per_lun;/* host (adapter) maximum commands per lun */
   1754     short d_queue_depth;/* device (or adapter) maximum queue length */
   1755     int unused[2];      /* probably find a good use, set 0 for now */
   1756 } vki_sg_scsi_id_t; /* 32 bytes long on i386 */
   1757 
   1758 #define VKI_SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
   1759 
   1760 #define VKI_SG_SET_RESERVED_SIZE 0x2275  /* request a new reserved buffer size */
   1761 #define VKI_SG_GET_RESERVED_SIZE 0x2272  /* actual size of reserved buffer */
   1762 
   1763 #define VKI_SG_GET_SCSI_ID 0x2276   /* Yields fd's bus, chan, dev, lun + type */
   1764 
   1765 #define VKI_SG_GET_SG_TABLESIZE 0x227F  /* 0 implies can't do scatter gather */
   1766 
   1767 #define VKI_SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
   1768 
   1769 #define VKI_SG_IO 0x2285   /* similar effect as write() followed by read() */
   1770 
   1771 #define VKI_SG_SET_TIMEOUT 0x2201  /* unit: jiffies (10ms on i386) */
   1772 #define VKI_SG_GET_TIMEOUT 0x2202  /* yield timeout as _return_ value */
   1773 
   1774 //#define SG_GET_COMMAND_Q 0x2270   /* Yields 0 (queuing off) or 1 (on) */
   1775 #define VKI_SG_SET_COMMAND_Q 0x2271   /* Change queuing state with 0 or 1 */
   1776 
   1777 //----------------------------------------------------------------------
   1778 // From linux-2.6.34/include/scsi/scsi.h and scsi/scsi_ioctl.h
   1779 //----------------------------------------------------------------------
   1780 
   1781 #define VKI_SCSI_IOCTL_DOORLOCK		0x5380 /* Lock the eject mechanism.  */
   1782 #define VKI_SCSI_IOCTL_DOORUNLOCK	0x5381 /* Unlock the mechanism.  */
   1783 #define VKI_SCSI_IOCTL_GET_IDLUN	0x5382
   1784 #define VKI_SCSI_IOCTL_GET_BUS_NUMBER	0x5386
   1785 
   1786 struct vki_scsi_idlun {
   1787 	__vki_u32 dev_id;
   1788 	__vki_u32 host_unique_id;
   1789 };
   1790 
   1791 //----------------------------------------------------------------------
   1792 // From linux-2.6.8.1/include/linux/cdrom.h
   1793 //----------------------------------------------------------------------
   1794 
   1795 #define VKI_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
   1796 #define VKI_CDROMREADTOCHDR		0x5305 /* Read TOC header
   1797                                 	           (struct cdrom_tochdr) */
   1798 #define VKI_CDROMREADTOCENTRY		0x5306 /* Read TOC entry
   1799                                 	           (struct cdrom_tocentry) */
   1800 #define VKI_CDROMSUBCHNL		0x530b /* Read subchannel data
   1801                                 	           (struct cdrom_subchnl) */
   1802 #define VKI_CDROMREADMODE2		0x530c /* Read CDROM mode 2 data (2336 Bytes)
   1803                                 	           (struct cdrom_read) */
   1804 #define VKI_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
   1805 #define VKI_CDROMMULTISESSION		0x5310 /* Obtain the start-of-last-session
   1806                                 	           address of multi session disks
   1807                                 	           (struct cdrom_multisession) */
   1808 #define VKI_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
   1809                                 	           if available (struct cdrom_mcn) */
   1810 #define VKI_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
   1811                                 	          (struct cdrom_volctrl) */
   1812 #define VKI_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
   1813                                 	           (struct cdrom_read) */
   1814 #define VKI_CDROM_CLEAR_OPTIONS		0x5321  /* Clear behavior options */
   1815 #define VKI_CDROM_DRIVE_STATUS		0x5326  /* Get tray position, etc. */
   1816 #define VKI_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
   1817 
   1818 #define VKI_CDROM_SEND_PACKET		0x5393	/* send a packet to the drive */
   1819 
   1820 struct vki_cdrom_msf0
   1821 {
   1822 	__vki_u8	minute;
   1823 	__vki_u8	second;
   1824 	__vki_u8	frame;
   1825 };
   1826 
   1827 union vki_cdrom_addr
   1828 {
   1829 	struct vki_cdrom_msf0	msf;
   1830 	int			lba;
   1831 };
   1832 
   1833 struct vki_cdrom_msf
   1834 {
   1835 	__vki_u8	cdmsf_min0;	/* start minute */
   1836 	__vki_u8	cdmsf_sec0;	/* start second */
   1837 	__vki_u8	cdmsf_frame0;	/* start frame */
   1838 	__vki_u8	cdmsf_min1;	/* end minute */
   1839 	__vki_u8	cdmsf_sec1;	/* end second */
   1840 	__vki_u8	cdmsf_frame1;	/* end frame */
   1841 };
   1842 
   1843 struct vki_cdrom_tochdr
   1844 {
   1845 	__vki_u8	cdth_trk0;	/* start track */
   1846 	__vki_u8	cdth_trk1;	/* end track */
   1847 };
   1848 
   1849 struct vki_cdrom_volctrl
   1850 {
   1851 	__vki_u8	channel0;
   1852 	__vki_u8	channel1;
   1853 	__vki_u8	channel2;
   1854 	__vki_u8	channel3;
   1855 };
   1856 
   1857 struct vki_cdrom_subchnl
   1858 {
   1859 	__vki_u8	cdsc_format;
   1860 	__vki_u8	cdsc_audiostatus;
   1861 	__vki_u8	cdsc_adr:	4;
   1862 	__vki_u8	cdsc_ctrl:	4;
   1863 	__vki_u8	cdsc_trk;
   1864 	__vki_u8	cdsc_ind;
   1865 	union vki_cdrom_addr cdsc_absaddr;
   1866 	union vki_cdrom_addr cdsc_reladdr;
   1867 };
   1868 
   1869 struct vki_cdrom_tocentry
   1870 {
   1871 	__vki_u8	cdte_track;
   1872 	__vki_u8	cdte_adr	:4;
   1873 	__vki_u8	cdte_ctrl	:4;
   1874 	__vki_u8	cdte_format;
   1875 	union vki_cdrom_addr cdte_addr;
   1876 	__vki_u8	cdte_datamode;
   1877 };
   1878 
   1879 struct vki_cdrom_read
   1880 {
   1881 	int	cdread_lba;
   1882 	char 	*cdread_bufaddr;
   1883 	int	cdread_buflen;
   1884 };
   1885 
   1886 struct vki_cdrom_read_audio
   1887 {
   1888 	union vki_cdrom_addr addr; /* frame address */
   1889 	__vki_u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
   1890 	int nframes;           /* number of 2352-byte-frames to read at once */
   1891 	__vki_u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
   1892 };
   1893 
   1894 struct vki_cdrom_multisession
   1895 {
   1896 	union vki_cdrom_addr addr; /* frame address: start-of-last-session
   1897 	                           (not the new "frame 16"!).  Only valid
   1898 	                           if the "xa_flag" is true. */
   1899 	__vki_u8 xa_flag;        /* 1: "is XA disk" */
   1900 	__vki_u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
   1901 };
   1902 
   1903 struct vki_cdrom_mcn
   1904 {
   1905   __vki_u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
   1906 };
   1907 
   1908 #define VKI_CDROM_PACKET_SIZE	12
   1909 
   1910 struct vki_cdrom_generic_command
   1911 {
   1912 	unsigned char 		cmd[VKI_CDROM_PACKET_SIZE];
   1913 	unsigned char		__user *buffer;
   1914 	unsigned int 		buflen;
   1915 	int			stat;
   1916         // [[replace with void* to reduce inclusion amounts]]
   1917 	void/*struct vki_request_sense	*/__user *sense;
   1918 	unsigned char		data_direction;
   1919 	int			quiet;
   1920 	int			timeout;
   1921 	void			__user *reserved[1];	/* unused, actually */
   1922 };
   1923 
   1924 #define VKI_CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
   1925 #define VKI_CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
   1926 #define VKI_CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
   1927 #define VKI_CD_FRAMESIZE_RAW0 (VKI_CD_FRAMESIZE_RAW-VKI_CD_SYNC_SIZE-VKI_CD_HEAD_SIZE) /*2336*/
   1928 
   1929 //----------------------------------------------------------------------
   1930 // From linux-2.6.8.1/include/linux/soundcard.h
   1931 //----------------------------------------------------------------------
   1932 
   1933 #ifndef _VKI_SIOWR
   1934 #if defined(_VKI_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
   1935 /* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
   1936 #define	_VKI_SIO		_VKI_IO
   1937 #define	_VKI_SIOR		_VKI_IOR
   1938 #define	_VKI_SIOW		_VKI_IOW
   1939 #define	_VKI_SIOWR		_VKI_IOWR
   1940 #else
   1941 // [[Valgrind: Install this case if/when necessary]
   1942 #error Valgrind: Cannot handle sparc/sun case yet...
   1943 #  endif /* _IOWR */
   1944 #endif  /* !_VKI_SIOWR */
   1945 
   1946 #define VKI_SNDCTL_SEQ_CTRLRATE		_VKI_SIOWR('Q', 3, int)	/* Set/get timer resolution (HZ) */
   1947 #define VKI_SNDCTL_SEQ_GETOUTCOUNT	_VKI_SIOR ('Q', 4, int)
   1948 #define VKI_SNDCTL_SEQ_GETINCOUNT	_VKI_SIOR ('Q', 5, int)
   1949 #define VKI_SNDCTL_SEQ_PERCMODE		_VKI_SIOW ('Q', 6, int)
   1950 #define VKI_SNDCTL_SEQ_TESTMIDI		_VKI_SIOW ('Q', 8, int)
   1951 #define VKI_SNDCTL_SEQ_RESETSAMPLES	_VKI_SIOW ('Q', 9, int)
   1952 #define VKI_SNDCTL_SEQ_NRSYNTHS		_VKI_SIOR ('Q',10, int)
   1953 #define VKI_SNDCTL_SEQ_NRMIDIS		_VKI_SIOR ('Q',11, int)
   1954 #define VKI_SNDCTL_SEQ_GETTIME		_VKI_SIOR ('Q',19, int)
   1955 
   1956 #define VKI_SNDCTL_TMR_TIMEBASE		_VKI_SIOWR('T', 1, int)
   1957 #define VKI_SNDCTL_TMR_TEMPO		_VKI_SIOWR('T', 5, int)
   1958 #define VKI_SNDCTL_TMR_SOURCE		_VKI_SIOWR('T', 6, int)
   1959 
   1960 #define VKI_SNDCTL_MIDI_PRETIME		_VKI_SIOWR('m', 0, int)
   1961 #define VKI_SNDCTL_MIDI_MPUMODE		_VKI_SIOWR('m', 1, int)
   1962 
   1963 #define VKI_SNDCTL_DSP_RESET		_VKI_SIO  ('P', 0)
   1964 #define VKI_SNDCTL_DSP_SYNC		_VKI_SIO  ('P', 1)
   1965 #define VKI_SNDCTL_DSP_SPEED		_VKI_SIOWR('P', 2, int)
   1966 #define VKI_SNDCTL_DSP_STEREO		_VKI_SIOWR('P', 3, int)
   1967 #define VKI_SNDCTL_DSP_GETBLKSIZE	_VKI_SIOWR('P', 4, int)
   1968 #define VKI_SNDCTL_DSP_CHANNELS		_VKI_SIOWR('P', 6, int)
   1969 #define VKI_SOUND_PCM_WRITE_FILTER	_VKI_SIOWR('P', 7, int)
   1970 #define VKI_SNDCTL_DSP_POST		_VKI_SIO  ('P', 8)
   1971 #define VKI_SNDCTL_DSP_SUBDIVIDE	_VKI_SIOWR('P', 9, int)
   1972 #define VKI_SNDCTL_DSP_SETFRAGMENT	_VKI_SIOWR('P',10, int)
   1973 
   1974 #define VKI_SNDCTL_DSP_GETFMTS		_VKI_SIOR ('P',11, int) /* Returns a mask */
   1975 #define VKI_SNDCTL_DSP_SETFMT		_VKI_SIOWR('P', 5, int) /* Selects ONE fmt */
   1976 
   1977 typedef struct vki_audio_buf_info {
   1978 			int fragments;	/* # of available fragments (partially usend ones not counted) */
   1979 			int fragstotal;	/* Total # of fragments allocated */
   1980 			int fragsize;	/* Size of a fragment in bytes */
   1981 
   1982 			int bytes;	/* Available space in bytes (includes partially used fragments) */
   1983 			/* Note! 'bytes' could be more than fragments*fragsize */
   1984 		} vki_audio_buf_info;
   1985 
   1986 #define VKI_SNDCTL_DSP_GETOSPACE	_VKI_SIOR ('P',12, vki_audio_buf_info)
   1987 #define VKI_SNDCTL_DSP_GETISPACE	_VKI_SIOR ('P',13, vki_audio_buf_info)
   1988 #define VKI_SNDCTL_DSP_NONBLOCK		_VKI_SIO  ('P',14)
   1989 #define VKI_SNDCTL_DSP_GETCAPS		_VKI_SIOR ('P',15, int)
   1990 
   1991 #define VKI_SNDCTL_DSP_GETTRIGGER	_VKI_SIOR ('P',16, int)
   1992 #define VKI_SNDCTL_DSP_SETTRIGGER	_VKI_SIOW ('P',16, int)
   1993 
   1994 #define VKI_SNDCTL_DSP_SETSYNCRO	_VKI_SIO  ('P', 21)
   1995 #define VKI_SNDCTL_DSP_SETDUPLEX	_VKI_SIO  ('P', 22)
   1996 #define VKI_SNDCTL_DSP_GETODELAY	_VKI_SIOR ('P', 23, int)
   1997 
   1998 #define VKI_SNDCTL_DSP_GETCHANNELMASK	_VKI_SIOWR('P', 64, int)
   1999 #define VKI_SNDCTL_DSP_BIND_CHANNEL	_VKI_SIOWR('P', 65, int)
   2000 
   2001 #define VKI_SNDCTL_DSP_SETSPDIF		_VKI_SIOW ('P', 66, int)
   2002 #define VKI_SNDCTL_DSP_GETSPDIF		_VKI_SIOR ('P', 67, int)
   2003 
   2004 #define VKI_SOUND_PCM_READ_RATE		_VKI_SIOR ('P', 2, int)
   2005 #define VKI_SOUND_PCM_READ_CHANNELS	_VKI_SIOR ('P', 6, int)
   2006 #define VKI_SOUND_PCM_READ_BITS		_VKI_SIOR ('P', 5, int)
   2007 #define VKI_SOUND_PCM_READ_FILTER	_VKI_SIOR ('P', 7, int)
   2008 
   2009 
   2010 //----------------------------------------------------------------------
   2011 // From linux-2.6.8.1/include/linux/hdreg.h
   2012 //----------------------------------------------------------------------
   2013 
   2014 struct vki_hd_geometry {
   2015       unsigned char heads;
   2016       unsigned char sectors;
   2017       unsigned short cylinders;
   2018       unsigned long start;
   2019 };
   2020 
   2021 #define VKI_HDIO_GETGEO		0x0301	/* get device geometry */
   2022 #define VKI_HDIO_GET_DMA	0x030b	/* get use-dma flag */
   2023 #define VKI_HDIO_GET_IDENTITY	0x030d	/* get IDE identification info */
   2024 
   2025 // [[Nb: done like this because the original type is a huge struct that will
   2026 //   always be the same size.]]
   2027 #define VKI_SIZEOF_STRUCT_HD_DRIVEID   512
   2028 
   2029 //----------------------------------------------------------------------
   2030 // From linux-2.6.8.1/include/linux/fb.h
   2031 //----------------------------------------------------------------------
   2032 
   2033 #define VKI_FBIOGET_VSCREENINFO	0x4600
   2034 #define VKI_FBIOPUT_VSCREENINFO	0x4601
   2035 #define VKI_FBIOGET_FSCREENINFO	0x4602
   2036 #define VKI_FBIOPAN_DISPLAY	0x4606
   2037 
   2038 struct vki_fb_fix_screeninfo {
   2039 	char id[16];			/* identification string eg "TT Builtin" */
   2040 	unsigned long smem_start;	/* Start of frame buffer mem */
   2041 					/* (physical address) */
   2042 	__vki_u32 smem_len;			/* Length of frame buffer mem */
   2043 	__vki_u32 type;			/* see FB_TYPE_*		*/
   2044 	__vki_u32 type_aux;		/* Interleave for interleaved Planes */
   2045 	__vki_u32 visual;		/* see FB_VISUAL_*		*/
   2046 	__vki_u16 xpanstep;		/* zero if no hardware panning  */
   2047 	__vki_u16 ypanstep;		/* zero if no hardware panning  */
   2048 	__vki_u16 ywrapstep;		/* zero if no hardware ywrap    */
   2049 	__vki_u32 line_length;		/* length of a line in bytes    */
   2050 	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
   2051 					/* (physical address) */
   2052 	__vki_u32 mmio_len;		/* Length of Memory Mapped I/O  */
   2053 	__vki_u32 accel;		/* Indicate to driver which	*/
   2054 					/*  specific chip/card we have	*/
   2055 	__vki_u16 reserved[3];		/* Reserved for future compatibility */
   2056 };
   2057 
   2058 struct vki_fb_bitfield {
   2059 	__vki_u32 offset;		/* beginning of bitfield	*/
   2060 	__vki_u32 length;		/* length of bitfield		*/
   2061 	__vki_u32 msb_right;		/* != 0 : Most significant bit is */
   2062 					/* right */
   2063 };
   2064 
   2065 struct vki_fb_var_screeninfo {
   2066 	__vki_u32 xres;			/* visible resolution		*/
   2067 	__vki_u32 yres;
   2068 	__vki_u32 xres_virtual;		/* virtual resolution		*/
   2069 	__vki_u32 yres_virtual;
   2070 	__vki_u32 xoffset;		/* offset from virtual to visible */
   2071 	__vki_u32 yoffset;		/* resolution			*/
   2072 
   2073 	__vki_u32 bits_per_pixel;	/* guess what			*/
   2074 	__vki_u32 grayscale;		/* != 0 Graylevels instead of colors */
   2075 
   2076 	struct vki_fb_bitfield red;	/* bitfield in fb mem if true color, */
   2077 	struct vki_fb_bitfield green;	/* else only length is significant */
   2078 	struct vki_fb_bitfield blue;
   2079 	struct vki_fb_bitfield transp;	/* transparency			*/
   2080 
   2081 	__vki_u32 nonstd;		/* != 0 Non standard pixel format */
   2082 
   2083 	__vki_u32 activate;		/* see FB_ACTIVATE_*		*/
   2084 
   2085 	__vki_u32 height;		/* height of picture in mm    */
   2086 	__vki_u32 width;		/* width of picture in mm     */
   2087 
   2088 	__vki_u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */
   2089 
   2090 	/* Timing: All values in pixclocks, except pixclock (of course) */
   2091 	__vki_u32 pixclock;		/* pixel clock in ps (pico seconds) */
   2092 	__vki_u32 left_margin;		/* time from sync to picture	*/
   2093 	__vki_u32 right_margin;		/* time from picture to sync	*/
   2094 	__vki_u32 upper_margin;		/* time from sync to picture	*/
   2095 	__vki_u32 lower_margin;
   2096 	__vki_u32 hsync_len;		/* length of horizontal sync	*/
   2097 	__vki_u32 vsync_len;		/* length of vertical sync	*/
   2098 	__vki_u32 sync;			/* see FB_SYNC_*		*/
   2099 	__vki_u32 vmode;		/* see FB_VMODE_*		*/
   2100 	__vki_u32 rotate;		/* angle we rotate counter clockwise */
   2101 	__vki_u32 reserved[5];		/* Reserved for future compatibility */
   2102 };
   2103 
   2104 //----------------------------------------------------------------------
   2105 // From linux-2.6.9/include/linux/kd.h
   2106 //----------------------------------------------------------------------
   2107 
   2108 #define VKI_GIO_FONT       0x4B60  /* gets font in expanded form */
   2109 #define VKI_PIO_FONT       0x4B61  /* use font in expanded form */
   2110 
   2111 #define VKI_GIO_FONTX      0x4B6B  /* get font using struct consolefontdesc */
   2112 #define VKI_PIO_FONTX      0x4B6C  /* set font using struct consolefontdesc */
   2113 struct vki_consolefontdesc {
   2114 	unsigned short charcount;	/* characters in font (256 or 512) */
   2115 	unsigned short charheight;	/* scan lines per character (1-32) */
   2116 	char __user *chardata;		/* font data in expanded form */
   2117 };
   2118 
   2119 #define VKI_PIO_FONTRESET  0x4B6D  /* reset to default font */
   2120 
   2121 #define VKI_GIO_CMAP       0x4B70  /* gets colour palette on VGA+ */
   2122 #define VKI_PIO_CMAP       0x4B71  /* sets colour palette on VGA+ */
   2123 
   2124 #define VKI_KIOCSOUND      0x4B2F  /* start sound generation (0 for off) */
   2125 #define VKI_KDMKTONE       0x4B30  /* generate tone */
   2126 
   2127 #define VKI_KDGETLED       0x4B31  /* return current led state */
   2128 #define VKI_KDSETLED       0x4B32  /* set led state [lights, not flags] */
   2129 
   2130 #define VKI_KDGKBTYPE      0x4B33  /* get keyboard type */
   2131 
   2132 #define VKI_KDADDIO        0x4B34  /* add i/o port as valid */
   2133 #define VKI_KDDELIO        0x4B35  /* del i/o port as valid */
   2134 #define VKI_KDENABIO       0x4B36  /* enable i/o to video board */
   2135 #define VKI_KDDISABIO      0x4B37  /* disable i/o to video board */
   2136 
   2137 #define VKI_KDSETMODE      0x4B3A  /* set text/graphics mode */
   2138 #define VKI_KDGETMODE      0x4B3B  /* get current mode */
   2139 
   2140 #define VKI_KDMAPDISP      0x4B3C  /* map display into address space */
   2141 #define VKI_KDUNMAPDISP    0x4B3D  /* unmap display from address space */
   2142 
   2143 #define		VKI_E_TABSZ		256
   2144 #define VKI_GIO_SCRNMAP    0x4B40  /* get screen mapping from kernel */
   2145 #define VKI_PIO_SCRNMAP	   0x4B41  /* put screen mapping table in kernel */
   2146 #define VKI_GIO_UNISCRNMAP 0x4B69  /* get full Unicode screen mapping */
   2147 #define VKI_PIO_UNISCRNMAP 0x4B6A  /* set full Unicode screen mapping */
   2148 
   2149 #define VKI_GIO_UNIMAP     0x4B66  /* get unicode-to-font mapping from kernel */
   2150 struct vki_unipair {
   2151 	unsigned short unicode;
   2152 	unsigned short fontpos;
   2153 };
   2154 struct vki_unimapdesc {
   2155 	unsigned short entry_ct;
   2156 	struct vki_unipair __user *entries;
   2157 };
   2158 #define VKI_PIO_UNIMAP     0x4B67  /* put unicode-to-font mapping in kernel */
   2159 #define VKI_PIO_UNIMAPCLR  0x4B68  /* clear table, possibly advise hash algorithm */
   2160 struct vki_unimapinit {
   2161 	unsigned short advised_hashsize;  /* 0 if no opinion */
   2162 	unsigned short advised_hashstep;  /* 0 if no opinion */
   2163 	unsigned short advised_hashlevel; /* 0 if no opinion */
   2164 };
   2165 
   2166 #define VKI_KDGKBMODE      0x4B44  /* gets current keyboard mode */
   2167 #define VKI_KDSKBMODE      0x4B45  /* sets current keyboard mode */
   2168 
   2169 #define VKI_KDGKBMETA      0x4B62  /* gets meta key handling mode */
   2170 #define VKI_KDSKBMETA      0x4B63  /* sets meta key handling mode */
   2171 
   2172 #define VKI_KDGKBLED       0x4B64  /* get led flags (not lights) */
   2173 #define VKI_KDSKBLED       0x4B65  /* set led flags (not lights) */
   2174 
   2175 struct vki_kbentry {
   2176 	unsigned char kb_table;
   2177 	unsigned char kb_index;
   2178 	unsigned short kb_value;
   2179 };
   2180 #define VKI_KDGKBENT       0x4B46  /* gets one entry in translation table */
   2181 #define VKI_KDSKBENT       0x4B47  /* sets one entry in translation table */
   2182 
   2183 struct vki_kbsentry {
   2184 	unsigned char kb_func;
   2185 	unsigned char kb_string[512];
   2186 };
   2187 #define VKI_KDGKBSENT      0x4B48  /* gets one function key string entry */
   2188 #define VKI_KDSKBSENT      0x4B49  /* sets one function key string entry */
   2189 
   2190 struct vki_kbdiacr {
   2191         unsigned char diacr, base, result;
   2192 };
   2193 struct vki_kbdiacrs {
   2194         unsigned int kb_cnt;    /* number of entries in following array */
   2195 	struct vki_kbdiacr kbdiacr[256];    /* MAX_DIACR from keyboard.h */
   2196 };
   2197 #define VKI_KDGKBDIACR     0x4B4A  /* read kernel accent table */
   2198 #define VKI_KDSKBDIACR     0x4B4B  /* write kernel accent table */
   2199 
   2200 struct vki_kbkeycode {
   2201 	unsigned int scancode, keycode;
   2202 };
   2203 #define VKI_KDGETKEYCODE   0x4B4C  /* read kernel keycode table entry */
   2204 #define VKI_KDSETKEYCODE   0x4B4D  /* write kernel keycode table entry */
   2205 
   2206 #define VKI_KDSIGACCEPT    0x4B4E  /* accept kbd generated signals */
   2207 
   2208 struct vki_kbd_repeat {
   2209 	int delay;	/* in msec; <= 0: don't change */
   2210 	int period;	/* in msec; <= 0: don't change */
   2211 			/* earlier this field was misnamed "rate" */
   2212 };
   2213 #define VKI_KDKBDREP       0x4B52  /* set keyboard delay/repeat rate;
   2214                                     * actually used values are returned */
   2215 
   2216 #define VKI_KDFONTOP       0x4B72  /* font operations */
   2217 
   2218 struct vki_console_font_op {
   2219 	unsigned int op;	/* operation code KD_FONT_OP_* */
   2220 	unsigned int flags;	/* KD_FONT_FLAG_* */
   2221 	unsigned int width, height;	/* font size */
   2222 	unsigned int charcount;
   2223 	unsigned char __user *data;	/* font data with height fixed to 32 */
   2224 };
   2225 
   2226 #define VKI_KD_FONT_OP_SET		0	/* Set font */
   2227 #define VKI_KD_FONT_OP_GET		1	/* Get font */
   2228 #define VKI_KD_FONT_OP_SET_DEFAULT	2	/* Set font to default, data points to name / NULL */
   2229 #define VKI_KD_FONT_OP_COPY		3	/* Copy from another console */
   2230 
   2231 //----------------------------------------------------------------------
   2232 // From linux-2.6.9/include/linux/kb.h
   2233 //----------------------------------------------------------------------
   2234 
   2235 typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
   2236 
   2237 //----------------------------------------------------------------------
   2238 // From linux-2.6.20.1/include/linux/ptrace.h
   2239 //----------------------------------------------------------------------
   2240 
   2241 #define VKI_PTRACE_TRACEME         0
   2242 #define VKI_PTRACE_PEEKTEXT	   1
   2243 #define VKI_PTRACE_PEEKDATA	   2
   2244 #define VKI_PTRACE_PEEKUSR	   3
   2245 #define VKI_PTRACE_POKEUSR	   6
   2246 
   2247 #define VKI_PTRACE_DETACH         17
   2248 
   2249 #define VKI_PTRACE_GETEVENTMSG	0x4201
   2250 #define VKI_PTRACE_GETSIGINFO	0x4202
   2251 #define VKI_PTRACE_SETSIGINFO	0x4203
   2252 
   2253 //----------------------------------------------------------------------
   2254 // From linux-2.6.14/include/sound/asound.h
   2255 //----------------------------------------------------------------------
   2256 
   2257 enum {
   2258 	VKI_SNDRV_PCM_IOCTL_HW_FREE = _VKI_IO('A', 0x12),
   2259 	VKI_SNDRV_PCM_IOCTL_HWSYNC = _VKI_IO('A', 0x22),
   2260 	VKI_SNDRV_PCM_IOCTL_PREPARE = _VKI_IO('A', 0x40),
   2261 	VKI_SNDRV_PCM_IOCTL_RESET = _VKI_IO('A', 0x41),
   2262 	VKI_SNDRV_PCM_IOCTL_START = _VKI_IO('A', 0x42),
   2263 	VKI_SNDRV_PCM_IOCTL_DROP = _VKI_IO('A', 0x43),
   2264 	VKI_SNDRV_PCM_IOCTL_DRAIN = _VKI_IO('A', 0x44),
   2265 	VKI_SNDRV_PCM_IOCTL_PAUSE = _VKI_IOW('A', 0x45, int),
   2266 	VKI_SNDRV_PCM_IOCTL_RESUME = _VKI_IO('A', 0x47),
   2267 	VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48),
   2268 	VKI_SNDRV_PCM_IOCTL_LINK = _VKI_IOW('A', 0x60, int),
   2269 	VKI_SNDRV_PCM_IOCTL_UNLINK = _VKI_IO('A', 0x61),
   2270 };
   2271 
   2272 enum {
   2273 	VKI_SNDRV_TIMER_IOCTL_START = _VKI_IO('T', 0xa0),
   2274 	VKI_SNDRV_TIMER_IOCTL_STOP = _VKI_IO('T', 0xa1),
   2275 	VKI_SNDRV_TIMER_IOCTL_CONTINUE = _VKI_IO('T', 0xa2),
   2276 	VKI_SNDRV_TIMER_IOCTL_PAUSE = _VKI_IO('T', 0xa3),
   2277 };
   2278 
   2279 //----------------------------------------------------------------------
   2280 // From linux-2.6.15.4/include/linux/serial.h
   2281 //----------------------------------------------------------------------
   2282 
   2283 struct vki_serial_icounter_struct {
   2284 	int cts, dsr, rng, dcd;
   2285 	int rx, tx;
   2286 	int frame, overrun, parity, brk;
   2287 	int buf_overrun;
   2288 	int reserved[9];
   2289 };
   2290 
   2291 //----------------------------------------------------------------------
   2292 // From linux-2.6.16/include/linux/vt.h
   2293 //----------------------------------------------------------------------
   2294 
   2295 #define VKI_VT_OPENQRY	0x5600	/* find available vt */
   2296 
   2297 struct vki_vt_mode {
   2298 	char mode;		/* vt mode */
   2299 	char waitv;		/* if set, hang on writes if not active */
   2300 	short relsig;		/* signal to raise on release req */
   2301 	short acqsig;		/* signal to raise on acquisition */
   2302 	short frsig;		/* unused (set to 0) */
   2303 };
   2304 #define VKI_VT_GETMODE	0x5601	/* get mode of active vt */
   2305 #define VKI_VT_SETMODE	0x5602	/* set mode of active vt */
   2306 
   2307 struct vki_vt_stat {
   2308 	unsigned short v_active;	/* active vt */
   2309 	unsigned short v_signal;	/* signal to send */
   2310 	unsigned short v_state;		/* vt bitmask */
   2311 };
   2312 #define VKI_VT_GETSTATE	0x5603	/* get global vt state info */
   2313 #define VKI_VT_SENDSIG	0x5604	/* signal to send to bitmask of vts */
   2314 
   2315 #define VKI_VT_RELDISP	0x5605	/* release display */
   2316 
   2317 #define VKI_VT_ACTIVATE	0x5606	/* make vt active */
   2318 #define VKI_VT_WAITACTIVE	0x5607	/* wait for vt active */
   2319 #define VKI_VT_DISALLOCATE	0x5608  /* free memory associated to vt */
   2320 
   2321 struct vki_vt_sizes {
   2322 	unsigned short v_rows;		/* number of rows */
   2323 	unsigned short v_cols;		/* number of columns */
   2324 	unsigned short v_scrollsize;	/* number of lines of scrollback */
   2325 };
   2326 #define VKI_VT_RESIZE	0x5609	/* set kernel's idea of screensize */
   2327 
   2328 struct vki_vt_consize {
   2329 	unsigned short v_rows;	/* number of rows */
   2330 	unsigned short v_cols;	/* number of columns */
   2331 	unsigned short v_vlin;	/* number of pixel rows on screen */
   2332 	unsigned short v_clin;	/* number of pixel rows per character */
   2333 	unsigned short v_vcol;	/* number of pixel columns on screen */
   2334 	unsigned short v_ccol;	/* number of pixel columns per character */
   2335 };
   2336 #define VKI_VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
   2337 #define VKI_VT_LOCKSWITCH   0x560B  /* disallow vt switching */
   2338 #define VKI_VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
   2339 
   2340 //----------------------------------------------------------------------
   2341 // From linux-2.6.19/include/linux/prctl.h
   2342 //----------------------------------------------------------------------
   2343 
   2344 #define VKI_PR_SET_PDEATHSIG  1  /* Second arg is a signal */
   2345 #define VKI_PR_GET_PDEATHSIG  2  /* Second arg is a ptr to return the signal */
   2346 
   2347 #define VKI_PR_GET_DUMPABLE   3
   2348 #define VKI_PR_SET_DUMPABLE   4
   2349 
   2350 #define VKI_PR_GET_UNALIGN	  5
   2351 #define VKI_PR_SET_UNALIGN	  6
   2352 # define VKI_PR_UNALIGN_NOPRINT	1	/* silently fix up unaligned user accesses */
   2353 # define VKI_PR_UNALIGN_SIGBUS	2	/* generate SIGBUS on unaligned user access */
   2354 
   2355 #define VKI_PR_GET_KEEPCAPS   7
   2356 #define VKI_PR_SET_KEEPCAPS   8
   2357 
   2358 #define VKI_PR_GET_FPEMU  9
   2359 #define VKI_PR_SET_FPEMU 10
   2360 # define VKI_PR_FPEMU_NOPRINT	1	/* silently emulate fp operations accesses */
   2361 # define VKI_PR_FPEMU_SIGFPE	2	/* don't emulate fp operations, send SIGFPE instead */
   2362 
   2363 #define VKI_PR_GET_FPEXC	11
   2364 #define VKI_PR_SET_FPEXC	12
   2365 # define VKI_PR_FP_EXC_SW_ENABLE	0x80	/* Use FPEXC for FP exception enables */
   2366 # define VKI_PR_FP_EXC_DIV		0x010000	/* floating point divide by zero */
   2367 # define VKI_PR_FP_EXC_OVF		0x020000	/* floating point overflow */
   2368 # define VKI_PR_FP_EXC_UND		0x040000	/* floating point underflow */
   2369 # define VKI_PR_FP_EXC_RES		0x080000	/* floating point inexact result */
   2370 # define VKI_PR_FP_EXC_INV		0x100000	/* floating point invalid operation */
   2371 # define VKI_PR_FP_EXC_DISABLED	0	/* FP exceptions disabled */
   2372 # define VKI_PR_FP_EXC_NONRECOV	1	/* async non-recoverable exc. mode */
   2373 # define VKI_PR_FP_EXC_ASYNC	2	/* async recoverable exception mode */
   2374 # define VKI_PR_FP_EXC_PRECISE	3	/* precise exception mode */
   2375 
   2376 #define VKI_PR_GET_TIMING   13
   2377 #define VKI_PR_SET_TIMING   14
   2378 # define VKI_PR_TIMING_STATISTICAL  0       /* Normal, traditional,
   2379                                                    statistical process timing */
   2380 # define VKI_PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
   2381                                                    process timing */
   2382 
   2383 #define VKI_PR_SET_NAME    15		/* Set process name */
   2384 #define VKI_PR_GET_NAME    16		/* Get process name */
   2385 
   2386 #define VKI_PR_GET_ENDIAN	19
   2387 #define VKI_PR_SET_ENDIAN	20
   2388 # define VKI_PR_ENDIAN_BIG		0
   2389 # define VKI_PR_ENDIAN_LITTLE	1	/* True little endian mode */
   2390 # define VKI_PR_ENDIAN_PPC_LITTLE	2	/* "PowerPC" pseudo little endian */
   2391 
   2392 //----------------------------------------------------------------------
   2393 // From linux-2.6.19/include/linux/usbdevice_fs.h
   2394 //----------------------------------------------------------------------
   2395 
   2396 struct vki_usbdevfs_ctrltransfer {
   2397 	__vki_u8 bRequestType;
   2398 	__vki_u8 bRequest;
   2399 	__vki_u16 wValue;
   2400 	__vki_u16 wIndex;
   2401 	__vki_u16 wLength;
   2402 	__vki_u32 timeout;  /* in milliseconds */
   2403  	void __user *data;
   2404 };
   2405 
   2406 struct vki_usbdevfs_bulktransfer {
   2407 	unsigned int ep;
   2408 	unsigned int len;
   2409 	unsigned int timeout; /* in milliseconds */
   2410 	void __user *data;
   2411 };
   2412 
   2413 #define VKI_USBDEVFS_MAXDRIVERNAME 255
   2414 
   2415 struct vki_usbdevfs_getdriver {
   2416 	unsigned int interface;
   2417 	char driver[VKI_USBDEVFS_MAXDRIVERNAME + 1];
   2418 };
   2419 
   2420 struct vki_usbdevfs_connectinfo {
   2421 	unsigned int devnum;
   2422 	unsigned char slow;
   2423 };
   2424 
   2425 struct vki_usbdevfs_iso_packet_desc {
   2426 	unsigned int length;
   2427 	unsigned int actual_length;
   2428 	unsigned int status;
   2429 };
   2430 
   2431 struct vki_usbdevfs_urb {
   2432 	unsigned char type;
   2433 	unsigned char endpoint;
   2434 	int status;
   2435 	unsigned int flags;
   2436 	void __user *buffer;
   2437 	int buffer_length;
   2438 	int actual_length;
   2439 	int start_frame;
   2440 	int number_of_packets;
   2441 	int error_count;
   2442 	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
   2443 	void *usercontext;
   2444 	struct vki_usbdevfs_iso_packet_desc iso_frame_desc[0];
   2445 };
   2446 
   2447 struct vki_usbdevfs_ioctl {
   2448 	int	ifno;		/* interface 0..N ; negative numbers reserved */
   2449 	int	ioctl_code;	/* MUST encode size + direction of data so the
   2450 				 * macros in <asm/ioctl.h> give correct values */
   2451 	void __user *data;	/* param buffer (in, or out) */
   2452 };
   2453 
   2454 #define VKI_USBDEVFS_CONTROL           _VKI_IOWR('U', 0, struct vki_usbdevfs_ctrltransfer)
   2455 #define VKI_USBDEVFS_BULK              _VKI_IOWR('U', 2, struct vki_usbdevfs_bulktransfer)
   2456 #define VKI_USBDEVFS_GETDRIVER         _VKI_IOW('U', 8, struct vki_usbdevfs_getdriver)
   2457 #define VKI_USBDEVFS_SUBMITURB         _VKI_IOR('U', 10, struct vki_usbdevfs_urb)
   2458 #define VKI_USBDEVFS_DISCARDURB        _VKI_IO('U', 11)
   2459 #define VKI_USBDEVFS_REAPURB           _VKI_IOW('U', 12, void *)
   2460 #define VKI_USBDEVFS_REAPURBNDELAY     _VKI_IOW('U', 13, void *)
   2461 #define VKI_USBDEVFS_CONNECTINFO       _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo)
   2462 #define VKI_USBDEVFS_IOCTL             _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl)
   2463 #define VKI_USBDEVFS_RESET             _VKI_IO('U', 20)
   2464 
   2465 #define VKI_USBDEVFS_URB_TYPE_ISO              0
   2466 #define VKI_USBDEVFS_URB_TYPE_INTERRUPT        1
   2467 #define VKI_USBDEVFS_URB_TYPE_CONTROL          2
   2468 #define VKI_USBDEVFS_URB_TYPE_BULK             3
   2469 
   2470 // [[this is missing in usbdevice_fs.h]]
   2471 struct vki_usbdevfs_setuppacket {
   2472        __vki_u8 bRequestType;
   2473        __vki_u8 bRequest;
   2474        __vki_u16 wValue;
   2475        __vki_u16 wIndex;
   2476        __vki_u16 wLength;
   2477 };
   2478 
   2479 //----------------------------------------------------------------------
   2480 // From linux-2.6.20.1/include/linux/i2c.h
   2481 //----------------------------------------------------------------------
   2482 
   2483 #define VKI_I2C_SLAVE		0x0703	/* Change slave address			*/
   2484 					/* Attn.: Slave address is 7 or 10 bits */
   2485 #define VKI_I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
   2486 					/* Attn.: Slave address is 7 or 10 bits */
   2487 					/* This changes the address, even if it */
   2488 					/* is already taken!			*/
   2489 #define VKI_I2C_TENBIT		0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit	*/
   2490 #define VKI_I2C_FUNCS		0x0705	/* Get the adapter functionality */
   2491 #define VKI_I2C_RDWR		0x0707	/* Combined R/W transfer (one STOP only) */
   2492 #define VKI_I2C_PEC		0x0708	/* != 0 for SMBus PEC                   */
   2493 
   2494 struct vki_i2c_msg {
   2495 	__vki_u16 addr;		/* slave address			*/
   2496 	__vki_u16 flags;
   2497 #define VKI_I2C_M_TEN		0x0010	/* this is a ten bit chip address */
   2498 #define VKI_I2C_M_RD		0x0001	/* read data, from slave to master */
   2499 #define VKI_I2C_M_NOSTART	0x4000	/* if I2C_FUNC_PROTOCOL_MANGLING */
   2500 #define VKI_I2C_M_REV_DIR_ADDR	0x2000	/* if I2C_FUNC_PROTOCOL_MANGLING */
   2501 #define VKI_I2C_M_IGNORE_NAK	0x1000	/* if I2C_FUNC_PROTOCOL_MANGLING */
   2502 #define VKI_I2C_M_NO_RD_ACK	0x0800	/* if I2C_FUNC_PROTOCOL_MANGLING */
   2503 #define VKI_I2C_M_RECV_LEN	0x0400	/* length will be first received byte */
   2504 	__vki_u16 len;		/* msg length				*/
   2505 	__vki_u8 *buf;		/* pointer to msg data			*/
   2506 };
   2507 
   2508 struct vki_i2c_rdwr_ioctl_data {
   2509 	struct vki_i2c_msg *msgs;	/* pointers to i2c_msgs */
   2510 	__vki_u32 nmsgs;		/* number of i2c_msgs */
   2511 };
   2512 
   2513 //----------------------------------------------------------------------
   2514 // From linux-2.6.20.1/include/linux/keyctl.h
   2515 //----------------------------------------------------------------------
   2516 
   2517 /* keyctl commands */
   2518 #define VKI_KEYCTL_GET_KEYRING_ID	0	/* ask for a keyring's ID */
   2519 #define VKI_KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
   2520 #define VKI_KEYCTL_UPDATE		2	/* update a key */
   2521 #define VKI_KEYCTL_REVOKE		3	/* revoke a key */
   2522 #define VKI_KEYCTL_CHOWN		4	/* set ownership of a key */
   2523 #define VKI_KEYCTL_SETPERM		5	/* set perms on a key */
   2524 #define VKI_KEYCTL_DESCRIBE		6	/* describe a key */
   2525 #define VKI_KEYCTL_CLEAR		7	/* clear contents of a keyring */
   2526 #define VKI_KEYCTL_LINK			8	/* link a key into a keyring */
   2527 #define VKI_KEYCTL_UNLINK		9	/* unlink a key from a keyring */
   2528 #define VKI_KEYCTL_SEARCH		10	/* search for a key in a keyring */
   2529 #define VKI_KEYCTL_READ			11	/* read a key or keyring's contents */
   2530 #define VKI_KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
   2531 #define VKI_KEYCTL_NEGATE		13	/* negate a partially constructed key */
   2532 #define VKI_KEYCTL_SET_REQKEY_KEYRING	14	/* set default request-key keyring */
   2533 #define VKI_KEYCTL_SET_TIMEOUT		15	/* set key timeout */
   2534 #define VKI_KEYCTL_ASSUME_AUTHORITY	16	/* assume request_key() authorisation */
   2535 
   2536 /*--------------------------------------------------------------------*/
   2537 // From linux-2.6.20.1/include/linux/key.h
   2538 /*--------------------------------------------------------------------*/
   2539 
   2540 /* key handle serial number */
   2541 typedef vki_int32_t vki_key_serial_t;
   2542 
   2543 /* key handle permissions mask */
   2544 typedef vki_uint32_t vki_key_perm_t;
   2545 
   2546 //----------------------------------------------------------------------
   2547 // From linux-2.6.24.7/include/linux/wireless.h
   2548 // (wireless extensions version 22, 2007-03-16)
   2549 //----------------------------------------------------------------------
   2550 
   2551 /*
   2552  * [[Wireless extensions ioctls.]]
   2553  */
   2554 
   2555 /* Wireless Identification */
   2556 #define VKI_SIOCSIWCOMMIT	0x8B00	/* Commit pending changes to driver */
   2557 #define VKI_SIOCGIWNAME		0x8B01	/* get name == wireless protocol */
   2558 
   2559 /* Basic operations */
   2560 #define VKI_SIOCSIWNWID		0x8B02	/* set network id (pre-802.11) */
   2561 #define VKI_SIOCGIWNWID		0x8B03	/* get network id (the cell) */
   2562 #define VKI_SIOCSIWFREQ		0x8B04	/* set channel/frequency (Hz) */
   2563 #define VKI_SIOCGIWFREQ		0x8B05	/* get channel/frequency (Hz) */
   2564 #define VKI_SIOCSIWMODE		0x8B06	/* set operation mode */
   2565 #define VKI_SIOCGIWMODE		0x8B07	/* get operation mode */
   2566 #define VKI_SIOCSIWSENS		0x8B08	/* set sensitivity (dBm) */
   2567 #define VKI_SIOCGIWSENS		0x8B09	/* get sensitivity (dBm) */
   2568 
   2569 /* Informative stuff */
   2570 #define VKI_SIOCSIWRANGE	0x8B0A	/* Unused */
   2571 #define VKI_SIOCGIWRANGE	0x8B0B	/* Get range of parameters */
   2572 #define VKI_SIOCSIWPRIV		0x8B0C	/* Unused */
   2573 #define VKI_SIOCGIWPRIV		0x8B0D	/* get private ioctl interface info */
   2574 #define VKI_SIOCSIWSTATS	0x8B0E	/* Unused */
   2575 #define VKI_SIOCGIWSTATS	0x8B0F	/* Get /proc/net/wireless stats */
   2576 
   2577 /* Spy support (statistics per MAC address - used for Mobile IP support) */
   2578 #define VKI_SIOCSIWSPY		0x8B10	/* set spy addresses */
   2579 #define VKI_SIOCGIWSPY		0x8B11	/* get spy info (quality of link) */
   2580 #define VKI_SIOCSIWTHRSPY	0x8B12	/* set spy threshold (spy event) */
   2581 #define VKI_SIOCGIWTHRSPY	0x8B13	/* get spy threshold */
   2582 
   2583 /* Access Point manipulation */
   2584 #define VKI_SIOCSIWAP		0x8B14	/* set access point MAC addresses */
   2585 #define VKI_SIOCGIWAP		0x8B15	/* get access point MAC addresses */
   2586 #define VKI_SIOCGIWAPLIST	0x8B17	/* Deprecated in favor of scanning */
   2587 #define VKI_SIOCSIWSCAN         0x8B18	/* trigger scanning (list cells) */
   2588 #define VKI_SIOCGIWSCAN         0x8B19	/* get scanning results */
   2589 
   2590 /* 802.11 specific support */
   2591 #define VKI_SIOCSIWESSID	0x8B1A	/* set ESSID (network name) */
   2592 #define VKI_SIOCGIWESSID	0x8B1B	/* get ESSID */
   2593 #define VKI_SIOCSIWNICKN	0x8B1C	/* set node name/nickname */
   2594 #define VKI_SIOCGIWNICKN	0x8B1D	/* get node name/nickname */
   2595 
   2596 /* Other parameters useful in 802.11 and some other devices */
   2597 #define VKI_SIOCSIWRATE		0x8B20	/* set default bit rate (bps) */
   2598 #define VKI_SIOCGIWRATE		0x8B21	/* get default bit rate (bps) */
   2599 #define VKI_SIOCSIWRTS		0x8B22	/* set RTS/CTS threshold (bytes) */
   2600 #define VKI_SIOCGIWRTS		0x8B23	/* get RTS/CTS threshold (bytes) */
   2601 #define VKI_SIOCSIWFRAG		0x8B24	/* set fragmentation thr (bytes) */
   2602 #define VKI_SIOCGIWFRAG		0x8B25	/* get fragmentation thr (bytes) */
   2603 #define VKI_SIOCSIWTXPOW	0x8B26	/* set transmit power (dBm) */
   2604 #define VKI_SIOCGIWTXPOW	0x8B27	/* get transmit power (dBm) */
   2605 #define VKI_SIOCSIWRETRY	0x8B28	/* set retry limits and lifetime */
   2606 #define VKI_SIOCGIWRETRY	0x8B29	/* get retry limits and lifetime */
   2607 
   2608 /* Encoding stuff (scrambling, hardware security, WEP...) */
   2609 #define VKI_SIOCSIWENCODE	0x8B2A	/* set encoding token & mode */
   2610 #define VKI_SIOCGIWENCODE	0x8B2B	/* get encoding token & mode */
   2611 
   2612 /* Power saving stuff (power management, unicast and multicast) */
   2613 #define VKI_SIOCSIWPOWER	0x8B2C	/* set Power Management settings */
   2614 #define VKI_SIOCGIWPOWER	0x8B2D	/* get Power Management settings */
   2615 
   2616 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
   2617 #define VKI_SIOCSIWGENIE	0x8B30		/* set generic IE */
   2618 #define VKI_SIOCGIWGENIE	0x8B31		/* get generic IE */
   2619 
   2620 /* WPA : IEEE 802.11 MLME requests */
   2621 #define VKI_SIOCSIWMLME		0x8B16	/* request MLME operation; uses
   2622 					 * struct iw_mlme */
   2623 /* WPA : Authentication mode parameters */
   2624 #define VKI_SIOCSIWAUTH		0x8B32	/* set authentication mode params */
   2625 #define VKI_SIOCGIWAUTH		0x8B33	/* get authentication mode params */
   2626 
   2627 /* WPA : Extended version of encoding configuration */
   2628 #define VKI_SIOCSIWENCODEEXT	0x8B34	/* set encoding token & mode */
   2629 #define VKI_SIOCGIWENCODEEXT	0x8B35	/* get encoding token & mode */
   2630 
   2631 /* WPA2 : PMKSA cache management */
   2632 #define VKI_SIOCSIWPMKSA	0x8B36	/* PMKSA cache operation */
   2633 
   2634 /*
   2635  * [[Payload for the wireless extensions ioctls.]]
   2636  */
   2637 
   2638 struct	vki_iw_param
   2639 {
   2640   __vki_s32	value;		/* The value of the parameter itself */
   2641   __vki_u8	fixed;		/* Hardware should not use auto select */
   2642   __vki_u8	disabled;	/* Disable the feature */
   2643   __vki_u16	flags;		/* Various specifc flags (if any) */
   2644 };
   2645 
   2646 struct	vki_iw_point
   2647 {
   2648   void __user	*pointer;	/* Pointer to the data  (in user space) */
   2649   __vki_u16	length;		/* number of fields or size in bytes */
   2650   __vki_u16	flags;		/* Optional params */
   2651 };
   2652 
   2653 struct	vki_iw_freq
   2654 {
   2655 	__vki_s32	m;		/* Mantissa */
   2656 	__vki_s16	e;		/* Exponent */
   2657 	__vki_u8	i;		/* List index (when in range struct) */
   2658 	__vki_u8	flags;		/* Flags (fixed/auto) */
   2659 };
   2660 
   2661 struct	vki_iw_quality
   2662 {
   2663 	__vki_u8	qual;		/* link quality (%retries, SNR,
   2664 					   %missed beacons or better...) */
   2665 	__vki_u8	level;		/* signal level (dBm) */
   2666 	__vki_u8	noise;		/* noise level (dBm) */
   2667 	__vki_u8	updated;	/* Flags to know if updated */
   2668 };
   2669 
   2670 union	vki_iwreq_data
   2671 {
   2672 	/* Config - generic */
   2673 	char		name[VKI_IFNAMSIZ];
   2674 	/* Name : used to verify the presence of  wireless extensions.
   2675 	 * Name of the protocol/provider... */
   2676 
   2677 	struct vki_iw_point	essid;	/* Extended network name */
   2678 	struct vki_iw_param	nwid;	/* network id (or domain - the cell) */
   2679 	struct vki_iw_freq	freq;	/* frequency or channel :
   2680 					 * 0-1000 = channel
   2681 					 * > 1000 = frequency in Hz */
   2682 
   2683 	struct vki_iw_param	sens;	/* signal level threshold */
   2684 	struct vki_iw_param	bitrate;/* default bit rate */
   2685 	struct vki_iw_param	txpower;/* default transmit power */
   2686 	struct vki_iw_param	rts;	/* RTS threshold threshold */
   2687 	struct vki_iw_param	frag;	/* Fragmentation threshold */
   2688 	__vki_u32		mode;	/* Operation mode */
   2689 	struct vki_iw_param	retry;	/* Retry limits & lifetime */
   2690 
   2691 	struct vki_iw_point	encoding; /* Encoding stuff : tokens */
   2692 	struct vki_iw_param	power;	/* PM duration/timeout */
   2693 	struct vki_iw_quality	qual;	/* Quality part of statistics */
   2694 
   2695 	struct vki_sockaddr ap_addr;	/* Access point address */
   2696 	struct vki_sockaddr addr;	/* Destination address (hw/mac) */
   2697 
   2698 	struct vki_iw_param	param;	/* Other small parameters */
   2699 	struct vki_iw_point	data;	/* Other large parameters */
   2700 };
   2701 
   2702 struct	vki_iwreq
   2703 {
   2704 	union
   2705 	{
   2706 		char ifrn_name[VKI_IFNAMSIZ];	/* if name, e.g. "eth0" */
   2707 	} ifr_ifrn;
   2708 
   2709 	/* Data part (defined just above) */
   2710 	union	vki_iwreq_data	u;
   2711 };
   2712 
   2713 /*--------------------------------------------------------------------*/
   2714 // From linux-2.6.31.5/include/linux/perf_event.h
   2715 /*--------------------------------------------------------------------*/
   2716 
   2717 struct vki_perf_event_attr {
   2718 
   2719 	/*
   2720 	 * Major type: hardware/software/tracepoint/etc.
   2721 	 */
   2722 	__vki_u32			type;
   2723 
   2724 	/*
   2725 	 * Size of the attr structure, for fwd/bwd compat.
   2726 	 */
   2727 	__vki_u32			size;
   2728 
   2729 	/*
   2730 	 * Type specific configuration information.
   2731 	 */
   2732 	__vki_u64			config;
   2733 
   2734 	union {
   2735 		__vki_u64		sample_period;
   2736 		__vki_u64		sample_freq;
   2737 	};
   2738 
   2739 	__vki_u64			sample_type;
   2740 	__vki_u64			read_format;
   2741 
   2742 	__vki_u64			disabled       :  1, /* off by default        */
   2743 					inherit	       :  1, /* children inherit it   */
   2744 					pinned	       :  1, /* must always be on PMU */
   2745 					exclusive      :  1, /* only group on PMU     */
   2746 					exclude_user   :  1, /* don't count user      */
   2747 					exclude_kernel :  1, /* ditto kernel          */
   2748 					exclude_hv     :  1, /* ditto hypervisor      */
   2749 					exclude_idle   :  1, /* don't count when idle */
   2750 					mmap           :  1, /* include mmap data     */
   2751 					comm	       :  1, /* include comm data     */
   2752 					freq           :  1, /* use freq, not period  */
   2753 					inherit_stat   :  1, /* per task counts       */
   2754 					enable_on_exec :  1, /* next exec enables     */
   2755 					task           :  1, /* trace fork/exit       */
   2756 					watermark      :  1, /* wakeup_watermark      */
   2757 					/*
   2758 					 * precise_ip:
   2759 					 *
   2760 					 *  0 - SAMPLE_IP can have arbitrary skid
   2761 					 *  1 - SAMPLE_IP must have constant skid
   2762 					 *  2 - SAMPLE_IP requested to have 0 skid
   2763 					 *  3 - SAMPLE_IP must have 0 skid
   2764 					 *
   2765 					 *  See also PERF_RECORD_MISC_EXACT_IP
   2766 					 */
   2767 					precise_ip     :  2, /* skid constraint       */
   2768 					mmap_data      :  1, /* non-exec mmap data    */
   2769 					sample_id_all  :  1, /* sample_type all events */
   2770 
   2771 					__reserved_1   : 45;
   2772 
   2773 	union {
   2774 		__vki_u32		wakeup_events;	  /* wakeup every n events */
   2775 		__vki_u32		wakeup_watermark; /* bytes before wakeup   */
   2776 	};
   2777 
   2778 	__vki_u32			bp_type;
   2779 	union {
   2780 		__vki_u64		bp_addr;
   2781 		__vki_u64		config1; /* extension of config */
   2782 	};
   2783 	union {
   2784 		__vki_u64		bp_len;
   2785 		__vki_u64		config2; /* extension of config1 */
   2786 	};
   2787 };
   2788 
   2789 /*--------------------------------------------------------------------*/
   2790 // From linux-2.6.32.4/include/linux/getcpu.h
   2791 /*--------------------------------------------------------------------*/
   2792 
   2793 struct vki_getcpu_cache {
   2794 	unsigned long blob[128 / sizeof(long)];
   2795 };
   2796 
   2797 //----------------------------------------------------------------------
   2798 // From linux-2.6.33.3/include/linux/input.h
   2799 //----------------------------------------------------------------------
   2800 
   2801 /*
   2802  * IOCTLs (0x00 - 0x7f)
   2803  */
   2804 
   2805 #define VKI_EVIOCGNAME(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x06, len)		/* get device name */
   2806 #define VKI_EVIOCGPHYS(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x07, len)		/* get physical location */
   2807 #define VKI_EVIOCGUNIQ(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x08, len)		/* get unique identifier */
   2808 
   2809 #define VKI_EVIOCGKEY(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x18, len)		/* get global keystate */
   2810 #define VKI_EVIOCGLED(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
   2811 #define VKI_EVIOCGSND(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
   2812 #define VKI_EVIOCGSW(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
   2813 
   2814 #define VKI_EVIOCGBIT(ev,len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
   2815 
   2816 #define VKI_EVIOCSSUSPENDBLOCK	_VKI_IOW('E', 0x91, int)	/* set suspend block enable */
   2817 
   2818 /*
   2819  * Event types
   2820  */
   2821 
   2822 #define VKI_EV_SYN		0x00
   2823 #define VKI_EV_KEY		0x01
   2824 #define VKI_EV_REL		0x02
   2825 #define VKI_EV_ABS		0x03
   2826 #define VKI_EV_MSC		0x04
   2827 #define VKI_EV_SW		0x05
   2828 #define VKI_EV_LED		0x11
   2829 #define VKI_EV_SND		0x12
   2830 #define VKI_EV_REP		0x14
   2831 #define VKI_EV_FF		0x15
   2832 #define VKI_EV_PWR		0x16
   2833 #define VKI_EV_FF_STATUS	0x17
   2834 #define VKI_EV_MAX		0x1f
   2835 #define VKI_EV_CNT		(VKI_EV_MAX+1)
   2836 
   2837 //----------------------------------------------------------------------
   2838 // From linux-2.6.39-rc2/include/asm_generic/ioctls.h
   2839 //----------------------------------------------------------------------
   2840 
   2841 #ifndef VKI_FIOQSIZE
   2842 #define VKI_FIOQSIZE 0x5460     /* Value differs on some platforms */
   2843 #endif
   2844 
   2845 //----------------------------------------------------------------------
   2846 // From kernel/common/include/linux/ashmem.h
   2847 //----------------------------------------------------------------------
   2848 
   2849 #if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
   2850 
   2851 #define VKI_ASHMEM_NAME_LEN 256
   2852 
   2853 #define VKI_ASHMEM_NAME_DEF "dev/ashmem"
   2854 
   2855 #define VKI_ASHMEM_NOT_PURGED 0
   2856 #define VKI_ASHMEM_WAS_PURGED 1
   2857 
   2858 #define VKI_ASHMEM_IS_UNPINNED 0
   2859 #define VKI_ASHMEM_IS_PINNED 1
   2860 
   2861 struct vki_ashmem_pin {
   2862    vki_uint32_t offset;
   2863    vki_uint32_t len;
   2864 };
   2865 
   2866 #define __VKI_ASHMEMIOC 0x77
   2867 
   2868 #define VKI_ASHMEM_SET_NAME _VKI_IOW(__VKI_ASHMEMIOC, 1, char[VKI_ASHMEM_NAME_LEN])
   2869 #define VKI_ASHMEM_GET_NAME _VKI_IOR(__VKI_ASHMEMIOC, 2, char[VKI_ASHMEM_NAME_LEN])
   2870 #define VKI_ASHMEM_SET_SIZE _VKI_IOW(__VKI_ASHMEMIOC, 3, vki_size_t)
   2871 #define VKI_ASHMEM_GET_SIZE _VKI_IO(__VKI_ASHMEMIOC, 4)
   2872 #define VKI_ASHMEM_SET_PROT_MASK _VKI_IOW(__VKI_ASHMEMIOC, 5, unsigned long)
   2873 #define VKI_ASHMEM_GET_PROT_MASK _VKI_IO(__VKI_ASHMEMIOC, 6)
   2874 #define VKI_ASHMEM_PIN _VKI_IOW(__VKI_ASHMEMIOC, 7, struct vki_ashmem_pin)
   2875 #define VKI_ASHMEM_UNPIN _VKI_IOW(__VKI_ASHMEMIOC, 8, struct vki_ashmem_pin)
   2876 #define VKI_ASHMEM_GET_PIN_STATUS _VKI_IO(__VKI_ASHMEMIOC, 9)
   2877 #define VKI_ASHMEM_PURGE_ALL_CACHES _VKI_IO(__VKI_ASHMEMIOC, 10)
   2878 
   2879 //----------------------------------------------------------------------
   2880 // From kernel/common/include/linux/binder.h
   2881 //----------------------------------------------------------------------
   2882 
   2883 struct vki_binder_write_read {
   2884  signed long write_size;
   2885  signed long write_consumed;
   2886  unsigned long write_buffer;
   2887  signed long read_size;
   2888  signed long read_consumed;
   2889  unsigned long read_buffer;
   2890 };
   2891 
   2892 struct vki_binder_version {
   2893  signed long protocol_version;
   2894 };
   2895 
   2896 #define VKI_BINDER_WRITE_READ _VKI_IOWR('b', 1, struct vki_binder_write_read)
   2897 #define VKI_BINDER_SET_IDLE_TIMEOUT _VKI_IOW('b', 3, vki_int64_t)
   2898 #define VKI_BINDER_SET_MAX_THREADS _VKI_IOW('b', 5, vki_size_t)
   2899 #define VKI_BINDER_SET_IDLE_PRIORITY _VKI_IOW('b', 6, int)
   2900 #define VKI_BINDER_SET_CONTEXT_MGR _VKI_IOW('b', 7, int)
   2901 #define VKI_BINDER_THREAD_EXIT _VKI_IOW('b', 8, int)
   2902 #define VKI_BINDER_VERSION _VKI_IOWR('b', 9, struct vki_binder_version)
   2903 
   2904 #endif /* defined(VGPV_*_linux_android) */
   2905 
   2906 //----------------------------------------------------------------------
   2907 // From linux-3.0.4/include/net/bluetooth/bluetooth.h
   2908 //----------------------------------------------------------------------
   2909 
   2910 typedef struct {
   2911    __vki_u8 b[6];
   2912 } __vki_packed vki_bdaddr_t;
   2913 
   2914 //----------------------------------------------------------------------
   2915 // From linux-3.0.4/include/net/bluetooth/hci.h
   2916 //----------------------------------------------------------------------
   2917 
   2918 #define VKI_HCIDEVUP        _VKI_IOW('H', 201, int)
   2919 #define VKI_HCIDEVDOWN      _VKI_IOW('H', 202, int)
   2920 #define VKI_HCIDEVRESET     _VKI_IOW('H', 203, int)
   2921 #define VKI_HCIDEVRESTAT    _VKI_IOW('H', 204, int)
   2922 
   2923 #define VKI_HCIGETDEVLIST   _VKI_IOR('H', 210, int)
   2924 #define VKI_HCIGETDEVINFO   _VKI_IOR('H', 211, int)
   2925 #define VKI_HCIGETCONNLIST  _VKI_IOR('H', 212, int)
   2926 #define VKI_HCIGETCONNINFO  _VKI_IOR('H', 213, int)
   2927 #define VKI_HCIGETAUTHINFO  _VKI_IOR('H', 215, int)
   2928 
   2929 #define VKI_HCISETRAW       _VKI_IOW('H', 220, int)
   2930 #define VKI_HCISETSCAN      _VKI_IOW('H', 221, int)
   2931 #define VKI_HCISETAUTH      _VKI_IOW('H', 222, int)
   2932 #define VKI_HCISETENCRYPT   _VKI_IOW('H', 223, int)
   2933 #define VKI_HCISETPTYPE     _VKI_IOW('H', 224, int)
   2934 #define VKI_HCISETLINKPOL   _VKI_IOW('H', 225, int)
   2935 #define VKI_HCISETLINKMODE  _VKI_IOW('H', 226, int)
   2936 #define VKI_HCISETACLMTU    _VKI_IOW('H', 227, int)
   2937 #define VKI_HCISETSCOMTU    _VKI_IOW('H', 228, int)
   2938 
   2939 #define VKI_HCIBLOCKADDR    _VKI_IOW('H', 230, int)
   2940 #define VKI_HCIUNBLOCKADDR  _VKI_IOW('H', 231, int)
   2941 
   2942 #define VKI_HCIINQUIRY      _VKI_IOR('H', 240, int)
   2943 
   2944 struct vki_inquiry_info {
   2945    vki_bdaddr_t bdaddr;
   2946    __vki_u8     pscan_rep_mode;
   2947    __vki_u8     pscan_period_mode;
   2948    __vki_u8     pscan_mode;
   2949    __vki_u8     dev_class[3];
   2950    __vki_le16   clock_offset;
   2951 } __vki_packed;
   2952 
   2953 struct vki_hci_inquiry_req {
   2954    __vki_u16 dev_id;
   2955    __vki_u16 flags;
   2956    __vki_u8  lap[3];
   2957    __vki_u8  length;
   2958    __vki_u8  num_rsp;
   2959 };
   2960 
   2961 //----------------------------------------------------------------------
   2962 // From linux-3.4/include/linux/kvm.h
   2963 //----------------------------------------------------------------------
   2964 #define KVMIO 0xAE
   2965 
   2966 #define VKI_KVM_GET_API_VERSION       _VKI_IO(KVMIO,   0x00)
   2967 #define VKI_KVM_CREATE_VM             _VKI_IO(KVMIO,   0x01) /* returns a VM fd */
   2968 #define VKI_KVM_CHECK_EXTENSION       _VKI_IO(KVMIO,   0x03)
   2969 #define VKI_KVM_GET_VCPU_MMAP_SIZE    _VKI_IO(KVMIO,   0x04) /* in bytes */
   2970 #define VKI_KVM_S390_ENABLE_SIE       _VKI_IO(KVMIO,   0x06)
   2971 #define VKI_KVM_CREATE_VCPU           _VKI_IO(KVMIO,   0x41)
   2972 #define VKI_KVM_SET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x44)
   2973 #define VKI_KVM_GET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x45)
   2974 #define VKI_KVM_SET_TSS_ADDR          _VKI_IO(KVMIO,   0x47)
   2975 #define VKI_KVM_CREATE_IRQCHIP        _VKI_IO(KVMIO,   0x60)
   2976 #define VKI_KVM_CREATE_PIT            _VKI_IO(KVMIO,   0x64)
   2977 #define VKI_KVM_REINJECT_CONTROL      _VKI_IO(KVMIO,   0x71)
   2978 #define VKI_KVM_SET_BOOT_CPU_ID       _VKI_IO(KVMIO,   0x78)
   2979 #define VKI_KVM_SET_TSC_KHZ           _VKI_IO(KVMIO,  0xa2)
   2980 #define VKI_KVM_GET_TSC_KHZ           _VKI_IO(KVMIO,  0xa3)
   2981 #define VKI_KVM_RUN                   _VKI_IO(KVMIO,   0x80)
   2982 #define VKI_KVM_S390_INITIAL_RESET    _VKI_IO(KVMIO,   0x97)
   2983 #define VKI_KVM_NMI                   _VKI_IO(KVMIO,   0x9a)
   2984 
   2985 //----------------------------------------------------------------------
   2986 // From linux-2.6/include/linux/net_stamp.h
   2987 //----------------------------------------------------------------------
   2988 
   2989 struct vki_hwtstamp_config {
   2990 	int flags;
   2991 	int tx_type;
   2992 	int rx_filter;
   2993 };
   2994 
   2995 //----------------------------------------------------------------------
   2996 // From linux-2.6.12-rc2/include/linux/uinput.h
   2997 //----------------------------------------------------------------------
   2998 
   2999 #define VKI_UINPUT_IOCTL_BASE       'U'
   3000 #define VKI_UI_DEV_CREATE		_VKI_IO(VKI_UINPUT_IOCTL_BASE, 1)
   3001 #define VKI_UI_DEV_DESTROY		_VKI_IO(VKI_UINPUT_IOCTL_BASE, 2)
   3002 
   3003 #define VKI_UI_SET_EVBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 100, int)
   3004 #define VKI_UI_SET_KEYBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 101, int)
   3005 #define VKI_UI_SET_RELBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 102, int)
   3006 #define VKI_UI_SET_ABSBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 103, int)
   3007 #define VKI_UI_SET_MSCBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 104, int)
   3008 #define VKI_UI_SET_LEDBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 105, int)
   3009 #define VKI_UI_SET_SNDBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 106, int)
   3010 #define VKI_UI_SET_FFBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 107, int)
   3011 #define VKI_UI_SET_SWBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 109, int)
   3012 #define VKI_UI_SET_PROPBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 110, int)
   3013 
   3014 //----------------------------------------------------------------------
   3015 // From include/linux/media.h
   3016 //----------------------------------------------------------------------
   3017 
   3018 struct vki_media_device_info {
   3019     char driver[16];
   3020     char model[32];
   3021     char serial[40];
   3022     char bus_info[32];
   3023     __vki_u32 media_version;
   3024     __vki_u32 hw_revision;
   3025     __vki_u32 driver_version;
   3026     __vki_u32 reserved[31];
   3027 };
   3028 
   3029 #define VKI_MEDIA_IOC_DEVICE_INFO _VKI_IOWR('|', 0x00, struct vki_media_device_info)
   3030 
   3031 #endif // __VKI_LINUX_H
   3032 
   3033 /*--------------------------------------------------------------------*/
   3034 /*--- end                                                          ---*/
   3035 /*--------------------------------------------------------------------*/
   3036